| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2011 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.88 2008/10/31 23:37:06 gengor Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/linux-mod.eclass,v 1.100 2011/04/24 18:55:20 ulm Exp $ |
| 4 | |
4 | |
| 5 | # Author(s): John Mylchreest <johnm@gentoo.org>, |
5 | # Author(s): John Mylchreest <johnm@gentoo.org>, |
| 6 | # Stefan Schweizer <genstef@gentoo.org> |
6 | # Stefan Schweizer <genstef@gentoo.org> |
| 7 | # Maintainer: kernel-misc@gentoo.org |
7 | # Maintainer: kernel-misc@gentoo.org |
| 8 | # |
8 | # |
| … | |
… | |
| 41 | |
41 | |
| 42 | # @ECLASS-VARIABLE: MODULE_NAMES |
42 | # @ECLASS-VARIABLE: MODULE_NAMES |
| 43 | # @DESCRIPTION: |
43 | # @DESCRIPTION: |
| 44 | # It's a string containing the modules to be built automatically using the default |
44 | # It's a string containing the modules to be built automatically using the default |
| 45 | # src_compile/src_install. It will only make ${BUILD_TARGETS} once in any directory. |
45 | # src_compile/src_install. It will only make ${BUILD_TARGETS} once in any directory. |
| 46 | |
|
|
| 47 | # |
46 | # |
| 48 | # The structure of each MODULE_NAMES entry is as follows: |
47 | # The structure of each MODULE_NAMES entry is as follows: |
| 49 | # |
48 | # |
| 50 | # modulename(libdir:srcdir:objdir) |
49 | # modulename(libdir:srcdir:objdir) |
| 51 | # |
50 | # |
| 52 | # where: |
51 | # where: |
| 53 | # |
52 | # |
| 54 | # modulename = name of the module file excluding the .ko |
53 | # modulename = name of the module file excluding the .ko |
| 55 | # libdir = place in system modules directory where module is installed: |
54 | # libdir = place in system modules directory where module is installed (by default it's misc) |
| 56 | # srcdir = place for ebuild to cd to before running make |
55 | # srcdir = place for ebuild to cd to before running make (by default it's ${S}) |
| 57 | # objdir = place the .ko and objects are located after make runs |
56 | # objdir = place the .ko and objects are located after make runs (by default it's set to srcdir) |
| 58 | # |
57 | # |
| 59 | # To get an idea of how these variables are used, here's a few lines |
58 | # To get an idea of how these variables are used, here's a few lines |
| 60 | # of code from around line 540 in this eclass: |
59 | # of code from around line 540 in this eclass: |
| 61 | # |
60 | # |
| 62 | # einfo "Installing ${modulename} module" |
61 | # einfo "Installing ${modulename} module" |
| 63 | # cd ${objdir} || die "${objdir} does not exist" |
62 | # cd ${objdir} || die "${objdir} does not exist" |
| 64 | # insinto /lib/modules/${KV_FULL}/${libdir} |
63 | # insinto /lib/modules/${KV_FULL}/${libdir} |
| 65 | # doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" |
64 | # doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" |
| 66 | # |
65 | # |
| … | |
… | |
| 135 | EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm |
134 | EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst src_install src_compile pkg_postrm |
| 136 | |
135 | |
| 137 | IUSE="kernel_linux" |
136 | IUSE="kernel_linux" |
| 138 | SLOT="0" |
137 | SLOT="0" |
| 139 | DESCRIPTION="Based on the $ECLASS eclass" |
138 | DESCRIPTION="Based on the $ECLASS eclass" |
| 140 | RESTRICT="distcc" |
|
|
| 141 | RDEPEND="kernel_linux? ( virtual/modutils )" |
139 | RDEPEND="kernel_linux? ( sys-apps/module-init-tools )" |
| 142 | DEPEND="${RDEPEND} |
140 | DEPEND="${RDEPEND} |
| 143 | sys-apps/sed" |
141 | sys-apps/sed |
|
|
142 | kernel_linux? ( virtual/linux-sources )" |
| 144 | |
143 | |
| 145 | # eclass utilities |
144 | # eclass utilities |
| 146 | # ---------------------------------- |
145 | # ---------------------------------- |
| 147 | |
146 | |
| 148 | check_vermagic() { |
147 | check_vermagic() { |
| 149 | debug-print-function ${FUNCNAME} $* |
148 | debug-print-function ${FUNCNAME} $* |
| 150 | |
149 | |
| 151 | local curr_gcc_ver=$(gcc -dumpversion) |
150 | local curr_gcc_ver=$(gcc -dumpversion) |
| 152 | local tmpfile old_chost old_gcc_ver result=0 |
151 | local tmpfile old_chost old_gcc_ver result=0 |
| 153 | |
152 | |
| 154 | tmpfile=`find ${KV_DIR}/ -iname "*.o.cmd" -exec grep usr/lib/gcc {} \; -quit` |
153 | tmpfile=`find "${KV_DIR}/" -iname "*.o.cmd" -exec grep usr/lib/gcc {} \; -quit` |
| 155 | tmpfile=${tmpfile//*usr/lib} |
154 | tmpfile=${tmpfile//*usr/lib} |
| 156 | tmpfile=${tmpfile//\/include*} |
155 | tmpfile=${tmpfile//\/include*} |
| 157 | old_chost=${tmpfile//*gcc\/} |
156 | old_chost=${tmpfile//*gcc\/} |
| 158 | old_chost=${old_chost//\/*} |
157 | old_chost=${old_chost//\/*} |
| 159 | old_gcc_ver=${tmpfile//*\/} |
158 | old_gcc_ver=${tmpfile//*\/} |
| … | |
… | |
| 210 | if use_m |
209 | if use_m |
| 211 | then |
210 | then |
| 212 | [ ! -f "${1}" ] && \ |
211 | [ ! -f "${1}" ] && \ |
| 213 | die "convert_to_m() requires a filename as an argument" |
212 | die "convert_to_m() requires a filename as an argument" |
| 214 | ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS=" |
213 | ebegin "Converting ${1/${WORKDIR}\//} to use M= instead of SUBDIRS=" |
| 215 | sed -i 's:SUBDIRS=:M=:g' ${1} |
214 | sed -i 's:SUBDIRS=:M=:g' "${1}" |
| 216 | eend $? |
215 | eend $? |
| 217 | fi |
216 | fi |
| 218 | } |
217 | } |
| 219 | |
218 | |
| 220 | # internal function |
219 | # internal function |
| … | |
… | |
| 227 | |
226 | |
| 228 | # if we haven't determined the version yet, we need too. |
227 | # if we haven't determined the version yet, we need too. |
| 229 | get_version; |
228 | get_version; |
| 230 | |
229 | |
| 231 | ebegin "Updating module dependencies for ${KV_FULL}" |
230 | ebegin "Updating module dependencies for ${KV_FULL}" |
| 232 | if [ -r ${KV_OUT_DIR}/System.map ] |
231 | if [ -r "${KV_OUT_DIR}"/System.map ] |
| 233 | then |
232 | then |
| 234 | depmod -ae -F ${KV_OUT_DIR}/System.map -b ${ROOT} -r ${KV_FULL} |
233 | depmod -ae -F "${KV_OUT_DIR}"/System.map -b "${ROOT}" -r ${KV_FULL} |
| 235 | eend $? |
234 | eend $? |
| 236 | else |
235 | else |
| 237 | ewarn |
236 | ewarn |
| 238 | ewarn "${KV_OUT_DIR}/System.map not found." |
237 | ewarn "${KV_OUT_DIR}/System.map not found." |
| 239 | ewarn "You must manually update the kernel module dependencies using depmod." |
238 | ewarn "You must manually update the kernel module dependencies using depmod." |
| … | |
… | |
| 249 | # It calls the update-modules utility. |
248 | # It calls the update-modules utility. |
| 250 | update_modules() { |
249 | update_modules() { |
| 251 | debug-print-function ${FUNCNAME} $* |
250 | debug-print-function ${FUNCNAME} $* |
| 252 | |
251 | |
| 253 | if [ -x /sbin/update-modules ] && \ |
252 | if [ -x /sbin/update-modules ] && \ |
| 254 | grep -v -e "^#" -e "^$" ${D}/etc/modules.d/* >/dev/null 2>&1; then |
253 | grep -v -e "^#" -e "^$" "${D}"/etc/modules.d/* >/dev/null 2>&1; then |
| 255 | ebegin "Updating modules.conf" |
254 | ebegin "Updating modules.conf" |
| 256 | /sbin/update-modules |
255 | /sbin/update-modules |
| 257 | eend $? |
256 | eend $? |
| 258 | elif [ -x /sbin/update-modules ] && \ |
257 | elif [ -x /sbin/update-modules ] && \ |
| 259 | grep -v -e "^#" -e "^$" ${D}/etc/modules.d/* >/dev/null 2>&1; then |
258 | grep -v -e "^#" -e "^$" "${D}"/etc/modules.d/* >/dev/null 2>&1; then |
| 260 | ebegin "Updating modules.conf" |
259 | ebegin "Updating modules.conf" |
| 261 | /sbin/update-modules |
260 | /sbin/update-modules |
| 262 | eend $? |
261 | eend $? |
| 263 | fi |
262 | fi |
| 264 | } |
263 | } |
| … | |
… | |
| 269 | # DESCRIPTION: |
268 | # DESCRIPTION: |
| 270 | # It updates the location of the database used by the module-rebuild utility. |
269 | # It updates the location of the database used by the module-rebuild utility. |
| 271 | move_old_moduledb() { |
270 | move_old_moduledb() { |
| 272 | debug-print-function ${FUNCNAME} $* |
271 | debug-print-function ${FUNCNAME} $* |
| 273 | |
272 | |
| 274 | local OLDDIR=${ROOT}/usr/share/module-rebuild/ |
273 | local OLDDIR="${ROOT}"/usr/share/module-rebuild/ |
| 275 | local NEWDIR=${ROOT}/var/lib/module-rebuild/ |
274 | local NEWDIR="${ROOT}"/var/lib/module-rebuild/ |
| 276 | |
275 | |
| 277 | if [[ -f ${OLDDIR}/moduledb ]]; then |
276 | if [[ -f "${OLDDIR}"/moduledb ]]; then |
| 278 | [[ ! -d ${NEWDIR} ]] && mkdir -p ${NEWDIR} |
277 | [[ ! -d "${NEWDIR}" ]] && mkdir -p "${NEWDIR}" |
| 279 | [[ ! -f ${NEWDIR}/moduledb ]] && \ |
278 | [[ ! -f "${NEWDIR}"/moduledb ]] && \ |
| 280 | mv ${OLDDIR}/moduledb ${NEWDIR}/moduledb |
279 | mv "${OLDDIR}"/moduledb "${NEWDIR}"/moduledb |
| 281 | rm -f ${OLDDIR}/* |
280 | rm -f "${OLDDIR}"/* |
| 282 | rmdir ${OLDDIR} |
281 | rmdir "${OLDDIR}" |
| 283 | fi |
282 | fi |
| 284 | } |
283 | } |
| 285 | |
284 | |
| 286 | # internal function |
285 | # internal function |
| 287 | # |
286 | # |
| … | |
… | |
| 289 | # DESCRIPTION: |
288 | # DESCRIPTION: |
| 290 | # It adds the package to the /var/lib/module-rebuild/moduledb database used by the module-rebuild utility. |
289 | # It adds the package to the /var/lib/module-rebuild/moduledb database used by the module-rebuild utility. |
| 291 | update_moduledb() { |
290 | update_moduledb() { |
| 292 | debug-print-function ${FUNCNAME} $* |
291 | debug-print-function ${FUNCNAME} $* |
| 293 | |
292 | |
| 294 | local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/ |
293 | local MODULEDB_DIR="${ROOT}"/var/lib/module-rebuild/ |
| 295 | move_old_moduledb |
294 | move_old_moduledb |
| 296 | |
295 | |
| 297 | if [[ ! -f ${MODULEDB_DIR}/moduledb ]]; then |
296 | if [[ ! -f "${MODULEDB_DIR}"/moduledb ]]; then |
| 298 | [[ ! -d ${MODULEDB_DIR} ]] && mkdir -p ${MODULEDB_DIR} |
297 | [[ ! -d "${MODULEDB_DIR}" ]] && mkdir -p "${MODULEDB_DIR}" |
| 299 | touch ${MODULEDB_DIR}/moduledb |
298 | touch "${MODULEDB_DIR}"/moduledb |
| 300 | fi |
299 | fi |
| 301 | |
300 | |
| 302 | if ! grep -qs ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb ; then |
301 | if ! grep -qs ${CATEGORY}/${PN}-${PVR} "${MODULEDB_DIR}"/moduledb ; then |
| 303 | einfo "Adding module to moduledb." |
302 | einfo "Adding module to moduledb." |
| 304 | echo "a:1:${CATEGORY}/${PN}-${PVR}" >> ${MODULEDB_DIR}/moduledb |
303 | echo "a:1:${CATEGORY}/${PN}-${PVR}" >> "${MODULEDB_DIR}"/moduledb |
| 305 | fi |
304 | fi |
| 306 | } |
305 | } |
| 307 | |
306 | |
| 308 | # internal function |
307 | # internal function |
| 309 | # |
308 | # |
| … | |
… | |
| 312 | # It removes the package from the /var/lib/module-rebuild/moduledb database used by |
311 | # It removes the package from the /var/lib/module-rebuild/moduledb database used by |
| 313 | # the module-rebuild utility. |
312 | # the module-rebuild utility. |
| 314 | remove_moduledb() { |
313 | remove_moduledb() { |
| 315 | debug-print-function ${FUNCNAME} $* |
314 | debug-print-function ${FUNCNAME} $* |
| 316 | |
315 | |
| 317 | local MODULEDB_DIR=${ROOT}/var/lib/module-rebuild/ |
316 | local MODULEDB_DIR="${ROOT}"/var/lib/module-rebuild/ |
| 318 | move_old_moduledb |
317 | move_old_moduledb |
| 319 | |
318 | |
| 320 | if grep -qs ${CATEGORY}/${PN}-${PVR} ${MODULEDB_DIR}/moduledb ; then |
319 | if grep -qs ${CATEGORY}/${PN}-${PVR} "${MODULEDB_DIR}"/moduledb ; then |
| 321 | einfo "Removing ${CATEGORY}/${PN}-${PVR} from moduledb." |
320 | einfo "Removing ${CATEGORY}/${PN}-${PVR} from moduledb." |
| 322 | sed -i -e "/.*${CATEGORY}\/${PN}-${PVR}.*/d" ${MODULEDB_DIR}/moduledb |
321 | sed -i -e "/.*${CATEGORY}\/${PN}-${PVR}.*/d" "${MODULEDB_DIR}"/moduledb |
| 323 | fi |
322 | fi |
| 324 | } |
323 | } |
| 325 | |
324 | |
| 326 | # @FUNCTION: set_kvobj |
325 | # @FUNCTION: set_kvobj |
| 327 | # @DESCRIPTION: |
326 | # @DESCRIPTION: |
| … | |
… | |
| 415 | module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})" |
414 | module_modinfo="$(modinfo -p ${currm_path}.${KV_OBJ})" |
| 416 | module_config="${T}/modulesd-${currm}" |
415 | module_config="${T}/modulesd-${currm}" |
| 417 | |
416 | |
| 418 | ebegin "Preparing file for modules.d" |
417 | ebegin "Preparing file for modules.d" |
| 419 | #----------------------------------------------------------------------- |
418 | #----------------------------------------------------------------------- |
| 420 | echo "# modules.d configuration file for ${currm}" >> ${module_config} |
419 | echo "# modules.d configuration file for ${currm}" >> "${module_config}" |
| 421 | #----------------------------------------------------------------------- |
420 | #----------------------------------------------------------------------- |
| 422 | [[ -n ${module_docs} ]] && \ |
421 | [[ -n ${module_docs} ]] && \ |
| 423 | echo "# For more information please read:" >> ${module_config} |
422 | echo "# For more information please read:" >> "${module_config}" |
| 424 | for t in ${module_docs} |
423 | for t in ${module_docs} |
| 425 | do |
424 | do |
| 426 | echo "# ${t//*\/}" >> ${module_config} |
425 | echo "# ${t//*\/}" >> "${module_config}" |
| 427 | done |
426 | done |
| 428 | echo >> ${module_config} |
427 | echo >> "${module_config}" |
| 429 | |
428 | |
| 430 | #----------------------------------------------------------------------- |
429 | #----------------------------------------------------------------------- |
| 431 | if [[ ${module_aliases} -gt 0 ]] |
430 | if [[ ${module_aliases} -gt 0 ]] |
| 432 | then |
431 | then |
| 433 | echo "# Internal Aliases - Do not edit" >> ${module_config} |
432 | echo "# Internal Aliases - Do not edit" >> "${module_config}" |
| 434 | echo "# ------------------------------" >> ${module_config} |
433 | echo "# ------------------------------" >> "${module_config}" |
| 435 | |
434 | |
| 436 | for((t=0; t<${module_aliases}; t++)) |
435 | for((t=0; t<${module_aliases}; t++)) |
| 437 | do |
436 | do |
| 438 | echo "alias $(eval echo \${MODULESD_${currm}_ALIASES[$t]})" \ |
437 | echo "alias $(eval echo \${MODULESD_${currm}_ALIASES[$t]})" \ |
| 439 | >> ${module_config} |
438 | >> "${module_config}" |
| 440 | done |
439 | done |
| 441 | echo '' >> ${module_config} |
440 | echo '' >> "${module_config}" |
| 442 | fi |
441 | fi |
| 443 | |
442 | |
| 444 | #----------------------------------------------------------------------- |
443 | #----------------------------------------------------------------------- |
| 445 | if [[ -n ${module_modinfo} ]] |
444 | if [[ -n ${module_modinfo} ]] |
| 446 | then |
445 | then |
| 447 | echo >> ${module_config} |
446 | echo >> "${module_config}" |
| 448 | echo "# Configurable module parameters" >> ${module_config} |
447 | echo "# Configurable module parameters" >> "${module_config}" |
| 449 | echo "# ------------------------------" >> ${module_config} |
448 | echo "# ------------------------------" >> "${module_config}" |
| 450 | myIFS="${IFS}" |
449 | myIFS="${IFS}" |
| 451 | IFS="$(echo -en "\n\b")" |
450 | IFS="$(echo -en "\n\b")" |
| 452 | |
451 | |
| 453 | for t in ${module_modinfo} |
452 | for t in ${module_modinfo} |
| 454 | do |
453 | do |
| 455 | myVAR="$(echo ${t#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")" |
454 | myVAR="$(echo ${t#*:} | grep -e " [0-9][ =]" | sed "s:.*\([01][= ]\).*:\1:")" |
| 456 | if [[ -n ${myVAR} ]] |
455 | if [[ -n ${myVAR} ]] |
| 457 | then |
456 | then |
| 458 | module_opts="${module_opts} ${t%%:*}:${myVAR}" |
457 | module_opts="${module_opts} ${t%%:*}:${myVAR}" |
| 459 | fi |
458 | fi |
| 460 | echo -e "# ${t%%:*}:\t${t#*:}" >> ${module_config} |
459 | echo -e "# ${t%%:*}:\t${t#*:}" >> "${module_config}" |
| 461 | done |
460 | done |
| 462 | IFS="${myIFS}" |
461 | IFS="${myIFS}" |
| 463 | echo '' >> ${module_config} |
462 | echo '' >> "${module_config}" |
| 464 | fi |
463 | fi |
| 465 | |
464 | |
| 466 | #----------------------------------------------------------------------- |
465 | #----------------------------------------------------------------------- |
| 467 | if [[ $(eval echo \${MODULESD_${currm}_ALIASES[0]}) == guess ]] |
466 | if [[ $(eval echo \${MODULESD_${currm}_ALIASES[0]}) == guess ]] |
| 468 | then |
467 | then |
| 469 | # So lets do some guesswork eh? |
468 | # So lets do some guesswork eh? |
| 470 | if [[ -n ${module_opts} ]] |
469 | if [[ -n ${module_opts} ]] |
| 471 | then |
470 | then |
| 472 | echo "# For Example..." >> ${module_config} |
471 | echo "# For Example..." >> "${module_config}" |
| 473 | echo "# --------------" >> ${module_config} |
472 | echo "# --------------" >> "${module_config}" |
| 474 | for t in ${module_opts} |
473 | for t in ${module_opts} |
| 475 | do |
474 | do |
| 476 | echo "# options ${currm} ${t//:*}=${t//*:}" >> ${module_config} |
475 | echo "# options ${currm} ${t//:*}=${t//*:}" >> "${module_config}" |
| 477 | done |
476 | done |
| 478 | echo '' >> ${module_config} |
477 | echo '' >> "${module_config}" |
| 479 | fi |
478 | fi |
| 480 | elif [[ ${module_examples} -gt 0 ]] |
479 | elif [[ ${module_examples} -gt 0 ]] |
| 481 | then |
480 | then |
| 482 | echo "# For Example..." >> ${module_config} |
481 | echo "# For Example..." >> "${module_config}" |
| 483 | echo "# --------------" >> ${module_config} |
482 | echo "# --------------" >> "${module_config}" |
| 484 | for((t=0; t<${module_examples}; t++)) |
483 | for((t=0; t<${module_examples}; t++)) |
| 485 | do |
484 | do |
| 486 | echo "options $(eval echo \${MODULESD_${currm}_EXAMPLES[$t]})" \ |
485 | echo "options $(eval echo \${MODULESD_${currm}_EXAMPLES[$t]})" \ |
| 487 | >> ${module_config} |
486 | >> "${module_config}" |
| 488 | done |
487 | done |
| 489 | echo '' >> ${module_config} |
488 | echo '' >> "${module_config}" |
| 490 | fi |
489 | fi |
| 491 | |
490 | |
| 492 | #----------------------------------------------------------------------- |
491 | #----------------------------------------------------------------------- |
| 493 | if [[ ${module_additions} -gt 0 ]] |
492 | if [[ ${module_additions} -gt 0 ]] |
| 494 | then |
493 | then |
| 495 | for((t=0; t<${module_additions}; t++)) |
494 | for((t=0; t<${module_additions}; t++)) |
| 496 | do |
495 | do |
| 497 | echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \ |
496 | echo "$(eval echo \${MODULESD_${currm}_ADDITIONS[$t]})" \ |
| 498 | >> ${module_config} |
497 | >> "${module_config}" |
| 499 | done |
498 | done |
| 500 | echo '' >> ${module_config} |
499 | echo '' >> "${module_config}" |
| 501 | fi |
500 | fi |
| 502 | |
501 | |
| 503 | #----------------------------------------------------------------------- |
502 | #----------------------------------------------------------------------- |
| 504 | |
503 | |
| 505 | # then we install it |
504 | # then we install it |
| 506 | if kernel_is ge 2 6; then |
505 | if kernel_is ge 2 6; then |
| 507 | insinto /etc/modprobe.d |
506 | insinto /etc/modprobe.d |
| 508 | else |
507 | else |
| 509 | insinto /etc/modules.d |
508 | insinto /etc/modules.d |
| 510 | fi |
509 | fi |
| 511 | newins ${module_config} ${currm_path//*\/} |
510 | newins "${module_config}" "${currm_path//*\/}.conf" |
| 512 | |
511 | |
| 513 | # and install any documentation we might have. |
512 | # and install any documentation we might have. |
| 514 | [[ -n ${module_docs} ]] && dodoc ${module_docs} |
513 | [[ -n ${module_docs} ]] && dodoc ${module_docs} |
| 515 | done |
514 | done |
| 516 | eend 0 |
515 | eend 0 |
| … | |
… | |
| 575 | # configured, verifies that the sources are prepared, verifies that the modules support is builtin |
574 | # configured, verifies that the sources are prepared, verifies that the modules support is builtin |
| 576 | # in the kernel and sets the object extension KV_OBJ. |
575 | # in the kernel and sets the object extension KV_OBJ. |
| 577 | linux-mod_pkg_setup() { |
576 | linux-mod_pkg_setup() { |
| 578 | debug-print-function ${FUNCNAME} $* |
577 | debug-print-function ${FUNCNAME} $* |
| 579 | |
578 | |
|
|
579 | # If we are installing a binpkg, take a different path. |
|
|
580 | if [[ $EMERGE_FROM == binary ]]; then |
|
|
581 | linux-mod_pkg_setup_binary |
|
|
582 | return |
|
|
583 | fi |
|
|
584 | |
| 580 | linux-info_pkg_setup; |
585 | linux-info_pkg_setup; |
| 581 | require_configured_kernel |
586 | require_configured_kernel |
| 582 | check_kernel_built; |
587 | check_kernel_built; |
| 583 | strip_modulenames; |
588 | strip_modulenames; |
| 584 | [[ -n ${MODULE_NAMES} ]] && check_modules_supported |
589 | [[ -n ${MODULE_NAMES} ]] && check_modules_supported |
| … | |
… | |
| 587 | # who intentionally use different kernel and userland compilers can be |
592 | # who intentionally use different kernel and userland compilers can be |
| 588 | # introduced - Jason Wever <weeve@gentoo.org>, 23 Oct 2005 |
593 | # introduced - Jason Wever <weeve@gentoo.org>, 23 Oct 2005 |
| 589 | #check_vermagic; |
594 | #check_vermagic; |
| 590 | } |
595 | } |
| 591 | |
596 | |
|
|
597 | # @FUNCTION: linux-mod_pkg_setup_binary |
|
|
598 | # @DESCRIPTION: |
|
|
599 | # Perform all kernel option checks non-fatally, as the .config and |
|
|
600 | # /proc/config.gz might not be present. Do not do anything that requires kernel |
|
|
601 | # sources. |
|
|
602 | linux-mod_pkg_setup_binary() { |
|
|
603 | debug-print-function ${FUNCNAME} $* |
|
|
604 | local new_CONFIG_CHECK |
|
|
605 | # ~ needs always to be quoted, else bash expands it. |
|
|
606 | for config in $CONFIG_CHECK ; do |
|
|
607 | optional='~' |
|
|
608 | [[ ${config:0:1} == "~" ]] && optional='' |
|
|
609 | new_CONFIG_CHECK="${new_CONFIG_CHECK} ${optional}${config}" |
|
|
610 | done |
|
|
611 | export CONFIG_CHECK="${new_CONFIG_CHECK}" |
|
|
612 | linux-info_pkg_setup; |
|
|
613 | } |
|
|
614 | |
| 592 | strip_modulenames() { |
615 | strip_modulenames() { |
| 593 | debug-print-function ${FUNCNAME} $* |
616 | debug-print-function ${FUNCNAME} $* |
| 594 | |
617 | |
| 595 | local i |
618 | local i |
| 596 | for i in ${MODULE_IGNORE}; do |
619 | for i in ${MODULE_IGNORE}; do |
| … | |
… | |
| 614 | ABI="${KERNEL_ABI}" |
637 | ABI="${KERNEL_ABI}" |
| 615 | |
638 | |
| 616 | BUILD_TARGETS=${BUILD_TARGETS:-clean module} |
639 | BUILD_TARGETS=${BUILD_TARGETS:-clean module} |
| 617 | strip_modulenames; |
640 | strip_modulenames; |
| 618 | cd "${S}" |
641 | cd "${S}" |
|
|
642 | touch Module.symvers |
| 619 | for i in ${MODULE_NAMES} |
643 | for i in ${MODULE_NAMES} |
| 620 | do |
644 | do |
| 621 | unset libdir srcdir objdir |
645 | unset libdir srcdir objdir |
| 622 | for n in $(find_module_params ${i}) |
646 | for n in $(find_module_params ${i}) |
| 623 | do |
647 | do |
| … | |
… | |
| 627 | srcdir=${srcdir:-${S}} |
651 | srcdir=${srcdir:-${S}} |
| 628 | objdir=${objdir:-${srcdir}} |
652 | objdir=${objdir:-${srcdir}} |
| 629 | |
653 | |
| 630 | if [ ! -f "${srcdir}/.built" ]; |
654 | if [ ! -f "${srcdir}/.built" ]; |
| 631 | then |
655 | then |
| 632 | cd ${srcdir} |
656 | cd "${srcdir}" |
|
|
657 | ln -s "${S}"/Module.symvers Module.symvers |
| 633 | einfo "Preparing ${modulename} module" |
658 | einfo "Preparing ${modulename} module" |
| 634 | if [[ -n ${ECONF_PARAMS} ]] |
659 | if [[ -n ${ECONF_PARAMS} ]] |
| 635 | then |
660 | then |
| 636 | econf ${ECONF_PARAMS} || \ |
661 | econf ${ECONF_PARAMS} || \ |
| 637 | die "Unable to run econf ${ECONF_PARAMS}" |
662 | die "Unable to run econf ${ECONF_PARAMS}" |
| … | |
… | |
| 647 | LDFLAGS=\"$(get_abi_LDFLAGS)\" \ |
672 | LDFLAGS=\"$(get_abi_LDFLAGS)\" \ |
| 648 | ${BUILD_FIXES} \ |
673 | ${BUILD_FIXES} \ |
| 649 | ${BUILD_PARAMS} \ |
674 | ${BUILD_PARAMS} \ |
| 650 | ${BUILD_TARGETS} " \ |
675 | ${BUILD_TARGETS} " \ |
| 651 | || die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}" |
676 | || die "Unable to emake HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" ${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}" |
| 652 | cd ${OLDPWD} |
677 | cd "${OLDPWD}" |
| 653 | touch ${srcdir}/.built |
678 | touch "${srcdir}"/.built |
| 654 | fi |
679 | fi |
| 655 | done |
680 | done |
| 656 | |
681 | |
| 657 | set_arch_to_portage |
682 | set_arch_to_portage |
| 658 | ABI="${myABI}" |
683 | ABI="${myABI}" |
| … | |
… | |
| 685 | libdir=${libdir:-misc} |
710 | libdir=${libdir:-misc} |
| 686 | srcdir=${srcdir:-${S}} |
711 | srcdir=${srcdir:-${S}} |
| 687 | objdir=${objdir:-${srcdir}} |
712 | objdir=${objdir:-${srcdir}} |
| 688 | |
713 | |
| 689 | einfo "Installing ${modulename} module" |
714 | einfo "Installing ${modulename} module" |
| 690 | cd ${objdir} || die "${objdir} does not exist" |
715 | cd "${objdir}" || die "${objdir} does not exist" |
| 691 | insinto /lib/modules/${KV_FULL}/${libdir} |
716 | insinto /lib/modules/${KV_FULL}/${libdir} |
| 692 | doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" |
717 | doins ${modulename}.${KV_OBJ} || die "doins ${modulename}.${KV_OBJ} failed" |
| 693 | cd ${OLDPWD} |
718 | cd "${OLDPWD}" |
| 694 | |
719 | |
| 695 | generate_modulesd ${objdir}/${modulename} |
720 | generate_modulesd "${objdir}/${modulename}" |
| 696 | done |
721 | done |
| 697 | } |
722 | } |
| 698 | |
723 | |
| 699 | # @FUNCTION: linux-mod_pkg_preinst |
724 | # @FUNCTION: linux-mod_pkg_preinst |
| 700 | # @DESCRIPTION: |
725 | # @DESCRIPTION: |