From 0a6910cade1e3771adef3b702721bac826bca025 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 21 Sep 2023 13:41:47 +0100 Subject: [PATCH] Use pattern rules in the makefile Less duplication ftw, specially with multilib-devel on the horizon. Unfortunately we'd need to tag the file pattern rules as precious, otherwise make thinks they are intermediate files and nukes them. Signed-off-by: Emil Velikov --- Makefile | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 049d931..31a0b81 100644 --- a/Makefile +++ b/Makefile @@ -6,24 +6,16 @@ OUTPUTDIR=$(shell pwd)/output clean: rm -rf $(BUILDDIR) $(OUTPUTDIR) -$(OUTPUTDIR)/base.tar.zst: - scripts/make-rootfs.sh base $(BUILDDIR) $(OUTPUTDIR) +.PRECIOUS: $(OUTPUTDIR)/%.tar.zst +$(OUTPUTDIR)/%.tar.zst: + scripts/make-rootfs.sh $(*) $(BUILDDIR) $(OUTPUTDIR) -$(OUTPUTDIR)/base-devel.tar.zst: - scripts/make-rootfs.sh base-devel $(BUILDDIR) $(OUTPUTDIR) - -$(OUTPUTDIR)/Dockerfile.base: $(OUTPUTDIR)/base.tar.zst - scripts/make-dockerfile.sh base $(OUTPUTDIR) - -$(OUTPUTDIR)/Dockerfile.base-devel: $(OUTPUTDIR)/base-devel.tar.zst - scripts/make-dockerfile.sh base-devel $(OUTPUTDIR) +.PRECIOUS: $(OUTPUTDIR)/Dockerfile.% +$(OUTPUTDIR)/Dockerfile.%: $(OUTPUTDIR)/%.tar.zst + scripts/make-dockerfile.sh $(*) $(OUTPUTDIR) "true" "Dev" # The following is for local builds only, it is not used by the CI/CD pipeline -.PHONY: image-base -image-base: $(OUTPUTDIR)/Dockerfile.base - ${OCITOOL} build -f $(OUTPUTDIR)/Dockerfile.base -t archlinux/archlinux:base $(OUTPUTDIR) - -.PHONY: image-base-devel -image-base-devel: $(OUTPUTDIR)/Dockerfile.base-devel - ${OCITOOL} build -f $(OUTPUTDIR)/Dockerfile.base-devel -t archlinux/archlinux:base-devel $(OUTPUTDIR) +all: image-base image-base-devel +image-%: $(OUTPUTDIR)/Dockerfile.% + ${OCITOOL} build -f $(OUTPUTDIR)/Dockerfile.$(*) -t archlinux/archlinux:$(*) $(OUTPUTDIR)