From a257ff7da8d2ae772011d3cce0b22c741e5b3ce1 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Thu, 26 May 2011 22:51:03 +0200 Subject: configure: add possibility to set arbitrary variable in check_for If check_for is able to find the required prog/inc/lib, allow it to set an arbitrary variable to 'y'. This variable is then pushed down to the kconfig definition. For example: has_or_abort prog=foobar kconfig=has_foobar If foobar is available, it yields a kconfig variable defaulting to y: config CONFIGURE_has_foobar bool default y If foobar is missing, it yields a kconfig variable defaulting to n: config CONFIGURE_has_foobar bool Thus it is possible to depends on that variabel to show/hide options: config SOME_FEATURE bool prompt "Some feature" depends on CONFIGURE_has_foobar Signed-off-by: "Yann E. MORIN" diff --git a/.hgignore b/.hgignore index a8b6e23..d39c8bd 100644 --- a/.hgignore +++ b/.hgignore @@ -13,6 +13,7 @@ kconfig/conf kconfig/?conf kconfig/**.o kconfig/**.dep +config/configure.in config.gen/ .config .config.2 diff --git a/Makefile.in b/Makefile.in index 35f6d36..a211fd6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -58,6 +58,9 @@ objdump:= @@objdump@@ readelf:= @@readelf@@ patch := @@patch@@ +# config options to push down to kconfig +KCONFIG:= @@KCONFIG@@ + ############################################################################### # Non-configure variables MAN_SECTION := 1 @@ -115,7 +118,7 @@ uninstall: real-uninstall build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh scripts/showTuple.sh @chmod 755 $^ -build-lib: paths.mk +build-lib: paths.mk config/configure.in build-doc: @@ -142,7 +145,7 @@ docs/ct-ng.1.gz: docs/ct-ng.1 # use := to set variables, although that will incur a (very small) # penalty from the Makefile that includes it (due to re-evaluation at # each call). -paths.mk: +paths.mk: FORCE @echo " GEN '$@'" @(echo "export install=$(install)"; \ echo "export bash=$(bash)"; \ @@ -156,6 +159,22 @@ paths.mk: echo "export patch=$(patch)"; \ ) >paths.mk +config/configure.in: FORCE + @echo " GEN '$@'" + @{ printf "# Generated file, do not edit\n"; \ + printf "# Default values as found by ./configure\n"; \ + for var in $(KCONFIG); do \ + printf "\n"; \ + printf "config CONFIGURE_$${var%%=*}\n"; \ + printf " bool\n"; \ + if [ "$${var#*=}" = "y" ]; then \ + printf " default y\n"; \ + fi; \ + done; \ + } >$@ + +FORCE: + #-------------------------------------- # Clean rules @@ -172,6 +191,8 @@ clean-bin: clean-lib: @echo " RM 'paths.mk'" @rm -f paths.mk + @echo " RM 'config/configure.in'" + @rm -f config/configure.in clean-doc: diff --git a/config/config.in b/config/config.in index 8be19f5..5ebd2be 100644 --- a/config/config.in +++ b/config/config.in @@ -1,4 +1,5 @@ mainmenu "The crosstool-NG configuration menu" +source "config/configure.in" source "config/backend.in" source "config/global.in" source "config/target.in" diff --git a/configure b/configure index b908fa4..b3519b4 100755 --- a/configure +++ b/configure @@ -69,12 +69,24 @@ set_tool() { # var_list is a list of variables, each one holding a path to a # tool, either detected by ./configure, or specified by the user. var_list="" +kconfig_list="" # This function adds a variable name to the above list of variable names. # $1: the name of the variable to add to the list add_to_var_list() { + local v + for v in ${var_list}; do + [ "${v}" = "${1}" ] && return 0 + done var_list="${var_list} ${1}" } +add_to_kconfig_list() { + local k + for k in ${kconfig_list}; do + [ "${k}" = "${1}" ] && return 0 + done + kconfig_list="${kconfig_list} ${1}" +} # A function to test for required tools/headers/libraries # Return 0 (true) if found, !0 (false) if not found @@ -97,23 +109,32 @@ add_to_var_list() { # optional, defaults to: '${prog}: none found' # eg: err="'bash' 3.x or above was not found" # Note: err may be printed by caller, not us +# $*: kconfig= +# the name of a variable to pass down to kconfig if +# the prog/inc/lib was found +# optional, defaults to none +# eg: kconfig=has_libncurses check_for() { local val local item local where local status - # Note: prog/inc/lib and var/ver/err are set here, + # Note: prog/inc/lib and var/kconfig/ver/err are set here, # but declared by the caller (because it needs it) for item in "${@}"; do case "${item}" in - prog=*|inc=*|lib=*|var=*|ver=*|err=*) + prog=*|inc=*|lib=*|var=*|ver=*|err=*|kconfig=*) eval ${item%%=*}="'${item#*=}'" ;; *) do_error "has_or_abort: incorrect parameters: '$@'";; esac done + if [ -n "${kconfig}" ]; then + add_to_kconfig_list "${kconfig}" + fi + case "${prog}:${inc}:${lib}" in ?*::) for item in ${prog}; do @@ -179,6 +200,9 @@ check_for() { eval ${var}='"'"${where}"'"' add_to_var_list "${var}" fi + if [ -n "${kconfig}" ]; then + eval ${kconfig}=y + fi printf "\n" } @@ -188,7 +212,7 @@ has_or_abort() { # We declare these 6 variables here, although they are # set in check_for(), called below local prog inc lib - local var ver err + local var ver err kconfig if ! check_for "$@"; then printf "\n${err:-${prog}${inc}${lib}: none found}\n\n" @@ -216,7 +240,7 @@ has_or_warn() { # We declare these 6 variables here, although they are # set in check_for(), called below local prog inc lib - local var ver err + local var ver err kconfig if ! check_for "$@"; then printf "${err:+${err}\n}" @@ -460,16 +484,23 @@ done printf "Building up Makefile... " var_sed="$( for var_name in ${var_list}; do eval echo 's,@@${var_name}@@,${'"${var_name}"'},g' - done + done )" -"${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g - s,@@LIBDIR@@,${LIBDIR},g - s,@@DOCDIR@@,${DOCDIR},g - s,@@MANDIR@@,${MANDIR},g - s,@@VERSION@@,${VERSION},g - s,@@DATE@@,${DATE},g - ${var_sed} - s,@@LOCAL@@,${LOCAL_set},g" Makefile.in >Makefile +kconfig_sed="s/@@KCONFIG@@/$( for k_name in ${kconfig_list}; do + eval printf \"${k_name}=\${${k_name}} \" + done + )/" +"${sed}" -r -e "s,@@BINDIR@@,${BINDIR},g" \ + -e "s,@@LIBDIR@@,${LIBDIR},g" \ + -e "s,@@DOCDIR@@,${DOCDIR},g" \ + -e "s,@@MANDIR@@,${MANDIR},g" \ + -e "s,@@VERSION@@,${VERSION},g" \ + -e "s,@@DATE@@,${DATE},g" \ + -e "s,@@LOCAL@@,${LOCAL_set},g" \ + -e "${var_sed}" \ + -e "${kconfig_sed}" \ + Makefile.in \ + >Makefile echo "done" cat <<__EOF__ -- cgit v0.10.2-6-g49f6