1.1 --- a/ct-ng.in Wed Oct 15 08:15:28 2008 +0000
1.2 +++ b/ct-ng.in Wed Oct 15 21:29:56 2008 +0000
1.3 @@ -27,13 +27,27 @@
1.4 export CT_STOP:=$(STOP)
1.5 export CT_RESTART:=$(RESTART)
1.6
1.7 +ifeq ($(strip $(V)),)
1.8 + SILENT=@
1.9 + ECHO=echo
1.10 +else
1.11 + ifeq ($(strip $(V)),0)
1.12 + SILENT=@
1.13 + ECHO=:
1.14 + else
1.15 + ifeq ($(strip $(V)),1)
1.16 + SILENT=
1.17 + ECHO=:
1.18 + endif)
1.19 + endif
1.20 +endif
1.21 +export V
1.22 +
1.23 .FORCE:
1.24 .PHONY: $(PHONY)
1.25 PHONY += all
1.26 all: help
1.27
1.28 -HOST_CC := gcc -funsigned-char
1.29 -
1.30 # Help system
1.31 help:: help-head help-config help-samples help-build help-clean help-distrib help-env help-tail
1.32
1.33 @@ -71,8 +85,6 @@
1.34 @echo 'Use action "version" to see the version'
1.35 @echo 'See "man 1 ct-ng" for some help as well'
1.36
1.37 -# End help system
1.38 -
1.39 help-build::
1.40 @echo ' build[.#] - Build the toolchain'
1.41
1.42 @@ -92,22 +104,24 @@
1.43 @echo ' STOP - Stop the build just after this step'
1.44 @echo ' RESTART - Restart the build just before this step'
1.45
1.46 +# End help system
1.47 +
1.48 .config:
1.49 @echo 'You must run either one of "$(CT_NG) config" or "$(CT_NG) menuconfig" first'
1.50 @false
1.51
1.52 # Actual build
1.53 build: .config
1.54 - @$(CT_LIB_DIR)/scripts/crosstool.sh
1.55 + $(SILENT)$(CT_LIB_DIR)/scripts/crosstool.sh
1.56
1.57 build.%:
1.58 - @$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
1.59 + $(SILENT)$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
1.60
1.61 PHONY += tarball
1.62 #tarball:
1.63 # @$(CT_LIB_DIR)/scripts/tarball.sh
1.64 tarball:
1.65 - @echo 'Tarbal creation disabled for now... Sorry.'
1.66 + @echo 'Tarball creation disabled for now... Sorry.'
1.67 @true
1.68
1.69 PHONY += version
1.70 @@ -122,11 +136,13 @@
1.71
1.72 PHONY += clean
1.73 clean::
1.74 - @rm -f $(CT_TOP_DIR)/.config.*
1.75 + $(SILENT)rm -f .config.*
1.76
1.77 PHONY += distclean
1.78 distclean:: clean
1.79 - @rm -f $(CT_TOP_DIR)/.config* $(CT_TOP_DIR)/..config.tmp
1.80 - @rm -f $(CT_TOP_DIR)/log.*
1.81 - @[ ! -d "$(CT_TOP_DIR)/targets" ] || chmod -R u+w "$(CT_TOP_DIR)/targets"
1.82 - @rm -rf "$(CT_TOP_DIR)/targets"
1.83 + @$(ECHO) " CLEAN .config log"
1.84 + $(SILENT)rm -f .config* ..config.tmp
1.85 + $(SILENT)rm -f log.*
1.86 + @$(ECHO) " CLEAN targets"
1.87 + $(SILENT)chmod -R u+w targets >/dev/null 2>&1 || true
1.88 + $(SILENT)rm -rf targets
2.1 --- a/kconfig/kconfig.mk Wed Oct 15 08:15:28 2008 +0000
2.2 +++ b/kconfig/kconfig.mk Wed Oct 15 21:29:56 2008 +0000
2.3 @@ -56,13 +56,13 @@
2.4
2.5 # Where to access to the source config files from
2.6 config:
2.7 - @echo " LN config"
2.8 - @ln -s $(CT_LIB_DIR)/config config
2.9 + @$(ECHO) " LN config"
2.10 + $(SILENT)ln -s $(CT_LIB_DIR)/config config
2.11
2.12 # Where to store the generated config files into
2.13 config.gen:
2.14 - @echo " MKDIR config.gen"
2.15 - @mkdir -p config.gen
2.16 + @$(ECHO) " MKDIR config.gen"
2.17 + $(SILENT)mkdir -p config.gen
2.18
2.19 #-----------------------------------------------------------
2.20 # Build list of per-component-type items to easily build generated files
2.21 @@ -89,8 +89,8 @@
2.22 # Example to build the kernels generated config file:
2.23 # $(call build_gen_choice_in,config.gen/kernel.in,Target OS,KERNEL,config/kernel,$(KERNELS))
2.24 define build_gen_choice_in
2.25 - @echo ' IN $(1)'
2.26 - @(echo "# $(2) menu"; \
2.27 + @$(ECHO) ' IN $(1)'
2.28 + $(SILENT)(echo "# $(2) menu"; \
2.29 echo "# Generated file, do not edit!!!"; \
2.30 echo ""; \
2.31 echo "choice"; \
2.32 @@ -136,8 +136,8 @@
2.33 # Example to build the tools generated config file:
2.34 # $(call build_gen_menu_in,config.gen/tools.in,Tools,TOOL,config/tools,$(TOOLS))
2.35 define build_gen_menu_in
2.36 - @echo ' IN $(1)'
2.37 - @(echo "# $(2) facilities menu"; \
2.38 + @$(ECHO) ' IN $(1)'
2.39 + $(SILENT)(echo "# $(2) facilities menu"; \
2.40 echo "# Generated file, do not edit!!!"; \
2.41 echo ""; \
2.42 for entry in $(5); do \
2.43 @@ -184,14 +184,14 @@
2.44 #-----------------------------------------------------------
2.45 # The configurators rules
2.46
2.47 -menuconfig: $(CONFIG_FILES) $(obj)/mconf
2.48 - @$(obj)/mconf $(KCONFIG_TOP)
2.49 +menuconfig: $(obj)/mconf $(CONFIG_FILES)
2.50 + $(SILENT)$< $(KCONFIG_TOP)
2.51
2.52 -oldconfig: $(CONFIG_FILES) $(obj)/conf
2.53 - @$(obj)/conf -s $(KCONFIG_TOP)
2.54 +oldconfig: .config $(obj)/conf $(CONFIG_FILES)
2.55 + $(SILENT)$< -s $(KCONFIG_TOP)
2.56
2.57 -defoldconfig: $(CONFIG_FILES) $(obj)/conf
2.58 - @yes "" |$(obj)/conf -s $(KCONFIG_TOP)
2.59 +defoldconfig: .config $(obj)/conf $(CONFIG_FILES)
2.60 + $(SILENT)yes "" |$< -s $(KCONFIG_TOP)
2.61
2.62 #-----------------------------------------------------------
2.63 # Help text used by make help
2.64 @@ -199,50 +199,84 @@
2.65 help-config::
2.66 @echo ' menuconfig - Update current config using a menu based program'
2.67 @echo ' oldconfig - Update current config using a provided .config as base'
2.68 - @echo ' build log piped into stdin'
2.69 + @echo ' defoldconfig - As oldconfig, above, but using defaults for new options'
2.70
2.71 #-----------------------------------------------------------
2.72 -# Not-so-cheesy build, needs rework...
2.73 +# Hmmm! Cheesy build!
2.74 +# Or: where I can unveil my make-fu... :-]
2.75
2.76 -SHIPPED := $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c
2.77 +# Oh! Files not here are there, in fact! :-)
2.78 +vpath %.c $(CT_LIB_DIR)
2.79 +vpath %.h $(CT_LIB_DIR)
2.80
2.81 -$(obj)/conf $(obj)/mconf: $(obj)
2.82 +# What is the compiler?
2.83 +HOST_CC ?= gcc -funsigned-char
2.84
2.85 -$(obj):
2.86 - @mkdir -p $(obj)
2.87 +# Compiler and linker flags to use ncurses
2.88 +CFLAGS += $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags)
2.89 +LDFLAGS += $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
2.90
2.91 -HEADERS = $(CT_LIB_DIR)/kconfig/expr.h \
2.92 - $(CT_LIB_DIR)/kconfig/lkc.h \
2.93 - $(CT_LIB_DIR)/kconfig/lkc_proto.h
2.94 +# Common source files, and lxdialog source files
2.95 +SRC = kconfig/zconf.tab.c
2.96 +LXSRC = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/kconfig/lxdialog/*.c))
2.97
2.98 -FILES = $(CT_LIB_DIR)/kconfig/confdata.c \
2.99 - $(CT_LIB_DIR)/kconfig/expr.c \
2.100 - $(CT_LIB_DIR)/kconfig/menu.c \
2.101 - $(CT_LIB_DIR)/kconfig/symbol.c \
2.102 - $(CT_LIB_DIR)/kconfig/util.c
2.103 +# What's needed to build 'conf'
2.104 +conf_SRC = $(SRC) kconfig/conf.c
2.105 +conf_OBJ = $(patsubst %.c,%.o,$(conf_SRC))
2.106
2.107 -$(obj)/mconf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/mconf.c \
2.108 - $(HEADERS) $(FILES) \
2.109 - $(CT_LIB_DIR)/kconfig/kconfig.mk
2.110 - @echo ' LD $@'
2.111 - @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{mconf.c,zconf.tab.c,lxdialog/*.c} \
2.112 - $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ccflags) \
2.113 - $(shell $(CT_LIB_DIR)/kconfig/lxdialog/check-lxdialog.sh -ldflags $(HOST_CC))
2.114 +# What's needed to build 'mconf'
2.115 +mconf_SRC = $(SRC) $(LXSRC) kconfig/mconf.c
2.116 +mconf_OBJ = $(patsubst %.c,%.o,$(mconf_SRC))
2.117
2.118 -$(obj)/conf: $(SHIPPED) $(CT_LIB_DIR)/kconfig/conf.c \
2.119 - $(HEADERS) $(FILES) \
2.120 - $(CT_LIB_DIR)/kconfig/kconfig.mk
2.121 - @echo ' LD $@'
2.122 - @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{conf.c,zconf.tab.c}
2.123 +# Cheesy auto-dependencies
2.124 +DEPS = $(patsubst %.c,%.d,$(sort $(conf_SRC) $(mconf_SRC)))
2.125 +
2.126 +# This is not very nice, as they will get rebuild even if (dist)cleaning... :-(
2.127 +# Should look into the Linux kernel Kbuild to see how they do that...
2.128 +# To really make me look into this, keep the annoying "DEP xxx" messages.
2.129 +# Also see the comment for the "%.o: %c" rule below
2.130 +%.d: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
2.131 + $(SILENT)if [ ! -d $(obj)/lxdialog ]; then \
2.132 + $(ECHO) " MKDIR $(obj)"; \
2.133 + mkdir -p $(obj)/lxdialog; \
2.134 + fi
2.135 + @$(ECHO) " DEP $@"
2.136 + $(SILENT)$(HOST_CC) $(CFLAGS) -MM $< |sed -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
2.137 +-include $(DEPS)
2.138 +
2.139 +# Each .o must depend on the corresponding .c (obvious, isn't it?),
2.140 +# but *can not* depend on kconfig/, because kconfig can be touched
2.141 +# during the build (who's touching it, btw?) so each .o would be
2.142 +# re-built when they sould not be.
2.143 +# So manually check for presence of $(obj) (ie. kconfig), and only mkdir
2.144 +# if needed. After all, that's not so bad...
2.145 +# mkdir $(obj)/lxdialog, because we need it, and incidentally, that
2.146 +# also creates $(obj).
2.147 +# Also rebuild the object files is the makefile is changed
2.148 +%.o: %.c $(CT_LIB_DIR)/kconfig/kconfig.mk
2.149 + $(SILENT)if [ ! -d $(obj)/lxdialog ]; then \
2.150 + $(ECHO) " MKDIR $(obj)"; \
2.151 + mkdir -p $(obj)/lxdialog; \
2.152 + fi
2.153 + @$(ECHO) " CC $@"
2.154 + $(SILENT)$(HOST_CC) $(CFLAGS) -o $@ -c $<
2.155 +
2.156 +$(obj)/mconf: $(mconf_OBJ)
2.157 + @$(ECHO) ' LD $@'
2.158 + $(SILENT)$(HOST_CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
2.159 +
2.160 +$(obj)/conf: $(conf_OBJ)
2.161 + @$(ECHO) ' LD $@'
2.162 + $(SILENT)$(HOST_CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
2.163
2.164 #-----------------------------------------------------------
2.165 # Cleaning up the mess...
2.166
2.167 clean::
2.168 - @echo " CLEAN kconfig"
2.169 - @rm -f kconfig/{,m}conf
2.170 - @rmdir --ignore-fail-on-non-empty kconfig 2>/dev/null || true
2.171 - @echo " CLEAN config"
2.172 - @rm -f config 2>/dev/null || true
2.173 - @echo " CLEAN config.gen"
2.174 - @rm -rf config.gen
2.175 + @$(ECHO) " CLEAN kconfig"
2.176 + $(SILENT)rm -f kconfig/{,m}conf $(conf_OBJ) $(mconf_OBJ) $(DEPS)
2.177 + $(SILENT)rmdir --ignore-fail-on-non-empty kconfig{/lxdialog,} 2>/dev/null || true
2.178 + @$(ECHO) " CLEAN config"
2.179 + $(SILENT)rm -f config 2>/dev/null || true
2.180 + @$(ECHO) " CLEAN config.gen"
2.181 + $(SILENT)rm -rf config.gen
3.1 --- a/samples/samples.mk Wed Oct 15 08:15:28 2008 +0000
3.2 +++ b/samples/samples.mk Wed Oct 15 21:29:56 2008 +0000
3.3 @@ -33,12 +33,12 @@
3.4 # How we do recall one sample
3.5 PHONY += $(CT_SAMPLES)
3.6 $(CT_SAMPLES):
3.7 - @cp $(call sample_dir,$@)/crosstool.config .config
3.8 - @$(MAKE) -rf $(CT_NG) oldconfig
3.9 + $(SILENT)cp $(call sample_dir,$@)/crosstool.config .config
3.10 + $(SILENT)$(MAKE) -rf $(CT_NG) oldconfig
3.11 @echo
3.12 @echo '***********************************************************'
3.13 @echo
3.14 - @( . $(call sample_dir,$@)/reported.by; \
3.15 + $(SILENT)( . $(call sample_dir,$@)/reported.by; \
3.16 echo "Initially reported by: $${reporter_name:-Yann E. MORIN}"; \
3.17 echo "URL: $${reporter_url:-http://ymorin.is-a-geek.org/}"; \
3.18 if [ -n "$${reporter_comment}" ]; then \
3.19 @@ -49,14 +49,14 @@
3.20 echo ; \
3.21 echo '***********************************************************'; \
3.22 )
3.23 - @if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \
3.24 - echo ; \
3.25 - echo 'WARNING! This sample may enable experimental features.'; \
3.26 - echo ' Please be sure to review the configuration prior'; \
3.27 - echo ' to building and using your toolchain!'; \
3.28 - echo 'Now, you have been warned!'; \
3.29 - echo ; \
3.30 - echo '***********************************************************'; \
3.31 + $(SILENT)if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \
3.32 + echo ; \
3.33 + echo 'WARNING! This sample may enable experimental features.'; \
3.34 + echo ' Please be sure to review the configuration prior'; \
3.35 + echo ' to building and using your toolchain!'; \
3.36 + echo 'Now, you have been warned!'; \
3.37 + echo ; \
3.38 + echo '***********************************************************'; \
3.39 fi
3.40 @echo
3.41 @echo 'Now configured for "$@"'
3.42 @@ -76,7 +76,7 @@
3.43 regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
3.44
3.45 regtest.% regtest-local.% regtest-global.%:
3.46 - @$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
3.47 + $(SILENT)$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
3.48
3.49 # One regtest per sample
3.50 # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
3.51 @@ -88,7 +88,7 @@
3.52 # if the options set has changed, but oldconfig does not like when stdin is
3.53 # not a terminal (eg. it is a pipe).
3.54 $(patsubst %,regtest_%,$(CT_SAMPLES)):
3.55 - @samp=$(patsubst regtest_%,%,$@) ; \
3.56 + $(SILENT)samp=$(patsubst regtest_%,%,$@) ; \
3.57 echo -e "\rBuilding sample \"$${samp}\"" && \
3.58 $(CT_NG) copy_config_$${samp} && \
3.59 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1 && \
3.60 @@ -109,7 +109,7 @@
3.61 echo -e "\r"
3.62
3.63 saveconfig:
3.64 - @$(CT_LIB_DIR)/scripts/saveSample.sh
3.65 + $(SILENT)$(CT_LIB_DIR)/scripts/saveSample.sh
3.66
3.67 wiki-samples:
3.68 - @$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)
3.69 + $(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)
4.1 --- a/steps.mk Wed Oct 15 08:15:28 2008 +0000
4.2 +++ b/steps.mk Wed Oct 15 21:29:56 2008 +0000
4.3 @@ -22,13 +22,13 @@
4.4 export CT_STEPS
4.5
4.6 $(CT_STEPS):
4.7 - @$(CT_NG) RESTART=$@ STOP=$@ build
4.8 + $(SILENT)$(MAKE) -rf $(CT_NG) RESTART=$@ STOP=$@ build
4.9
4.10 $(patsubst %,+%,$(CT_STEPS)):
4.11 - @$(CT_NG) STOP=$(patsubst +%,%,$@) build
4.12 + $(SILENT)$(MAKE) -rf $(CT_NG) STOP=$(patsubst +%,%,$@) build
4.13
4.14 $(patsubst %,%+,$(CT_STEPS)):
4.15 - @$(CT_NG) RESTART=$(patsubst %+,%,$@) build
4.16 + $(SILENT)$(MAKE) -rf $(CT_NG) RESTART=$(patsubst %+,%,$@) build
4.17
4.18 help-build::
4.19 @echo ' list-steps - List all build steps'
5.1 --- a/tools/tools.mk Wed Oct 15 08:15:28 2008 +0000
5.2 +++ b/tools/tools.mk Wed Oct 15 21:29:56 2008 +0000
5.3 @@ -11,21 +11,21 @@
5.4 CONFIG_GUESS_DEST="$(CT_TOP_DIR)/tools/config.guess"
5.5
5.6 $(CT_TOP_DIR)/tools:
5.7 - @mkdir -p $(CT_TOP_DIR)/tools
5.8 + $(SILENT)mkdir -p $(CT_TOP_DIR)/tools
5.9
5.10 PHONY += updatetools
5.11 updatetools: $(CT_TOP_DIR)/tools $(CONFIG_SUB_DEST) $(CONFIG_GUESS_DEST)
5.12
5.13 $(CONFIG_SUB_DEST):
5.14 - @wget $(CONFIG_SUB_SRC) -O $@
5.15 - @chmod u+rwx,go+rx-w $@
5.16 + $(SILENT)wget $(CONFIG_SUB_SRC) -O $@
5.17 + $(SILENT)chmod u+rwx,go+rx-w $@
5.18
5.19 $(CONFIG_GUESS_DEST):
5.20 - @wget $(CONFIG_GUESS_SRC) -O $@
5.21 - @chmod u+rwx,go+rx-w $@
5.22 + $(SILENT)wget $(CONFIG_GUESS_SRC) -O $@
5.23 + $(SILENT)chmod u+rwx,go+rx-w $@
5.24
5.25 help-distrib::
5.26 @echo ' updatetools - Update the config tools'
5.27
5.28 distclean::
5.29 - @[ $(CT_TOP_DIR) = $(CT_LIB_DIR) ] || rm -rf $(CT_TOP_DIR)/tools
5.30 + $(SILENT)[ $(CT_TOP_DIR) = $(CT_LIB_DIR) ] || rm -rf $(CT_TOP_DIR)/tools