[CRIU] [PATCH 2/6] Makefiles: don't use the FORCE, Luke!
Kir Kolyshkin
kir at openvz.org
Wed Feb 24 10:08:24 PST 2016
On 02/24/2016 12:10 AM, Dmitry Safonov wrote:
> On 02/23/2016 05:44 AM, Kir Kolyshkin wrote:
>> 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
>>
>> Signed-off-by: Kir Kolyshkin <kir at openvz.org>
>> ---
>> scripts/build/Makefile | 5 ++---
>> scripts/nmk/scripts/include.mk | 4 ----
>> test/Makefile | 23 ++++++++++++-----------
>> 3 files changed, 14 insertions(+), 18 deletions(-)
>>
>> diff --git a/scripts/build/Makefile b/scripts/build/Makefile
>> index 4b90a91..71b7ada 100644
>> --- a/scripts/build/Makefile
>> +++ b/scripts/build/Makefile
>> @@ -4,8 +4,6 @@ AARCH64_IMG ?= aarch64/ubuntu:trusty
>> ARMV7HF_IMG ?= armv7/armhf-ubuntu
>> PPC64LE_IMG ?= ppc64le/ubuntu
>> -.FORCE:
>> -
>> Dockerfile.aarch64: Dockerfile.aarch64.hdr Dockerfile.tmpl
>> cat Dockerfile.aarch64.hdr > Dockerfile.aarch64
>> cat Dockerfile.tmpl >> Dockerfile.aarch64
>> @@ -25,8 +23,9 @@ Dockerfile.x86_64: Dockerfile.x86_64.hdr
>> Dockerfile.tmpl
>> qemu-user-static:
>> ./extract-deb-pkg qemu-user-static
>> -binfmt_misc: .FORCE
>> +binfmt_misc:
>> ./binfmt_misc
>> +.PHONY: binfmt_misc
> A small nit:
> maybe we could use the same approach as in root/Makefile:
> PHONY += binfmt_misc
> # ...
> .PHONY: $(PHONY)
> Just for similarity, as we touch here anyway, eh?
I don't like this style, two reasons are:
1. It doesn't add any clarity
2. When we use $(PHONY) for something else then defining phony targets,
such as
> all: $(PHONY)
in criu/Makefile and lib/Makefile, this becomes a mess as
say we can't use PHONY += clean in this case.
So, I'd rather stick to the usual ".PHONY: targetname".
>> armv7hf: qemu-user-static binfmt_misc Dockerfile.armv7hf
>> docker build -t criu-armv7hf -f Dockerfile.armv7hf ../..
>> diff --git a/scripts/nmk/scripts/include.mk
>> b/scripts/nmk/scripts/include.mk
>> index c7dd7cc..6842a56 100644
>> --- a/scripts/nmk/scripts/include.mk
>> +++ b/scripts/nmk/scripts/include.mk
>> @@ -51,10 +51,6 @@ build-as := -r -R -f $(__nmk_dir)main.mk
>> makefile=$$(1) obj=$$(2)
>> export build-as
>> #
>> -# Dummy target for force building.
>> -FORCE: ;
>> -
>> -#
>> # Footer.
>> $(__nmk_dir)scripts/include.mk:
>> @true
>> diff --git a/test/Makefile b/test/Makefile
>> index 499ecf3..d28febb 100644
>> --- a/test/Makefile
>> +++ b/test/Makefile
>> @@ -3,43 +3,44 @@ 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: .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-pre-dump
>> 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
>> @@ -47,6 +48,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
>> @@ -56,5 +58,4 @@ clean: clean_root
>> $(Q) $(MAKE) -C libcriu clean
>> $(Q) $(MAKE) -C rpc clean
>> $(Q) $(MAKE) -C crit clean
>> -
>> -.PHONY: zdtm_ns
>> +.PHONY: clean
>
>
More information about the CRIU
mailing list