You need to sign in or sign up before continuing.
Makefile 2.17 KB
Newer Older
1
# umbrella mkimage-profiles makefile:
2 3
# iterate over multiple goals/arches,
# collect proceedings
4

5 6 7 8 9 10 11 12
ifeq (,$(CHECK))
ifeq (,$(DEBUG))
ifneq (,$(REPORT))
$(warning REPORT is disabled, DEBUG must be enabled for this)
endif
endif
endif

13
ifndef BRANCH
14
BRANCH := $(shell rpm --eval %_priority_distbranch | cut -d _ -f 1)
15 16 17 18 19 20 21 22
export BRANCH
endif

ifeq (,$(BRANCH))
override BRANCH=sisyphus
MAKEOVERRIDES += BRANCH=sisyphus
endif

23 24 25
# preferences
-include $(HOME)/.mkimage/profiles.mk

26
# for immediate assignment
27
ifeq (,$(ARCH))
28
ARCH := $(shell arch \
29
	| sed 's/i686/i586/; s/armv7.*/armh/; s/armv.*/arm/')
30
endif
31

32
ifeq (,$(ARCHES))
33
ARCHES := $(ARCH)
34
endif
35 36

export ARCHES ARCH
37

38 39
export PATH := $(CURDIR)/bin:$(PATH)

40
# recursive make considered useful for m-p
41
MAKE += -r --no-print-directory
42

43
export DIRECT_TARGETS := help help/distro help/ve help/vm clean distclean check
Michael Shigorin's avatar
Michael Shigorin committed
44
.PHONY: $(DIRECT_TARGETS)
45 46

# these build nothing so no use of reports either
Michael Shigorin's avatar
Michael Shigorin committed
47
$(DIRECT_TARGETS):
48
	@$(MAKE) -f main.mk REPORT= $@
49 50 51

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

52 53 54
# for pipefail
SHELL = /bin/bash

55 56 57
# don't even consider remaking a configuration file
.PHONY: $(HOME)/.mkimage/profiles.mk

58
# real targets need real work
59 60
%:
	@n=1; \
61
	set -o pipefail; \
62
	say() { echo "$$@" >&2; }; \
63 64 65 66 67
	if [ "$(NUM_TARGETS)" -gt 1 ]; then \
		n="`echo $(MAKECMDGOALS) \
		| tr '[[:space:]]' '\n' \
		| grep -nx "$@" \
		| cut -d: -f1`"; \
68
		say "** goal: $@ [$$n/$(NUM_TARGETS)]"; \
69 70
	else \
		say "** goal: $@"; \
71
	fi; \
72
	say "** BRANCH: $(BRANCH)"; \
73
	for ARCH in $(ARCHES); do \
74 75 76 77 78 79
		if [ -z "$(QUIET)" ]; then \
			if [ "$$ARCH" != "$(firstword $(ARCHES))" ]; then \
				say; \
			fi; \
			say "** ARCH: $$ARCH"; \
		fi; \
80
		if [ -n "$(REPORT)" ] && [ -n "$(DEBUG)" ] && [ -z "$(CHECK)" ]; then \
81 82 83
			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; \
84
		else \
85
			$(MAKE) -f main.mk ARCH=$$ARCH $@ || exit 1; \
86
		fi; \
87
		if [ -n "$(AUTOCLEAN)" ]; then $(MAKE) distclean; fi; \
88
	done; \
89
	if [ "$$n" -lt "$(NUM_TARGETS)" ]; then say; fi
90 91 92

docs:
	@$(MAKE) -C doc
93 94 95

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