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@933
|
33 |
# How we do recall one sample
|
yann@182
|
34 |
PHONY += $(CT_SAMPLES)
|
yann@166
|
35 |
$(CT_SAMPLES):
|
yann@933
|
36 |
@cp $(call sample_dir,$@)/crosstool.config .config
|
yann@933
|
37 |
@$(MAKE) -rf $(CT_NG) oldconfig
|
yann@935
|
38 |
@echo
|
yann@935
|
39 |
@echo '***********************************************************'
|
yann@935
|
40 |
@echo
|
yann@935
|
41 |
@( . $(call sample_dir,$@)/reported.by; \
|
yann@935
|
42 |
echo "Initially reported by: $${reporter_name:-Yann E. MORIN}"; \
|
yann@935
|
43 |
echo "URL: $${reporter_url:-http://ymorin.is-a-geek.org/}"; \
|
yann@935
|
44 |
if [ -n "$${reporter_comment}" ]; then \
|
yann@935
|
45 |
echo ; \
|
yann@935
|
46 |
echo "Comment:"; \
|
yann@935
|
47 |
printf "$${reporter_comment}\n"; \
|
yann@935
|
48 |
fi; \
|
yann@935
|
49 |
echo ; \
|
yann@935
|
50 |
echo '***********************************************************'; \
|
yann@935
|
51 |
)
|
yann@822
|
52 |
@if grep -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \
|
yann@935
|
53 |
echo ; \
|
yann@822
|
54 |
echo 'WARNING! This sample may enable experimental features.'; \
|
yann@822
|
55 |
echo ' Please be sure to review the configuration prior'; \
|
yann@822
|
56 |
echo ' to building and using your toolchain!'; \
|
yann@822
|
57 |
echo 'Now, you have been warned!'; \
|
yann@935
|
58 |
echo ; \
|
yann@822
|
59 |
echo '***********************************************************'; \
|
yann@822
|
60 |
fi
|
yann@935
|
61 |
@echo
|
yann@933
|
62 |
@echo 'Now configured for "$@"'
|
yann@182
|
63 |
|
yann@933
|
64 |
# The 'sample_dir' function prints the directory in which the sample is,
|
yann@933
|
65 |
# searching first in local samples, then in global samples
|
yann@933
|
66 |
define sample_dir
|
yann@933
|
67 |
$$( [ -d $(CT_TOP_DIR)/samples/$(1) ] && echo "$(CT_TOP_DIR)/samples/$(1)" || echo "$(CT_LIB_DIR)/samples/$(1)")
|
yann@933
|
68 |
endef
|
yann@166
|
69 |
|
yann@166
|
70 |
# And now for building all samples one after the other
|
yann@230
|
71 |
PHONY += regtest regtest_local regtest_global
|
yann@230
|
72 |
regtest: regtest-local regtest-global
|
yann@230
|
73 |
|
yann@230
|
74 |
regtest-local: $(patsubst %,regtest_%,$(CT_TOP_SAMPLES))
|
yann@230
|
75 |
|
yann@230
|
76 |
regtest-global: $(patsubst %,regtest_%,$(CT_LIB_SAMPLES))
|
yann@230
|
77 |
|
yann@333
|
78 |
regtest.% regtest-local.% regtest-global.%:
|
yann@333
|
79 |
@$(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
|
yann@333
|
80 |
|
yann@230
|
81 |
# One regtest per sample
|
yann@166
|
82 |
# We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't
|
yann@166
|
83 |
# work because we want to save the samples as well.
|
yann@166
|
84 |
# Also, we don't want to see anylog at all, save for the elapsed time, and we
|
yann@166
|
85 |
# want to save the log file in a specific place
|
yann@166
|
86 |
# Furthermore, force the location where the toolchain will be installed.
|
yann@166
|
87 |
# Finaly, we can't use 'make sample-name' as we need to provide default values
|
yann@166
|
88 |
# if the options set has changed, but oldconfig does not like when stdin is
|
yann@166
|
89 |
# not a terminal (eg. it is a pipe).
|
yann@230
|
90 |
$(patsubst %,regtest_%,$(CT_SAMPLES)):
|
yann@230
|
91 |
@samp=$(patsubst regtest_%,%,$@) ; \
|
yann@230
|
92 |
echo -e "\rBuilding sample \"$${samp}\"" && \
|
yann@230
|
93 |
$(CT_NG) copy_config_$${samp} && \
|
yann@230
|
94 |
yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1 && \
|
yann@230
|
95 |
sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config && \
|
yann@230
|
96 |
sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config && \
|
yann@230
|
97 |
sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config && \
|
yann@230
|
98 |
sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config && \
|
yann@230
|
99 |
sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config && \
|
yann@230
|
100 |
sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config && \
|
yann@230
|
101 |
yes "" |$(CT_NG) defoldconfig >/dev/null 2>&1 && \
|
yann@230
|
102 |
$(CT_NG) build && \
|
yann@230
|
103 |
echo -e "\rSuccessfully built sample \"$${samp}\"" && \
|
yann@230
|
104 |
echo -e "\rMaking tarball for sample \"$${samp}\"" && \
|
yann@230
|
105 |
$(CT_NG) tarball && \
|
yann@230
|
106 |
echo -e "\rSuccessfully built tarball for sample \"$${samp}\"" ; \
|
yann@230
|
107 |
echo -e "\rCleaning sample \"$${samp}\"" ; \
|
yann@230
|
108 |
$(CT_NG) distclean ; \
|
yann@230
|
109 |
echo -e "\r"
|
yann@166
|
110 |
|
yann@63
|
111 |
saveconfig:
|
yann@189
|
112 |
@$(CT_LIB_DIR)/scripts/saveSample.sh
|
yann@560
|
113 |
|
yann@560
|
114 |
wiki-samples:
|
yann@560
|
115 |
@$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)
|