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