[CRIU] [PATCH 1/2] Makefiles: don't use the FORCE, Luke!

Kir Kolyshkin kir at openvz.org
Wed Feb 24 12:29:57 PST 2016


With GNU make, using .PHONY leads to the same result as using
the "FORCE" hack, but unlike FORCE is not a hack. Since we do not
plan to use any other make than GNU make, let's just mark phony
targets as such.

For more details about why PHONY is better than FORCE, see
http://www.gnu.org/software/make/manual/make.html#index-FORCE

[v2: rebased and splitted]

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 scripts/build/Makefile |  5 ++---
 test/Makefile          | 23 ++++++++++++-----------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/scripts/build/Makefile b/scripts/build/Makefile
index ce3f463..ec4146b 100644
--- a/scripts/build/Makefile
+++ b/scripts/build/Makefile
@@ -1,16 +1,15 @@
 ARCHES ?= armv7hf aarch64 ppc64le # x86_64
 all: $(ARCHES)
 
-.FORCE:
-
 Dockerfile.%: Dockerfile.%.hdr Dockerfile.tmpl
 	cat $^ > $@
 
 qemu-user-static:
 	./extract-deb-pkg qemu-user-static
 
-binfmt_misc: .FORCE
+binfmt_misc:
 	./binfmt_misc
+.PHONY: binfmt_misc
 
 %: Dockerfile.% qemu-user-static binfmt_misc
 	docker build  -t criu-$@ -f $< ../..
diff --git a/test/Makefile b/test/Makefile
index 744ab7a..4102658 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -3,45 +3,46 @@ RM := rm -f --one-file-system
 ZDTM_ARGS ?= -C
 export ZDTM_ARGS
 
-.FORCE:
-
 all:
 	$(MAKE) zdtm
 	$(MAKE) zdtm-pre-dump
 	$(MAKE) zdtm-snapshot
 	$(MAKE) zdtm-iter
 	$(MAKE) zdtm-freezer
-
 .PHONY: all
 
 TESTS = unix-callback mem-snap rpc libcriu mounts/ext security pipes crit socketpairs overlayfs
 
-other: .FORCE
+other:
 	for t in $(TESTS); do				\
 		setsid $(MAKE) -C $$t run || exit 1;	\
-	done						\
+	done
+.PHONY: other
 
 zdtm_ct: zdtm_ct.c
 
-zdtm: .FORCE
+zdtm:
 	./zdtm.py run -a --parallel 2
+.PHONY: zdtm
 
 zdtm-pre-dump:
 	./zdtm.py run --pre 2:1 -t zdtm/transition/fork -f uns
+.PHONY: zdtm
 
 zdtm-snapshot:
 	./zdtm.py run --pre 2:1 --snap -t zdtm/transition/fork -f uns
+.PHONY: zdtm-snapshot
 
 zdtm-iter:
 	./zdtm.py run --iters 3:1 -t zdtm/transition/fork -f uns
+.PHONY: zdtm-iter
 
 zdtm-freezer:
 	./zdtm.py run --test zdtm/transition/thread-bomb --pre 3 --freezecg zdtm:t
 	./zdtm.py run --test zdtm/transition/thread-bomb --pre 3 --freezecg zdtm:f
+.PHONY: zdtm-freezer
 
-.PHONY: zdtm
-
-fault-injection: .FORCE
+fault-injection:
 	$(MAKE) -C fault-injection
 .PHONY: fault-injection
 
@@ -49,6 +50,7 @@ override CFLAGS += -D_GNU_SOURCE
 
 clean_root:
 	$(Q) ./zdtm.py clean nsroot
+.PHONY: clean_root
 
 clean: clean_root
 	$(RM) zdtm_ct zdtm-tst-list
@@ -58,5 +60,4 @@ clean: clean_root
 	$(Q) $(MAKE) -C libcriu clean
 	$(Q) $(MAKE) -C rpc clean
 	$(Q) $(MAKE) -C crit clean
-
-.PHONY: zdtm_ns
+.PHONY: clean
-- 
2.5.0



More information about the CRIU mailing list