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