summaryrefslogtreecommitdiff
path: root/kconfig
diff options
context:
space:
mode:
Diffstat (limited to 'kconfig')
-rw-r--r--kconfig/kconfig.mk142
1 files changed, 88 insertions, 54 deletions
diff --git a/kconfig/kconfig.mk b/kconfig/kconfig.mk
index 0c8b54d..2be7141 100644
--- a/kconfig/kconfig.mk
+++ b/kconfig/kconfig.mk
@@ -56,13 +56,13 @@ CONFIG_FILES = $(sort $(KCONFIG_TOP) $(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES))
# 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 @@ TOOLS = $(patsubst config/tools/%.in,%,$(TOOL_CONFIG_FILES))
# 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 @@ endef
# 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 @@ config.gen/debug.in: $(DEBUG_CONFIG_FILES)
#-----------------------------------------------------------
# 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 @@ defoldconfig: $(CONFIG_FILES) $(obj)/conf
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...
-
-SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c
-
-$(obj)/conf $(obj)/mconf: $(obj)
-
-$(obj):
- @mkdir -p $(obj)
-
-HEADERS = $(CT_LIB_DIR)/kconfig/expr.h \
- $(CT_LIB_DIR)/kconfig/lkc.h \
- $(CT_LIB_DIR)/kconfig/lkc_proto.h
-
-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
-
-$(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))
-
-$(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}
+# Hmmm! Cheesy build!
+# Or: where I can unveil my make-fu... :-]
+
+# Oh! Files not here are there, in fact! :-)
+vpath %.c $(CT_LIB_DIR)
+vpath %.h $(CT_LIB_DIR)
+
+# What is the compiler?
+HOST_CC ?= gcc -funsigned-char
+
+# 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))
+
+# Common source files, and lxdialog source files
+SRC = kconfig/zconf.tab.c
+LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
+
+# What's needed to build 'conf'
+conf_SRC = $(SRC) kconfig/conf.c
+conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
+
+# What's needed to build 'mconf'
+mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c
+mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
+
+# 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