Makefile 1.52 KB
Newer Older
1
# umbrella mkimage-profiles makefile:
2 3
# iterate over multiple goals/arches,
# collect proceedings
4

5 6 7
# preferences
-include $(HOME)/.mkimage/profiles.mk

8
# for immediate assignment
9 10 11 12
ifndef ARCHES
ifdef ARCH
ARCHES := $(ARCH)
else
13
ARCHES := $(shell arch | sed 's/i686/i586/; s/armv.*/arm/; s/ppc.*/ppc/')
14
endif
15
endif
16 17
export ARCHES

18 19
export PATH := $(CURDIR)/bin:$(PATH)

20 21 22
# supervise target tracing; leave stderr alone
ifdef REPORT
export REPORT_PATH := $(shell mktemp --tmpdir mkimage-profiles.report.XXXXXXX)
23
POSTPROC := | report-filter > $(REPORT_PATH)
24 25
endif

26
# recursive make considered useful for m-p
27
MAKE += -r --no-print-directory
28

29
DIRECT_TARGETS := help help/distro help/ve help/vm clean distclean check
Michael Shigorin's avatar
Michael Shigorin committed
30 31
.PHONY: $(DIRECT_TARGETS)
$(DIRECT_TARGETS):
32 33 34 35
	@$(MAKE) -f main.mk $@

export NUM_TARGETS := $(words $(MAKECMDGOALS))

36 37 38
# for pipefail
SHELL = /bin/bash

39 40 41
# don't even consider remaking a configuration file
.PHONY: $(HOME)/.mkimage/profiles.mk

42
# real targets need real work
43 44
%:
	@n=1; \
45
	set -o pipefail; \
46
	say() { echo "$$@" >&2; }; \
47 48 49 50 51
	if [ "$(NUM_TARGETS)" -gt 1 ]; then \
		n="`echo $(MAKECMDGOALS) \
		| tr '[[:space:]]' '\n' \
		| grep -nx "$@" \
		| cut -d: -f1`"; \
52
		say "** goal: $@ [$$n/$(NUM_TARGETS)]"; \
53 54
	fi; \
	for ARCH in $(ARCHES); do \
55
		if [ "$$ARCH" != "$(firstword $(ARCHES))" ]; then say; fi; \
56
		say "** ARCH: $$ARCH"; \
57 58 59 60 61
		if $(MAKE) -f main.mk ARCH=$$ARCH $@ $(POSTPROC); then \
			if [ -n "$$REPORT" ]; then \
				$(MAKE) -f reports.mk ARCH=$$ARCH; \
			fi; \
		fi; \
62
	done; \
63
	if [ "$$n" -lt "$(NUM_TARGETS)" ]; then say; fi