[CRIU] [PATCH 4/7] scripts/build/Makefile: fix
Kir Kolyshkin
kir at openvz.org
Wed Mar 15 16:17:21 PDT 2017
Unify alpine and non-alpine builds. The only difference is foreign
arch builds need some preparation -- separate that to a dependency.
Unfortunately we can't use wildcard targets ("%: ") as non-wildcard
ones are prevaling. Therefore, a somewhat ugly hack to generate
$arch: Dockerfile.$arch dependency is added.
While at it:
- rename DB_ARGS to DB_CC
- mark clean as phony
- make "all" really run all the builds we can
Nice side effect: autocompletion ("make -C scripts/build <TAB>")
now works!
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
scripts/build/Makefile | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/scripts/build/Makefile b/scripts/build/Makefile
index dc00bfb..fc8317b 100644
--- a/scripts/build/Makefile
+++ b/scripts/build/Makefile
@@ -1,5 +1,16 @@
-ARCHES ?= armv7hf aarch64 ppc64le # x86_64
-all: $(ARCHES)
+QEMU_ARCHES := armv7hf aarch64 ppc64le # require qemu
+ARCHES := $(QEMU_ARCHES) x86_64
+TARGETS := $(ARCHES) alpine
+TARGETS_CLANG := $(addsuffix $(TARGETS),-clang)
+
+all: $(TARGETS) $(TARGETS_CLANG)
+.PHONY: all
+
+# A build for each architecture requires appropriate Dockerfile
+define ARCH_DEP
+$(1): Dockerfile.$(1)
+endef
+$(foreach arch,$(ARCHES),$(eval $(call ARCH_DEP,$(arch))))
Dockerfile.%: Dockerfile.%.hdr Dockerfile.tmpl
cat $^ > $@
@@ -11,21 +22,22 @@ binfmt_misc:
./binfmt_misc
.PHONY: binfmt_misc
-alpine:
- docker build -t criu-$@ -f Dockerfile.alpine $(DB_ARGS) ../..
+$(QEMU_ARCHES): qemu-user-static binfmt_misc
+
+$(TARGETS):
+ docker build -t criu-$@ -f Dockerfile.$@ $(DB_CC) ../..
+.PHONY: $(TARGETS)
-%: Dockerfile.% qemu-user-static binfmt_misc
- docker build -t criu-$@ -f $< $(DB_ARGS) ../..
+# Clang builds add some Docker build env
+define CLANG_DEP
+$(1)-clang: $(1)
+endef
+$(foreach t,$(TARGETS),$(eval $(call CLANG_DEP,$(t))))
-%-clang: DB_ARGS=--build-arg CC=clang-3.8
-alpine-clang: DB_ARGS=--build-arg CC=clang
-alpine-clang: alpine
-armv7hf-clang: armv7hf
-aarch64-clang: DB_ARGS=--build-arg CC=clang-3.6
-aarch64-clang: aarch64
-ppc64le-clang: ppc64le
-x86_64-clang: x86_64
-.PHONY: alpine-clang armv7hf-clang aarch64-clang ppc64le-clang x86_64-clang
+%-clang: DB_CC=--build-arg CC=clang-3.8
+alpine-clang: DB_CC=--build-arg CC=clang
+aarch64-clang: DB_CC=--build-arg CC=clang-3.6
+.PHONY: $(TARGETS_CLANG)
clean:
rm -rf qemu-user-static
@@ -34,3 +46,4 @@ clean:
test -f $$FILE && echo -1 > $$FILE; \
rm -f Dockerfile.$$ARCH; \
done
+.PHONY: clean
--
2.9.3
More information about the CRIU
mailing list