From a02ed2be9886dac818b0473cffaca7999d6ac5de Mon Sep 17 00:00:00 2001 From: Mark Rustad Date: Sat, 2 Jun 2018 23:39:20 -0700 Subject: [PATCH] safestring: Allow clean along with other targets Allow clean to be used along with other targets by processing the clean first and then all other targets. Signed-off-by: Mark Rustad --- makefile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index d9addc8..7cd94c0 100644 --- a/makefile +++ b/makefile @@ -11,6 +11,11 @@ OTDIR=objtest SRCDIR=safeclib TESTDIR=unittests +CLEANGOAL := $(filter clean,${MAKECMDGOALS}) +OTHERGOALS := $(filter-out clean,${MAKECMDGOALS}) + +ifeq (${CLEANGOAL},) + .PHONY: all all: libsafestring.a safestringtest @@ -84,6 +89,11 @@ ${ODIR}: ${OTDIR}: ${MKDIR_P} ${OTDIR} +-include $(wildcard ${ODIR}/*.d) +-include $(wildcard ${OTDIR}/*.d) + +else + .PHONY: clean clean: @@ -91,6 +101,10 @@ clean: rm -rf ${ODIR} ${OTDIR} rm -f libsafestring.a rm -f safestringtest +ifneq (${OTHERGOALS},) + ${MAKE} ${OTHERGOALS} +endif --include $(wildcard ${ODIR}/*.d) --include $(wildcard ${OTDIR}/*.d) +%: ; + +endif # CLEANGOAL