/[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.52 Revision 1.53
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.52 2007/10/03 12:53:10 phreak Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.53 2008/01/22 21:05:31 dsd 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
129 129
130 ARCH=${myARCH} 130 ARCH=${myARCH}
131 fi 131 fi
132} 132}
133 133
134
135linux_config_exists() {
136 [ -s "${KV_OUT_DIR}/.config" ]
137}
138
139require_configured_kernel() {
140 if ! linux_config_exists; then
141 qeerror "Could not find a usable .config in the kernel source directory."
142 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources."
143 qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that"
144 qeerror "it points to the necessary object directory so that it might find .config."
145 die "Kernel not configured; no .config found in ${KV_OUT_DIR}"
146 fi
147}
148
134linux_chkconfig_present() { 149linux_chkconfig_present() {
135local RESULT 150local RESULT
151 require_configured_kernel
136 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 152 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)"
137 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1 153 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
138} 154}
139 155
140linux_chkconfig_module() { 156linux_chkconfig_module() {
141local RESULT 157local RESULT
158 require_configured_kernel
142 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 159 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)"
143 [ "${RESULT}" = "m" ] && return 0 || return 1 160 [ "${RESULT}" = "m" ] && return 0 || return 1
144} 161}
145 162
146linux_chkconfig_builtin() { 163linux_chkconfig_builtin() {
147local RESULT 164local RESULT
165 require_configured_kernel
148 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)" 166 RESULT="$(getfilevar CONFIG_${1} ${KV_OUT_DIR}/.config)"
149 [ "${RESULT}" = "y" ] && return 0 || return 1 167 [ "${RESULT}" = "y" ] && return 0 || return 1
150} 168}
151 169
152linux_chkconfig_string() { 170linux_chkconfig_string() {
171 require_configured_kernel
153 getfilevar "CONFIG_${1}" "${KV_OUT_DIR}/.config" 172 getfilevar "CONFIG_${1}" "${KV_OUT_DIR}/.config"
154} 173}
155 174
156# Versioning Functions 175# Versioning Functions
157# --------------------------------------- 176# ---------------------------------------
166# kernel_is 2 6 9 returns true 185# kernel_is 2 6 9 returns true
167# 186#
168# got the jist yet? 187# got the jist yet?
169 188
170kernel_is() { 189kernel_is() {
171 # if we haven't determined the version yet, we need too. 190 # if we haven't determined the version yet, we need to.
172 get_version; 191 get_version
173 local operator test value x=0 y=0 z=0 192 local operator test value x=0 y=0 z=0
174 193
175 case ${1} in 194 case ${1} in
176 lt) operator="-lt"; shift;; 195 lt) operator="-lt"; shift;;
177 gt) operator="-gt"; shift;; 196 gt) operator="-gt"; shift;;
297 KV_LOCAL="$(get_localversion ${KV_OUT_DIR})" 316 KV_LOCAL="$(get_localversion ${KV_OUT_DIR})"
298 fi 317 fi
299 # and if we STILL have not got it, then we better just set it to KV_DIR 318 # and if we STILL have not got it, then we better just set it to KV_DIR
300 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}" 319 KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}"
301 320
302 if [ ! -s "${KV_OUT_DIR}/.config" ]
303 then
304 qeerror "Could not find a usable .config in the kernel source directory."
305 qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources."
306 qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that"
307 qeerror "it points to the necessary object directory so that it might find .config."
308 return 1
309 fi
310
311 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})" 321 KV_LOCAL="${KV_LOCAL}$(get_localversion ${KV_DIR})"
322 if linux_config_exists; then
312 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)" 323 KV_LOCAL="${KV_LOCAL}$(linux_chkconfig_string LOCALVERSION)"
313 KV_LOCAL="${KV_LOCAL//\"/}" 324 KV_LOCAL="${KV_LOCAL//\"/}"
314 325
315 # For things like git that can append extra stuff: 326 # For things like git that can append extra stuff:
316 [ -e ${KV_DIR}/scripts/setlocalversion ] && 327 [ -e ${KV_DIR}/scripts/setlocalversion ] &&
317 linux_chkconfig_builtin LOCALVERSION_AUTO && 328 linux_chkconfig_builtin LOCALVERSION_AUTO &&
318 KV_LOCAL="${KV_LOCAL}$(sh ${KV_DIR}/scripts/setlocalversion ${KV_DIR})" 329 KV_LOCAL="${KV_LOCAL}$(sh ${KV_DIR}/scripts/setlocalversion ${KV_DIR})"
330 fi
319 331
320 # And we should set KV_FULL to the full expanded version 332 # And we should set KV_FULL to the full expanded version
321 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}" 333 KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}"
322 334
323 qeinfo "Found sources for kernel version:" 335 qeinfo "Found sources for kernel version:"
353 365
354# ebuild check functions 366# ebuild check functions
355# --------------------------------------- 367# ---------------------------------------
356 368
357check_kernel_built() { 369check_kernel_built() {
358 # if we haven't determined the version yet, we need too. 370 # if we haven't determined the version yet, we need to
371 require_kernel_config
359 get_version; 372 get_version
360 373
361 if [ ! -f "${KV_OUT_DIR}/include/linux/version.h" ] 374 if [ ! -f "${KV_OUT_DIR}/include/linux/version.h" ]
362 then 375 then
363 eerror "These sources have not yet been prepared." 376 eerror "These sources have not yet been prepared."
364 eerror "We cannot build against an unprepared tree." 377 eerror "We cannot build against an unprepared tree."
373 fi 386 fi
374} 387}
375 388
376check_modules_supported() { 389check_modules_supported() {
377 # if we haven't determined the version yet, we need too. 390 # if we haven't determined the version yet, we need too.
391 require_configured_kernel
378 get_version; 392 get_version
379 393
380 if ! linux_chkconfig_builtin "MODULES" 394 if ! linux_chkconfig_builtin "MODULES"
381 then 395 then
382 eerror "These sources do not support loading external modules." 396 eerror "These sources do not support loading external modules."
383 eerror "to be able to use this module please enable \"Loadable modules support\"" 397 eerror "to be able to use this module please enable \"Loadable modules support\""
386 fi 400 fi
387} 401}
388 402
389check_extra_config() { 403check_extra_config() {
390 local config negate die error reworkmodulenames 404 local config negate die error reworkmodulenames
391 local soft_errors_count=0 hard_errors_count=0 405 local soft_errors_count=0 hard_errors_count=0 config_required=0
406
407 # Determine if we really need a .config. The only time when we don't need
408 # one is when all of the CONFIG_CHECK options are prefixed with "~".
409 for config in ${CONFIG_CHECK}
410 do
411 if [[ "${config:0:1}" != "~" ]]; then
412 config_required=1
413 break
414 fi
415 done
416
417 if [[ ${config_required} == 0 ]]; then
418 # In the case where we don't require a .config, we can now bail out
419 # if the user has no .config as there is nothing to do. Otherwise
420 # code later will cause a failure due to missing .config.
421 if ! linux_config_exists; then
422 return 0
423 fi
424 else
425 require_configured_kernel
426 fi
392 427
393 # if we haven't determined the version yet, we need too. 428 # if we haven't determined the version yet, we need too.
394 get_version; 429 get_version
395 430
396 einfo "Checking for suitable kernel configuration options..." 431 einfo "Checking for suitable kernel configuration options..."
432
397 for config in ${CONFIG_CHECK} 433 for config in ${CONFIG_CHECK}
398 do 434 do
399 # if we specify any fatal, ensure we honor them 435 # if we specify any fatal, ensure we honor them
400 die=1 436 die=1
401 error=0 437 error=0
402 negate=0 438 negate=0
403 reworkmodulenames=0 439 reworkmodulenames=0
404 440
405 if [[ -z ${config/\~*} ]]; then 441 if [[ ${config:0:1} == "~" ]]; then
406 die=0 442 die=0
407 config=${config:1} 443 config=${config:1}
408 elif [[ -z ${config/\@*} ]]; then 444 elif [[ ${config:0:1} == "@" ]]; then
409 die=0 445 die=0
410 reworkmodulenames=1 446 reworkmodulenames=1
411 config=${config:1} 447 config=${config:1}
412 fi 448 fi
413 if [[ -z ${config//\!*} ]]; then 449 if [[ ${config:0:1} == "!" ]]; then
414 negate=1 450 negate=1
415 config=${config:1} 451 config=${config:1}
416 fi 452 fi
417 453
418 if [[ ${negate} == 1 ]]; then 454 if [[ ${negate} == 1 ]]; then
480 eend 0 516 eend 0
481 fi 517 fi
482} 518}
483 519
484check_zlibinflate() { 520check_zlibinflate() {
485 # if we haven't determined the version yet, we need too. 521 # if we haven't determined the version yet, we need to
522 require_configured_kernel
486 get_version; 523 get_version
487 524
488 # although I restructured this code - I really really really dont support it! 525 # although I restructured this code - I really really really dont support it!
489 526
490 # bug #27882 - zlib routines are only linked into the kernel 527 # bug #27882 - zlib routines are only linked into the kernel
491 # if something compiled into the kernel calls them 528 # if something compiled into the kernel calls them

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

  ViewVC Help
Powered by ViewVC 1.1.20