config/config.mk
author Johannes Stezenbach <js@sig21.net>
Tue Oct 30 00:22:25 2012 +0000 (2012-10-30)
changeset 3097 5c67476c7342
parent 2537 95d470b5a6a9
child 3123 6a5946fbc728
permissions -rw-r--r--
scripts/functions: fix endless loop in debug-shell with IO redirection

CT_DEBUG_INTERACTIVE is disabled when stdin, stdout or
stderr are redirected, but the check is only done at
the start of the build and doesn't catch when individual
build commands use redirection. When stdin is redirected
it will cause the debug shell to exit immediately, causing
and endless loop. Thus, save the stdin/our/err file handles
and restore them before invoking the debug shell.

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Message-Id: <20121030102225.GA8303@sig21.net>
Patchwork-Id: 195409
     1 # ===========================================================================
     2 # crosstool-NG genererated config files
     3 # These targets are used from top-level makefile
     4 
     5 #-----------------------------------------------------------
     6 # List all config files, wether sourced or generated
     7 
     8 # The top-level config file to be used be configurators
     9 # We need it to savedefconfig in scripts/saveSample.sh
    10 export KCONFIG_TOP = config/config.in
    11 
    12 # Build the list of all source config files
    13 STATIC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(shell find $(CT_LIB_DIR)/config -type f \( -name '*.in' -o -name '*.in.2' \) 2>/dev/null))
    14 # ... and how to access them:
    15 $(STATIC_CONFIG_FILES): config
    16 
    17 # Build a list of per-component-type source config files
    18 ARCH_CONFIG_FILES     = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/arch/*.in))
    19 ARCH_CONFIG_FILES_2   = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/arch/*.in.2))
    20 KERNEL_CONFIG_FILES   = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in))
    21 KERNEL_CONFIG_FILES_2 = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in.2))
    22 CC_CONFIG_FILES       = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in))
    23 CC_CONFIG_FILES_2     = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in.2))
    24 LIBC_CONFIG_FILES     = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in))
    25 LIBC_CONFIG_FILES_2   = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in.2))
    26 DEBUG_CONFIG_FILES    = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/debug/*.in))
    27 
    28 # Build the list of generated config files
    29 GEN_CONFIG_FILES = config.gen/arch.in     \
    30                    config.gen/kernel.in   \
    31                    config.gen/cc.in       \
    32                    config.gen/libc.in     \
    33                    config.gen/debug.in
    34 # ... and how to access them:
    35 # Generated files depends on the gen_in_frags script because it has the
    36 # functions needed to build the genrated files, and thus they might need
    37 # re-generation if it changes.
    38 # They also depends on config.mk (this file) because it has the dependency
    39 # rules, and thus they might need re-generation if the deps change.
    40 $(GEN_CONFIG_FILES): config.gen                             \
    41                      $(CT_LIB_DIR)/scripts/gen_in_frags.sh  \
    42                      $(CT_LIB_DIR)/config/config.mk
    43 
    44 # Helper entry for the configurators
    45 PHONY += config_files
    46 config_files: $(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES)
    47 
    48 # Where to access to the source config files from
    49 config:
    50 	@$(ECHO) "  LN    config"
    51 	$(SILENT)ln -s $(CT_LIB_DIR)/config config
    52 
    53 # Where to store the generated config files into
    54 config.gen:
    55 	@$(ECHO) "  MKDIR config.gen"
    56 	$(SILENT)mkdir -p config.gen
    57 
    58 #-----------------------------------------------------------
    59 # Build list of per-component-type items to easily build generated files
    60 
    61 ARCHS   = $(patsubst config/arch/%.in,%,$(ARCH_CONFIG_FILES))
    62 KERNELS = $(patsubst config/kernel/%.in,%,$(KERNEL_CONFIG_FILES))
    63 CCS     = $(patsubst config/cc/%.in,%,$(CC_CONFIG_FILES))
    64 LIBCS   = $(patsubst config/libc/%.in,%,$(LIBC_CONFIG_FILES))
    65 DEBUGS  = $(patsubst config/debug/%.in,%,$(DEBUG_CONFIG_FILES))
    66 
    67 #-----------------------------------------------------------
    68 # The rules for the generated config files
    69 
    70 # WARNING! If a .in file disapears between two runs, that will NOT be detected!
    71 
    72 config.gen/arch.in: $(ARCH_CONFIG_FILES) $(ARCH_CONFIG_FILES_2)
    73 	@$(ECHO) '  IN    $(@)'
    74 	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "Target Architecture" "ARCH" "config/arch" "Y" $(ARCHS)
    75 
    76 config.gen/kernel.in: $(KERNEL_CONFIG_FILES) $(KERNEL_CONFIG_FILES_2)
    77 	@$(ECHO) '  IN    $(@)'
    78 	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "Target OS" "KERNEL" "config/kernel" "Y" $(KERNELS)
    79 
    80 config.gen/cc.in: $(CC_CONFIG_FILES) $(CC_CONFIG_FILES_2)
    81 	@$(ECHO) '  IN    $(@)'
    82 	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "C compiler" "CC" "config/cc" "N" $(CCS)
    83 
    84 config.gen/libc.in: $(LIBC_CONFIG_FILES) $(LIBC_CONFIG_FILES_2)
    85 	@$(ECHO) '  IN    $(@)'
    86 	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "C library" "LIBC" "config/libc" "Y" $(LIBCS)
    87 
    88 config.gen/debug.in: $(DEBUG_CONFIG_FILES)
    89 	@$(ECHO) '  IN    $(@)'
    90 	$(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh menu "$@" "Debug facilities" "DEBUG" "config/debug" $(DEBUGS)
    91 
    92 #-----------------------------------------------------------
    93 # Cleaning up the mess...
    94 
    95 clean::
    96 	@$(ECHO) "  CLEAN config"
    97 	$(SILENT)rm -f config 2>/dev/null || true
    98 	@$(ECHO) "  CLEAN config.gen"
    99 	$(SILENT)rm -rf config.gen