1.1 --- a/kconfig/kconfig.mk Tue Aug 30 11:35:29 2011 +0200
1.2 +++ b/kconfig/kconfig.mk Mon Apr 16 15:29:06 2012 +0200
1.3 @@ -2,9 +2,6 @@
1.4 # crosstool-NG configuration targets
1.5 # These targets are used from top-level makefile
1.6
1.7 -# The place where the kconfig stuff lies
1.8 -obj = kconfig
1.9 -
1.10 #-----------------------------------------------------------
1.11 # The configurators rules
1.12
1.13 @@ -13,17 +10,21 @@
1.14
1.15 $(configurators): config_files
1.16
1.17 -menuconfig: $(obj)/mconf
1.18 +CONF := $(CT_LIB_DIR)/kconfig/conf
1.19 +MCONF := $(CT_LIB_DIR)/kconfig/mconf
1.20 +NCONF := $(CT_LIB_DIR)/kconfig/nconf
1.21 +
1.22 +menuconfig:
1.23 @$(ECHO) " CONF $(KCONFIG_TOP)"
1.24 - $(SILENT)$< $(KCONFIG_TOP)
1.25 + $(SILENT)$(MCONF) $(KCONFIG_TOP)
1.26
1.27 -nconfig: $(obj)/nconf
1.28 +nconfig:
1.29 @$(ECHO) " CONF $(KCONFIG_TOP)"
1.30 - $(SILENT)$< $(KCONFIG_TOP)
1.31 + $(SILENT)$(NCONF) $(KCONFIG_TOP)
1.32
1.33 -oldconfig: $(obj)/conf .config
1.34 +oldconfig: .config
1.35 @$(ECHO) " CONF $(KCONFIG_TOP)"
1.36 - $(SILENT)$< --silent$@ $(KCONFIG_TOP)
1.37 + $(SILENT)$(CONF) --silent$@ $(KCONFIG_TOP)
1.38
1.39 # Always be silent, the stdout an be >.config
1.40 extractconfig:
1.41 @@ -48,155 +49,3 @@
1.42 @echo ' oldconfig - Update current config using a provided .config as base'
1.43 @echo ' extractconfig - Extract to stdout the configuration items from a'
1.44 @echo ' build.log file piped to stdin'
1.45 -
1.46 -#-----------------------------------------------------------
1.47 -# Hmmm! Cheesy build!
1.48 -# Or: where I can unveil my make-fu... :-]
1.49 -
1.50 -# Oh! Files not here are there, in fact! :-)
1.51 -vpath %.c $(CT_LIB_DIR)
1.52 -vpath %.h $(CT_LIB_DIR)
1.53 -
1.54 -# What is the compiler?
1.55 -HOST_CC ?= gcc -funsigned-char
1.56 -HOST_LD ?= gcc
1.57 -
1.58 -# Helpers
1.59 -check_gettext = $(CT_LIB_DIR)/kconfig/check.sh
1.60 -check_lxdialog = $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh
1.61 -
1.62 -# Build flags
1.63 -CFLAGS = -DCONFIG_=\"CT_\" -DPACKAGE="\"crosstool-NG $(CT_VERSION)\""
1.64 -LDFLAGS =
1.65 -
1.66 -# Compiler flags to use gettext
1.67 -INTL_CFLAGS = $(shell $(SHELL) $(check_gettext) $(HOST_CC) $(EXTRA_CFLAGS))
1.68 -
1.69 -# Compiler and linker flags to use ncurses
1.70 -NCURSES_CFLAGS = $(shell $(SHELL) $(check_lxdialog) -ccflags)
1.71 -NCURSES_LDFLAGS = $(shell $(SHELL) $(check_lxdialog) -ldflags $(HOST_CC))
1.72 -
1.73 -# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
1.74 -dochecklxdialog:
1.75 - $(SILENT)$(SHELL) $(check_lxdialog) -check $(HOST_CC) $(NCURSES_CFLAGS) $(NCURSES_LDFLAGS)
1.76 -
1.77 -# Common source files
1.78 -COMMON_SRC = kconfig/zconf.tab.c
1.79 -COMMON_OBJ = $(patsubst %.c,%.o,$(COMMON_SRC))
1.80 -COMMON_DEP = $(patsubst %.o,%.dep,$(COMMON_OBJ))
1.81 -$(COMMON_OBJ) $(COMMON_DEP): CFLAGS += $(INTL_CFLAGS)
1.82 -
1.83 -# lxdialog source files
1.84 -LX_SRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
1.85 -LX_OBJ = $(patsubst %.c,%.o,$(LX_SRC))
1.86 -LX_DEP = $(patsubst %.o,%.dep,$(LX_OBJ))
1.87 -$(LX_OBJ) $(LX_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS)
1.88 -
1.89 -# What's needed to build 'conf'
1.90 -conf_SRC = kconfig/conf.c
1.91 -conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
1.92 -conf_DEP = $(patsubst %.o,%.dep,$(conf_OBJ))
1.93 -$(conf_OBJ) $(conf_DEP): CFLAGS += $(INTL_CFLAGS)
1.94 -
1.95 -# What's needed to build 'mconf'
1.96 -mconf_SRC = kconfig/mconf.c
1.97 -mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
1.98 -mconf_DEP = $(patsubst %.c,%.dep,$(mconf_SRC))
1.99 -$(mconf_OBJ) $(mconf_DEP): CFLAGS += $(NCURSES_CFLAGS) $(INTL_CFLAGS)
1.100 -$(obj)/mconf: LDFLAGS += $(NCURSES_LDFLAGS)
1.101 -
1.102 -# What's needed to build 'nconf'
1.103 -nconf_SRC = kconfig/nconf.c kconfig/nconf.gui.c
1.104 -nconf_OBJ = $(patsubst %.c,%.o,$(nconf_SRC))
1.105 -nconf_DEP = $(patsubst %.c,%.dep,$(nconf_SRC))
1.106 -$(nconf_OBJ) $(nconf_DEP): CFLAGS += $(INTL_CFLAGS)
1.107 -$(obj)/nconf: LDFLAGS += -lmenu -lpanel -lncurses
1.108 -
1.109 -# Under Cygwin, we need to auto-import some libs (which ones, exactly?)
1.110 -# for mconf and nconf to lin properly.
1.111 -ifeq ($(shell uname -o 2>/dev/null || echo unknown),Cygwin)
1.112 -$(obj)/mconf: LDFLAGS += -Wl,--enable-auto-import
1.113 -$(obj)/nconf: LDFLAGS += -Wl,--enable-auto-import
1.114 -endif
1.115 -
1.116 -# These are generated files:
1.117 -ALL_OBJS = $(sort $(COMMON_OBJ) $(LX_OBJ) $(conf_OBJ) $(mconf_OBJ) $(nconf_OBJ))
1.118 -ALL_DEPS = $(sort $(COMMON_DEP) $(LX_DEP) $(conf_DEP) $(mconf_DEP) $(nconf_DEP))
1.119 -
1.120 -# Cheesy auto-dependencies
1.121 -# Only parse the following if a configurator was called, to avoid building
1.122 -# dependencies when not needed (eg. list-steps, list-samples...)
1.123 -# We must be careful what we enclose, because we need some of the variable
1.124 -# definitions for clean (and distclean) at least.
1.125 -# Just protecting the "-include $(DEPS)" line should be sufficient.
1.126 -# And in case we want menuconfig, we have to check that lxdialog
1.127 -# can find a curses lib.
1.128 -
1.129 -ifneq ($(strip $(MAKECMDGOALS)),)
1.130 -ifneq ($(strip $(filter $(configurators),$(MAKECMDGOALS))),)
1.131 -
1.132 -DEPS = $(COMMON_DEP)
1.133 -ifneq ($(strip $(filter oldconfig,$(MAKECMDGOALS))),)
1.134 -DEPS += $(conf_DEP)
1.135 -endif
1.136 -ifneq ($(strip $(filter menuconfig,$(MAKECMDGOALS))),)
1.137 -DEPS += $(mconf_DEP) $(LX_DEP)
1.138 -$(COMMON_OBJ) $(COMMON_DEP): |dochecklxdialog
1.139 -$(LX_OBJ) $(LX_DEP): |dochecklxdialog
1.140 -$(mconf_OBJ) $(mconf_DEP): |dochecklxdialog
1.141 -endif
1.142 -ifneq ($(strip $(filter nconfig,$(MAKECMDGOALS))),)
1.143 -DEPS += $(nconf_DEP)
1.144 -endif
1.145 -
1.146 --include $(DEPS)
1.147 -
1.148 -endif # MAKECMDGOALS contains a configurator rule
1.149 -endif # MAKECMDGOALS != ""
1.150 -
1.151 -# Each .o or .dep *can not* directly depend on kconfig/, because kconfig can
1.152 -# be touched during the build (who's touching it, btw?) so each .o or .dep
1.153 -# would be re-built when it should not be.
1.154 -# So manually check for presence of $(obj) (ie. kconfig), and only mkdir
1.155 -# if needed. After all, that's not so bad...
1.156 -# mkdir $(obj)/lxdialog, because we need it, and incidentally, that
1.157 -# also creates $(obj).
1.158 -define check_kconfig_dir
1.159 - $(SILENT)if [ ! -d $(obj)/lxdialog ]; then \
1.160 - $(ECHO) " MKDIR $(obj)"; \
1.161 - mkdir -p $(obj)/lxdialog; \
1.162 - fi
1.163 -endef
1.164 -
1.165 -# Build the dependency for C files
1.166 -%.dep: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
1.167 - $(check_kconfig_dir)
1.168 - @$(ECHO) " DEP $@"
1.169 - $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |$(sed) -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
1.170 -
1.171 -# Build C files
1.172 -%.o: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
1.173 - $(check_kconfig_dir)
1.174 - @$(ECHO) " CC $@"
1.175 - $(SILENT)$(HOST_CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
1.176 -
1.177 -# Actual link
1.178 -$(obj)/mconf: $(COMMON_OBJ) $(LX_OBJ) $(mconf_OBJ)
1.179 - @$(ECHO) ' LD $@'
1.180 - $(SILENT)$(HOST_LD) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS)
1.181 -
1.182 -$(obj)/nconf: $(COMMON_OBJ) $(nconf_OBJ)
1.183 - @$(ECHO) ' LD $@'
1.184 - $(SILENT)$(HOST_LD) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS)
1.185 -
1.186 -$(obj)/conf: $(COMMON_OBJ) $(conf_OBJ)
1.187 - @$(ECHO) ' LD $@'
1.188 - $(SILENT)$(HOST_LD) -o $@ $^ $(LDFLAGS) $(EXTRA_LDFLAGS)
1.189 -
1.190 -#-----------------------------------------------------------
1.191 -# Cleaning up the mess...
1.192 -
1.193 -clean::
1.194 - @$(ECHO) " CLEAN kconfig"
1.195 - $(SILENT)rm -f kconfig/{,m,n}conf{,.exe} $(ALL_OBJS) $(ALL_DEPS)
1.196 - $(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true