| 1 | # Copyright 1999-2012 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.93 2012/10/22 19:00:52 mpagano 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: |
| … | |
… | |
| 165 | # @DESCRIPTION: |
165 | # @DESCRIPTION: |
| 166 | # 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 |
| 167 | # done by including the configfile, and printing the variable with Make. |
167 | # done by including the configfile, and printing the variable with Make. |
| 168 | # It WILL break if your makefile has missing dependencies! |
168 | # It WILL break if your makefile has missing dependencies! |
| 169 | getfilevar() { |
169 | getfilevar() { |
| 170 | local ERROR basefname basedname myARCH="${ARCH}" |
170 | local ERROR basefname basedname myARCH="${ARCH}" |
| 171 | ERROR=0 |
171 | ERROR=0 |
| 172 | |
172 | |
| 173 | [ -z "${1}" ] && ERROR=1 |
173 | [ -z "${1}" ] && ERROR=1 |
| 174 | [ ! -f "${2}" ] && ERROR=1 |
174 | [ ! -f "${2}" ] && ERROR=1 |
| 175 | |
175 | |
| … | |
… | |
| 196 | # @DESCRIPTION: |
196 | # @DESCRIPTION: |
| 197 | # 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. |
| 198 | # 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, |
| 199 | # you will run into problems. See getfilevar for those cases. |
199 | # you will run into problems. See getfilevar for those cases. |
| 200 | getfilevar_noexec() { |
200 | getfilevar_noexec() { |
| 201 | local ERROR basefname basedname mycat myARCH="${ARCH}" |
201 | local ERROR basefname basedname mycat myARCH="${ARCH}" |
| 202 | ERROR=0 |
202 | ERROR=0 |
| 203 | mycat='cat' |
203 | mycat='cat' |
| 204 | |
204 | |
| 205 | [ -z "${1}" ] && ERROR=1 |
205 | [ -z "${1}" ] && ERROR=1 |
| 206 | [ ! -f "${2}" ] && ERROR=1 |
206 | [ ! -f "${2}" ] && ERROR=1 |
| … | |
… | |
| 289 | # 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 |
| 290 | # 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 |
| 291 | # MUST call linux_config_exists first. |
291 | # MUST call linux_config_exists first. |
| 292 | linux_chkconfig_present() { |
292 | linux_chkconfig_present() { |
| 293 | linux_config_qa_check linux_chkconfig_present |
293 | linux_config_qa_check linux_chkconfig_present |
| 294 | local RESULT |
|
|
| 295 | local config |
294 | local RESULT config |
| 296 | config="${KV_OUT_DIR}/.config" |
295 | config="${KV_OUT_DIR}/.config" |
| 297 | [ ! -f "${config}" ] && config="/proc/config.gz" |
296 | [ ! -f "${config}" ] && config="/proc/config.gz" |
| 298 | RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" |
297 | RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" |
| 299 | [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1 |
298 | [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1 |
| 300 | } |
299 | } |
| … | |
… | |
| 306 | # 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 |
| 307 | # 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 |
| 308 | # MUST call linux_config_exists first. |
307 | # MUST call linux_config_exists first. |
| 309 | linux_chkconfig_module() { |
308 | linux_chkconfig_module() { |
| 310 | linux_config_qa_check linux_chkconfig_module |
309 | linux_config_qa_check linux_chkconfig_module |
| 311 | local RESULT |
|
|
| 312 | local config |
310 | local RESULT config |
| 313 | config="${KV_OUT_DIR}/.config" |
311 | config="${KV_OUT_DIR}/.config" |
| 314 | [ ! -f "${config}" ] && config="/proc/config.gz" |
312 | [ ! -f "${config}" ] && config="/proc/config.gz" |
| 315 | RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" |
313 | RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" |
| 316 | [ "${RESULT}" = "m" ] && return 0 || return 1 |
314 | [ "${RESULT}" = "m" ] && return 0 || return 1 |
| 317 | } |
315 | } |
| … | |
… | |
| 323 | # 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 |
| 324 | # 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 |
| 325 | # MUST call linux_config_exists first. |
323 | # MUST call linux_config_exists first. |
| 326 | linux_chkconfig_builtin() { |
324 | linux_chkconfig_builtin() { |
| 327 | linux_config_qa_check linux_chkconfig_builtin |
325 | linux_config_qa_check linux_chkconfig_builtin |
| 328 | local RESULT |
|
|
| 329 | local config |
326 | localRESULT config |
| 330 | config="${KV_OUT_DIR}/.config" |
327 | config="${KV_OUT_DIR}/.config" |
| 331 | [ ! -f "${config}" ] && config="/proc/config.gz" |
328 | [ ! -f "${config}" ] && config="/proc/config.gz" |
| 332 | RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" |
329 | RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")" |
| 333 | [ "${RESULT}" = "y" ] && return 0 || return 1 |
330 | [ "${RESULT}" = "y" ] && return 0 || return 1 |
| 334 | } |
331 | } |
| … | |
… | |
| 653 | check_modules_supported() { |
650 | check_modules_supported() { |
| 654 | # if we haven't determined the version yet, we need too. |
651 | # if we haven't determined the version yet, we need too. |
| 655 | require_configured_kernel |
652 | require_configured_kernel |
| 656 | get_version |
653 | get_version |
| 657 | |
654 | |
| 658 | if ! linux_chkconfig_builtin "MODULES" |
655 | if ! linux_chkconfig_builtin "MODULES"; then |
| 659 | then |
|
|
| 660 | eerror "These sources do not support loading external modules." |
656 | eerror "These sources do not support loading external modules." |
| 661 | 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\"" |
| 662 | 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." |
| 663 | die "No support for external modules in ${KV_FULL} config" |
659 | die "No support for external modules in ${KV_FULL} config" |
| 664 | fi |
660 | fi |
| … | |
… | |
| 667 | # @FUNCTION: check_extra_config |
663 | # @FUNCTION: check_extra_config |
| 668 | # @DESCRIPTION: |
664 | # @DESCRIPTION: |
| 669 | # 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. |
| 670 | # the prefix ~ is not used) doesn't satisfy the directive. |
666 | # the prefix ~ is not used) doesn't satisfy the directive. |
| 671 | check_extra_config() { |
667 | check_extra_config() { |
| 672 | local config negate die error reworkmodulenames |
668 | local config negate die error reworkmodulenames |
| 673 | 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 |
| 674 | # 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 |
| 675 | # 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 |
| 676 | # later. |
672 | # later. |
| 677 | local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}" |
673 | local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}" |
| 678 | |
674 | |
| 679 | # if we haven't determined the version yet, we need to |
675 | # if we haven't determined the version yet, we need to |
| 680 | linux-info_get_any_version |
676 | linux-info_get_any_version |
| 681 | |
677 | |
| 682 | # 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 |
| 683 | # 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 "~". |
| 684 | for config in ${CONFIG_CHECK} |
680 | for config in ${CONFIG_CHECK}; do |
| 685 | do |
|
|
| 686 | if [[ "${config:0:1}" != "~" ]]; then |
681 | if [[ "${config:0:1}" != "~" ]]; then |
| 687 | config_required=1 |
682 | config_required=1 |
| 688 | break |
683 | break |
| 689 | fi |
684 | fi |
| 690 | done |
685 | done |