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

Contents of /eclass/linux-mod.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.85 - (hide annotations) (download)
Fri Oct 31 21:25:56 2008 UTC (5 years, 8 months ago) by dsd
Branch: MAIN
Changes since 1.84: +15 -1 lines
add some documentation, patch from Eric Brown in bug #190934

1 johnm 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 dsd 1.85 # $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.84 2008/10/27 05:22:13 vapier Exp $
4 johnm 1.1
5 johnm 1.10 # Description: This eclass is used to interface with linux-info in such a way
6     # to provide the functionality required and initial functions
7     # required to install external modules against a kernel source
8     # tree.
9     #
10 phreak 1.75 # Author(s): John Mylchreest <johnm@gentoo.org>,
11     # Stefan Schweizer <genstef@gentoo.org>
12     # Maintainer: kernel-misc@gentoo.org
13 johnm 1.10 #
14     # Please direct your bugs to the current eclass maintainer :)
15    
16     # A Couple of env vars are available to effect usage of this eclass
17     # These are as follows:
18 swegener 1.49 #
19 johnm 1.26 # Env Var Option Default Description
20     # KERNEL_DIR <string> /usr/src/linux The directory containing kernel
21     # the target kernel sources.
22     # ECONF_PARAMS <string> The parameters to pass to econf.
23     # If this is not set, then econf
24     # isn't run.
25     # BUILD_PARAMS <string> The parameters to pass to emake.
26     # BUILD_TARGETS <string> clean modules The build targets to pass to
27     # make.
28     # MODULE_NAMES <string> This is the modules which are
29 swegener 1.49 # to be built automatically using
30     # the default pkg_compile/install.
31     # They are explained properly
32     # below. It will only make
33 johnm 1.26 # BUILD_TARGETS once in any
34     # directory.
35 johnm 1.10
36     # MODULE_NAMES - Detailed Overview
37 swegener 1.49 #
38 johnm 1.10 # The structure of each MODULE_NAMES entry is as follows:
39 johnm 1.26 # modulename(libdir:srcdir:objdir)
40 dsd 1.85 #
41     # modulename = name of the module file excluding the .ko
42     # libdir = place in system modules directory where module is installed:
43     # srcdir = place for ebuild to cd to before running make
44     # objdir = place the .ko and objects are located after make runs
45     #
46     # To get an idea of how these variables are used, here's a few lines
47     # of code from around line 540 in this eclass:
48     #
49     # einfo "Installing ${modulename} module"
50     # cd ${objdir} || die "${objdir} does not exist"
51     # insinto /lib/modules/${KV_FULL}/${libdir}
52     # doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
53     #
54 johnm 1.10 # for example:
55 johnm 1.26 # MODULE_NAMES="module_pci(pci:${S}/pci:${S}) module_usb(usb:${S}/usb:${S})"
56 swegener 1.49 #
57 johnm 1.10 # what this would do is
58     # cd ${S}/pci
59     # make ${BUILD_PARAMS} ${BUILD_TARGETS}
60 johnm 1.26 # cd ${S}
61 johnm 1.10 # insinto /lib/modules/${KV_FULL}/pci
62     # doins module_pci.${KV_OBJ}
63     #
64     # cd ${S}/usb
65     # make ${BUILD_PARAMS} ${BUILD_TARGETS}
66 johnm 1.26 # cd ${S}
67 johnm 1.10 # insinto /lib/modules/${KV_FULL}/usb
68     # doins module_usb.${KV_OBJ}
69     #
70 johnm 1.26 # if the srcdir isnt specified, it assumes ${S}
71     # if the libdir isnt specified, it assumes misc.
72     # if the objdir isnt specified, it assumes srcdir
73    
74 genstef 1.80 # There is also support for automated modprobe.d/modules.d(2.4) file generation.
75 johnm 1.26 # This can be explicitly enabled by setting any of the following variables.
76     #
77     #
78     # MODULESD_${modulename}_ENABLED This enables the modules.d file
79     # generation even if we dont
80     # specify any additional info.
81     # MODULESD_${modulename}_EXAMPLES This is a bash array containing
82     # a list of examples which should
83     # be used. If you want us to try and
84     # take a guess. Set this to "guess"
85     # MODULESD_${modulename}_ALIASES This is a bash array containing
86     # a list of associated aliases.
87     # MODULESD_${modulename}_ADDITIONS This is a bash array containing
88     # A list of additional things to
89     # add to the bottom of the file.
90     # This can be absolutely anything.
91     # Each entry is a new line.
92     # MODULES_${modulename}_DOCS This is a string list which contains
93     # the full path to any associated
94     # documents for $modulename
95    
96 betelgeuse 1.61 # The order of these is important as both of linux-info and eutils contain
97     # set_arch_to_kernel and set_arch_to_portage functions and the ones in eutils
98     # are deprecated in favor of the ones in linux-info.
99     # See http://bugs.gentoo.org/show_bug.cgi?id=127506
100 johnm 1.1
101 blubb 1.62 inherit eutils linux-info multilib
102 genstef 1.65 EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm
103 johnm 1.1
104 genstef 1.67 IUSE="kernel_linux"
105 johnm 1.26 SLOT="0"
106 johnm 1.1 DESCRIPTION="Based on the $ECLASS eclass"
107 genstef 1.67 RDEPEND="kernel_linux? ( virtual/modutils )"
108 genstef 1.65 DEPEND="${RDEPEND}
109 vapier 1.66 sys-apps/sed"
110 johnm 1.26
111 johnm 1.1 # eclass utilities
112     # ----------------------------------
113    
114 johnm 1.53 check_vermagic() {
115 genstef 1.69 debug-print-function ${FUNCNAME} $*
116    
117 johnm 1.53 local curr_gcc_ver=$(gcc -dumpversion)
118     local tmpfile old_chost old_gcc_ver result=0
119    
120 johnm 1.54 tmpfile=`find ${KV_DIR}/ -iname "*.o.cmd" -exec grep usr/lib/gcc {} \; -quit`
121 johnm 1.53 tmpfile=${tmpfile//*usr/lib}
122     tmpfile=${tmpfile//\/include*}
123     old_chost=${tmpfile//*gcc\/}
124     old_chost=${old_chost//\/*}
125     old_gcc_ver=${tmpfile//*\/}
126    
127 johnm 1.54 if [[ -z ${old_gcc_ver} || -z ${old_chost} ]]; then
128     ewarn ""
129     ewarn "Unable to detect what version of GCC was used to compile"
130     ewarn "the kernel. Build will continue, but you may experience problems."
131     elif [[ ${curr_gcc_ver} != ${old_gcc_ver} ]]; then
132 johnm 1.53 ewarn ""
133     ewarn "The version of GCC you are using (${curr_gcc_ver}) does"
134     ewarn "not match the version of GCC used to compile the"
135     ewarn "kernel (${old_gcc_ver})."
136     result=1
137     elif [[ ${CHOST} != ${old_chost} ]]; then
138     ewarn ""
139     ewarn "The current CHOST (${CHOST}) does not match the chost"
140     ewarn "used when compiling the kernel (${old_chost})."
141     result=1
142     fi
143    
144     if [[ ${result} -gt 0 ]]; then
145     ewarn ""
146     ewarn "Build will not continue, because you will experience problems."
147     ewarn "To fix this either change the version of GCC you wish to use"
148     ewarn "to match the kernel, or recompile the kernel first."
149     die "GCC Version Mismatch."
150     fi
151     }
152    
153 johnm 1.1 use_m() {
154 genstef 1.69 debug-print-function ${FUNCNAME} $*
155    
156 johnm 1.1 # if we haven't determined the version yet, we need too.
157     get_version;
158 swegener 1.49
159 johnm 1.1 # if the kernel version is greater than 2.6.6 then we should use
160 johnm 1.8 # M= instead of SUBDIRS=
161 johnm 1.1 [ ${KV_MAJOR} -eq 2 -a ${KV_MINOR} -gt 5 -a ${KV_PATCH} -gt 5 ] && \
162     return 0 || return 1
163     }
164    
165     convert_to_m() {
166 genstef 1.69 debug-print-function ${FUNCNAME} $*
167    
168 johnm 1.1 if use_m
169     then
170 johnm 1.32 [ ! -f "${1}" ] && \
171     die "convert_to_m() requires a filename as an argument"
172 johnm 1.8 ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS="
173 johnm 1.1 sed -i 's:SUBDIRS=:M=:g' ${1}
174     eend $?
175     fi
176     }
177    
178     update_depmod() {
179 genstef 1.69 debug-print-function ${FUNCNAME} $*
180    
181 johnm 1.1 # if we haven't determined the version yet, we need too.
182     get_version;
183 swegener 1.49
184 johnm 1.1 ebegin "Updating module dependencies for ${KV_FULL}"
185 johnm 1.5 if [ -r ${KV_OUT_DIR}/System.map ]
186 johnm 1.1 then
187 johnm 1.5 depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL}
188 johnm 1.18 eend $?
189 johnm 1.1 else
190     ewarn
191 johnm 1.5 ewarn "${KV_OUT_DIR}/System.map not found."
192 johnm 1.1 ewarn "You must manually update the kernel module dependencies using depmod."
193 johnm 1.18 eend 1
194 johnm 1.1 ewarn
195     fi
196     }
197    
198 johnm 1.3 update_modules() {
199 genstef 1.69 debug-print-function ${FUNCNAME} $*
200    
201 genstef 1.73 if [ -x /sbin/update-modules ] && \
202     grep -v -e "^#" -e "^$" ${D}/etc/modules.d/* >/dev/null 2>&1; then
203     ebegin "Updating modules.conf"
204     /sbin/update-modules
205     eend $?
206 vapier 1.74 elif [ -x /sbin/update-modules ] && \
207 kingtaco 1.31 grep -v -e "^#" -e "^$" ${D}/etc/modules.d/* >/dev/null 2>&1; then
208 johnm 1.3 ebegin "Updating modules.conf"
209 vapier 1.74 /sbin/update-modules
210 johnm 1.3 eend $?
211     fi
212     }
213    
214 johnm 1.41 move_old_moduledb() {
215 genstef 1.69 debug-print-function ${FUNCNAME} $*
216    
217 johnm 1.41 local OLDDIR=${ROOT}/usr/share/module-rebuild/
218     local NEWDIR=${ROOT}/var/lib/module-rebuild/
219 swegener 1.49
220 johnm 1.41 if [[ -f ${OLDDIR}/moduledb ]]; then
221     [[ ! -d ${NEWDIR} ]] && mkdir -p ${NEWDIR}
222 johnm 1.42 [[ ! -f ${NEWDIR}/moduledb ]] && \
223     mv ${OLDDIR}/moduledb ${NEWDIR}/moduledb
224     rm -f ${OLDDIR}/*
225 johnm 1.41 rmdir ${OLDDIR}
226     fi
227     }
228    
229 johnm 1.37 update_moduledb() {
230 genstef 1.69 debug-print-function ${FUNCNAME} $*
231    
232 johnm 1.40 local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/
233 johnm 1.41 move_old_moduledb
234 johnm 1.40
235     if [[ ! -f ${MODULEDB_DIR}/moduledb ]]; then
236     [[ ! -d ${MODULEDB_DIR} ]] && mkdir -p ${MODULEDB_DIR}
237     touch ${MODULEDB_DIR}/moduledb
238 johnm 1.37 fi
239 vapier 1.72
240     if ! grep -qs ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb ; then
241 johnm 1.37 einfo "Adding module to moduledb."
242 johnm 1.40 echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${MODULEDB_DIR}/moduledb
243 swegener 1.49 fi
244 johnm 1.37 }
245    
246     remove_moduledb() {
247 genstef 1.69 debug-print-function ${FUNCNAME} $*
248    
249 johnm 1.40 local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/
250 johnm 1.41 move_old_moduledb
251 johnm 1.40
252 vapier 1.72 if grep -qs ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb ; then
253 johnm 1.37 einfo "Removing ${CATEGORY}/${PN}-${PVR} from moduledb."
254 dsd 1.71 sed -i -e "/.*${CATEGORY}\/${PN}-${PVR}.*/d" ${MODULEDB_DIR}/moduledb
255 johnm 1.37 fi
256     }
257    
258 johnm 1.1 set_kvobj() {
259 genstef 1.69 debug-print-function ${FUNCNAME} $*
260    
261 johnm 1.1 if kernel_is 2 6
262     then
263     KV_OBJ="ko"
264     else
265     KV_OBJ="o"
266     fi
267 johnm 1.26 # Do we really need to know this?
268     # Lets silence it.
269     # einfo "Using KV_OBJ=${KV_OBJ}"
270 johnm 1.1 }
271    
272 genstef 1.68 get-KERNEL_CC() {
273 genstef 1.69 debug-print-function ${FUNCNAME} $*
274    
275 vapier 1.82 if [[ -n ${KERNEL_CC} ]] ; then
276     echo "${KERNEL_CC}"
277     return
278     fi
279    
280 genstef 1.68 local kernel_cc
281     if [ -n "${KERNEL_ABI}" ]; then
282     # In future, an arch might want to define CC_$ABI
283     #kernel_cc="$(get_abi_CC)"
284 swegener 1.70 #[ -z "${kernel_cc}" ] &&
285 genstef 1.68 kernel_cc="$(tc-getCC $(ABI=${KERNEL_ABI} get_abi_CHOST))"
286     else
287     kernel_cc=$(tc-getCC)
288     fi
289     echo "${kernel_cc}"
290     }
291    
292 johnm 1.11 generate_modulesd() {
293 genstef 1.69 debug-print-function ${FUNCNAME} $*
294    
295 johnm 1.11 # This function will generate the neccessary modules.d file from the
296     # information contained in the modules exported parms
297 johnm 1.26
298 johnm 1.54 local currm_path currm currm_t t myIFS myVAR
299 johnm 1.26 local module_docs module_enabled module_aliases \
300     module_additions module_examples module_modinfo module_opts
301    
302     for currm_path in ${@}
303 johnm 1.11 do
304 johnm 1.26 currm=${currm_path//*\/}
305     currm=$(echo ${currm} | tr '[:lower:]' '[:upper:]')
306 johnm 1.54 currm_t=${currm}
307     while [[ -z ${currm_t//*-*} ]]; do
308     currm_t=${currm_t/-/_}
309     done
310 johnm 1.26
311 johnm 1.54 module_docs="$(eval echo \${MODULESD_${currm_t}_DOCS})"
312     module_enabled="$(eval echo \${MODULESD_${currm_t}_ENABLED})"
313     module_aliases="$(eval echo \${#MODULESD_${currm_t}_ALIASES[*]})"
314     module_additions="$(eval echo \${#MODULESD_${currm_t}_ADDITIONS[*]})"
315     module_examples="$(eval echo \${#MODULESD_${currm_t}_EXAMPLES[*]})"
316 johnm 1.26
317 johnm 1.27 [[ ${module_aliases} -eq 0 ]] && unset module_aliases
318     [[ ${module_additions} -eq 0 ]] && unset module_additions
319     [[ ${module_examples} -eq 0 ]] && unset module_examples
320 johnm 1.26
321 swegener 1.49 # If we specify we dont want it, then lets exit, otherwise we assume
322 johnm 1.26 # that if its set, we do want it.
323     [[ ${module_enabled} == no ]] && return 0
324    
325     # unset any unwanted variables.
326     for t in ${!module_*}
327 johnm 1.11 do
328 johnm 1.26 [[ -z ${!t} ]] && unset ${t}
329 johnm 1.11 done
330    
331 johnm 1.26 [[ -z ${!module_*} ]] && return 0
332    
333     # OK so now if we have got this far, then we know we want to continue
334     # and generate the modules.d file.
335     module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})"
336     module_config="${T}/modulesd-${currm}"
337    
338 johnm 1.11 ebegin "Preparing file for modules.d"
339 johnm 1.26 #-----------------------------------------------------------------------
340     echo "# modules.d configuration file for ${currm}" >> ${module_config}
341     #-----------------------------------------------------------------------
342     [[ -n ${module_docs} ]] && \
343     echo "# For more information please read:" >> ${module_config}
344     for t in ${module_docs}
345 johnm 1.11 do
346 johnm 1.26 echo "# ${t//*\/}" >> ${module_config}
347 johnm 1.11 done
348 johnm 1.26 echo >> ${module_config}
349 johnm 1.11
350 johnm 1.26 #-----------------------------------------------------------------------
351 johnm 1.27 if [[ ${module_aliases} -gt 0 ]]
352 johnm 1.11 then
353     echo "# Internal Aliases - Do not edit" >> ${module_config}
354     echo "# ------------------------------" >> ${module_config}
355 johnm 1.12
356 johnm 1.26 for((t=0; t<${module_aliases}; t++))
357 johnm 1.11 do
358 johnm 1.26 echo "alias $(eval echo \${MODULESD_${currm}_ALIASES[$t]})" \
359     >> ${module_config}
360 johnm 1.12 done
361 johnm 1.26 echo '' >> ${module_config}
362 johnm 1.11 fi
363    
364 johnm 1.26 #-----------------------------------------------------------------------
365     if [[ -n ${module_modinfo} ]]
366 johnm 1.11 then
367     echo >> ${module_config}
368     echo "# Configurable module parameters" >> ${module_config}
369     echo "# ------------------------------" >> ${module_config}
370 johnm 1.26 myIFS="${IFS}"
371 johnm 1.11 IFS="$(echo -en "\n\b")"
372 swegener 1.49
373 johnm 1.26 for t in ${module_modinfo}
374 johnm 1.11 do
375 johnm 1.26 myVAR="$(echo ${t#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")"
376     if [[ -n ${myVAR} ]]
377 johnm 1.11 then
378 johnm 1.26 module_opts="${module_opts} ${t%%:*}:${myVAR}"
379 johnm 1.11 fi
380 johnm 1.26 echo -e "# ${t%%:*}:\t${t#*:}" >> ${module_config}
381 swegener 1.49 done
382 johnm 1.26 IFS="${myIFS}"
383     echo '' >> ${module_config}
384     fi
385    
386     #-----------------------------------------------------------------------
387     if [[ $(eval echo \${MODULESD_${currm}_ALIASES[0]}) == guess ]]
388     then
389     # So lets do some guesswork eh?
390     if [[ -n ${module_opts} ]]
391     then
392     echo "# For Example..." >> ${module_config}
393     echo "# --------------" >> ${module_config}
394     for t in ${module_opts}
395     do
396     echo "# options ${currm} ${t//:*}=${t//*:}" >> ${module_config}
397     done
398     echo '' >> ${module_config}
399     fi
400 johnm 1.27 elif [[ ${module_examples} -gt 0 ]]
401 johnm 1.26 then
402     echo "# For Example..." >> ${module_config}
403     echo "# --------------" >> ${module_config}
404     for((t=0; t<${module_examples}; t++))
405     do
406     echo "options $(eval echo \${MODULESD_${currm}_EXAMPLES[$t]})" \
407     >> ${module_config}
408 johnm 1.11 done
409 johnm 1.26 echo '' >> ${module_config}
410 johnm 1.11 fi
411 johnm 1.26
412     #-----------------------------------------------------------------------
413 johnm 1.27 if [[ ${module_additions} -gt 0 ]]
414 johnm 1.11 then
415 johnm 1.26 for((t=0; t<${module_additions}; t++))
416 johnm 1.11 do
417 johnm 1.26 echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \
418     >> ${module_config}
419 johnm 1.11 done
420 johnm 1.26 echo '' >> ${module_config}
421 johnm 1.11 fi
422 swegener 1.49
423 johnm 1.26 #-----------------------------------------------------------------------
424    
425 johnm 1.12 # then we install it
426 cardoe 1.81 if kernel_is ge 2 6; then
427 genstef 1.80 insinto /etc/modprobe.d
428     else
429     insinto /etc/modules.d
430     fi
431 johnm 1.27 newins ${module_config} ${currm_path//*\/}
432    
433 johnm 1.12 # and install any documentation we might have.
434 johnm 1.26 [[ -n ${module_docs} ]] && dodoc ${module_docs}
435 johnm 1.11 done
436     eend 0
437 johnm 1.26 return 0
438 johnm 1.11 }
439    
440 johnm 1.18 find_module_params() {
441 genstef 1.69 debug-print-function ${FUNCNAME} $*
442    
443 johnm 1.18 local matched_offset=0 matched_opts=0 test="${@}" temp_var result
444     local i=0 y=0 z=0
445 swegener 1.49
446 johnm 1.18 for((i=0; i<=${#test}; i++))
447     do
448     case ${test:${i}:1} in
449     \() matched_offset[0]=${i};;
450     \:) matched_opts=$((${matched_opts} + 1));
451     matched_offset[${matched_opts}]="${i}";;
452     \)) matched_opts=$((${matched_opts} + 1));
453     matched_offset[${matched_opts}]="${i}";;
454     esac
455     done
456 swegener 1.49
457 johnm 1.18 for((i=0; i<=${matched_opts}; i++))
458     do
459     # i = offset were working on
460     # y = last offset
461     # z = current offset - last offset
462     # temp_var = temporary name
463     case ${i} in
464     0) tempvar=${test:0:${matched_offset[0]}};;
465     *) y=$((${matched_offset[$((${i} - 1))]} + 1))
466     z=$((${matched_offset[${i}]} - ${matched_offset[$((${i} - 1))]}));
467     z=$((${z} - 1))
468     tempvar=${test:${y}:${z}};;
469     esac
470 swegener 1.49
471 johnm 1.18 case ${i} in
472     0) result="${result} modulename:${tempvar}";;
473     1) result="${result} libdir:${tempvar}";;
474     2) result="${result} srcdir:${tempvar}";;
475     3) result="${result} objdir:${tempvar}";;
476     esac
477     done
478 swegener 1.49
479 johnm 1.18 echo ${result}
480     }
481    
482 johnm 1.1 # default ebuild functions
483     # --------------------------------
484    
485     linux-mod_pkg_setup() {
486 genstef 1.69 debug-print-function ${FUNCNAME} $*
487    
488 johnm 1.6 linux-info_pkg_setup;
489 dsd 1.78 require_configured_kernel
490 johnm 1.6 check_kernel_built;
491 johnm 1.63 strip_modulenames;
492     [[ -n ${MODULE_NAMES} ]] && check_modules_supported
493 johnm 1.1 set_kvobj;
494 weeve 1.55 # Commented out with permission from johnm until a fixed version for arches
495     # who intentionally use different kernel and userland compilers can be
496     # introduced - Jason Wever <weeve@gentoo.org>, 23 Oct 2005
497     #check_vermagic;
498 johnm 1.1 }
499    
500 johnm 1.63 strip_modulenames() {
501 genstef 1.69 debug-print-function ${FUNCNAME} $*
502    
503 johnm 1.63 local i
504     for i in ${MODULE_IGNORE}; do
505     MODULE_NAMES=${MODULE_NAMES//${i}(*}
506     done
507     }
508    
509 johnm 1.1 linux-mod_src_compile() {
510 genstef 1.69 debug-print-function ${FUNCNAME} $*
511    
512 vapier 1.84 local modulename libdir srcdir objdir i n myABI="${ABI}"
513     set_arch_to_kernel
514 blubb 1.62 ABI="${KERNEL_ABI}"
515 johnm 1.26
516 johnm 1.16 BUILD_TARGETS=${BUILD_TARGETS:-clean module}
517 johnm 1.63 strip_modulenames;
518 phreak 1.76 cd "${S}"
519 johnm 1.9 for i in ${MODULE_NAMES}
520 johnm 1.1 do
521 johnm 1.23 unset libdir srcdir objdir
522 johnm 1.18 for n in $(find_module_params ${i})
523     do
524     eval ${n/:*}=${n/*:/}
525     done
526     libdir=${libdir:-misc}
527     srcdir=${srcdir:-${S}}
528     objdir=${objdir:-${srcdir}}
529 swegener 1.49
530 johnm 1.18 if [ ! -f "${srcdir}/.built" ];
531 johnm 1.16 then
532 johnm 1.18 cd ${srcdir}
533 johnm 1.16 einfo "Preparing ${modulename} module"
534 johnm 1.22 if [[ -n ${ECONF_PARAMS} ]]
535     then
536     econf ${ECONF_PARAMS} || \
537     die "Unable to run econf ${ECONF_PARAMS}"
538     fi
539 vapier 1.83
540 robbat2 1.79 # This looks messy, but it is needed to handle multiple variables
541     # being passed in the BUILD_* stuff where the variables also have
542     # spaces that must be preserved. If don't do this, then the stuff
543     # inside the variables gets used as targets for Make, which then
544     # fails.
545     eval "emake HOSTCC=\"$(tc-getBUILD_CC)\" \
546 vapier 1.83 CROSS_COMPILE=${CHOST}- \
547 robbat2 1.79 LDFLAGS=\"$(get_abi_LDFLAGS)\" \
548     ${BUILD_FIXES} \
549     ${BUILD_PARAMS} \
550     ${BUILD_TARGETS} " \
551 vapier 1.83 || die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}"
552 johnm 1.18 touch ${srcdir}/.built
553 johnm 1.16 cd ${OLDPWD}
554     fi
555 johnm 1.1 done
556 johnm 1.26
557 vapier 1.84 set_arch_to_portage
558 blubb 1.62 ABI="${myABI}"
559 johnm 1.1 }
560    
561     linux-mod_src_install() {
562 genstef 1.69 debug-print-function ${FUNCNAME} $*
563    
564 johnm 1.18 local modulename libdir srcdir objdir i n
565 swegener 1.49
566 johnm 1.63 strip_modulenames;
567 johnm 1.9 for i in ${MODULE_NAMES}
568 johnm 1.1 do
569 johnm 1.23 unset libdir srcdir objdir
570 johnm 1.18 for n in $(find_module_params ${i})
571     do
572     eval ${n/:*}=${n/*:/}
573     done
574     libdir=${libdir:-misc}
575     srcdir=${srcdir:-${S}}
576     objdir=${objdir:-${srcdir}}
577 johnm 1.1
578     einfo "Installing ${modulename} module"
579 vapier 1.56 cd ${objdir} || die "${objdir} does not exist"
580 brix 1.57 insinto /lib/modules/${KV_FULL}/${libdir}
581 vapier 1.56 doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed"
582 johnm 1.16 cd ${OLDPWD}
583 swegener 1.49
584 johnm 1.26 generate_modulesd ${objdir}/${modulename}
585 johnm 1.1 done
586     }
587    
588 genstef 1.65 linux-mod_pkg_preinst() {
589 genstef 1.69 debug-print-function ${FUNCNAME} $*
590    
591 zmedico 1.77 [ -d "${D}lib/modules" ] && UPDATE_DEPMOD=true || UPDATE_DEPMOD=false
592     [ -d "${D}etc/modules.d" ] && UPDATE_MODULES=true || UPDATE_MODULES=false
593     [ -d "${D}lib/modules" ] && UPDATE_MODULEDB=true || UPDATE_MODULEDB=false
594 genstef 1.65 }
595    
596 johnm 1.1 linux-mod_pkg_postinst() {
597 genstef 1.69 debug-print-function ${FUNCNAME} $*
598    
599 genstef 1.65 ${UPDATE_DEPMOD} && update_depmod;
600     ${UPDATE_MODULES} && update_modules;
601     ${UPDATE_MODULEDB} && update_moduledb;
602 johnm 1.1 }
603 johnm 1.37
604     linux-mod_pkg_postrm() {
605 swegener 1.70 debug-print-function ${FUNCNAME} $*
606 johnm 1.37 remove_moduledb;
607     }

  ViewVC Help
Powered by ViewVC 1.1.20