/[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.91 Revision 1.94
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 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.91 2011/12/12 22:01:37 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/linux-info.eclass,v 1.94 2013/01/14 21:19:39 vapier Exp $
4 4
5# @ECLASS: linux-info.eclass 5# @ECLASS: linux-info.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# kernel-misc@gentoo.org 7# kernel-misc@gentoo.org
8# @AUTHOR: 8# @AUTHOR:
16# using additional eclasses. 16# using additional eclasses.
17# 17#
18# "kernel config" in this file means: 18# "kernel config" in this file means:
19# The .config of the currently installed sources is used as the first 19# The .config of the currently installed sources is used as the first
20# preference, with a fall-back to bundled config (/proc/config.gz) if available. 20# preference, with a fall-back to bundled config (/proc/config.gz) if available.
21#
22# Before using any of the config-handling functions in this eclass, you must
23# ensure that one of the following functions has been called (in order of
24# preference), otherwise you will get bugs like #364041):
25# linux-info_pkg_setup
26# linux-info_get_any_version
27# get_version
28# get_running_version
21 29
22# A Couple of env vars are available to effect usage of this eclass 30# A Couple of env vars are available to effect usage of this eclass
23# These are as follows: 31# These are as follows:
24 32
25# @ECLASS-VARIABLE: KERNEL_DIR 33# @ECLASS-VARIABLE: KERNEL_DIR
157# @DESCRIPTION: 165# @DESCRIPTION:
158# It detects the value of the variable defined in the file configfile. This is 166# It detects the value of the variable defined in the file configfile. This is
159# done by including the configfile, and printing the variable with Make. 167# done by including the configfile, and printing the variable with Make.
160# It WILL break if your makefile has missing dependencies! 168# It WILL break if your makefile has missing dependencies!
161getfilevar() { 169getfilevar() {
162local ERROR basefname basedname myARCH="${ARCH}" 170 local ERROR basefname basedname myARCH="${ARCH}"
163 ERROR=0 171 ERROR=0
164 172
165 [ -z "${1}" ] && ERROR=1 173 [ -z "${1}" ] && ERROR=1
166 [ ! -f "${2}" ] && ERROR=1 174 [ ! -f "${2}" ] && ERROR=1
167 175
188# @DESCRIPTION: 196# @DESCRIPTION:
189# It detects the value of the variable defined in the file configfile. 197# It detects the value of the variable defined in the file configfile.
190# This is done with sed matching an expression only. If the variable is defined, 198# This is done with sed matching an expression only. If the variable is defined,
191# you will run into problems. See getfilevar for those cases. 199# you will run into problems. See getfilevar for those cases.
192getfilevar_noexec() { 200getfilevar_noexec() {
193 local ERROR basefname basedname mycat myARCH="${ARCH}" 201 local ERROR basefname basedname mycat myARCH="${ARCH}"
194 ERROR=0 202 ERROR=0
195 mycat='cat' 203 mycat='cat'
196 204
197 [ -z "${1}" ] && ERROR=1 205 [ -z "${1}" ] && ERROR=1
198 [ ! -f "${2}" ] && ERROR=1 206 [ ! -f "${2}" ] && ERROR=1
281# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config 289# It checks that CONFIG_<option>=y or CONFIG_<option>=m is present in the current kernel .config
282# If linux_config_exists returns false, the results of this are UNDEFINED. You 290# If linux_config_exists returns false, the results of this are UNDEFINED. You
283# MUST call linux_config_exists first. 291# MUST call linux_config_exists first.
284linux_chkconfig_present() { 292linux_chkconfig_present() {
285 linux_config_qa_check linux_chkconfig_present 293 linux_config_qa_check linux_chkconfig_present
286 local RESULT
287 local config 294 local RESULT config
288 config="${KV_OUT_DIR}/.config" 295 config="${KV_OUT_DIR}/.config"
289 [ ! -f "${config}" ] && config="/proc/config.gz" 296 [ ! -f "${config}" ] && config="/proc/config.gz"
290 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" 297 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
291 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1 298 [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
292} 299}
298# It checks that CONFIG_<option>=m is present in the current kernel .config 305# It checks that CONFIG_<option>=m is present in the current kernel .config
299# If linux_config_exists returns false, the results of this are UNDEFINED. You 306# If linux_config_exists returns false, the results of this are UNDEFINED. You
300# MUST call linux_config_exists first. 307# MUST call linux_config_exists first.
301linux_chkconfig_module() { 308linux_chkconfig_module() {
302 linux_config_qa_check linux_chkconfig_module 309 linux_config_qa_check linux_chkconfig_module
303 local RESULT
304 local config 310 local RESULT config
305 config="${KV_OUT_DIR}/.config" 311 config="${KV_OUT_DIR}/.config"
306 [ ! -f "${config}" ] && config="/proc/config.gz" 312 [ ! -f "${config}" ] && config="/proc/config.gz"
307 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" 313 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
308 [ "${RESULT}" = "m" ] && return 0 || return 1 314 [ "${RESULT}" = "m" ] && return 0 || return 1
309} 315}
315# It checks that CONFIG_<option>=y is present in the current kernel .config 321# It checks that CONFIG_<option>=y is present in the current kernel .config
316# If linux_config_exists returns false, the results of this are UNDEFINED. You 322# If linux_config_exists returns false, the results of this are UNDEFINED. You
317# MUST call linux_config_exists first. 323# MUST call linux_config_exists first.
318linux_chkconfig_builtin() { 324linux_chkconfig_builtin() {
319 linux_config_qa_check linux_chkconfig_builtin 325 linux_config_qa_check linux_chkconfig_builtin
320 local RESULT
321 local config 326 localRESULT config
322 config="${KV_OUT_DIR}/.config" 327 config="${KV_OUT_DIR}/.config"
323 [ ! -f "${config}" ] && config="/proc/config.gz" 328 [ ! -f "${config}" ] && config="/proc/config.gz"
324 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" 329 RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")"
325 [ "${RESULT}" = "y" ] && return 0 || return 1 330 [ "${RESULT}" = "y" ] && return 0 || return 1
326} 331}
615check_kernel_built() { 620check_kernel_built() {
616 # if we haven't determined the version yet, we need to 621 # if we haven't determined the version yet, we need to
617 require_configured_kernel 622 require_configured_kernel
618 get_version 623 get_version
619 624
625 local versionh_path
626 if kernel_is -ge 3 7; then
627 versionh_path="include/generated/uapi/linux/version.h"
628 else
629 versionh_path="include/linux/version.h"
630 fi
631
620 if [ ! -f "${KV_OUT_DIR}/include/linux/version.h" ] 632 if [ ! -f "${KV_OUT_DIR}/${versionh_path}" ]
621 then 633 then
622 eerror "These sources have not yet been prepared." 634 eerror "These sources have not yet been prepared."
623 eerror "We cannot build against an unprepared tree." 635 eerror "We cannot build against an unprepared tree."
624 eerror "To resolve this, please type the following:" 636 eerror "To resolve this, please type the following:"
625 eerror 637 eerror
638check_modules_supported() { 650check_modules_supported() {
639 # if we haven't determined the version yet, we need too. 651 # if we haven't determined the version yet, we need too.
640 require_configured_kernel 652 require_configured_kernel
641 get_version 653 get_version
642 654
643 if ! linux_chkconfig_builtin "MODULES" 655 if ! linux_chkconfig_builtin "MODULES"; then
644 then
645 eerror "These sources do not support loading external modules." 656 eerror "These sources do not support loading external modules."
646 eerror "to be able to use this module please enable \"Loadable modules support\"" 657 eerror "to be able to use this module please enable \"Loadable modules support\""
647 eerror "in your kernel, recompile and then try merging this module again." 658 eerror "in your kernel, recompile and then try merging this module again."
648 die "No support for external modules in ${KV_FULL} config" 659 die "No support for external modules in ${KV_FULL} config"
649 fi 660 fi
652# @FUNCTION: check_extra_config 663# @FUNCTION: check_extra_config
653# @DESCRIPTION: 664# @DESCRIPTION:
654# It checks the kernel config options specified by CONFIG_CHECK. It dies only when a required config option (i.e. 665# It checks the kernel config options specified by CONFIG_CHECK. It dies only when a required config option (i.e.
655# the prefix ~ is not used) doesn't satisfy the directive. 666# the prefix ~ is not used) doesn't satisfy the directive.
656check_extra_config() { 667check_extra_config() {
657 local config negate die error reworkmodulenames 668 local config negate die error reworkmodulenames
658 local soft_errors_count=0 hard_errors_count=0 config_required=0 669 local soft_errors_count=0 hard_errors_count=0 config_required=0
659 # store the value of the QA check, because otherwise we won't catch usages 670 # store the value of the QA check, because otherwise we won't catch usages
660 # after if check_extra_config is called AND other direct calls are done 671 # after if check_extra_config is called AND other direct calls are done
661 # later. 672 # later.
662 local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}" 673 local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}"
663 674
664 # if we haven't determined the version yet, we need to 675 # if we haven't determined the version yet, we need to
665 linux-info_get_any_version 676 linux-info_get_any_version
666 677
667 # Determine if we really need a .config. The only time when we don't need 678 # Determine if we really need a .config. The only time when we don't need
668 # one is when all of the CONFIG_CHECK options are prefixed with "~". 679 # one is when all of the CONFIG_CHECK options are prefixed with "~".
669 for config in ${CONFIG_CHECK} 680 for config in ${CONFIG_CHECK}; do
670 do
671 if [[ "${config:0:1}" != "~" ]]; then 681 if [[ "${config:0:1}" != "~" ]]; then
672 config_required=1 682 config_required=1
673 break 683 break
674 fi 684 fi
675 done 685 done

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.94

  ViewVC Help
Powered by ViewVC 1.1.20