Commit 04db5336 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

test/zdtm/lib/Makefile: fix

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: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent e4000c59
MAKEFLAGS += -r
LIBDIR := .
include ../Makefile.inc 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) CFLAGS += $(USERCFLAGS)
LIBDIR = . LIB := libzdtmtst.a
LIB = libzdtmtst.a
GRPS = groups
LIBSRC = datagen.c msg.c parseargs.c test.c streamutil.c lock.c ns.c tcp.c fs.c LIBSRC := datagen.c msg.c parseargs.c test.c streamutil.c lock.c ns.c tcp.c fs.c
LIBOBJ = $(LIBSRC:%.c=%.o) LIBOBJ := $(LIBSRC:%.c=%.o)
LIBDEP = $(LIBSRC:%.c=%.d)
DEPEND.c = $(COMPILE.c) -MM -MP BIN := groups
%.d: %.c SRC := $(LIBSRC) groups.c
$(DEPEND.c) $(OUTPUT_OPTION) $< DEP := $(SRC:%.c=%.d)
OBJ := $(SRC:%.c=%.o)
LDLIBS := $(LIB)
all: $(LIB) TARGETS := $(LIB) $(BIN)
@true
install: all
.PHONY: all install
$(LIB): $(LIBOBJ) all: $(TARGETS)
$(Q) ar rv $@ $^ .PHONY: all
clean: DEPEND.c = $(COMPILE.c) -MM -MP
$(RM) -f $(LIBOBJ) $(LIB) *~ %.d: %.c
$(E) " DEP " $*.d
$(Q)$(DEPEND.c) $(OUTPUT_OPTION) $<
cleandep: %.o: %.c | %.d
$(RM) -f $(LIBDEP) $(E) " CC " $@
$(Q)$(COMPILE.c) $(OUTPUT_OPTION) $<
cleanout: %: %.o $(LDLIBS)
@true $(E) " LINK " $@
$(Q)$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(GRPS): $(LIB) $(LIB): $(LIBOBJ)
$(E) " AR " $@
$(Q)ar rcs $@ $^
dep: $(DEP)
.PHONY: dep
$(GRPS:%=%.pid): $(GRPS) clean:
$(<D)/$(<F) --pidfile=$@ --outfile=$<.out $(RM) $(OBJ) $(TARGETS)
$(GRPS:%=%.out): $(GRPS:%=%.pid) cleandep: clean
-kill -TERM `cat $<` $(RM) $(DEP)
$(GRPS:%=%.cleanout): $(GRPS) cleanout: clean ;
$(Q) $(RM) -f -r $<.pid $<.out* *$<.test* $<.*.test $<.state $<.init.pid
realclean: clean cleandep realclean: clean cleandep
.PHONY: clean cleandep cleanout realclean .PHONY: clean cleandep cleanout realclean
ifeq ($(filter-out no-deps-targets, $(MAKECMDGOALS)),) no-deps-targets := clean cleandep cleanout realclean
-include $(LIBDEP)
ifeq ($(filter $(no-deps-targets), $(MAKECMDGOALS)),)
-include $(DEP)
endif endif
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