[CRIU] [PATCH 1/9] test/zdtm/lib/Makefile: fix
Kir Kolyshkin
kir at openvz.org
Wed Mar 29 15:21:12 PDT 2017
When optimizing our Travis runs, I noticed that test/zdtm/lib is built 3
times in a row -- first time the binaries, 2nd and 3rd time the deps,
in parallel (sic!).
I took a look at Makefile and found this, and some more problems,
like:
- dependencies are generated but not included
- cleandep does not depend on clean
- groups.c dependencies are not generated (or used)
- "make all" does not make groups binary
- overcomplicated and unused groups.{pid,out,cleanout} targets
- extra -f flag to rm
- etc.
This patch (hopefully) fixes all of the above. In addition, it provides
a few enhancements:
- enables "silent make" rules, so now lib/ is in line with the rest of zdtm
- adds "dep" target (not used, just for convenience)
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
test/zdtm/lib/Makefile | 70 ++++++++++++++++++++++++++++----------------------
1 file changed, 39 insertions(+), 31 deletions(-)
diff --git a/test/zdtm/lib/Makefile b/test/zdtm/lib/Makefile
index 592d934..6b37e0d 100644
--- a/test/zdtm/lib/Makefile
+++ b/test/zdtm/lib/Makefile
@@ -1,52 +1,60 @@
+MAKEFLAGS += -r
+LIBDIR := .
include ../Makefile.inc
-CFLAGS = -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
+CFLAGS := -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
CFLAGS += $(USERCFLAGS)
-LIBDIR = .
-LIB = libzdtmtst.a
-GRPS = groups
+LIB := libzdtmtst.a
-LIBSRC = datagen.c msg.c parseargs.c test.c streamutil.c lock.c ns.c tcp.c fs.c
-LIBOBJ = $(LIBSRC:%.c=%.o)
-LIBDEP = $(LIBSRC:%.c=%.d)
+LIBSRC := datagen.c msg.c parseargs.c test.c streamutil.c lock.c ns.c tcp.c fs.c
+LIBOBJ := $(LIBSRC:%.c=%.o)
-DEPEND.c = $(COMPILE.c) -MM -MP
-%.d: %.c
- $(DEPEND.c) $(OUTPUT_OPTION) $<
+BIN := groups
+SRC := $(LIBSRC) groups.c
+DEP := $(SRC:%.c=%.d)
+OBJ := $(SRC:%.c=%.o)
+LDLIBS := $(LIB)
-all: $(LIB)
- @true
-install: all
-.PHONY: all install
+TARGETS := $(LIB) $(BIN)
-$(LIB): $(LIBOBJ)
- $(Q) ar rv $@ $^
+all: $(TARGETS)
+.PHONY: all
-clean:
- $(RM) -f $(LIBOBJ) $(LIB) *~
+DEPEND.c = $(COMPILE.c) -MM -MP
+%.d: %.c
+ $(E) " DEP " $*.d
+ $(Q)$(DEPEND.c) $(OUTPUT_OPTION) $<
-cleandep:
- $(RM) -f $(LIBDEP)
+%.o: %.c | %.d
+ $(E) " CC " $@
+ $(Q)$(COMPILE.c) $(OUTPUT_OPTION) $<
-cleanout:
- @true
+%: %.o $(LDLIBS)
+ $(E) " LINK " $@
+ $(Q)$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
-$(GRPS): $(LIB)
+$(LIB): $(LIBOBJ)
+ $(E) " AR " $@
+ $(Q)ar rcs $@ $^
+
+dep: $(DEP)
+.PHONY: dep
-$(GRPS:%=%.pid): $(GRPS)
- $(<D)/$(<F) --pidfile=$@ --outfile=$<.out
+clean:
+ $(RM) $(OBJ) $(TARGETS)
-$(GRPS:%=%.out): $(GRPS:%=%.pid)
- -kill -TERM `cat $<`
+cleandep: clean
+ $(RM) $(DEP)
-$(GRPS:%=%.cleanout): $(GRPS)
- $(Q) $(RM) -f -r $<.pid $<.out* *$<.test* $<.*.test $<.state $<.init.pid
+cleanout: clean ;
realclean: clean cleandep
.PHONY: clean cleandep cleanout realclean
-ifeq ($(filter-out no-deps-targets, $(MAKECMDGOALS)),)
--include $(LIBDEP)
+no-deps-targets := clean cleandep cleanout realclean
+
+ifeq ($(filter $(no-deps-targets), $(MAKECMDGOALS)),)
+-include $(DEP)
endif
--
2.9.3
More information about the CRIU
mailing list