Commit ab90777c authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Andrei Vagin

Makefiles: protect from % rules, don't rebuild

GNU make tries to rebuild any makefiles it uses. While in general it's
a good idea (and it is used e.g. in autoconf-based builds), in our case
it is not necessary, as all the makefiles are static.

More to say, as we have a few "match anything" rules for subdirectories,
Makefiles in these subdirs are also matching these rules, which leads to
excessive (re)building while a particular makefile is needed.

Protect such Makefiles with explicit (or pattern) rules, so make knows
it should do nothing to rebuild those.
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Reviewed-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 15a757f6
#
# Import the build engine first
__nmk_dir=$(CURDIR)/scripts/nmk/scripts/ __nmk_dir=$(CURDIR)/scripts/nmk/scripts/
export __nmk_dir export __nmk_dir
#
# No need to try to remake our Makefiles
Makefile: ;
Makefile.%: ;
scripts/%.mak: ;
$(__nmk_dir)%.mk: ;
#
# Import the build engine
include $(__nmk_dir)include.mk include $(__nmk_dir)include.mk
include $(__nmk_dir)macro.mk include $(__nmk_dir)macro.mk
...@@ -213,6 +220,7 @@ SOCCR_A := soccr/libsoccr.a ...@@ -213,6 +220,7 @@ SOCCR_A := soccr/libsoccr.a
SOCCR_CONFIG := soccr/config.h SOCCR_CONFIG := soccr/config.h
$(SOCCR_CONFIG): $(CONFIG_HEADER) $(SOCCR_CONFIG): $(CONFIG_HEADER)
$(Q) test -f $@ || ln -s ../$(CONFIG_HEADER) $@ $(Q) test -f $@ || ln -s ../$(CONFIG_HEADER) $@
soccr/Makefile: ;
soccr/%: $(SOCCR_CONFIG) .FORCE soccr/%: $(SOCCR_CONFIG) .FORCE
$(Q) $(MAKE) $(build)=soccr $@ $(Q) $(MAKE) $(build)=soccr $@
soccr/built-in.o: $(SOCCR_CONFIG) .FORCE soccr/built-in.o: $(SOCCR_CONFIG) .FORCE
...@@ -228,6 +236,9 @@ criu-deps += $(SOCCR_A) ...@@ -228,6 +236,9 @@ criu-deps += $(SOCCR_A)
# #
# But note that we're already included # But note that we're already included
# the nmk so we can reuse it there. # the nmk so we can reuse it there.
criu/Makefile: ;
criu/Makefile.packages: ;
criu/Makefile.crtools: ;
criu/%: $(criu-deps) .FORCE criu/%: $(criu-deps) .FORCE
$(Q) $(MAKE) $(build)=criu $@ $(Q) $(MAKE) $(build)=criu $@
criu: $(criu-deps) criu: $(criu-deps)
...@@ -238,6 +249,7 @@ criu: $(criu-deps) ...@@ -238,6 +249,7 @@ criu: $(criu-deps)
# Libraries next once criu it ready # Libraries next once criu it ready
# (we might generate headers and such # (we might generate headers and such
# when building criu itself). # when building criu itself).
lib/Makefile: ;
lib/%: criu .FORCE lib/%: criu .FORCE
$(Q) $(MAKE) $(build)=lib $@ $(Q) $(MAKE) $(build)=lib $@
lib: criu lib: criu
......
...@@ -31,6 +31,7 @@ criu-deps += compel/$(LIBCOMPEL_A) ...@@ -31,6 +31,7 @@ criu-deps += compel/$(LIBCOMPEL_A)
# #
# Compel itself. # Compel itself.
compel/Makefile: ;
compel/%: $(compel-deps) $(compel-plugins) .FORCE compel/%: $(compel-deps) $(compel-plugins) .FORCE
$(Q) $(MAKE) $(build)=compel $@ $(Q) $(MAKE) $(build)=compel $@
...@@ -38,6 +39,7 @@ criu-deps += compel/compel-host-bin ...@@ -38,6 +39,7 @@ criu-deps += compel/compel-host-bin
# #
# Plugins # Plugins
compel/plugins/Makefile: ;
compel/plugins/%: $(compel-deps) .FORCE compel/plugins/%: $(compel-deps) .FORCE
$(Q) $(MAKE) $(build)=compel/plugins $@ $(Q) $(MAKE) $(build)=compel/plugins $@
......
...@@ -57,6 +57,8 @@ pie: criu/pie/pie.lib.a ...@@ -57,6 +57,8 @@ pie: criu/pie/pie.lib.a
$(Q) $(MAKE) $(build)=criu/pie all $(Q) $(MAKE) $(build)=criu/pie all
.PHONY: pie .PHONY: pie
criu/pie/Makefile: ;
criu/pie/Makefile.library: ;
criu/pie/%: pie ; criu/pie/%: pie ;
# #
...@@ -71,8 +73,10 @@ PROGRAM-BUILTINS += $(COMPEL_LIBS) ...@@ -71,8 +73,10 @@ PROGRAM-BUILTINS += $(COMPEL_LIBS)
$(obj)/built-in.o: pie $(obj)/built-in.o: pie
$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) all $(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) all
$(obj)/Makefile:
@true $(obj)/Makefile: ;
$(obj)/Makefile.crtools: ;
$(obj)/Makefile.packages: ;
$(obj)/%: pie $(obj)/%: pie
$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) $@ $(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) $@
......
...@@ -12,8 +12,8 @@ all-y += lib-c lib-py ...@@ -12,8 +12,8 @@ all-y += lib-c lib-py
# #
# C language bindings. # C language bindings.
lib/c/Makefile: ;
lib/c/%: .FORCE lib/c/%: .FORCE
$(call msg-gen, $@)
$(Q) $(MAKE) $(build)=lib/c $@ $(Q) $(MAKE) $(build)=lib/c $@
cflags-so += $(CFLAGS) -rdynamic -Wl,-soname,$(CRIU_SO).$(CRIU_SO_VERSION_MAJOR) cflags-so += $(CFLAGS) -rdynamic -Wl,-soname,$(CRIU_SO).$(CRIU_SO_VERSION_MAJOR)
...@@ -27,6 +27,7 @@ lib-c: lib/c/$(CRIU_SO) ...@@ -27,6 +27,7 @@ lib-c: lib/c/$(CRIU_SO)
# #
# Python bindings. # Python bindings.
lib/py/Makefile: ;
lib/py/%: .FORCE lib/py/%: .FORCE
$(call msg-gen, $@) $(call msg-gen, $@)
$(Q) $(MAKE) $(build)=lib/py $@ $(Q) $(MAKE) $(build)=lib/py $@
......
...@@ -2,6 +2,7 @@ all-y += libpy-images rpc_pb2.py ...@@ -2,6 +2,7 @@ all-y += libpy-images rpc_pb2.py
.PHONY: .FORCE .PHONY: .FORCE
$(obj)/images/Makefile: ;
$(obj)/images/%: .FORCE $(obj)/images/%: .FORCE
$(Q) $(MAKE) $(build)=$(obj)/images $@ $(Q) $(MAKE) $(build)=$(obj)/images $@
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment