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
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
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