diff -r fe3e5a3331b6 -r f0f9ba3f98f2 kconfig/kconfig.mk --- a/kconfig/kconfig.mk Tue Oct 14 16:50:33 2008 +0000 +++ b/kconfig/kconfig.mk Wed Oct 15 21:29:56 2008 +0000 @@ -56,13 +56,13 @@ # Where to access to the source config files from config: - @echo " LN config" - @ln -s $(CT_LIB_DIR)/config config + @$(ECHO) " LN config" + $(SILENT)ln -s $(CT_LIB_DIR)/config config # Where to store the generated config files into config.gen: - @echo " MKDIR config.gen" - @mkdir -p config.gen + @$(ECHO) " MKDIR config.gen" + $(SILENT)mkdir -p config.gen #----------------------------------------------------------- # Build list of per-component-type items to easily build generated files @@ -89,8 +89,8 @@ # Example to build the kernels generated config file: # $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS)) define build_gen_choice_in - @echo ' IN $(1)' - @(echo "# $(2) menu"; \ + @$(ECHO) ' IN $(1)' + $(SILENT)(echo "# $(2) menu"; \ echo "# Generated file, do not edit!!!"; \ echo ""; \ echo "choice"; \ @@ -136,8 +136,8 @@ # Example to build the tools generated config file: # $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS)) define build_gen_menu_in - @echo ' IN $(1)' - @(echo "# $(2) facilities menu"; \ + @$(ECHO) ' IN $(1)' + $(SILENT)(echo "# $(2) facilities menu"; \ echo "# Generated file, do not edit!!!"; \ echo ""; \ for entry in $(5); do \ @@ -184,14 +184,14 @@ #----------------------------------------------------------- # The configurators rules -menuconfig: $(CONFIG_FILES) $(obj)/mconf - @$(obj)/mconf $(KCONFIG_TOP) +menuconfig: $(obj)/mconf $(CONFIG_FILES) + $(SILENT)$< $(KCONFIG_TOP) -oldconfig: $(CONFIG_FILES) $(obj)/conf - @$(obj)/conf -s $(KCONFIG_TOP) +oldconfig: .config $(obj)/conf $(CONFIG_FILES) + $(SILENT)$< -s $(KCONFIG_TOP) -defoldconfig: $(CONFIG_FILES) $(obj)/conf - @yes "" |$(obj)/conf -s $(KCONFIG_TOP) +defoldconfig: .config $(obj)/conf $(CONFIG_FILES) + $(SILENT)yes "" |$< -s $(KCONFIG_TOP) #----------------------------------------------------------- # Help text used by make help @@ -199,50 +199,84 @@ help-config:: @echo ' menuconfig - Update current config using a menu based program' @echo ' oldconfig - Update current config using a provided .config as base' - @echo ' build log piped into stdin' + @echo ' defoldconfig - As oldconfig, above, but using defaults for new options' #----------------------------------------------------------- -# Not-so-cheesy build, needs rework... +# Hmmm! Cheesy build! +# Or: where I can unveil my make-fu... :-] -SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c +# Oh! Files not here are there, in fact! :-) +vpath %.c $(CT_LIB_DIR) +vpath %.h $(CT_LIB_DIR) -$(obj)/conf $(obj)/mconf: $(obj) +# What is the compiler? +HOST_CC ?= gcc -funsigned-char -$(obj): - @mkdir -p $(obj) +# Compiler and linker flags to use ncurses +CFLAGS += $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags) +LDFLAGS += $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC)) -HEADERS = $(CT_LIB_DIR)/kconfig/expr.h \ - $(CT_LIB_DIR)/kconfig/lkc.h \ - $(CT_LIB_DIR)/kconfig/lkc_proto.h +# Common source files, and lxdialog source files +SRC = kconfig/zconf.tab.c +LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c)) -FILES = $(CT_LIB_DIR)/kconfig/confdata.c \ - $(CT_LIB_DIR)/kconfig/expr.c \ - $(CT_LIB_DIR)/kconfig/menu.c \ - $(CT_LIB_DIR)/kconfig/symbol.c \ - $(CT_LIB_DIR)/kconfig/util.c +# What's needed to build 'conf' +conf_SRC = $(SRC) kconfig/conf.c +conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC)) -$(obj)/mconf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/mconf.c \ - $(HEADERS) $(FILES) \ - $(CT_LIB_DIR)/kconfig/kconfig.mk - @echo ' LD $@' - @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{mconf.c,zconf.tab.c,lxdialog/*.c} \ - $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags) \ - $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC)) +# What's needed to build 'mconf' +mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c +mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC)) -$(obj)/conf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/conf.c \ - $(HEADERS) $(FILES) \ - $(CT_LIB_DIR)/kconfig/kconfig.mk - @echo ' LD $@' - @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{conf.c,zconf.tab.c} +# Cheesy auto-dependencies +DEPS = $(patsubst %.c,%.d,$(sort $(conf_SRC) $(mconf_SRC))) + +# This is not very nice, as they will get rebuild even if (dist)cleaning... :-( +# Should look into the Linux kernel Kbuild to see how they do that... +# To really make me look into this, keep the annoying "DEP xxx" messages. +# Also see the comment for the "%.o: %c" rule below +%.d: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk + $(SILENT)if [ ! -d $(obj)/lxdialog ]; then \ + $(ECHO) " MKDIR $(obj)"; \ + mkdir -p $(obj)/lxdialog; \ + fi + @$(ECHO) " DEP $@" + $(SILENT)$(HOST_CC) $(CFLAGS) -MM $< |sed -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@ +-include $(DEPS) + +# Each .o must depend on the corresponding .c (obvious, isn't it?), +# but *can not* depend on kconfig/, because kconfig can be touched +# during the build (who's touching it, btw?) so each .o would be +# re-built when they sould not be. +# So manually check for presence of $(obj) (ie. kconfig), and only mkdir +# if needed. After all, that's not so bad... +# mkdir $(obj)/lxdialog, because we need it, and incidentally, that +# also creates $(obj). +# Also rebuild the object files is the makefile is changed +%.o: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk + $(SILENT)if [ ! -d $(obj)/lxdialog ]; then \ + $(ECHO) " MKDIR $(obj)"; \ + mkdir -p $(obj)/lxdialog; \ + fi + @$(ECHO) " CC $@" + $(SILENT)$(HOST_CC) $(CFLAGS) -o $@ -c $< + +$(obj)/mconf: $(mconf_OBJ) + @$(ECHO) ' LD $@' + $(SILENT)$(HOST_CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ + +$(obj)/conf: $(conf_OBJ) + @$(ECHO) ' LD $@' + $(SILENT)$(HOST_CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ #----------------------------------------------------------- # Cleaning up the mess... clean:: - @echo " CLEAN kconfig" - @rm -f kconfig/{,m}conf - @rmdir --ignore-fail-on-non-empty kconfig 2>/dev/null || true - @echo " CLEAN config" - @rm -f config 2>/dev/null || true - @echo " CLEAN config.gen" - @rm -rf config.gen + @$(ECHO) " CLEAN kconfig" + $(SILENT)rm -f kconfig/{,m}conf $(conf_OBJ) $(mconf_OBJ) $(DEPS) + $(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true + @$(ECHO) " CLEAN config" + $(SILENT)rm -f config 2>/dev/null || true + @$(ECHO) " CLEAN config.gen" + $(SILENT)rm -rf config.gen