2007-06-17 11:13:48 +00:00
|
|
|
# Makefile to manage samples
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2008-10-27 18:42:26 +00:00
|
|
|
# ----------------------------------------------------------
|
2007-06-17 11:13:48 +00:00
|
|
|
# Build the list of available samples
|
2014-06-25 21:33:01 +00:00
|
|
|
CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(sort $(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config)))
|
|
|
|
CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(sort $(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config))))
|
2010-01-03 17:33:23 +00:00
|
|
|
CT_SAMPLES := $(shell echo $(sort $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES)) \
|
2011-10-16 19:48:10 +00:00
|
|
|
|$(sed) -r -e 's/ /\n/g;' \
|
|
|
|
|$(sed) -r -e 's/(.*),(.*)/\2,\1/;' \
|
|
|
|
|sort \
|
|
|
|
|$(sed) -r -e 's/(.*),(.*)/\2,\1/;' \
|
2010-01-03 17:33:23 +00:00
|
|
|
)
|
2007-05-07 09:04:02 +00:00
|
|
|
|
2008-10-27 18:42:26 +00:00
|
|
|
# ----------------------------------------------------------
|
|
|
|
# This part deals with the samples help entries
|
|
|
|
|
2007-06-17 16:24:23 +00:00
|
|
|
help-config::
|
2007-08-15 14:59:37 +00:00
|
|
|
@echo ' saveconfig - Save current config as a preconfigured target'
|
2007-06-17 16:24:23 +00:00
|
|
|
|
|
|
|
help-samples::
|
2008-06-01 21:12:00 +00:00
|
|
|
@echo ' list-samples - prints the list of all samples (for scripting)'
|
2010-04-01 22:18:26 +00:00
|
|
|
@echo ' show-<sample> - show a brief overview of <sample> (list with list-samples)'
|
|
|
|
@echo ' <sample> - preconfigure crosstool-NG with <sample> (list with list-samples)'
|
|
|
|
@echo ' build-all[.#] - Build *all* samples (list with list-samples) and install in'
|
2008-10-31 18:31:01 +00:00
|
|
|
@echo ' $${CT_PREFIX} (which you must set)'
|
2007-06-17 16:24:23 +00:00
|
|
|
|
2008-06-15 19:25:51 +00:00
|
|
|
help-distrib::
|
|
|
|
@echo ' wiki-samples - Print a DokuWiki table of samples'
|
|
|
|
|
2008-10-31 18:31:01 +00:00
|
|
|
help-env::
|
2010-04-01 22:18:26 +00:00
|
|
|
@echo ' CT_PREFIX=dir - install samples in dir (see action "build-all", above).'
|
2008-10-31 18:31:01 +00:00
|
|
|
|
2008-10-27 18:42:26 +00:00
|
|
|
# ----------------------------------------------------------
|
|
|
|
# This part deals with printing samples information
|
|
|
|
|
2010-01-31 14:57:22 +00:00
|
|
|
# Print the details of current configuration
|
|
|
|
PHONY += show-config
|
|
|
|
show-config: .config
|
2012-05-07 19:37:59 +00:00
|
|
|
@cp .config .config.sample
|
|
|
|
@$(CT_LIB_DIR)/scripts/showSamples.sh -v current
|
|
|
|
@rm -f .config.sample
|
2010-01-31 14:57:22 +00:00
|
|
|
|
2008-10-27 18:42:26 +00:00
|
|
|
# Prints the details of a sample
|
|
|
|
PHONY += $(patsubst %,show-%,$(CT_SAMPLES))
|
2012-05-07 19:37:59 +00:00
|
|
|
$(patsubst %,show-%,$(CT_SAMPLES)): config_files
|
|
|
|
@KCONFIG_CONFIG=$$(pwd)/.config.sample \
|
2012-07-23 20:02:23 +00:00
|
|
|
$(CONF) --defconfig=$(call sample_dir,$(patsubst show-%,%,$(@)))/crosstool.config \
|
2012-05-07 19:37:59 +00:00
|
|
|
$(KCONFIG_TOP) >/dev/null
|
2008-05-26 21:49:36 +00:00
|
|
|
@$(CT_LIB_DIR)/scripts/showSamples.sh -v $(patsubst show-%,%,$(@))
|
2012-05-07 19:37:59 +00:00
|
|
|
@rm -f .config.sample
|
2008-05-26 21:49:36 +00:00
|
|
|
|
2010-01-03 17:36:07 +00:00
|
|
|
# Prints the details of all samples
|
|
|
|
PHONY += show-all
|
|
|
|
show-all: $(patsubst %,show-%,$(CT_SAMPLES))
|
|
|
|
|
2008-10-27 18:42:26 +00:00
|
|
|
# print the list of all available samples
|
2008-06-01 21:12:00 +00:00
|
|
|
PHONY += list-samples
|
2012-07-23 20:02:23 +00:00
|
|
|
list-samples: list-samples-pre $(patsubst %,list-%,$(CT_SAMPLES))
|
|
|
|
@echo ' L (Local) : sample was found in current directory'
|
|
|
|
@echo ' G (Global) : sample was installed with crosstool-NG'
|
|
|
|
@echo ' X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
|
|
|
|
@echo ' B (BROKEN) : sample is currently broken'
|
|
|
|
|
|
|
|
PHONY += list-samples-pre
|
|
|
|
list-samples-pre: FORCE
|
|
|
|
@echo 'Status Sample name'
|
|
|
|
|
|
|
|
PHONY += $(patsubst %,list-%,$(CT_SAMPLES))
|
|
|
|
$(patsubst %,list-%,$(CT_SAMPLES)): config_files
|
|
|
|
@KCONFIG_CONFIG=$$(pwd)/.config.sample \
|
|
|
|
$(CONF) --defconfig=$(call sample_dir,$(patsubst list-%,%,$(@)))/crosstool.config \
|
|
|
|
$(KCONFIG_TOP) >/dev/null
|
|
|
|
@$(CT_LIB_DIR)/scripts/showSamples.sh $(patsubst list-%,%,$(@))
|
|
|
|
@rm -f .config.sample
|
2008-05-02 21:49:43 +00:00
|
|
|
|
2010-07-30 21:30:02 +00:00
|
|
|
PHONY += list-samples-short
|
|
|
|
list-samples-short: FORCE
|
|
|
|
$(SILENT)for s in $(CT_SAMPLES); do \
|
2012-07-23 20:02:23 +00:00
|
|
|
printf "%s\n" "$${s}"; \
|
2010-07-30 21:30:02 +00:00
|
|
|
done
|
|
|
|
|
2013-01-21 23:32:38 +00:00
|
|
|
# Check one sample
|
|
|
|
PHONY += $(patsubst %,check-%,$(CT_SAMPLES))
|
|
|
|
$(patsubst %,check-%,$(CT_SAMPLES)): config_files
|
|
|
|
@export KCONFIG_CONFIG=$$(pwd)/.config.sample; \
|
|
|
|
CT_NG_SAMPLE=$(call sample_dir,$(patsubst check-%,%,$(@)))/crosstool.config; \
|
|
|
|
$(CONF) --defconfig=$${CT_NG_SAMPLE} $(KCONFIG_TOP) >/dev/null; \
|
|
|
|
$(CONF) --savedefconfig=$$(pwd)/.defconfig $(KCONFIG_TOP) >/dev/null; \
|
|
|
|
old_sha1=$$( sha1sum "$${CT_NG_SAMPLE}" |cut -d ' ' -f 1 ); \
|
|
|
|
new_sha1=$$( sha1sum .defconfig |cut -d ' ' -f 1 ); \
|
|
|
|
if [ $${old_sha1} != $${new_sha1} ]; then \
|
2013-01-24 21:24:38 +00:00
|
|
|
echo "$(patsubst check-%,%,$(@)) needs update:"; \
|
|
|
|
diff -du0 "$${CT_NG_SAMPLE}" .defconfig |tail -n +4; \
|
2013-01-21 23:32:38 +00:00
|
|
|
fi
|
|
|
|
@rm -f .config.sample* .defconfig
|
|
|
|
|
|
|
|
check-samples: $(patsubst %,check-%,$(CT_SAMPLES))
|
|
|
|
|
2010-07-30 21:30:02 +00:00
|
|
|
PHONY += wiki-samples
|
2012-07-23 20:02:23 +00:00
|
|
|
wiki-samples: wiki-samples-pre $(patsubst %,wiki-%,$(CT_SAMPLES)) wiki-samples-post
|
|
|
|
|
|
|
|
wiki-samples-pre: FORCE
|
|
|
|
$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w
|
|
|
|
|
|
|
|
wiki-samples-post: FORCE
|
|
|
|
$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -W $(CT_SAMPLES)
|
|
|
|
|
|
|
|
$(patsubst %,wiki-%,$(CT_SAMPLES)): config_files
|
|
|
|
$(SILENT)KCONFIG_CONFIG=$$(pwd)/.config.sample \
|
|
|
|
$(CONF) --defconfig=$(call sample_dir,$(patsubst wiki-%,%,$(@)))/crosstool.config \
|
|
|
|
$(KCONFIG_TOP) >/dev/null
|
|
|
|
$(SILENT)$(CT_LIB_DIR)/scripts/showSamples.sh -w $(patsubst wiki-%,%,$(@))
|
|
|
|
$(SILENT)rm -f .config.sample
|
2008-10-27 18:42:26 +00:00
|
|
|
|
|
|
|
# ----------------------------------------------------------
|
|
|
|
# This part deals with saving/restoring samples
|
|
|
|
|
2009-10-30 19:08:44 +00:00
|
|
|
PHONY += samples
|
|
|
|
samples:
|
2015-10-30 02:34:24 +00:00
|
|
|
@$(CT_ECHO) ' MKDIR $@'
|
2009-10-30 19:08:44 +00:00
|
|
|
$(SILENT)mkdir -p $@
|
|
|
|
|
2008-10-27 18:42:26 +00:00
|
|
|
# Save a sample
|
2009-10-30 19:08:44 +00:00
|
|
|
saveconfig: .config samples
|
2008-10-27 18:42:26 +00:00
|
|
|
$(SILENT)$(CT_LIB_DIR)/scripts/saveSample.sh
|
|
|
|
|
|
|
|
# The 'sample_dir' function prints the directory in which the sample is,
|
|
|
|
# searching first in local samples, then in global samples
|
|
|
|
define sample_dir
|
|
|
|
$$( [ -d $(CT_TOP_DIR)/samples/$(1) ] && echo "$(CT_TOP_DIR)/samples/$(1)" || echo "$(CT_LIB_DIR)/samples/$(1)")
|
|
|
|
endef
|
|
|
|
|
2008-10-14 19:40:12 +00:00
|
|
|
# How we do recall one sample
|
2007-07-01 19:04:20 +00:00
|
|
|
PHONY += $(CT_SAMPLES)
|
2012-05-06 22:27:05 +00:00
|
|
|
$(CT_SAMPLES): config_files
|
2015-10-30 02:34:24 +00:00
|
|
|
@$(CT_ECHO) " CONF $(KCONFIG_TOP)"
|
2012-05-06 22:27:05 +00:00
|
|
|
$(SILENT)$(CONF) --defconfig=$(call sample_dir,$@)/crosstool.config $(KCONFIG_TOP)
|
2008-10-14 21:30:27 +00:00
|
|
|
@echo
|
|
|
|
@echo '***********************************************************'
|
|
|
|
@echo
|
Cheesy kconfig stuff:
- silent/quiet/verbose build:
- ct-ng by default only prints quit messages, such as "CC xxx",
- if using V=0, nothing is printed,
- if using V=1, the full command lines are printed,
- other values are indeterminate,
- should help in debugging the kconfig stuff;
- complete kconfig/{,m}conf generation:
- fully dynamic dependencies on source files,
- compilation of .c into .o, then linking (instead of direct linking),
- VPATH usage when not --local;
Typo + a coment moved.
/trunk/kconfig/kconfig.mk | 140 87 53 0 +++++++++++++++++++++++++++++++++--------------------
/trunk/tools/tools.mk | 12 6 6 0 ++--
/trunk/steps.mk | 6 3 3 0 +-
/trunk/samples/samples.mk | 30 15 15 0 +++++-----
/trunk/ct-ng.in | 40 28 12 0 +++++++++++----
5 files changed, 139 insertions(+), 89 deletions(-)
2008-10-15 21:29:56 +00:00
|
|
|
$(SILENT)( . $(call sample_dir,$@)/reported.by; \
|
2011-10-18 18:17:41 +00:00
|
|
|
echo "Initially reported by: $${reporter_name}"; \
|
|
|
|
echo "URL: $${reporter_url}"; \
|
2008-10-14 21:30:27 +00:00
|
|
|
if [ -n "$${reporter_comment}" ]; then \
|
|
|
|
echo ; \
|
|
|
|
echo "Comment:"; \
|
|
|
|
printf "$${reporter_comment}\n"; \
|
|
|
|
fi; \
|
|
|
|
echo ; \
|
|
|
|
echo '***********************************************************'; \
|
|
|
|
)
|
2009-01-27 20:38:48 +00:00
|
|
|
$(SILENT)if $(grep) -E '^CT_EXPERIMENTAL=y$$' .config >/dev/null 2>&1; then \
|
Cheesy kconfig stuff:
- silent/quiet/verbose build:
- ct-ng by default only prints quit messages, such as "CC xxx",
- if using V=0, nothing is printed,
- if using V=1, the full command lines are printed,
- other values are indeterminate,
- should help in debugging the kconfig stuff;
- complete kconfig/{,m}conf generation:
- fully dynamic dependencies on source files,
- compilation of .c into .o, then linking (instead of direct linking),
- VPATH usage when not --local;
Typo + a coment moved.
/trunk/kconfig/kconfig.mk | 140 87 53 0 +++++++++++++++++++++++++++++++++--------------------
/trunk/tools/tools.mk | 12 6 6 0 ++--
/trunk/steps.mk | 6 3 3 0 +-
/trunk/samples/samples.mk | 30 15 15 0 +++++-----
/trunk/ct-ng.in | 40 28 12 0 +++++++++++----
5 files changed, 139 insertions(+), 89 deletions(-)
2008-10-15 21:29:56 +00:00
|
|
|
echo ; \
|
|
|
|
echo 'WARNING! This sample may enable experimental features.'; \
|
|
|
|
echo ' Please be sure to review the configuration prior'; \
|
|
|
|
echo ' to building and using your toolchain!'; \
|
|
|
|
echo 'Now, you have been warned!'; \
|
|
|
|
echo ; \
|
|
|
|
echo '***********************************************************'; \
|
2008-09-02 12:43:11 +00:00
|
|
|
fi
|
2008-10-14 21:30:27 +00:00
|
|
|
@echo
|
2008-10-14 19:40:12 +00:00
|
|
|
@echo 'Now configured for "$@"'
|
2007-07-01 19:04:20 +00:00
|
|
|
|
2008-10-27 18:42:26 +00:00
|
|
|
# ----------------------------------------------------------
|
2008-10-31 18:31:01 +00:00
|
|
|
# Some helper functions
|
|
|
|
|
2015-10-29 01:12:03 +00:00
|
|
|
# Construct a CT_PREFIX_DIR path from the sample name. Sample names use
|
|
|
|
# comma as a separator between host and target triplets in canadian cross
|
|
|
|
# configurations, but ct-ng does not allow commas in the path. Substitute
|
|
|
|
# with = (equal sign).
|
|
|
|
# $1: sample
|
|
|
|
__comma = ,
|
|
|
|
prefix_dir = $(CT_PREFIX)/$(subst $(__comma),=,$(1))
|
2015-10-29 07:21:43 +00:00
|
|
|
host_triplet = $(if $(findstring $(__comma),$(1)),$(firstword $(subst $(__comma), ,$(1))))
|
2015-10-29 01:12:03 +00:00
|
|
|
|
2008-10-31 18:31:01 +00:00
|
|
|
# Create the rule to build a sample
|
2015-10-29 01:12:03 +00:00
|
|
|
# $1: sample name (target tuple, or host/target tuples separated by a comma)
|
2008-10-31 18:31:01 +00:00
|
|
|
define build_sample
|
2015-10-30 02:34:24 +00:00
|
|
|
@$(CT_ECHO) ' CONF $(1)'
|
2015-10-29 00:35:23 +00:00
|
|
|
$(SILENT)$(CONF) -s --defconfig=$(call sample_dir,$(1))/crosstool.config $(KCONFIG_TOP)
|
2015-10-29 01:12:03 +00:00
|
|
|
$(SILENT)$(sed) -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$(call prefix_dir,$(1))":;' .config
|
2009-01-26 18:36:02 +00:00
|
|
|
$(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config
|
|
|
|
$(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config
|
|
|
|
$(SILENT)$(sed) -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config
|
|
|
|
$(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config
|
|
|
|
$(SILENT)$(sed) -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config
|
2015-10-29 00:35:23 +00:00
|
|
|
$(SILENT)$(CONF) -s --oldconfig $(KCONFIG_TOP)
|
2015-10-30 02:34:24 +00:00
|
|
|
@$(CT_ECHO) ' BUILD $(1)'
|
2015-10-29 07:21:43 +00:00
|
|
|
$(SILENT)if [ ! -z "$(call host_triplet,$(1))" -a -d "$(call prefix_dir,$(call host_triplet,$(1)))" ]; then \
|
|
|
|
PATH="$$PATH:$(call prefix_dir,$(call host_triplet,$(1)))/bin"; \
|
|
|
|
fi; \
|
2015-10-29 08:11:28 +00:00
|
|
|
if $(MAKE) -rf $(CT_NG) V=0 build; then \
|
|
|
|
status=PASS; \
|
|
|
|
elif [ -e $(call sample_dir,$(1))/broken ]; then \
|
|
|
|
status=XFAIL; \
|
|
|
|
else \
|
|
|
|
status=FAIL; \
|
|
|
|
fi; \
|
|
|
|
printf '\r %-5s %s\n' $$status '$(1)'; \
|
|
|
|
mkdir -p .build-all/$$status/$(1); \
|
|
|
|
bzip2 < build.log > .build-all/$$status/$(1)/build.log.bz2
|
2008-10-31 18:31:01 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
# ----------------------------------------------------------
|
|
|
|
# Build samples for use (not regtest!)
|
|
|
|
|
|
|
|
# Check that PREFIX is set if building samples
|
|
|
|
ifneq ($(strip $(MAKECMDGOALS)),)
|
|
|
|
ifneq ($(strip $(filter $(patsubst %,build-%,$(CT_SAMPLES)) build-all,$(MAKECMDGOALS))),)
|
|
|
|
|
|
|
|
ifeq ($(strip $(CT_PREFIX)),)
|
|
|
|
$(error Please set 'CT_PREFIX' to where you want to install generated toolchain samples!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif # MAKECMDGOALS contains a build sample rule
|
|
|
|
endif # MAKECMDGOALS != ""
|
|
|
|
|
|
|
|
# Build a single sample
|
2015-10-29 01:12:03 +00:00
|
|
|
$(patsubst %,build-%,$(CT_SAMPLES)): build-%: config_files
|
|
|
|
$(call build_sample,$*)
|
2008-10-31 18:31:01 +00:00
|
|
|
|
2015-10-29 07:21:43 +00:00
|
|
|
# Cross samples (build==host)
|
|
|
|
CT_SAMPLES_CROSS = $(strip $(foreach s,$(CT_SAMPLES),$(if $(findstring $(__comma),$(s)),, $(s))))
|
|
|
|
# Canadian cross (build!=host)
|
|
|
|
CT_SAMPLES_CANADIAN = $(strip $(foreach s,$(CT_SAMPLES),$(if $(findstring $(__comma),$(s)), $(s),)))
|
2008-10-31 18:31:01 +00:00
|
|
|
|
2015-10-29 07:21:43 +00:00
|
|
|
# Build all samples; first, build simple cross as canadian configurations may depend on
|
|
|
|
# build-to-host cross being pre-built.
|
2015-10-29 08:11:28 +00:00
|
|
|
build-all: build-all-pre $(patsubst %,build-%,$(CT_SAMPLES_CROSS) $(CT_SAMPLES_CANADIAN))
|
|
|
|
@echo
|
|
|
|
@if [ -d .build-all/PASS ]; then \
|
|
|
|
echo 'Success:'; \
|
|
|
|
(cd .build-all/PASS && ls | sed 's/^/ - /'); \
|
|
|
|
echo; \
|
|
|
|
fi
|
|
|
|
@if [ -d .build-all/XFAIL ]; then \
|
|
|
|
echo 'Expected failure:'; \
|
|
|
|
(cd .build-all/XFAIL && ls | sed 's/^/ - /'); \
|
|
|
|
echo; \
|
|
|
|
fi
|
|
|
|
@if [ -d .build-all/FAIL ]; then \
|
|
|
|
echo 'Failure:'; \
|
|
|
|
(cd .build-all/FAIL && ls | sed 's/^/ - /'); \
|
|
|
|
echo; \
|
|
|
|
fi
|
|
|
|
@[ ! -d .build-all/FAIL ]
|
|
|
|
|
|
|
|
build-all-pre:
|
|
|
|
@rm -rf .build-all
|
2008-10-31 18:31:01 +00:00
|
|
|
|
|
|
|
# Build all samples, overiding the number of // jobs per sample
|
|
|
|
build-all.%:
|
2015-10-30 17:32:16 +00:00
|
|
|
$(SILENT)$(MAKE) -rf $(CT_NG) build-all CT_JOBS=$*
|
2008-10-31 18:31:01 +00:00
|
|
|
|