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/
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)macro.mk
......@@ -213,6 +220,7 @@ SOCCR_A := soccr/libsoccr.a
SOCCR_CONFIG := soccr/config.h
$(SOCCR_CONFIG): $(CONFIG_HEADER)
$(Q) test -f $@ || ln -s ../$(CONFIG_HEADER) $@
soccr/Makefile: ;
soccr/%: $(SOCCR_CONFIG) .FORCE
$(Q) $(MAKE) $(build)=soccr $@
soccr/built-in.o: $(SOCCR_CONFIG) .FORCE
......@@ -228,6 +236,9 @@ criu-deps += $(SOCCR_A)
#
# But note that we're already included
# the nmk so we can reuse it there.
criu/Makefile: ;
criu/Makefile.packages: ;
criu/Makefile.crtools: ;
criu/%: $(criu-deps) .FORCE
$(Q) $(MAKE) $(build)=criu $@
criu: $(criu-deps)
......@@ -238,6 +249,7 @@ criu: $(criu-deps)
# Libraries next once criu it ready
# (we might generate headers and such
# when building criu itself).
lib/Makefile: ;
lib/%: criu .FORCE
$(Q) $(MAKE) $(build)=lib $@
lib: criu
......
......@@ -31,6 +31,7 @@ criu-deps += compel/$(LIBCOMPEL_A)
#
# Compel itself.
compel/Makefile: ;
compel/%: $(compel-deps) $(compel-plugins) .FORCE
$(Q) $(MAKE) $(build)=compel $@
......@@ -38,6 +39,7 @@ criu-deps += compel/compel-host-bin
#
# Plugins
compel/plugins/Makefile: ;
compel/plugins/%: $(compel-deps) .FORCE
$(Q) $(MAKE) $(build)=compel/plugins $@
......
......@@ -57,6 +57,8 @@ pie: criu/pie/pie.lib.a
$(Q) $(MAKE) $(build)=criu/pie all
.PHONY: pie
criu/pie/Makefile: ;
criu/pie/Makefile.library: ;
criu/pie/%: pie ;
#
......@@ -71,8 +73,10 @@ PROGRAM-BUILTINS += $(COMPEL_LIBS)
$(obj)/built-in.o: pie
$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) all
$(obj)/Makefile:
@true
$(obj)/Makefile: ;
$(obj)/Makefile.crtools: ;
$(obj)/Makefile.packages: ;
$(obj)/%: pie
$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) $@
......
......@@ -12,8 +12,8 @@ all-y += lib-c lib-py
#
# C language bindings.
lib/c/Makefile: ;
lib/c/%: .FORCE
$(call msg-gen, $@)
$(Q) $(MAKE) $(build)=lib/c $@
cflags-so += $(CFLAGS) -rdynamic -Wl,-soname,$(CRIU_SO).$(CRIU_SO_VERSION_MAJOR)
......@@ -27,6 +27,7 @@ lib-c: lib/c/$(CRIU_SO)
#
# Python bindings.
lib/py/Makefile: ;
lib/py/%: .FORCE
$(call msg-gen, $@)
$(Q) $(MAKE) $(build)=lib/py $@
......
......@@ -2,6 +2,7 @@ all-y += libpy-images rpc_pb2.py
.PHONY: .FORCE
$(obj)/images/Makefile: ;
$(obj)/images/%: .FORCE
$(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