yann@1: # =========================================================================== yann@197: # crosstool-NG configuration targets yann@1: # These targets are used from top-level makefile yann@1: yann@148: # Derive the project version from, well, the project version: yann@148: export PROJECTVERSION=$(CT_VERSION) yann@148: yann@926: #----------------------------------------------------------- yann@926: # Some static /configuration/ yann@926: yann@945: # The place where the kconfig stuff lies yann@926: obj = kconfig yann@926: yann@926: #----------------------------------------------------------- yann@926: # The configurators rules yann@182: yann@946: configurators = menuconfig oldconfig defoldconfig yann@946: PHONY += $(configurators) yann@945: yann@946: $(configurators): config_files yann@946: yann@946: menuconfig: $(obj)/mconf yann@945: @$(ECHO) " MCONF $(KCONFIG_TOP)" yann@940: $(SILENT)$< $(KCONFIG_TOP) yann@1: yann@946: oldconfig: $(obj)/conf .config yann@945: @$(ECHO) " CONF $(KCONFIG_TOP)" yann@940: $(SILENT)$< -s $(KCONFIG_TOP) yann@1: yann@946: defoldconfig: $(obj)/conf .config yann@945: @$(ECHO) " CONF $(KCONFIG_TOP)" yann@940: $(SILENT)yes "" |$< -s $(KCONFIG_TOP) yann@159: yann@926: #----------------------------------------------------------- yann@1: # Help text used by make help yann@926: yann@176: help-config:: yann@333: @echo ' menuconfig - Update current config using a menu based program' yann@333: @echo ' oldconfig - Update current config using a provided .config as base' yann@940: @echo ' defoldconfig - As oldconfig, above, but using defaults for new options' yann@1: yann@926: #----------------------------------------------------------- yann@940: # Hmmm! Cheesy build! yann@940: # Or: where I can unveil my make-fu... :-] yann@1: yann@940: # Oh! Files not here are there, in fact! :-) yann@940: vpath %.c $(CT_LIB_DIR) yann@940: vpath %.h $(CT_LIB_DIR) yann@1: yann@940: # What is the compiler? yann@940: HOST_CC ?= gcc -funsigned-char yann@182: yann@943: # Compiler flags to use gettext yann@943: EXTRA_CFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/check-gettext.sh $(HOST_CC) $(CFLAGS)) yann@943: yann@940: # Compiler and linker flags to use ncurses yann@943: EXTRA_CFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags) yann@943: EXTRA_LDFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC)) yann@182: yann@940: # Common source files, and lxdialog source files yann@940: SRC = kconfig/zconf.tab.c yann@940: LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c)) yann@816: yann@940: # What's needed to build 'conf' yann@940: conf_SRC = $(SRC) kconfig/conf.c yann@940: conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC)) yann@816: yann@940: # What's needed to build 'mconf' yann@940: mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c yann@940: mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC)) yann@1: yann@940: # Cheesy auto-dependencies yann@945: DEPS = $(patsubst %.c,%.dep,$(sort $(conf_SRC) $(mconf_SRC))) yann@946: yann@946: # Only parse the following if a configurator was called, to avoid building yann@946: # dependencies when not needed (eg. list-steps, list-samples...) yann@946: # We must be carefull what we enclose, because we need some of the variable yann@946: # definitions for clean (and distclean) at least. yann@946: # Just protecting the "-include $(DEPS)" line should be sufficient. yann@946: yann@946: ifneq ($(strip $(MAKECMDGOALS)),) yann@946: ifneq ($(strip $(filter $(configurators),$(MAKECMDGOALS))),) yann@946: yann@945: -include $(DEPS) yann@940: yann@946: endif # MAKECMDGOALS contains a configurator rule yann@946: endif # MAKECMDGOALS != "" yann@946: yann@940: # This is not very nice, as they will get rebuild even if (dist)cleaning... :-( yann@940: # Should look into the Linux kernel Kbuild to see how they do that... yann@940: # To really make me look into this, keep the annoying "DEP xxx" messages. yann@940: # Also see the comment for the "%.o: %c" rule below yann@945: %.dep: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk $(CT_NG) yann@940: $(SILENT)if [ ! -d $(obj)/lxdialog ]; then \ yann@940: $(ECHO) " MKDIR $(obj)"; \ yann@940: mkdir -p $(obj)/lxdialog; \ yann@940: fi yann@940: @$(ECHO) " DEP $@" yann@943: $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |sed -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@ yann@940: yann@940: # Each .o must depend on the corresponding .c (obvious, isn't it?), yann@940: # but *can not* depend on kconfig/, because kconfig can be touched yann@940: # during the build (who's touching it, btw?) so each .o would be yann@940: # re-built when they sould not be. yann@940: # So manually check for presence of $(obj) (ie. kconfig), and only mkdir yann@940: # if needed. After all, that's not so bad... yann@940: # mkdir $(obj)/lxdialog, because we need it, and incidentally, that yann@940: # also creates $(obj). yann@940: # Also rebuild the object files is the makefile is changed yann@940: %.o: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk yann@940: $(SILENT)if [ ! -d $(obj)/lxdialog ]; then \ yann@940: $(ECHO) " MKDIR $(obj)"; \ yann@940: mkdir -p $(obj)/lxdialog; \ yann@940: fi yann@940: @$(ECHO) " CC $@" yann@943: $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $< yann@940: yann@940: $(obj)/mconf: $(mconf_OBJ) yann@940: @$(ECHO) ' LD $@' yann@943: $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^ yann@940: yann@940: $(obj)/conf: $(conf_OBJ) yann@940: @$(ECHO) ' LD $@' yann@943: $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^ yann@1: yann@926: #----------------------------------------------------------- yann@926: # Cleaning up the mess... yann@926: yann@1: clean:: yann@940: @$(ECHO) " CLEAN kconfig" yann@940: $(SILENT)rm -f kconfig/{,m}conf $(conf_OBJ) $(mconf_OBJ) $(DEPS) yann@940: $(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true