samples/samples.mk
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Sep 23 14:48:10 2008 +0000 (2008-09-23)
changeset 872 fd4bf138f08f
parent 605 c9c5a29cb295
child 933 fb5a4a36e0da
permissions -rw-r--r--
Bart De VOS pointed out that removing absolute paths from the libc linker scripts is plainly wrong.
It dates from dawn ages of the original crosstool code, and is not well explained. At that time, binutils might not understand the sysroot stuff, and it was necessary to remove absolute paths in that case.

/trunk/scripts/build/libc/glibc.sh | 14 2 12 0 ++------------
1 file changed, 2 insertions(+), 12 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 	@if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then        \
    39 	   echo  '';                                                            \
    40 	   echo  '***********************************************************'; \
    41 	   echo  '';                                                            \
    42 	   echo  'WARNING! This sample may enable experimental features.';      \
    43 	   echo  '         Please be sure to review the configuration prior';   \
    44 	   echo  '         to building and using your toolchain!';              \
    45 	   echo  'Now, you have been warned!';                                  \
    46 	   echo  '';                                                            \
    47 	   echo  '***********************************************************'; \
    48 	   echo  '';                                                            \
    49 	 fi
    50 	@echo  'Execute "$(CT_NG) build" to build your toolchain'
    51 
    52 $(patsubst %,copy_config_%,$(CT_SAMPLES)):
    53 	@if [ -f $(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config ]; then                    \
    54 	      cp "$(CT_TOP_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    55 	 else                                                                                                       \
    56 	      cp "$(CT_LIB_DIR)/samples/$(patsubst copy_config_%,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \
    57 	 fi
    58 
    59 # And now for building all samples one after the other
    60 PHONY += regtest regtest_local regtest_global
    61 regtest: regtest-local regtest-global
    62 
    63 regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
    64 
    65 regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
    66 
    67 regtest.% regtest-local.% regtest-global.%:
    68 	@$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
    69 
    70 # One regtest per sample
    71 # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
    72 # work because we want to save the samples as well.
    73 # Also, we don't want to see anylog at all, save for the elapsed time, and we
    74 # want to save the log file in a specific place
    75 # Furthermore, force the location where the toolchain will be installed.
    76 # Finaly, we can't use 'make sample-name' as we need to provide default values
    77 # if the options set has changed, but oldconfig does not like when stdin is
    78 # not a terminal (eg. it is a pipe).
    79 $(patsubst %,regtest_%,$(CT_SAMPLES)):
    80 	@samp=$(patsubst regtest_%,%,$@)                                                                ;   \
    81 	 echo -e "\rBuilding sample \"$${samp}\""                                                       &&  \
    82 	 $(CT_NG) copy_config_$${samp}                                                                  &&  \
    83 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    84 	 sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config  &&  \
    85 	 sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config         &&  \
    86 	 sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config                                          &&  \
    87 	 sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config                                 &&  \
    88 	 sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config                                        &&  \
    89 	 sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config                                   &&  \
    90 	 yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1                                                  &&  \
    91 	 $(CT_NG) build                                                                                 &&  \
    92 	 echo -e "\rSuccessfully built sample \"$${samp}\""                                             &&  \
    93 	 echo -e "\rMaking tarball for sample \"$${samp}\""                                             &&  \
    94 	 $(CT_NG) tarball                                                                               &&  \
    95 	 echo -e "\rSuccessfully built tarball for sample \"$${samp}\""                                 ;   \
    96 	 echo -e "\rCleaning sample \"$${samp}\""                                                       ;   \
    97 	 $(CT_NG) distclean                                                                             ;   \
    98 	 echo -e "\r"
    99 
   100 saveconfig:
   101 	@$(CT_LIB_DIR)/scripts/saveSample.sh
   102 
   103 wiki-samples:
   104 	@$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)