samples/samples.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed May 21 22:00:52 2008 +0000 (2008-05-21)
changeset 527 4ac12179ef23
parent 333 d647d0e6021e
child 539 c538627f69f1
permissions -rw-r--r--
Introduce target-specific LDFLAGS, the same way we have CFLAGS for the target.
It seems to be helping gcc somewhat into telling the correct endianness to ld that sticks with little endian even when the target is big (eg armeb-unknown-linux-uclibcgnueabi).
There's still work to do, especially finish the gcc part that is not in this commit.

/trunk/scripts/functions | 9 7 2 0 +++++++--
1 file changed, 7 insertions(+), 2 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 := $(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  '  show-samples       - show a brief overview of each samples listed below:'
    14 	@$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
    15 
    16 help-build::
    17 	@echo  '  regtest[.#]        - Regtest-build all samples'
    18 	@echo  '  regtest-local[.#]  - Regtest-build all local samples'
    19 	@echo  '  regtest-global[.#] - Regtest-build all global samples'
    20 
    21 show-samples:
    22 	@$(CT_LIB_DIR)/scripts/showSamples.sh -v $(CT_SAMPLES)
    23 
    24 # How we do build one sample
    25 PHONY += $(CT_SAMPLES)
    26 $(CT_SAMPLES):
    27 	@echo  'Configuring for "$@"'
    28 	@$(CT_NG) $(patsubst %,copy_config_%,$(@)) oldconfig
    29 	@echo  'Execute "$(CT_NG) build" to build your toolchain'
    30 
    31 $(patsubst %,copy_config_%,$(CT_SAMPLES)):
    32 	@if [ -f $(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config ]; then                    \
    33 	      cp "$(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    34 	 else                                                                                                       \
    35 	      cp "$(CT_LIB_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    36 	 fi
    37 
    38 # And now for building all samples one after the other
    39 PHONY += regtest regtest_local regtest_global
    40 regtest: regtest-local regtest-global
    41 
    42 regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
    43 
    44 regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
    45 
    46 regtest.% regtest-local.% regtest-global.%:
    47 	@$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
    48 
    49 # One regtest per sample
    50 # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    51 # work because we want to save the samples as well.
    52 # Also, we don't want to see anylog at all, save for the elapsed time, and we
    53 # want to save the log file in a specific place
    54 # Furthermore, force the location where the toolchain will be installed.
    55 # Finaly, we can't use 'make sample-name' as we need to provide default values
    56 # if the options set has changed, but oldconfig does not like when stdin is
    57 # not a terminal (eg. it is a pipe).
    58 $(patsubst %,regtest_%,$(CT_SAMPLES)):
    59 	@samp=$(patsubst regtest_%,%,$@)                                                                ;   \
    60 	 echo -e "\rBuilding sample \"$${samp}\""                                                       &&  \
    61 	 $(CT_NG) copy_config_$${samp}                                                                  &&  \
    62 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    63 	 sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config  &&  \
    64 	 sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    65 	 sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    66 	 sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    67 	 sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
    68 	 sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    69 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    70 	 $(CT_NG) build                                                                                 &&  \
    71 	 echo -e "\rSuccessfully built sample \"$${samp}\""                                             &&  \
    72 	 echo -e "\rMaking tarball for sample \"$${samp}\""                                             &&  \
    73 	 $(CT_NG) tarball                                                                               &&  \
    74 	 echo -e "\rSuccessfully built tarball for sample \"$${samp}\""                                 ;   \
    75 	 echo -e "\rCleaning sample \"$${samp}\""                                                       ;   \
    76 	 $(CT_NG) distclean                                                                             ;   \
    77 	 echo -e "\r"
    78 
    79 saveconfig:
    80 	@$(CT_LIB_DIR)/scripts/saveSample.sh