samples/samples.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Jun 25 09:04:38 2008 +0000 (2008-06-25)
changeset 619 399b85eeb5be
parent 560 0ca969b84057
child 822 04a1937d5f0b
permissions -rw-r--r--
Update samples.

/trunk/samples/armeb-unknown-linux-uclibc/crosstool.config | 5 3 2 0 +++--
/trunk/samples/arm-unknown-linux-gnueabi/crosstool.config | 5 3 2 0 +++--
/trunk/samples/arm-unknown-linux-gnueabi/reported.by | 2 1 1 0 +-
/trunk/samples/mips-unknown-linux-uclibc/crosstool.config | 5 3 2 0 +++--
/trunk/samples/arm-unknown-linux-uclibcgnueabi/crosstool.config | 5 3 2 0 +++--
/trunk/samples/ia64-unknown-linux-gnu/crosstool.config | 7 3 4 0 +++----
/trunk/samples/armeb-unknown-linux-gnu/crosstool.config | 5 3 2 0 +++--
/trunk/samples/x86_64-unknown-linux-uclibc/crosstool.config | 5 3 2 0 +++--
/trunk/samples/arm-unknown-linux-uclibc/crosstool.config | 5 3 2 0 +++--
/trunk/samples/i586-geode-linux-uclibc/crosstool.config | 5 3 2 0 +++--
/trunk/samples/armeb-unknown-linux-uclibcgnueabi/crosstool.config | 5 3 2 0 +++--
/trunk/samples/i686-nptl-linux-gnu/crosstool.config | 5 3 2 0 +++--
/trunk/samples/alphaev56-unknown-linux-gnu/crosstool.config | 5 3 2 0 +++--
13 files changed, 37 insertions(+), 27 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 build one sample
    34 PHONY += $(CT_SAMPLES)
    35 $(CT_SAMPLES):
    36 	@echo  'Configuring for "$@"'
    37 	@$(CT_NG) $(patsubst %,copy_config_%,$(@)) oldconfig
    38 	@echo  'Execute "$(CT_NG) build" to build your toolchain'
    39 
    40 $(patsubst %,copy_config_%,$(CT_SAMPLES)):
    41 	@if [ -f $(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config ]; then                    \
    42 	      cp "$(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    43 	 else                                                                                                       \
    44 	      cp "$(CT_LIB_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    45 	 fi
    46 
    47 # And now for building all samples one after the other
    48 PHONY += regtest regtest_local regtest_global
    49 regtest: regtest-local regtest-global
    50 
    51 regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
    52 
    53 regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
    54 
    55 regtest.% regtest-local.% regtest-global.%:
    56 	@$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
    57 
    58 # One regtest per sample
    59 # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    60 # work because we want to save the samples as well.
    61 # Also, we don't want to see anylog at all, save for the elapsed time, and we
    62 # want to save the log file in a specific place
    63 # Furthermore, force the location where the toolchain will be installed.
    64 # Finaly, we can't use 'make sample-name' as we need to provide default values
    65 # if the options set has changed, but oldconfig does not like when stdin is
    66 # not a terminal (eg. it is a pipe).
    67 $(patsubst %,regtest_%,$(CT_SAMPLES)):
    68 	@samp=$(patsubst regtest_%,%,$@)                                                                ;   \
    69 	 echo -e "\rBuilding sample \"$${samp}\""                                                       &&  \
    70 	 $(CT_NG) copy_config_$${samp}                                                                  &&  \
    71 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    72 	 sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config  &&  \
    73 	 sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    74 	 sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    75 	 sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    76 	 sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
    77 	 sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    78 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    79 	 $(CT_NG) build                                                                                 &&  \
    80 	 echo -e "\rSuccessfully built sample \"$${samp}\""                                             &&  \
    81 	 echo -e "\rMaking tarball for sample \"$${samp}\""                                             &&  \
    82 	 $(CT_NG) tarball                                                                               &&  \
    83 	 echo -e "\rSuccessfully built tarball for sample \"$${samp}\""                                 ;   \
    84 	 echo -e "\rCleaning sample \"$${samp}\""                                                       ;   \
    85 	 $(CT_NG) distclean                                                                             ;   \
    86 	 echo -e "\r"
    87 
    88 saveconfig:
    89 	@$(CT_LIB_DIR)/scripts/saveSample.sh
    90 
    91 wiki-samples:
    92 	@$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)