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 <emil.l.velikov@gmail.com>
This commit is contained in:
Emil Velikov 2023-09-21 13:41:47 +01:00
parent 64cb18a0c3
commit 0a6910cade

View File

@ -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)