Makefile 1.71 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
ifndef ARCH
ARCH := $(shell arch \
Michael Shigorin's avatar
Michael Shigorin committed
11
	| sed 's/i686/i586/; s/armv7.*/armh/; s/armv.*/arm/; s/ppc.*/ppc/')
12
endif
13 14 15

ifndef ARCHES
ARCHES := $(ARCH)
16
endif
17 18

export ARCHES ARCH
19

20 21
export PATH := $(CURDIR)/bin:$(PATH)

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

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

31
DIRECT_TARGETS := help help/distro help/ve help/vm clean distclean check
Michael Shigorin's avatar
Michael Shigorin committed
32
.PHONY: $(DIRECT_TARGETS)
33 34

# these build nothing so no use of reports either
Michael Shigorin's avatar
Michael Shigorin committed
35
$(DIRECT_TARGETS):
36
	@$(MAKE) -f main.mk REPORT= $@
37 38 39

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

40 41 42
# for pipefail
SHELL = /bin/bash

43 44 45
# don't even consider remaking a configuration file
.PHONY: $(HOME)/.mkimage/profiles.mk

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

docs:
	@$(MAKE) -C doc
75 76 77

docs-publish:
	@$(MAKE) -C doc publish