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