From be0266b073e6b629023528ab64294d390d821f2c Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Wed, 18 Sep 2019 09:15:45 -0400 Subject: [PATCH] Makefile: have cleanup and dependencies Signed-off-by: Vincent Batts --- Makefile | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 147e515..d355c66 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,30 @@ SRC := ./BuildSourceImage.sh CTR_IMAGE := localhost/containers/buildsourceimage CTR_ENGINE ?= podman +cleanfiles = all: validate -.PHONY: validate -validate: $(SRC) - shellcheck $(SRC) +validate: .validate -.PHONY: build-container -build-container: Dockerfile +cleanfiles += .validate +.validate: $(SRC) + shellcheck $(SRC) && touch $@ + +build-container: .build-container + +cleanfiles += .build-container +.build-container: .validate Dockerfile $(SRC) @echo @echo "Building BuildSourceImage Container" - $(CTR_ENGINE) build --quiet --file Dockerfile --tag $(CTR_IMAGE) . + $(CTR_ENGINE) build --quiet --file Dockerfile --tag $(CTR_IMAGE) . && touch $@ .PHONY: test-integration -test-integration: build-container +test-integration: .build-container @echo @echo "Running integration tests" CTR_IMAGE=$(CTR_IMAGE) CTR_ENGINE=$(CTR_ENGINE) bats test/ + + +clean: + if [ -n "$(cleanfiles)" ] ; then rm -rf $(cleanfiles) ; fi