samples/samples.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Oct 14 21:30:27 2008 +0000 (2008-10-14)
changeset 935 e175e3538310
parent 933 fb5a4a36e0da
child 940 f0f9ba3f98f2
permissions -rw-r--r--
Introduce the notion of a 'sample comment'.

- presence of the sample's reported.by file is now mandatory.
- when saving a sample, reporter name & URL are queried, to avoid operator forget about creating the reported.by file.
- when saving a sample, one can store a few-liner comment.
- when recalling a sample, the reporter name, URL and comment (if present) are printed.
- update the powerpc-e500v2-linux-gnuspe sample to include Nate's comment (from his original mail).
- update all samples that were missing the reported.by file.

/trunk/scripts/saveSample.sh | 46 35 11 0 ++++++++++++++++++------
/trunk/scripts/showSamples.sh | 12 6 6 0 +++---
/trunk/samples/powerpc-e500v2-linux-gnuspe/reported.by | 15 15 0 0 ++++++++
/trunk/samples/samples.mk | 22 17 5 0 +++++++++--
4 files changed, 73 insertions(+), 22 deletions(-)
     1 # Makefile to manage samples
     2 
     3 # Build the list of available samples
     4 CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
     5 CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config)))
     6 
     7 CT_SAMPLES := $(sort $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES))
     8 
     9 help-config::
    10 	@echo  '  saveconfig         - Save current config as a preconfigured target'
    11 
    12 help-samples::
    13 	@echo  '  list-samples       - prints the list of all samples (for scripting)'
    14 	@echo  '  show-<sample>      - show a brief overview of <sample> (list below)'
    15 	@echo  '  <sample>           - preconfigure crosstool-NG with <sample> (list below)'
    16 	@$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
    17 
    18 help-build::
    19 	@echo  '  regtest[.#]        - Regtest-build all samples'
    20 	@echo  '  regtest-local[.#]  - Regtest-build all local samples'
    21 	@echo  '  regtest-global[.#] - Regtest-build all global samples'
    22 
    23 help-distrib::
    24 	@echo  '  wiki-samples       - Print a DokuWiki table of samples'
    25 
    26 $(patsubst %,show-%,$(CT_SAMPLES)):
    27 	@$(CT_LIB_DIR)/scripts/showSamples.sh -v $(patsubst show-%,%,$(@))
    28 
    29 PHONY += list-samples
    30 list-samples: .FORCE
    31 	@echo $(CT_SAMPLES) |sed -r -e 's/ /\n/g;' |sort
    32 
    33 # How we do recall one sample
    34 PHONY += $(CT_SAMPLES)
    35 $(CT_SAMPLES):
    36 	@cp $(call sample_dir,$@)/crosstool.config .config
    37 	@$(MAKE) -rf $(CT_NG) oldconfig
    38 	@echo
    39 	@echo  '***********************************************************'
    40 	@echo
    41 	@( . $(call sample_dir,$@)/reported.by;                                     \
    42 	   echo "Initially reported by: $${reporter_name:-Yann E. MORIN}";          \
    43 	   echo "URL: $${reporter_url:-http://ymorin.is-a-geek.org/}";              \
    44 	   if [ -n "$${reporter_comment}" ]; then                                   \
    45 	     echo  ;                                                                \
    46 	     echo  "Comment:";                                                      \
    47 	     printf "$${reporter_comment}\n";                                       \
    48 	   fi;                                                                      \
    49 	   echo  ;                                                                  \
    50 	   echo  '***********************************************************';     \
    51 	 )
    52 	@if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then        \
    53 	   echo  ;                                                              \
    54 	   echo  'WARNING! This sample may enable experimental features.';      \
    55 	   echo  '         Please be sure to review the configuration prior';   \
    56 	   echo  '         to building and using your toolchain!';              \
    57 	   echo  'Now, you have been warned!';                                  \
    58 	   echo  ;                                                              \
    59 	   echo  '***********************************************************'; \
    60 	 fi
    61 	@echo
    62 	@echo  'Now configured for "$@"'
    63 
    64 # The 'sample_dir' function prints the directory in which the sample is,
    65 # searching first in local samples, then in global samples
    66 define sample_dir
    67 $$( [ -d $(CT_TOP_DIR)/samples/$(1) ] && echo "$(CT_TOP_DIR)/samples/$(1)" || echo "$(CT_LIB_DIR)/samples/$(1)")
    68 endef
    69 
    70 # And now for building all samples one after the other
    71 PHONY += regtest regtest_local regtest_global
    72 regtest: regtest-local regtest-global
    73 
    74 regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
    75 
    76 regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
    77 
    78 regtest.% regtest-local.% regtest-global.%:
    79 	@$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
    80 
    81 # One regtest per sample
    82 # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    83 # work because we want to save the samples as well.
    84 # Also, we don't want to see anylog at all, save for the elapsed time, and we
    85 # want to save the log file in a specific place
    86 # Furthermore, force the location where the toolchain will be installed.
    87 # Finaly, we can't use 'make sample-name' as we need to provide default values
    88 # if the options set has changed, but oldconfig does not like when stdin is
    89 # not a terminal (eg. it is a pipe).
    90 $(patsubst %,regtest_%,$(CT_SAMPLES)):
    91 	@samp=$(patsubst regtest_%,%,$@)                                                                ;   \
    92 	 echo -e "\rBuilding sample \"$${samp}\""                                                       &&  \
    93 	 $(CT_NG) copy_config_$${samp}                                                                  &&  \
    94 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    95 	 sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config  &&  \
    96 	 sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    97 	 sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    98 	 sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    99 	 sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
   100 	 sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
   101 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
   102 	 $(CT_NG) build                                                                                 &&  \
   103 	 echo -e "\rSuccessfully built sample \"$${samp}\""                                             &&  \
   104 	 echo -e "\rMaking tarball for sample \"$${samp}\""                                             &&  \
   105 	 $(CT_NG) tarball                                                                               &&  \
   106 	 echo -e "\rSuccessfully built tarball for sample \"$${samp}\""                                 ;   \
   107 	 echo -e "\rCleaning sample \"$${samp}\""                                                       ;   \
   108 	 $(CT_NG) distclean                                                                             ;   \
   109 	 echo -e "\r"
   110 
   111 saveconfig:
   112 	@$(CT_LIB_DIR)/scripts/saveSample.sh
   113 
   114 wiki-samples:
   115 	@$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)