[CRIU] [PATCH] Makefile: add .FORCE target

Dmitry Safonov dsafonov at virtuozzo.com
Wed May 25 10:12:15 PDT 2016


Sorry for introducing that, but we need to force-rebuild implicit
rules on the level of main Makefile. All the sub-makefiles should
decide if the force-rebuilding target really needs a rebuild,
because they know it's dependencies.

Pattern-specific rules are implicit, so something like:
.PHONY: compel/% criu/% #...
will not work.
.FORCE target seems the simplest way to solve this
"going to submake on rebuild" problem.
But maybe there is more elegant proposal?

FWIW, before this patch:
    [criu]$ make compel/compel
    make[1]: Entering directory '~/tools/criu'
      HOSTDEP  compel/handle-elf-32.d
    ...
      HOSTLINK compel/compel
    make[1]: Leaving directory '~/tools/criu'
    [criu]$ touch compel/main.c
    [criu]$ make compel/compel
    make: 'compel/compel' is up to date.
    [criu]$ touch compel/Makefile
    [criu]$ make compel/compel
    make: 'compel/compel' is up to date.
After the patch:
    [criu]$ touch compel/main.c
    [criu]$ make compel/compel
    make[1]: Entering directory '~/tools/criu'
      HOSTDEP  compel/main.d
      HOSTCC   compel/main.o
      HOSTLINK compel/compel
    make[1]: Leaving directory '~/tools/criu'
    [criu]$ touch compel/Makefile
    [criu]$ make compel/compel
    make[1]: Entering directory '~/tools/criu'
      HOSTDEP  compel/handle-elf-32.d
    ...
      HOSTLINK compel/compel
    make[1]: Leaving directory '~/tools/criu'

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 Makefile | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 27101700ecba..23ee8e0a7fa3 100644
--- a/Makefile
+++ b/Makefile
@@ -178,11 +178,13 @@ endif
 # on anything else.
 $(eval $(call gen-built-in,images))
 
+.PHONY: .FORCE
+
 # Compel get used by CRIU, build it earlier
-compel/%:
+compel/%: .FORCE
 	$(Q) $(MAKE) $(build)=compel $@
 
-test/compel/%:
+test/compel/%: .FORCE
 	$(Q) $(MAKE) $(build)=compel $@
 
 #
@@ -193,7 +195,7 @@ test/compel/%:
 #
 # But note that we're already included
 # the nmk so we can reuse it there.
-criu/%: images/built-in.o compel/compel $(VERSION_HEADER)
+criu/%: images/built-in.o compel/compel $(VERSION_HEADER) .FORCE
 	$(Q) $(MAKE) -C criu $@
 criu: images/built-in.o compel/compel $(VERSION_HEADER)
 	$(Q) $(MAKE) -C criu all
@@ -203,7 +205,7 @@ criu: images/built-in.o compel/compel $(VERSION_HEADER)
 # Libraries next once criu it ready
 # (we might generate headers and such
 # when building criu itself).
-lib/%: criu
+lib/%: criu .FORCE
 	$(Q) $(MAKE) -C lib $@
 lib: criu
 	$(Q) $(MAKE) -C lib all
-- 
2.8.2



More information about the CRIU mailing list