Makefile 1.78 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 \
11
	| sed 's/i686/i586/; s/armv7.*/armh/; s/armv.*/arm/')
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
# recursive make considered useful for m-p
23
MAKE += -r --no-print-directory
24

25
export DIRECT_TARGETS := help help/distro help/ve help/vm clean distclean check
Michael Shigorin's avatar
Michael Shigorin committed
26
.PHONY: $(DIRECT_TARGETS)
27 28

# these build nothing so no use of reports either
Michael Shigorin's avatar
Michael Shigorin committed
29
$(DIRECT_TARGETS):
30
	@$(MAKE) -f main.mk REPORT= $@
31 32 33

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

34 35 36
# for pipefail
SHELL = /bin/bash

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

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

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

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