summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ct-ng.in40
-rw-r--r--kconfig/kconfig.mk142
-rw-r--r--samples/samples.mk30
-rw-r--r--steps.mk6
-rw-r--r--tools/tools.mk12
5 files changed, 140 insertions, 90 deletions
diff --git a/ct-ng.in b/ct-ng.in
index a6d9820..2a29f2a 100644
--- a/ct-ng.in
+++ b/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
diff --git a/kconfig/kconfig.mk b/kconfig/kconfig.mk
index 0c8b54d..2be7141 100644
--- a/kconfig/kconfig.mk
+++ b/kconfig/kconfig.mk
@@ -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...
-
-SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c
-
-$(obj)/conf $(obj)/mconf: $(obj)
-
-$(obj):
- @mkdir -p $(obj)
-
-HEADERS = $(CT_LIB_DIR)/kconfig/expr.h \
- $(CT_LIB_DIR)/kconfig/lkc.h \
- $(CT_LIB_DIR)/kconfig/lkc_proto.h
-
-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
-
-$(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))
-
-$(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}
+# Hmmm! Cheesy build!
+# Or: where I can unveil my make-fu... :-]
+
+# Oh! Files not here are there, in fact! :-)
+vpath %.c $(CT_LIB_DIR)
+vpath %.h $(CT_LIB_DIR)
+
+# What is the compiler?
+HOST_CC ?= gcc -funsigned-char
+
+# 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))
+
+# Common source files, and lxdialog source files
+SRC = kconfig/zconf.tab.c
+LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
+
+# What's needed to build 'conf'
+conf_SRC = $(SRC) kconfig/conf.c
+conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
+
+# What's needed to build 'mconf'
+mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c
+mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
+
+# 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
diff --git a/samples/samples.mk b/samples/samples.mk
index 5ea7276..ab8fdb7 100644
--- a/samples/samples.mk
+++ b/samples/samples.mk
@@ -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)
diff --git a/steps.mk b/steps.mk
index 267ee93..bcd440f 100644
--- a/steps.mk
+++ b/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'
diff --git a/tools/tools.mk b/tools/tools.mk
index 2327c72..dc8de4d 100644
--- a/tools/tools.mk
+++ b/tools/tools.mk
@@ -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