Cheesy kconfig stuff:

- silent/quiet/verbose build:
   - ct-ng by default only prints quit messages, such as "CC xxx",
   - if using V=0, nothing is printed,
   - if using V=1, the full command lines are printed,
   - other values are indeterminate,
   - should help in debugging the kconfig stuff;
 - complete kconfig/{,m}conf generation:
   - fully dynamic dependencies on source files,
   - compilation of .c into .o, then linking (instead of direct linking),
   - VPATH usage when not --local;
Typo + a coment moved.

 /trunk/kconfig/kconfig.mk |  140    87    53     0 +++++++++++++++++++++++++++++++++--------------------
 /trunk/tools/tools.mk     |   12     6     6     0 ++--
 /trunk/steps.mk           |    6     3     3     0 +-
 /trunk/samples/samples.mk |   30    15    15     0 +++++-----
 /trunk/ct-ng.in           |   40    28    12     0 +++++++++++----
 5 files changed, 139 insertions(+), 89 deletions(-)
This commit is contained in:
Yann E. MORIN" 2008-10-15 21:29:56 +00:00
parent b77f4abe34
commit 4e7d6836a5
5 changed files with 133 additions and 83 deletions

View File

@ -27,13 +27,27 @@ export CT_VERSION:=@@CT_VERSION@@
export CT_STOP:=$(STOP) export CT_STOP:=$(STOP)
export CT_RESTART:=$(RESTART) export CT_RESTART:=$(RESTART)
ifeq ($(strip $(V)),)
SILENT=@
ECHO=echo
else
ifeq ($(strip $(V)),0)
SILENT=@
ECHO=:
else
ifeq ($(strip $(V)),1)
SILENT=
ECHO=:
endif)
endif
endif
export V
.FORCE: .FORCE:
.PHONY: $(PHONY) .PHONY: $(PHONY)
PHONY += all PHONY += all
all: help all: help
HOST_CC := gcc -funsigned-char
# Help system # Help system
help:: help-head help-config help-samples help-build help-clean help-distrib help-env help-tail help:: help-head help-config help-samples help-build help-clean help-distrib help-env help-tail
@ -71,8 +85,6 @@ help-tail::
@echo 'Use action "version" to see the version' @echo 'Use action "version" to see the version'
@echo 'See "man 1 ct-ng" for some help as well' @echo 'See "man 1 ct-ng" for some help as well'
# End help system
help-build:: help-build::
@echo ' build[.#] - Build the toolchain' @echo ' build[.#] - Build the toolchain'
@ -92,22 +104,24 @@ help-env::
@echo ' STOP - Stop the build just after this step' @echo ' STOP - Stop the build just after this step'
@echo ' RESTART - Restart the build just before this step' @echo ' RESTART - Restart the build just before this step'
# End help system
.config: .config:
@echo 'You must run either one of "$(CT_NG) config" or "$(CT_NG) menuconfig" first' @echo 'You must run either one of "$(CT_NG) config" or "$(CT_NG) menuconfig" first'
@false @false
# Actual build # Actual build
build: .config build: .config
@$(CT_LIB_DIR)/scripts/crosstool.sh $(SILENT)$(CT_LIB_DIR)/scripts/crosstool.sh
build.%: build.%:
@$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;') $(SILENT)$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
PHONY += tarball PHONY += tarball
#tarball: #tarball:
# @$(CT_LIB_DIR)/scripts/tarball.sh # @$(CT_LIB_DIR)/scripts/tarball.sh
tarball: tarball:
@echo 'Tarbal creation disabled for now... Sorry.' @echo 'Tarball creation disabled for now... Sorry.'
@true @true
PHONY += version PHONY += version
@ -122,11 +136,13 @@ version:
PHONY += clean PHONY += clean
clean:: clean::
@rm -f $(CT_TOP_DIR)/.config.* $(SILENT)rm -f .config.*
PHONY += distclean PHONY += distclean
distclean:: clean distclean:: clean
@rm -f $(CT_TOP_DIR)/.config* $(CT_TOP_DIR)/..config.tmp @$(ECHO) " CLEAN .config log"
@rm -f $(CT_TOP_DIR)/log.* $(SILENT)rm -f .config* ..config.tmp
@[ ! -d "$(CT_TOP_DIR)/targets" ] || chmod -R u+w "$(CT_TOP_DIR)/targets" $(SILENT)rm -f log.*
@rm -rf "$(CT_TOP_DIR)/targets" @$(ECHO) " CLEAN targets"
$(SILENT)chmod -R u+w targets >/dev/null 2>&1 || true
$(SILENT)rm -rf targets

