/[gentoo-x86]/eclass/linux-mod.eclass
Gentoo

Contents of /eclass/linux-mod.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Mon Dec 6 22:05:08 2004 UTC (9 years, 7 months ago) by johnm
Branch: MAIN
Changes since 1.7: +3 -4 lines
moving make clean and fixing SUBDIR typos

1 johnm 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 johnm 1.3 # $Header: $
4 johnm 1.1
5     # This eclass provides functions for compiling external kernel modules
6     # from source.
7    
8     inherit linux-info
9     ECLASS=linux-mod
10     INHERITED="$INHERITED $ECLASS"
11     EXPORT_FUNCTIONS pkg_setup pkg_postinst src_compile
12    
13     DESCRIPTION="Based on the $ECLASS eclass"
14     SLOT=0
15     DEPEND="virtual/linux-sources
16     sys-apps/sed"
17    
18    
19     # This eclass is designed to help ease the installation of external kernel
20     # modules into the kernel tree.
21    
22 johnm 1.3
23 johnm 1.1 # eclass utilities
24     # ----------------------------------
25    
26     use_m() {
27     # if we haven't determined the version yet, we need too.
28     get_version;
29    
30     # if the kernel version is greater than 2.6.6 then we should use
31 johnm 1.8 # M= instead of SUBDIRS=
32 johnm 1.1 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \
33     return 0 || return 1
34     }
35    
36     convert_to_m() {
37     [ ! -f "${1}" ] && die "convert_to_m() requires a filename as an argument"
38     if use_m
39     then
40 johnm 1.8 ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS="
41 johnm 1.1 sed -i 's:SUBDIRS=:M=:g' ${1}
42     eend $?
43     fi
44     }
45    
46     update_depmod() {
47     # if we haven't determined the version yet, we need too.
48     get_version;
49    
50     ebegin "Updating module dependencies for ${KV_FULL}"
51 johnm 1.5 if [ -r ${KV_OUT_DIR}/System.map ]
52 johnm 1.1 then
53 johnm 1.5 depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL}
54 johnm 1.1 else
55     ewarn
56 johnm 1.5 ewarn "${KV_OUT_DIR}/System.map not found."
57 johnm 1.1 ewarn "You must manually update the kernel module dependencies using depmod."
58     ewarn
59     fi
60     eend $?
61     }
62    
63 johnm 1.3 update_modules() {
64     if [ -x /sbin/modules-update ] ;
65     then
66     ebegin "Updating modules.conf"
67     /sbin/modules-update
68     eend $?
69     fi
70     }
71    
72 johnm 1.1 set_kvobj() {
73     if kernel_is 2 6
74     then
75     KV_OBJ="ko"
76     else
77     KV_OBJ="o"
78     fi
79     einfo "Using KV_OBJ=${KV_OBJ}"
80     }
81    
82     display_postinst() {
83     # if we haven't determined the version yet, we need too.
84     get_version;
85    
86     local modulename moduledir sourcedir module_temp file i
87    
88     file=${ROOT}/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}
89     file=${file/\/\///}
90    
91     einfo "If you would like to load this module automatically upon boot"
92     einfo "please type the following as root:"
93     for i in ${MODULE_NAMES}
94     do
95     module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")"
96     modulename="${i/(*/}"
97     moduledir="${module_temp/:*/}"
98     moduledir="${moduledir:-misc}"
99     sourcedir="${module_temp/*:/}"
100     sourcedir="${sourcedir:-${S}}"
101    
102     einfo " # echo \"${modulename}\" >> ${file}"
103     done
104     echo
105     }
106    
107     # default ebuild functions
108     # --------------------------------
109    
110     linux-mod_pkg_setup() {
111 johnm 1.6 linux-info_pkg_setup;
112     check_kernel_built;
113 johnm 1.1 check_modules_supported;
114 johnm 1.4 check_extra_config;
115 johnm 1.1 set_kvobj;
116     }
117    
118     linux-mod_src_compile() {
119     local modulename moduledir sourcedir module_temp xarch i
120     xarch="${ARCH}"
121     unset ARCH
122    
123 johnm 1.3 for i in "${MODULE_NAMES}"
124 johnm 1.1 do
125     module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")"
126     modulename="${i/(*/}"
127     moduledir="${module_temp/:*/}"
128     moduledir="${moduledir:-misc}"
129     sourcedir="${module_temp/*:/}"
130     sourcedir="${sourcedir:-${S}}"
131    
132     einfo "Preparing ${modulename} module"
133     cd ${sourcedir}
134 johnm 1.8 emake ${BUILD_PARAMS} ${BUILD_TARGETS:-clean module} || die Unable to make ${BUILD_PARAMS} ${BUILD_TARGETS:-clean module}.
135 johnm 1.1 done
136     ARCH="${xarch}"
137     }
138    
139     linux-mod_src_install() {
140     local modulename moduledir sourcedir module_temp i
141    
142     for i in "${MODULE_NAMES}"
143     do
144     module_temp="$(echo ${i} | sed -e "s:.*(\(.*\)):\1:")"
145     modulename="${i/(*/}"
146     moduledir="${module_temp/:*/}"
147     moduledir="${moduledir:-misc}"
148     sourcedir="${module_temp/*:/}"
149     sourcedir="${sourcedir:-${S}}"
150    
151     einfo "Installing ${modulename} module"
152     cd ${sourcedir}
153     insinto /lib/modules/${KV_FULL}/${moduledir}
154     doins ${modulename}.${KV_OBJ}
155     done
156     }
157    
158     linux-mod_pkg_postinst() {
159     update_depmod;
160 johnm 1.3 update_modules;
161 johnm 1.1 display_postinst;
162     }

  ViewVC Help
Powered by ViewVC 1.1.20