docs: do not document CT_KERNEL_ARCH, it's going away...
Since we merged the 32/64-bit archs, and we explicitly used
the Linux kernel arch name, we can get rid of CT_KERNEL_ARCH.
1 # Makefile to manage samples
3 # ----------------------------------------------------------
4 # Build the list of available samples
5 CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
6 CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config)))
7 CT_SAMPLES := $(shell echo $(sort $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES)) \
8 |sed -r -e 's/ /\n/g;' \
9 |sed -r -e 's/(.*),(.*)/\2,\1/;' \
11 |sed -r -e 's/(.*),(.*)/\2,\1/;' \
14 # ----------------------------------------------------------
15 # This part deals with the samples help entries
18 @echo ' saveconfig - Save current config as a preconfigured target'
21 @echo ' list-samples - prints the list of all samples (for scripting)'
22 @echo ' show-<sample> - show a brief overview of <sample> (list below)'
23 @echo ' <sample> - preconfigure crosstool-NG with <sample> (list below)'
24 @echo ' build-all[.#] - Build *all* samples (list below) and install in'
25 @echo ' $${CT_PREFIX} (which you must set)'
26 @echo ' Available samples:'
27 @$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES)
30 @echo ' wiki-samples - Print a DokuWiki table of samples'
33 @echo ' CT_PREFIX - directory in which to auto-install samples'
34 @echo ' (see action "build-all", above).'
36 # ----------------------------------------------------------
37 # This part deals with printing samples information
39 # Prints the details of a sample
40 PHONY += $(patsubst %,show-%,$(CT_SAMPLES))
41 $(patsubst %,show-%,$(CT_SAMPLES)):
42 @$(CT_LIB_DIR)/scripts/showSamples.sh -v $(patsubst show-%,%,$(@))
44 # Prints the details of all samples
46 show-all: $(patsubst %,show-%,$(CT_SAMPLES))
48 # print the list of all available samples
51 @echo $(CT_SAMPLES) |$(sed) -r -e 's/ /\n/g;' |sed -r -e 's/(.*),(.*)/\2 \(host: \1\)/;'
54 $(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w $(CT_SAMPLES)
56 # ----------------------------------------------------------
57 # This part deals with saving/restoring samples
65 saveconfig: .config samples
66 $(SILENT)$(CT_LIB_DIR)/scripts/saveSample.sh
68 # The 'sample_dir' function prints the directory in which the sample is,
69 # searching first in local samples, then in global samples
71 $$( [ -d $(CT_TOP_DIR)/samples/$(1) ] && echo "$(CT_TOP_DIR)/samples/$(1)" || echo "$(CT_LIB_DIR)/samples/$(1)")
74 # How we do recall one sample
75 PHONY += $(CT_SAMPLES)
77 $(SILENT)cp $(call sample_dir,$@)/crosstool.config .config
78 $(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) oldconfig
80 @echo '***********************************************************'
82 $(SILENT)( . $(call sample_dir,$@)/reported.by; \
83 echo "Initially reported by: $${reporter_name:-Yann E. MORIN}"; \
84 echo "URL: $${reporter_url:-http://ymorin.is-a-geek.org/}"; \
85 if [ -n "$${reporter_comment}" ]; then \
88 printf "$${reporter_comment}\n"; \
91 echo '***********************************************************'; \
93 $(SILENT)if $(grep) -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \
95 echo 'WARNING! This sample may enable experimental features.'; \
96 echo ' Please be sure to review the configuration prior'; \
97 echo ' to building and using your toolchain!'; \
98 echo 'Now, you have been warned!'; \
100 echo '***********************************************************'; \
103 @echo 'Now configured for "$@"'
105 # ----------------------------------------------------------
106 # Some helper functions
108 # Create the rule to build a sample
112 @$(ECHO) ' CONF $(1)'
113 $(SILENT)cp $(call sample_dir,$(1))/crosstool.config .config
114 $(SILENT)$(sed) -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$(2)":;' .config
115 $(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config
116 $(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config
117 $(SILENT)$(sed) -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config
118 $(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config
119 $(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config
120 $(SILENT)$(MAKE) -rf $(CT_NG) V=0 oldconfig
121 @$(ECHO) ' BUILD $(1)'
122 $(SILENT)$(MAKE) -rf $(CT_NG) V=0 build
125 # ----------------------------------------------------------
126 # Build samples for use (not regtest!)
128 # Check that PREFIX is set if building samples
129 ifneq ($(strip $(MAKECMDGOALS)),)
130 ifneq ($(strip $(filter $(patsubst %,build-%,$(CT_SAMPLES)) build-all,$(MAKECMDGOALS))),)
132 ifeq ($(strip $(CT_PREFIX)),)
133 $(error Please set 'CT_PREFIX' to where you want to install generated toolchain samples!)
136 endif # MAKECMDGOALS contains a build sample rule
137 endif # MAKECMDGOALS != ""
139 # Build a single sample
140 $(patsubst %,build-%,$(CT_SAMPLES)):
141 $(call build_sample,$(patsubst build-%,%,$@),$(CT_PREFIX)/$(patsubst build-%,%,$@))
144 build-all: $(patsubst %,build-%,$(CT_SAMPLES))
146 # Build all samples, overiding the number of // jobs per sample
148 $(SILENT)$(MAKE) -rf $(CT_NG) V=$(V) $(shell echo "$(@)" |$(sed) -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')