mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-20 21:33:08 +00:00
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:
parent
b77f4abe34
commit
4e7d6836a5
40
ct-ng.in
40
ct-ng.in
@ -27,13 +27,27 @@ export CT_VERSION:=@@CT_VERSION@@
|
||||
export CT_STOP:=$(STOP)
|
||||
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:
|
||||
.PHONY: $(PHONY)
|
||||
PHONY += all
|
||||
all: help
|
||||
|
||||
HOST_CC := gcc -funsigned-char
|
||||
|
||||
# Help system
|
||||
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 'See "man 1 ct-ng" for some help as well'
|
||||
|
||||
# End help system
|
||||
|
||||
help-build::
|
||||
@echo ' build[.#] - Build the toolchain'
|
||||
|
||||
@ -92,22 +104,24 @@ help-env::
|
||||
@echo ' STOP - Stop the build just after this step'
|
||||
@echo ' RESTART - Restart the build just before this step'
|
||||
|
||||
# End help system
|
||||
|
||||
.config:
|
||||
@echo 'You must run either one of "$(CT_NG) config" or "$(CT_NG) menuconfig" first'
|
||||
@false
|
||||
|
||||
# Actual build
|
||||
build: .config
|
||||
@$(CT_LIB_DIR)/scripts/crosstool.sh
|
||||
$(SILENT)$(CT_LIB_DIR)/scripts/crosstool.sh
|
||||
|
||||
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
|
||||
#tarball:
|
||||
# @$(CT_LIB_DIR)/scripts/tarball.sh
|
||||
tarball:
|
||||
@echo 'Tarbal creation disabled for now... Sorry.'
|
||||
@echo 'Tarball creation disabled for now... Sorry.'
|
||||
@true
|
||||
|
||||
PHONY += version
|
||||
@ -122,11 +136,13 @@ version:
|
||||
|
||||
PHONY += clean
|
||||
clean::
|
||||
@rm -f $(CT_TOP_DIR)/.config.*
|
||||
$(SILENT)rm -f .config.*
|
||||
|
||||
PHONY += distclean
|
||||
distclean:: clean
|
||||
@rm -f $(CT_TOP_DIR)/.config* $(CT_TOP_DIR)/..config.tmp
|
||||
@rm -f $(CT_TOP_DIR)/log.*
|
||||
@[ ! -d "$(CT_TOP_DIR)/targets" ] || chmod -R u+w "$(CT_TOP_DIR)/targets"
|
||||
@rm -rf "$(CT_TOP_DIR)/targets"
|
||||
@$(ECHO) " CLEAN .config log"
|
||||
$(SILENT)rm -f .config* ..config.tmp
|
||||
$(SILENT)rm -f log.*
|
||||
@$(ECHO) " CLEAN targets"
|
||||
$(SILENT)chmod -R u+w targets >/dev/null 2>&1 || true
|
||||
$(SILENT)rm -rf targets
|
||||
|
@ -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...
|
||||
# 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):
|
||||
@mkdir -p $(obj)
|
||||
# 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))
|
||||
|
||||
HEADERS = $(CT_LIB_DIR)/kconfig/expr.h \
|
||||
$(CT_LIB_DIR)/kconfig/lkc.h \
|
||||
$(CT_LIB_DIR)/kconfig/lkc_proto.h
|
||||
# Common source files, and lxdialog source files
|
||||
SRC = kconfig/zconf.tab.c
|
||||
LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
|
||||
|
||||
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
|
||||
# What's needed to build 'conf'
|
||||
conf_SRC = $(SRC) kconfig/conf.c
|
||||
conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
|
||||
|
||||
$(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))
|
||||
# What's needed to build 'mconf'
|
||||
mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c
|
||||
mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
|
||||
|
||||
$(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}
|
||||
# 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
|
||||
|
@ -33,12 +33,12 @@ list-samples: .FORCE
|
||||
# How we do recall one sample
|
||||
PHONY += $(CT_SAMPLES)
|
||||
$(CT_SAMPLES):
|
||||
@cp $(call sample_dir,$@)/crosstool.config .config
|
||||
@$(MAKE) -rf $(CT_NG) oldconfig
|
||||
$(SILENT)cp $(call sample_dir,$@)/crosstool.config .config
|
||||
$(SILENT)$(MAKE) -rf $(CT_NG) oldconfig
|
||||
@echo
|
||||
@echo '***********************************************************'
|
||||
@echo
|
||||
@( . $(call sample_dir,$@)/reported.by; \
|
||||
$(SILENT)( . $(call sample_dir,$@)/reported.by; \
|
||||
echo "Initially reported by: $${reporter_name:-Yann E. MORIN}"; \
|
||||
echo "URL: $${reporter_url:-http://ymorin.is-a-geek.org/}"; \
|
||||
if [ -n "$${reporter_comment}" ]; then \
|
||||
@ -49,14 +49,14 @@ $(CT_SAMPLES):
|
||||
echo ; \
|
||||
echo '***********************************************************'; \
|
||||
)
|
||||
@if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \
|
||||
echo ; \
|
||||
echo 'WARNING! This sample may enable experimental features.'; \
|
||||
echo ' Please be sure to review the configuration prior'; \
|
||||
echo ' to building and using your toolchain!'; \
|
||||
echo 'Now, you have been warned!'; \
|
||||
echo ; \
|
||||
echo '***********************************************************'; \
|
||||
$(SILENT)if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \
|
||||
echo ; \
|
||||
echo 'WARNING! This sample may enable experimental features.'; \
|
||||
echo ' Please be sure to review the configuration prior'; \
|
||||
echo ' to building and using your toolchain!'; \
|
||||
echo 'Now, you have been warned!'; \
|
||||
echo ; \
|
||||
echo '***********************************************************'; \
|
||||
fi
|
||||
@echo
|
||||
@echo 'Now configured for "$@"'
|
||||
@ -76,7 +76,7 @@ regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
|
||||
regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
|
||||
|
||||
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
|
||||
# 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
|
||||
# not a terminal (eg. it is a pipe).
|
||||
$(patsubst %,regtest_%,$(CT_SAMPLES)):
|
||||
@samp=$(patsubst regtest_%,%,$@) ; \
|
||||
$(SILENT)samp=$(patsubst regtest_%,%,$@) ; \
|
||||
echo -e "\rBuilding sample \"$${samp}\"" && \
|
||||
$(CT_NG) copy_config_$${samp} && \
|
||||
yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1 && \
|
||||
@ -109,7 +109,7 @@ $(patsubst %,regtest_%,$(CT_SAMPLES)):
|
||||
echo -e "\r"
|
||||
|
||||
saveconfig:
|
||||
@$(CT_LIB_DIR)/scripts/saveSample.sh
|
||||
$(SILENT)$(CT_LIB_DIR)/scripts/saveSample.sh
|
||||
|
||||
wiki-samples:
|
||||
@$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)
|
||||
$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)
|
||||
|
6
steps.mk
6
steps.mk
@ -22,13 +22,13 @@ CT_STEPS := libc_check_config \
|
||||
export CT_STEPS
|
||||
|
||||
$(CT_STEPS):
|
||||
@$(CT_NG) RESTART=$@ STOP=$@ build
|
||||
$(SILENT)$(MAKE) -rf $(CT_NG) RESTART=$@ STOP=$@ build
|
||||
|
||||
$(patsubst %,+%,$(CT_STEPS)):
|
||||
@$(CT_NG) STOP=$(patsubst +%,%,$@) build
|
||||
$(SILENT)$(MAKE) -rf $(CT_NG) STOP=$(patsubst +%,%,$@) build
|
||||
|
||||
$(patsubst %,%+,$(CT_STEPS)):
|
||||
@$(CT_NG) RESTART=$(patsubst %+,%,$@) build
|
||||
$(SILENT)$(MAKE) -rf $(CT_NG) RESTART=$(patsubst %+,%,$@) build
|
||||
|
||||
help-build::
|
||||
@echo ' list-steps - List all build steps'
|
||||
|
@ -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"
|
||||
|
||||
$(CT_TOP_DIR)/tools:
|
||||
@mkdir -p $(CT_TOP_DIR)/tools
|
||||
$(SILENT)mkdir -p $(CT_TOP_DIR)/tools
|
||||
|
||||
PHONY += updatetools
|
||||
updatetools: $(CT_TOP_DIR)/tools $(CONFIG_SUB_DEST) $(CONFIG_GUESS_DEST)
|
||||
|
||||
$(CONFIG_SUB_DEST):
|
||||
@wget $(CONFIG_SUB_SRC) -O $@
|
||||
@chmod u+rwx,go+rx-w $@
|
||||
$(SILENT)wget $(CONFIG_SUB_SRC) -O $@
|
||||
$(SILENT)chmod u+rwx,go+rx-w $@
|
||||
|
||||
$(CONFIG_GUESS_DEST):
|
||||
@wget $(CONFIG_GUESS_SRC) -O $@
|
||||
@chmod u+rwx,go+rx-w $@
|
||||
$(SILENT)wget $(CONFIG_GUESS_SRC) -O $@
|
||||
$(SILENT)chmod u+rwx,go+rx-w $@
|
||||
|
||||
help-distrib::
|
||||
@echo ' updatetools - Update the config tools'
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user