8a04d9b656
Raw disk images are convenient and universal but there are custom formats like Qemu's qcow2 providing additional features, e.g. copy-on-write or space savings. All of this ultimately belongs to mkimage but in the mean time has been implemented here as well.
61 lines
1.4 KiB
Makefile
61 lines
1.4 KiB
Makefile
# umbrella mkimage-profiles makefile:
|
|
# iterate over multiple goals/arches,
|
|
# collect proceedings
|
|
|
|
# preferences
|
|
-include $(HOME)/.mkimage/profiles.mk
|
|
|
|
# for immediate assignment
|
|
ifndef ARCHES
|
|
ifdef ARCH
|
|
ARCHES := $(ARCH)
|
|
else
|
|
ARCHES := $(shell arch | sed 's/i686/i586/')
|
|
endif
|
|
endif
|
|
export ARCHES
|
|
|
|
export PATH := $(CURDIR)/bin:$(PATH)
|
|
|
|
# supervise target tracing; leave stderr alone
|
|
ifdef REPORT
|
|
export REPORT_PATH := $(shell mktemp --tmpdir mkimage-profiles.report.XXXXXXX)
|
|
POSTPROC := | report-filter > $(REPORT_PATH)
|
|
endif
|
|
|
|
# recursive make considered useful for m-p
|
|
MAKE += -r --no-print-directory
|
|
|
|
DIRECT_TARGETS := clean distclean check help help/distro help/ve help/vm
|
|
.PHONY: $(DIRECT_TARGETS)
|
|
$(DIRECT_TARGETS):
|
|
@$(MAKE) -f main.mk $@
|
|
|
|
export NUM_TARGETS := $(words $(MAKECMDGOALS))
|
|
|
|
# for pipefail
|
|
SHELL = /bin/bash
|
|
|
|
# real targets need real work
|
|
%:
|
|
@n=1; \
|
|
set -o pipefail; \
|
|
say() { echo "$$@" >&2; }; \
|
|
if [ "$(NUM_TARGETS)" -gt 1 ]; then \
|
|
n="`echo $(MAKECMDGOALS) \
|
|
| tr '[[:space:]]' '\n' \
|
|
| grep -nx "$@" \
|
|
| cut -d: -f1`"; \
|
|
say "** goal: $@ [$$n/$(NUM_TARGETS)]"; \
|
|
fi; \
|
|
for ARCH in $(ARCHES); do \
|
|
if [ "$$ARCH" != "$(firstword $(ARCHES))" ]; then say; fi; \
|
|
say "** ARCH: $$ARCH" >&2; \
|
|
if $(MAKE) -f main.mk ARCH=$$ARCH $@ $(POSTPROC); then \
|
|
if [ -n "$$REPORT" ]; then \
|
|
$(MAKE) -f reports.mk ARCH=$$ARCH; \
|
|
fi; \
|
|
fi; \
|
|
done; \
|
|
if [ "$$n" -lt "$(NUM_TARGETS)" ]; then say; fi
|