View File

@ -56,13 +56,13 @@ CONFIG_FILES = $(sort $(KCONFIG_TOP) $(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES))
# Where to access to the source config files from # Where to access to the source config files from
config: config:
@echo " LN config" @$(ECHO) " LN config"
@ln -s $(CT_LIB_DIR)/config config $(SILENT)ln -s $(CT_LIB_DIR)/config config
# Where to store the generated config files into # Where to store the generated config files into
config.gen: config.gen:
@echo " MKDIR config.gen" @$(ECHO) " MKDIR config.gen"
@mkdir -p config.gen $(SILENT)mkdir -p config.gen
#----------------------------------------------------------- #-----------------------------------------------------------
# Build list of per-component-type items to easily build generated files # 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: # Example to build the kernels generated config file:
# $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS)) # $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS))
define build_gen_choice_in define build_gen_choice_in
@echo ' IN $(1)' @$(ECHO) ' IN $(1)'
@(echo "# $(2) menu"; \ $(SILENT)(echo "# $(2) menu"; \
echo "# Generated file, do not edit!!!"; \ echo "# Generated file, do not edit!!!"; \
echo ""; \ echo ""; \
echo "choice"; \ echo "choice"; \
@ -136,8 +136,8 @@ endef
# Example to build the tools generated config file: # Example to build the tools generated config file:
# $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS)) # $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS))
define build_gen_menu_in define build_gen_menu_in
@echo ' IN $(1)' @$(ECHO) ' IN $(1)'
@(echo "# $(2) facilities menu"; \ $(SILENT)(echo "# $(2) facilities menu"; \
echo "# Generated file, do not edit!!!"; \ echo "# Generated file, do not edit!!!"; \
echo ""; \ echo ""; \
for entry in $(5); do \ for entry in $(5); do \
@ -184,14 +184,14 @@ config.gen/debug.in: $(DEBUG_CONFIG_FILES)
#----------------------------------------------------------- #-----------------------------------------------------------
# The configurators rules # The configurators rules
menuconfig: $(CONFIG_FILES) $(obj)/mconf menuconfig: $(obj)/mconf $(CONFIG_FILES)
@$(obj)/mconf $(KCONFIG_TOP) $(SILENT)$< $(KCONFIG_TOP)
oldconfig: $(CONFIG_FILES) $(obj)/conf oldconfig: .config $(obj)/conf $(CONFIG_FILES)
@$(obj)/conf -s $(KCONFIG_TOP) $(SILENT)$< -s $(KCONFIG_TOP)
defoldconfig: $(CONFIG_FILES) $(obj)/conf defoldconfig: .config $(obj)/conf $(CONFIG_FILES)
@yes "" |$(obj)/conf -s $(KCONFIG_TOP) $(SILENT)yes "" |$< -s $(KCONFIG_TOP)
#----------------------------------------------------------- #-----------------------------------------------------------
# Help text used by make help # Help text used by make help
@ -199,50 +199,84 @@ defoldconfig: $(CONFIG_FILES) $(obj)/conf
help-config:: help-config::
@echo ' menuconfig - Update current config using a menu based program' @echo ' menuconfig - Update current config using a menu based program'
@echo ' oldconfig - Update current config using a provided .config as base' @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... # Hmmm! Cheesy build!
# Or: where I can unveil my make-fu... :-]
SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c # Oh! Files not here are there, in fact! :-)
vpath %.c $(CT_LIB_DIR)
vpath %.h $(CT_LIB_DIR)
$(obj)/conf $(obj)/mconf: $(obj) # What is the compiler?
HOST_CC ?= gcc -funsigned-char
$(obj): # Compiler and linker flags to use ncurses
@mkdir -p $(obj) CFLAGS += $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags)
LDFLAGS += $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
HEADERS = $(CT_LIB_DIR)/kconfig/expr.h \ # Common source files, and lxdialog source files
$(CT_LIB_DIR)/kconfig/lkc.h \ SRC = kconfig/zconf.tab.c
$(CT_LIB_DIR)/kconfig/lkc_proto.h LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
FILES = $(CT_LIB_DIR)/kconfig/confdata.c \ # What's needed to build 'conf'
$(CT_LIB_DIR)/kconfig/expr.c \ conf_SRC = $(SRC) kconfig/conf.c
$(CT_LIB_DIR)/kconfig/menu.c \ conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
$(CT_LIB_DIR)/kconfig/symbol.c \
$(CT_LIB_DIR)/kconfig/util.c
$(obj)/mconf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/mconf.c \ # What's needed to build 'mconf'
$(HEADERS) $(FILES) \ mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c
$(CT_LIB_DIR)/kconfig/kconfig.mk mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
@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 \ # Cheesy auto-dependencies
$(HEADERS) $(FILES) \ DEPS = $(patsubst %.c,%.d,$(sort $(conf_SRC) $(mconf_SRC)))
$(CT_LIB_DIR)/kconfig/kconfig.mk
@echo ' LD $@' # This is not very nice, as they will get rebuild even if (dist)cleaning... :-(
@$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{conf.c,zconf.tab.c} # 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... # Cleaning up the mess...
clean:: clean::
@echo " CLEAN kconfig" @$(ECHO) " CLEAN kconfig"
@rm -f kconfig/{,m}conf $(SILENT)rm -f kconfig/{,m}conf $(conf_OBJ) $(mconf_OBJ) $(DEPS)
@rmdir --ignore-fail-on-non-empty kconfig 2>/dev/null || true $(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true
@echo " CLEAN config" @$(ECHO) " CLEAN config"
@rm -f config 2>/dev/null || true $(SILENT)rm -f config 2>/dev/null || true
@echo " CLEAN config.gen" @$(ECHO) " CLEAN config.gen"
@rm -rf config.gen $(SILENT)rm -rf config.gen

View File

@ -33,12 +33,12 @@ list-samples: .FORCE
# How we do recall one sample # How we do recall one sample
PHONY += $(CT_SAMPLES) PHONY += $(CT_SAMPLES)
$(CT_SAMPLES): $(CT_SAMPLES):
@cp $(call sample_dir,$@)/crosstool.config .config $(SILENT)cp $(call sample_dir,$@)/crosstool.config .config
@$(MAKE) -rf $(CT_NG) oldconfig $(SILENT)$(MAKE) -rf $(CT_NG) oldconfig
@echo @echo
@echo '***********************************************************' @echo '***********************************************************'
@echo @echo
@( . $(call sample_dir,$@)/reported.by; \ $(SILENT)( . $(call sample_dir,$@)/reported.by; \
echo "Initially reported by: $${reporter_name:-Yann E. MORIN}"; \ echo "Initially reported by: $${reporter_name:-Yann E. MORIN}"; \
echo "URL: $${reporter_url:-http://ymorin.is-a-geek.org/}"; \ echo "URL: $${reporter_url:-http://ymorin.is-a-geek.org/}"; \
if [ -n "$${reporter_comment}" ]; then \ if [ -n "$${reporter_comment}" ]; then \
@ -49,14 +49,14 @@ $(CT_SAMPLES):
echo ; \ echo ; \
echo '***********************************************************'; \ echo '***********************************************************'; \
) )
@if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \ $(SILENT)if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \
echo ; \ echo ; \
echo 'WARNING! This sample may enable experimental features.'; \ echo 'WARNING! This sample may enable experimental features.'; \
echo ' Please be sure to review the configuration prior'; \ echo ' Please be sure to review the configuration prior'; \
echo ' to building and using your toolchain!'; \ echo ' to building and using your toolchain!'; \
echo 'Now, you have been warned!'; \ echo 'Now, you have been warned!'; \
echo ; \ echo ; \
echo '***********************************************************'; \ echo '***********************************************************'; \
fi fi
@echo @echo
@echo 'Now configured for "$@"' @echo 'Now configured for "$@"'
@ -76,7 +76,7 @@ regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES)) regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
regtest.% regtest-local.% regtest-global.%: regtest.% regtest-local.% regtest-global.%:
@$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;') $(SILENT)$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
# One regtest per sample # One regtest per sample
# We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
@ -88,7 +88,7 @@ regtest.% regtest-local.% regtest-global.%:
# if the options set has changed, but oldconfig does not like when stdin is # if the options set has changed, but oldconfig does not like when stdin is
# not a terminal (eg. it is a pipe). # not a terminal (eg. it is a pipe).
$(patsubst %,regtest_%,$(CT_SAMPLES)): $(patsubst %,regtest_%,$(CT_SAMPLES)):
@samp=$(patsubst regtest_%,%,$@) ; \ $(SILENT)samp=$(patsubst regtest_%,%,$@) ; \
echo -e "\rBuilding sample \"$${samp}\"" && \ echo -e "\rBuilding sample \"$${samp}\"" && \
$(CT_NG) copy_config_$${samp} && \ $(CT_NG) copy_config_$${samp} && \
yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1 && \ yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1 && \
@ -109,7 +109,7 @@ $(patsubst %,regtest_%,$(CT_SAMPLES)):
echo -e "\r" echo -e "\r"
saveconfig: saveconfig:
@$(CT_LIB_DIR)/scripts/saveSample.sh $(SILENT)$(CT_LIB_DIR)/scripts/saveSample.sh
wiki-samples: wiki-samples:
@$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES) $(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)

View File

@ -22,13 +22,13 @@ CT_STEPS := libc_check_config \
export CT_STEPS export CT_STEPS
$(CT_STEPS): $(CT_STEPS):
@$(CT_NG) RESTART=$@ STOP=$@ build $(SILENT)$(MAKE) -rf $(CT_NG) RESTART=$@ STOP=$@ build
$(patsubst %,+%,$(CT_STEPS)): $(patsubst %,+%,$(CT_STEPS)):
@$(CT_NG) STOP=$(patsubst +%,%,$@) build $(SILENT)$(MAKE) -rf $(CT_NG) STOP=$(patsubst +%,%,$@) build
$(patsubst %,%+,$(CT_STEPS)): $(patsubst %,%+,$(CT_STEPS)):
@$(CT_NG) RESTART=$(patsubst %+,%,$@) build $(SILENT)$(MAKE) -rf $(CT_NG) RESTART=$(patsubst %+,%,$@) build
help-build:: help-build::
@echo ' list-steps - List all build steps' @echo ' list-steps - List all build steps'

View File

@ -11,21 +11,21 @@ CONFIG_GUESS_SRC="http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;
CONFIG_GUESS_DEST="$(CT_TOP_DIR)/tools/config.guess" CONFIG_GUESS_DEST="$(CT_TOP_DIR)/tools/config.guess"
$(CT_TOP_DIR)/tools: $(CT_TOP_DIR)/tools:
@mkdir -p $(CT_TOP_DIR)/tools $(SILENT)mkdir -p $(CT_TOP_DIR)/tools
PHONY += updatetools PHONY += updatetools
updatetools: $(CT_TOP_DIR)/tools $(CONFIG_SUB_DEST) $(CONFIG_GUESS_DEST) updatetools: $(CT_TOP_DIR)/tools $(CONFIG_SUB_DEST) $(CONFIG_GUESS_DEST)
$(CONFIG_SUB_DEST): $(CONFIG_SUB_DEST):
@wget $(CONFIG_SUB_SRC) -O $@ $(SILENT)wget $(CONFIG_SUB_SRC) -O $@
@chmod u+rwx,go+rx-w $@ $(SILENT)chmod u+rwx,go+rx-w $@
$(CONFIG_GUESS_DEST): $(CONFIG_GUESS_DEST):
@wget $(CONFIG_GUESS_SRC) -O $@ $(SILENT)wget $(CONFIG_GUESS_SRC) -O $@
@chmod u+rwx,go+rx-w $@ $(SILENT)chmod u+rwx,go+rx-w $@
help-distrib:: help-distrib::
@echo ' updatetools - Update the config tools' @echo ' updatetools - Update the config tools'
distclean:: distclean::
@[ $(CT_TOP_DIR) = $(CT_LIB_DIR) ] || rm -rf $(CT_TOP_DIR)/tools $(SILENT)[ $(CT_TOP_DIR) = $(CT_LIB_DIR) ] || rm -rf $(CT_TOP_DIR)/tools