Enhance the make fragments:
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Oct 27 18:42:26 2008 +0000 (2008-10-27)
changeset 1001c8ac48ba1411
parent 1000 b5bbe3bf5204
child 1002 27c52570055f
Enhance the make fragments:
- comment the different parts
- re-order the code so that it is homogeneous amogst fragments
- eye-candy in some existing comments

/trunk/tools/tools.mk | 17 15 2 0 +++++++++++++++--
/trunk/steps.mk | 38 26 12 0 ++++++++++++++++++++++++++------------
/trunk/samples/samples.mk | 41 28 13 0 ++++++++++++++++++++++++++++-------------
/trunk/config/config.mk | 2 1 1 0 +-
4 files changed, 70 insertions(+), 28 deletions(-)
config/config.mk
samples/samples.mk
steps.mk
tools/tools.mk
     1.1 --- a/config/config.mk	Mon Oct 27 18:39:24 2008 +0000
     1.2 +++ b/config/config.mk	Mon Oct 27 18:42:26 2008 +0000
     1.3 @@ -3,7 +3,7 @@
     1.4  # These targets are used from top-level makefile
     1.5  
     1.6  #-----------------------------------------------------------
     1.7 -# List all config files, source and generated
     1.8 +# List all config files, wether sourced or generated
     1.9  
    1.10  # The top-level config file to be used be configurators
    1.11  KCONFIG_TOP = config/config.in
     2.1 --- a/samples/samples.mk	Mon Oct 27 18:39:24 2008 +0000
     2.2 +++ b/samples/samples.mk	Mon Oct 27 18:42:26 2008 +0000
     2.3 @@ -1,10 +1,13 @@
     2.4  # Makefile to manage samples
     2.5  
     2.6 +# ----------------------------------------------------------
     2.7  # Build the list of available samples
     2.8  CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
     2.9  CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config)))
    2.10 +CT_SAMPLES := $(sort $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES))
    2.11  
    2.12 -CT_SAMPLES := $(sort $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES))
    2.13 +# ----------------------------------------------------------
    2.14 +# This part deals with the samples help entries
    2.15  
    2.16  help-config::
    2.17  	@echo  '  saveconfig         - Save current config as a preconfigured target'
    2.18 @@ -23,13 +26,35 @@
    2.19  help-distrib::
    2.20  	@echo  '  wiki-samples       - Print a DokuWiki table of samples'
    2.21  
    2.22 +# ----------------------------------------------------------
    2.23 +# This part deals with printing samples information
    2.24 +
    2.25 +# Prints the details of a sample
    2.26 +PHONY += $(patsubst %,show-%,$(CT_SAMPLES))
    2.27  $(patsubst %,show-%,$(CT_SAMPLES)):
    2.28  	@$(CT_LIB_DIR)/scripts/showSamples.sh -v $(patsubst show-%,%,$(@))
    2.29  
    2.30 +# print the list of all available samples
    2.31  PHONY += list-samples
    2.32  list-samples: .FORCE
    2.33  	@echo $(CT_SAMPLES) |sed -r -e 's/ /\n/g;' |sort
    2.34  
    2.35 +wiki-samples:
    2.36 +	$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)
    2.37 +
    2.38 +# ----------------------------------------------------------
    2.39 +# This part deals with saving/restoring samples
    2.40 +
    2.41 +# Save a sample
    2.42 +saveconfig:
    2.43 +	$(SILENT)$(CT_LIB_DIR)/scripts/saveSample.sh
    2.44 +
    2.45 +# The 'sample_dir' function prints the directory in which the sample is,
    2.46 +# searching first in local samples, then in global samples
    2.47 +define sample_dir
    2.48 +$$( [ -d $(CT_TOP_DIR)/samples/$(1) ] && echo "$(CT_TOP_DIR)/samples/$(1)" || echo "$(CT_LIB_DIR)/samples/$(1)")
    2.49 +endef
    2.50 +
    2.51  # How we do recall one sample
    2.52  PHONY += $(CT_SAMPLES)
    2.53  $(CT_SAMPLES):
    2.54 @@ -61,13 +86,9 @@
    2.55  	@echo
    2.56  	@echo  'Now configured for "$@"'
    2.57  
    2.58 -# The 'sample_dir' function prints the directory in which the sample is,
    2.59 -# searching first in local samples, then in global samples
    2.60 -define sample_dir
    2.61 -$$( [ -d $(CT_TOP_DIR)/samples/$(1) ] && echo "$(CT_TOP_DIR)/samples/$(1)" || echo "$(CT_LIB_DIR)/samples/$(1)")
    2.62 -endef
    2.63 +# ----------------------------------------------------------
    2.64 +# And now for building all samples one after the other
    2.65  
    2.66 -# And now for building all samples one after the other
    2.67  PHONY += regtest regtest_local regtest_global
    2.68  regtest: regtest-local regtest-global
    2.69  
    2.70 @@ -107,9 +128,3 @@
    2.71  	 echo -e "\rCleaning sample \"$${samp}\""                                                       ;   \
    2.72  	 $(CT_NG) distclean                                                                             ;   \
    2.73  	 echo -e "\r"
    2.74 -
    2.75 -saveconfig:
    2.76 -	$(SILENT)$(CT_LIB_DIR)/scripts/saveSample.sh
    2.77 -
    2.78 -wiki-samples:
    2.79 -	$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)
     3.1 --- a/steps.mk	Mon Oct 27 18:39:24 2008 +0000
     3.2 +++ b/steps.mk	Mon Oct 27 18:42:26 2008 +0000
     3.3 @@ -1,6 +1,17 @@
     3.4  # Makefile for each steps
     3.5  # Copyright 2006 Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
     3.6  
     3.7 +# ----------------------------------------------------------
     3.8 +# This is the steps help entry
     3.9 +
    3.10 +help-build::
    3.11 +	@echo  '  list-steps         - List all build steps'
    3.12 +
    3.13 +# ----------------------------------------------------------
    3.14 +# The steps list
    3.15 +
    3.16 +# Please keep the last line with a '\' and keep the folowing empy line:
    3.17 +# it helps when diffing and merging.
    3.18  CT_STEPS := libc_check_config   \
    3.19              kernel_headers      \
    3.20              gmp                 \
    3.21 @@ -19,8 +30,23 @@
    3.22              tools               \
    3.23              debug               \
    3.24  
    3.25 +# Make the list available to sub-processes (scripts/crosstool.sh needs it)
    3.26  export CT_STEPS
    3.27  
    3.28 +# Print the steps list
    3.29 +PHONY += list-steps
    3.30 +list-steps:
    3.31 +	@echo  'Available build steps, in order:'
    3.32 +	@for step in $(CT_STEPS); do    \
    3.33 +	     echo "  - $${step}";       \
    3.34 +	 done
    3.35 +	@echo  'Use "<step>" as action to execute only that step.'
    3.36 +	@echo  'Use "+<step>" as action to execute up to that step.'
    3.37 +	@echo  'Use "<step>+" as action to execute from that step onward.'
    3.38 +
    3.39 +# ----------------------------------------------------------
    3.40 +# This part deals with executing steps
    3.41 +
    3.42  $(CT_STEPS):
    3.43  	$(SILENT)$(MAKE) -rf $(CT_NG) RESTART=$@ STOP=$@ build
    3.44  
    3.45 @@ -29,15 +55,3 @@
    3.46  
    3.47  $(patsubst %,%+,$(CT_STEPS)):
    3.48  	$(SILENT)$(MAKE) -rf $(CT_NG) RESTART=$(patsubst %+,%,$@) build
    3.49 -
    3.50 -help-build::
    3.51 -	@echo  '  list-steps         - List all build steps'
    3.52 -
    3.53 -list-steps:
    3.54 -	@echo  'Available build steps, in order:'
    3.55 -	@for step in $(CT_STEPS); do    \
    3.56 -	     echo "  - $${step}";       \
    3.57 -	 done
    3.58 -	@echo  'Use "<step>" as action to execute only that step.'
    3.59 -	@echo  'Use "+<step>" as action to execute up to that step.'
    3.60 -	@echo  'Use "<step>+" as action to execute from that step onward.'
     4.1 --- a/tools/tools.mk	Mon Oct 27 18:39:24 2008 +0000
     4.2 +++ b/tools/tools.mk	Mon Oct 27 18:42:26 2008 +0000
     4.3 @@ -5,6 +5,16 @@
     4.4  # scripts for later inclusion mainline. If CT_LIB_DIR != CT_TOP_DIR, then those
     4.5  # scripts are downloaded only for use in CT_TOP_DIR.
     4.6  
     4.7 +# ----------------------------------------------------------
     4.8 +# The tools help entry
     4.9 +
    4.10 +help-distrib::
    4.11 +	@echo  '  updatetools        - Update the config tools'
    4.12 +
    4.13 +# ----------------------------------------------------------
    4.14 +# Where to get tools from, and where to store them into
    4.15 +# The tools are: config.guess and config.sub
    4.16 +
    4.17  CONFIG_SUB_SRC="http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD"
    4.18  CONFIG_SUB_DEST="$(CT_TOP_DIR)/tools/config.sub"
    4.19  CONFIG_GUESS_SRC="http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD"
    4.20 @@ -16,6 +26,9 @@
    4.21  PHONY += updatetools
    4.22  updatetools: $(CT_TOP_DIR)/tools $(CONFIG_SUB_DEST) $(CONFIG_GUESS_DEST)
    4.23  
    4.24 +# ----------------------------------------------------------
    4.25 +# How to retrieve the tools
    4.26 +
    4.27  $(CONFIG_SUB_DEST):
    4.28  	$(SILENT)wget $(CONFIG_SUB_SRC) -O $@
    4.29  	$(SILENT)chmod u+rwx,go+rx-w $@
    4.30 @@ -24,8 +37,8 @@
    4.31  	$(SILENT)wget $(CONFIG_GUESS_SRC) -O $@
    4.32  	$(SILENT)chmod u+rwx,go+rx-w $@
    4.33  
    4.34 -help-distrib::
    4.35 -	@echo  '  updatetools        - Update the config tools'
    4.36 +# ----------------------------------------------------------
    4.37 +# Clean up the mess
    4.38  
    4.39  distclean::
    4.40  	@$(ECHO) "  CLEAN tools"