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 PHONY += oldconfig menuconfig defoldconfig
19 menuconfig: $(obj)/mconf config_files
20 @$(ECHO) " MCONF $(KCONFIG_TOP)"
21 $(SILENT)$< $(KCONFIG_TOP)
23 oldconfig: $(obj)/conf .config config_files
24 @$(ECHO) " CONF $(KCONFIG_TOP)"
25 $(SILENT)$< -s $(KCONFIG_TOP)
27 defoldconfig: $(obj)/conf .config config_files
28 @$(ECHO) " CONF $(KCONFIG_TOP)"
29 $(SILENT)yes "" |$< -s $(KCONFIG_TOP)
31 #-----------------------------------------------------------
32 # Help text used by make help
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'
39 #-----------------------------------------------------------
41 # Or: where I can unveil my make-fu... :-]
43 # Oh! Files not here are there, in fact! :-)
44 vpath %.c $(CT_LIB_DIR)
45 vpath %.h $(CT_LIB_DIR)
47 # What is the compiler?
48 HOST_CC ?= gcc -funsigned-char
50 # Compiler flags to use gettext
51 EXTRA_CFLAGS += $(shell $(SHELL) $(CT_LIB_DIR)/kconfig/check-gettext.sh $(HOST_CC) $(CFLAGS))
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))
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))
61 # What's needed to build 'conf'
62 conf_SRC = $(SRC) kconfig/conf.c
63 conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
65 # What's needed to build 'mconf'
66 mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c
67 mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
69 # Cheesy auto-dependencies
70 DEPS = $(patsubst %.c,%.dep,$(sort $(conf_SRC) $(mconf_SRC)))
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; \
83 $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |sed -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
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; \
100 $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
102 $(obj)/mconf: $(mconf_OBJ)
104 $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^
106 $(obj)/conf: $(conf_OBJ)
108 $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^
110 #-----------------------------------------------------------
111 # Cleaning up the mess...
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