kconfig/kconfig.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Oct 18 18:37:28 2008 +0000 (2008-10-18)
changeset 945 d0e5f04d2e06
parent 943 1cca90ce0481
child 946 253df9d80065
permissions -rw-r--r--
Extract the config files related stuff from the kconfig stuff
- create config/config.mk, with all the config.gen/ rules
- the only common points between config files and configurators:
- the top-level config file to include, stored in KCONFIG_TOP
- the config_file rules, which makes config files available to configurators
- dependency-files are renamed from %.d to %.dep (.d is reserved for directories)
- a few eye-candy here and there

/trunk/kconfig/kconfig.mk | 184 12 172 0 +++--------------------------------------------------
/trunk/config/config.mk | 118 9 109 0 +++-------------------------------
/trunk/ct-ng.in | 1 1 0 0 +
3 files changed, 22 insertions(+), 281 deletions(-)
     1 # ===========================================================================
     2 # crosstool-NG configuration targets
     3 # These targets are used from top-level makefile
     4 
     5 # Derive the project version from, well, the project version:
     6 export PROJECTVERSION=$(CT_VERSION)
     7 
     8 #-----------------------------------------------------------
     9 # Some static /configuration/
    10 
    11 # The place where the kconfig stuff lies
    12 obj = kconfig
    13 
    14 #-----------------------------------------------------------
    15 # The configurators rules
    16 
    17 PHONY += oldconfig menuconfig defoldconfig
    18 
    19 menuconfig: $(obj)/mconf config_files
    20 	@$(ECHO) "  MCONF $(KCONFIG_TOP)"
    21 	$(SILENT)$< $(KCONFIG_TOP)
    22 
    23 oldconfig: $(obj)/conf .config config_files
    24 	@$(ECHO) "  CONF  $(KCONFIG_TOP)"
    25 	$(SILENT)$< -s $(KCONFIG_TOP)
    26 
    27 defoldconfig: $(obj)/conf .config config_files
    28 	@$(ECHO) "  CONF  $(KCONFIG_TOP)"
    29 	$(SILENT)yes "" |$< -s $(KCONFIG_TOP)
    30 
    31 #-----------------------------------------------------------
    32 # Help text used by make help
    33 
    34 help-config::
    35 	@echo  '  menuconfig         - Update current config using a menu based program'
    36 	@echo  '  oldconfig          - Update current config using a provided .config as base'
    37 	@echo  '  defoldconfig       - As oldconfig, above, but using defaults for new options'
    38 
    39 #-----------------------------------------------------------
    40 # Hmmm! Cheesy build!
    41 # Or: where I can unveil my make-fu... :-]
    42 
    43 # Oh! Files not here are there, in fact! :-)
    44 vpath %.c $(CT_LIB_DIR)
    45 vpath %.h $(CT_LIB_DIR)
    46 
    47 # What is the compiler?
    48 HOST_CC ?= gcc -funsigned-char
    49 
    50 # Compiler flags to use gettext
    51 EXTRA_CFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/check-gettext.sh $(HOST_CC) $(CFLAGS))
    52 
    53 # Compiler and linker flags to use ncurses
    54 EXTRA_CFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags)
    55 EXTRA_LDFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
    56 
    57 # Common source files, and lxdialog source files
    58 SRC = kconfig/zconf.tab.c
    59 LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
    60 
    61 # What's needed to build 'conf'
    62 conf_SRC  = $(SRC) kconfig/conf.c
    63 conf_OBJ  = $(patsubst %.c,%.o,$(conf_SRC))
    64 
    65 # What's needed to build 'mconf'
    66 mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c
    67 mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
    68 
    69 # Cheesy auto-dependencies
    70 DEPS = $(patsubst %.c,%.dep,$(sort $(conf_SRC) $(mconf_SRC)))
    71 -include $(DEPS)
    72 
    73 # This is not very nice, as they will get rebuild even if (dist)cleaning... :-(
    74 # Should look into the Linux kernel Kbuild to see how they do that...
    75 # To really make me look into this, keep the annoying "DEP xxx" messages.
    76 # Also see the comment for the "%.o: %c" rule below
    77 %.dep: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk $(CT_NG)
    78 	$(SILENT)if [ ! -d $(obj)/lxdialog ]; then  \
    79 	   $(ECHO) "  MKDIR $(obj)";           \
    80 	   mkdir -p $(obj)/lxdialog;        \
    81 	 fi
    82 	@$(ECHO) "  DEP   $@"
    83 	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |sed -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
    84 
    85 # Each .o must depend on the corresponding .c (obvious, isn't it?),
    86 # but *can not* depend on kconfig/, because kconfig can be touched
    87 # during the build (who's touching it, btw?) so each .o would be
    88 # re-built when they sould not be.
    89 # So manually check for presence of $(obj) (ie. kconfig), and only mkdir
    90 # if needed. After all, that's not so bad...
    91 # mkdir $(obj)/lxdialog, because we need it, and incidentally, that
    92 # also creates $(obj).
    93 # Also rebuild the object files is the makefile is changed
    94 %.o: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
    95 	$(SILENT)if [ ! -d $(obj)/lxdialog ]; then  \
    96 	   $(ECHO) "  MKDIR $(obj)";           \
    97 	   mkdir -p $(obj)/lxdialog;        \
    98 	 fi
    99 	@$(ECHO) "  CC    $@"
   100 	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
   101 
   102 $(obj)/mconf: $(mconf_OBJ)
   103 	@$(ECHO) '  LD    $@'
   104 	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^
   105 
   106 $(obj)/conf: $(conf_OBJ)
   107 	@$(ECHO) '  LD    $@'
   108 	$(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^
   109 
   110 #-----------------------------------------------------------
   111 # Cleaning up the mess...
   112 
   113 clean::
   114 	@$(ECHO) "  CLEAN kconfig"
   115 	$(SILENT)rm -f kconfig/{,m}conf $(conf_OBJ) $(mconf_OBJ) $(DEPS)
   116 	$(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true