Commit c903ddfc authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

scripts/build/Makefile: fix

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: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 6866fd2e
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment