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

Diff of /eclass/linux-info.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.40 Revision 1.52
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2006 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-info.eclass,v 1.40 2006/02/16 21:46:50 exg Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.52 2007/10/03 12:53:10 phreak Exp $
4# 4#
5# Description: This eclass is used as a central eclass for accessing kernel 5# Description: This eclass is used as a central eclass for accessing kernel
6# related information for sources already installed. 6# related information for sources already installed.
7# It is vital for linux-mod to function correctly, and is split 7# It is vital for linux-mod to function correctly, and is split
8# out so that any ebuild behaviour "templates" are abstracted out 8# out so that any ebuild behaviour "templates" are abstracted out
9# using additional eclasses. 9# using additional eclasses.
10# 10#
11# Maintainer: John Mylchreest <johnm@gentoo.org> 11# Original author: John Mylchreest <johnm@gentoo.org>
12# Copyright 2004 Gentoo Linux 12# Maintainer: kernel-misc@gentoo.org
13# 13#
14# Please direct your bugs to the current eclass maintainer :) 14# Please direct your bugs to the current eclass maintainer :)
15 15
16# A Couple of env vars are available to effect usage of this eclass 16# A Couple of env vars are available to effect usage of this eclass
17# These are as follows: 17# These are as follows:
67case ${ARCH} in 67case ${ARCH} in
68 ppc) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";; 68 ppc) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
69 ppc64) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";; 69 ppc64) BUILD_FIXES="${BUILD_FIXES} TOUT=${T}/.tmp_gas_check";;
70esac 70esac
71 71
72# These are legacy wrappers for toolchain-funcs. 72# @FUNCTION: set_arch_to_kernel
73# I dont like them here, but oh well. 73# @DESCRIPTION:
74# Set the env ARCH to match what the kernel expects.
74set_arch_to_kernel() { export ARCH="$(tc-arch-kernel)"; } 75set_arch_to_kernel() { export ARCH=$(tc-arch-kernel); }
76# @FUNCTION: set_arch_to_portage
77# @DESCRIPTION:
78# Set the env ARCH to match what portage expects.
75set_arch_to_portage() { export ARCH="$(tc-arch)"; } 79set_arch_to_portage() { export ARCH=$(tc-arch); }
76 80
77# qeinfo "Message" 81# qeinfo "Message"
78# ------------------- 82# -------------------
79# qeinfo is a quiet einfo call when EBUILD_PHASE 83# qeinfo is a quiet einfo call when EBUILD_PHASE
80# should not have visible output. 84# should not have visible output.
117 basefname="$(basename ${2})" 121 basefname="$(basename ${2})"
118 basedname="$(dirname ${2})" 122 basedname="$(dirname ${2})"
119 unset ARCH 123 unset ARCH
120 124
121 cd "${basedname}" 125 cd "${basedname}"
122 echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \ 126 echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | \
123 make ${BUILD_FIXES} -s -f - e 2>/dev/null 127 make M="${S}" ${BUILD_FIXES} -s -f - 2>/dev/null
124 cd "${workingdir}" 128 cd "${workingdir}"
125 129
126 ARCH=${myARCH} 130 ARCH=${myARCH}
127 fi 131 fi
128} 132}
278 282
279 # and in newer versions we can also pull LOCALVERSION if it is set. 283 # and in newer versions we can also pull LOCALVERSION if it is set.
280 # but before we do this, we need to find if we use a different object directory. 284 # but before we do this, we need to find if we use a different object directory.
281 # This *WILL* break if the user is using localversions, but we assume it was 285 # This *WILL* break if the user is using localversions, but we assume it was
282 # caught before this if they are. 286 # caught before this if they are.
283 [ "${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.${KV_EXTRA}" == "$(uname -r)" ] && \ 287 [ "${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}" == "$(uname -r)" ] && \
284 OUTPUT_DIR="${OUTPUT_DIR:-/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}.${KV_EXTRA}/build}" 288 OUTPUT_DIR="${OUTPUT_DIR:-/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build}"
285 289
286 [ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})" 290 [ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})"
287 [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}" 291 [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}"
288 if [ -n "${KV_OUT_DIR}" ]; 292 if [ -n "${KV_OUT_DIR}" ];
289 then 293 then
290 qeinfo "Found kernel object directory:" 294 qeinfo "Found kernel object directory:"
291 qeinfo " ${KV_OUT_DIR}" 295 qeinfo " ${KV_OUT_DIR}"
292 296
293 KV_LOCAL="$(get_localversion ${KV_OUT_DIR})" 297 KV_LOCAL="$(get_localversion ${KV_OUT_DIR})"
294 fi 298 fi
295 # and if we STILL haven't got it, then we better just set it to KV_DIR 299 # and if we STILL have not got it, then we better just set it to KV_DIR
296 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}" 300 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
297
298 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})"
299 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)"
300 KV_LOCAL="${KV_LOCAL//\"/}"
301
302 # And we should set KV_FULL to the full expanded version
303 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"
304
305 qeinfo "Found sources for kernel version:"
306 qeinfo " ${KV_FULL}"
307 301
308 if [ ! -s "${KV_OUT_DIR}/.config" ] 302 if [ ! -s "${KV_OUT_DIR}/.config" ]
309 then 303 then
310 qeerror "Could not find a usable .config in the kernel source directory." 304 qeerror "Could not find a usable .config in the kernel source directory."
311 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources." 305 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources."
312 qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that" 306 qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that"
313 qeerror "it points to the necessary object directory so that it might find .config." 307 qeerror "it points to the necessary object directory so that it might find .config."
314 return 1 308 return 1
315 fi 309 fi
310
311 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})"
312 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)"
313 KV_LOCAL="${KV_LOCAL//\"/}"
314
315 # For things like git that can append extra stuff:
316 [ -e ${KV_DIR}/scripts/setlocalversion ] &&
317 linux_chkconfig_builtin LOCALVERSION_AUTO &&
318 KV_LOCAL="${KV_LOCAL}$(sh ${KV_DIR}/scripts/setlocalversion ${KV_DIR})"
319
320 # And we should set KV_FULL to the full expanded version
321 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"
322
323 qeinfo "Found sources for kernel version:"
324 qeinfo " ${KV_FULL}"
316 325
317 return 0 326 return 0
318} 327}
319 328
320get_running_version() { 329get_running_version() {
376 die "No support for external modules in ${KV_FULL} config" 385 die "No support for external modules in ${KV_FULL} config"
377 fi 386 fi
378} 387}
379 388
380check_extra_config() { 389check_extra_config() {
381 local config negate error local_error i n
382 local temp_config die reworkmodulenames 390 local config negate die error reworkmodulenames
391 local soft_errors_count=0 hard_errors_count=0
383 392
384 # if we haven't determined the version yet, we need too. 393 # if we haven't determined the version yet, we need too.
385 get_version; 394 get_version;
386 395
387 einfo "Checking for suitable kernel configuration options:" 396 einfo "Checking for suitable kernel configuration options..."
388 for config in ${CONFIG_CHECK} 397 for config in ${CONFIG_CHECK}
389 do 398 do
390 # if we specify any fatal, ensure we honor them 399 # if we specify any fatal, ensure we honor them
391 die=1 400 die=1
392 error=0 401 error=0
393 negate=0 402 negate=0
394 reworkmodulenames=0 403 reworkmodulenames=0
395 404
405 if [[ -z ${config/\~*} ]]; then
406 die=0
407 config=${config:1}
408 elif [[ -z ${config/\@*} ]]; then
409 die=0
410 reworkmodulenames=1
411 config=${config:1}
412 fi
396 if [[ -z ${config//\!*} ]]; then 413 if [[ -z ${config//\!*} ]]; then
397 negate=1 414 negate=1
398 config=${config:1} 415 config=${config:1}
399 fi 416 fi
400 if [[ -z ${config/\@*} ]]; then
401 die=2
402 reworkmodulenames=1
403 config=${config:1}
404 fi
405 if [[ -z ${config/\~*} ]]; then
406 die=0
407 config=${config:1}
408 fi
409 417
410 if [[ ${negate} == 1 ]]; then 418 if [[ ${negate} == 1 ]]; then
411 linux_chkconfig_present ${config} && error=2 419 linux_chkconfig_present ${config} && error=2
412 elif [[ ${reworkmodulenames} == 1 ]]; then 420 elif [[ ${reworkmodulenames} == 1 ]]; then
413 temp_config="${config//*:}" 421 local temp_config="${config//*:}" i n
414 config="${config//:*}" 422 config="${config//:*}"
415 if linux_chkconfig_present ${config}; then 423 if linux_chkconfig_present ${config}; then
416 for i in ${MODULE_NAMES}; do 424 for i in ${MODULE_NAMES}; do
417 n="${i//${temp_config}}" 425 n="${i//${temp_config}}"
418 [[ -z ${n//\(*} ]] && \ 426 [[ -z ${n//\(*} ]] && \
422 fi 430 fi
423 else 431 else
424 linux_chkconfig_present ${config} || error=1 432 linux_chkconfig_present ${config} || error=1
425 fi 433 fi
426 434
427 if [[ ${die} == 0 ]]; then
428 ebegin "CONFIG_${config}"
429 eend ${error}
430 else
431 if [[ ${error} > 0 ]]; then 435 if [[ ${error} > 0 ]]; then
436 local report_func="eerror" local_error
432 local_error="ERROR_${config}" 437 local_error="ERROR_${config}"
438 local_error="${!local_error}"
439
440 if [[ -z "${local_error}" ]]; then
441 # using old, deprecated format.
442 local_error="${config}_ERROR"
433 local_error="${!local_error}" 443 local_error="${!local_error}"
434 444 fi
435 if [[ -z "${local_error}" ]]; then 445 if [[ ${die} == 0 && -z "${local_error}" ]]; then
436 # using old, deprecated format. 446 #soft errors can be warnings
437 local_error="${config}_ERROR" 447 local_error="WARNING_${config}"
438 local_error="${!local_error}" 448 local_error="${!local_error}"
449 if [[ -n "${local_error}" ]] ; then
450 report_func="ewarn"
439 fi 451 fi
440
441 if [[ -z "${local_error}" ]]; then
442 [[ ${error} == 1 ]] \
443 && local_error="is not set when it should be." \
444 || local_error="should not be set. But it is."
445 local_error="CONFIG_${config}:\t ${local_error}"
446 fi
447 eerror " ${local_error}"
448 fi 452 fi
453
454 if [[ -z "${local_error}" ]]; then
455 [[ ${error} == 1 ]] \
456 && local_error="is not set when it should be." \
457 || local_error="should not be set. But it is."
458 local_error="CONFIG_${config}:\t ${local_error}"
459 fi
460 if [[ ${die} == 0 ]]; then
461 ${report_func} " ${local_error}"
462 soft_errors_count=$[soft_errors_count + 1]
463 else
464 ${report_func} " ${local_error}"
465 hard_errors_count=$[hard_errors_count + 1]
466 fi
449 fi 467 fi
450 done 468 done
451 469
452 if [[ ${error} > 0 ]]; then 470 if [[ ${hard_errors_count} > 0 ]]; then
453 eerror "Please check to make sure these options are set correctly." 471 eerror "Please check to make sure these options are set correctly."
454 eerror "Failure to do so may cause unexpected problems." 472 eerror "Failure to do so may cause unexpected problems."
455 if [[ ${die} == 1 ]]; then
456 eerror "Once you have satisfied these options, please try merging" 473 eerror "Once you have satisfied these options, please try merging"
457 eerror "this package again." 474 eerror "this package again."
458 die "Incorrect kernel configuration options" 475 die "Incorrect kernel configuration options"
459 fi 476 elif [[ ${soft_errors_count} > 0 ]]; then
477 ewarn "Please check to make sure these options are set correctly."
478 ewarn "Failure to do so may cause unexpected problems."
479 else
480 eend 0
460 fi 481 fi
461} 482}
462 483
463check_zlibinflate() { 484check_zlibinflate() {
464 # if we haven't determined the version yet, we need too. 485 # if we haven't determined the version yet, we need too.
533# Default pkg_setup 554# Default pkg_setup
534# Also used when inheriting linux-mod to force a get_version call 555# Also used when inheriting linux-mod to force a get_version call
535 556
536linux-info_pkg_setup() { 557linux-info_pkg_setup() {
537 get_version || die "Unable to calculate Linux Kernel version" 558 get_version || die "Unable to calculate Linux Kernel version"
559
560 if kernel_is 2 4; then
561 if [ "$( gcc-major-version )" -eq "4" ] ; then
562 echo
563 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with"
564 ewarn "linux-2.4 (or modules building against a linux-2.4 kernel)!"
565 echo
566 ewarn "Either switch to another gcc-version (via gcc-config) or use a"
567 ewarn "newer kernel that supports gcc-4."
568 echo
569 ewarn "Also be aware that bugreports about gcc-4 not working"
570 ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
571 echo
572 epause 10
573 fi
574 fi
575
538 [ -n "${CONFIG_CHECK}" ] && check_extra_config; 576 [ -n "${CONFIG_CHECK}" ] && check_extra_config;
539} 577}

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.52

  ViewVC Help
Powered by ViewVC 1.1.20