Commit 50d79911 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

test/zdtm: unify common code

This commit expands the success with lib/Makefile to the rest of
ztdm/Makefiles. In particular, it moves the common part to Makefile.inc
and let {lib,static,transition}/Makefile use it.

This results in:
 - dependencies being handled properly;
 - reduction of makefiles length due to unification;
 - possibly more proper dependencies and builds.

While at it, let's also:
 - make rules for criu-rtc.so silent;
 - set default CC=gcc;
 - remove duplicate -m32 from CFLAGS.
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 4dcceffe
/lib/libzdtmtst.a /lib/libzdtmtst.a
/lib/.gitignore
/static/.gitignore /static/.gitignore
/transition/.gitignore /transition/.gitignore
......
MAKEFLAGS += -r
ARCH ?= $(shell uname -m | sed \ ARCH ?= $(shell uname -m | sed \
-e s/i.86/x86/ \ -e s/i.86/x86/ \
-e s/x86_64/x86/ \ -e s/x86_64/x86/ \
...@@ -18,6 +20,9 @@ endif ...@@ -18,6 +20,9 @@ endif
SRCARCH ?= $(ARCH) SRCARCH ?= $(ARCH)
CC := gcc
CFLAGS += -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
CFLAGS += $(USERCFLAGS)
CPPFLAGS += -iquote $(LIBDIR)/arch/$(SRCARCH)/include CPPFLAGS += -iquote $(LIBDIR)/arch/$(SRCARCH)/include
ifeq ($(strip $(V)),) ifeq ($(strip $(V)),)
...@@ -32,10 +37,57 @@ RM := rm -f --one-file-system ...@@ -32,10 +37,57 @@ RM := rm -f --one-file-system
ifeq ($(COMPAT_TEST),y) ifeq ($(COMPAT_TEST),y)
ifeq ($(ARCH),x86) ifeq ($(ARCH),x86)
export USERCFLAGS += -m32
export CFLAGS += -m32 export CFLAGS += -m32
export LDFLAGS += -m32 export LDFLAGS += -m32
endif endif
endif endif
export E Q RM DEPEND.c = $(COMPILE.c) -MM -MP
%.d: %.c
$(E) " DEP " $*.d
$(Q)$(DEPEND.c) $(OUTPUT_OPTION) $<
%.o: %.c | %.d
$(E) " CC " $@
$(Q)$(COMPILE.c) $(OUTPUT_OPTION) $<
%: %.o $(LDLIBS)
@echo $@ >> .gitignore
$(E) " LINK " $@
$(Q)$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
default: all
.PHONY: default
gitignore-clean:
$(RM) .gitignore
.PHONY: gitignore-clean
clean: gitignore-clean
$(RM) $(OBJ) $(TST) *~
.PHONY: clean
cleandep: clean
$(RM) $(DEP)
.PHONY: cleandep
cleanout:
$(RM) -r *.pid *.out* *.test* *.state
.PHONY: cleanout
%.cleanout: %
$(Q) $(RM) -r $<.pid* $<.out* *$<.test* $<.*.test $<.*.state $<.state chew_$<.test*
realclean: cleandep cleanout
.PHONY: realclean
dep: $(DEP)
.PHONY: dep
no-deps-targets := clean cleandep cleanout realclean groups.cleanout
ifeq ($(filter $(no-deps-targets), $(MAKECMDGOALS)),)
-include $(DEP)
endif
.SECONDARY:
MAKEFLAGS += -r
LIBDIR := . LIBDIR := .
include ../Makefile.inc
CFLAGS := -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
CFLAGS += $(USERCFLAGS) CFLAGS += $(USERCFLAGS)
LIB := libzdtmtst.a LIB := libzdtmtst.a
...@@ -18,43 +15,16 @@ LDLIBS := $(LIB) ...@@ -18,43 +15,16 @@ LDLIBS := $(LIB)
TARGETS := $(LIB) $(BIN) TARGETS := $(LIB) $(BIN)
include ../Makefile.inc
all: $(TARGETS) all: $(TARGETS)
.PHONY: all .PHONY: all
DEPEND.c = $(COMPILE.c) -MM -MP clean-more:
%.d: %.c $(RM) $(TARGETS)
$(E) " DEP " $*.d .PHONY: clean-more
$(Q)$(DEPEND.c) $(OUTPUT_OPTION) $< clean: clean-more
%.o: %.c | %.d
$(E) " CC " $@
$(Q)$(COMPILE.c) $(OUTPUT_OPTION) $<
%: %.o $(LDLIBS)
$(E) " LINK " $@
$(Q)$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
$(LIB): $(LIBOBJ) $(LIB): $(LIBOBJ)
$(E) " AR " $@ $(E) " AR " $@
$(Q)ar rcs $@ $^ $(Q)ar rcs $@ $^
dep: $(DEP)
.PHONY: dep
clean:
$(RM) $(OBJ) $(TARGETS)
cleandep: clean
$(RM) $(DEP)
cleanout: clean ;
realclean: clean cleandep
.PHONY: clean cleandep cleanout realclean
no-deps-targets := clean cleandep cleanout realclean
ifeq ($(filter $(no-deps-targets), $(MAKECMDGOALS)),)
-include $(DEP)
endif
include ../Makefile.inc LIBDIR := ../lib
.SUFFIXES: # No implicit rules LIB := $(LIBDIR)/libzdtmtst.a
LDLIBS += $(LIB)
LIBDIR = ../lib
LIB = $(LIBDIR)/libzdtmtst.a
LDLIBS += $(LIBDIR)/libzdtmtst.a
CPPFLAGS += -I$(LIBDIR) CPPFLAGS += -I$(LIBDIR)
CFLAGS = -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
CFLAGS += $(USERCFLAGS)
TST_NOFILE := \ TST_NOFILE := \
busyloop00 \ busyloop00 \
...@@ -314,15 +309,7 @@ OUT = $(TST:%=%.out) ...@@ -314,15 +309,7 @@ OUT = $(TST:%=%.out)
STATE = $(TST_STATE:%=%.state) STATE = $(TST_STATE:%=%.state)
STATE_OUT = $(TST_STATE:%=%.out) STATE_OUT = $(TST_STATE:%=%.out)
%.o: %.c include ../Makefile.inc
@echo $@ >> .gitignore
$(E) " CC " $@
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
%: %.o
@echo $@ >> .gitignore
$(E) " LINK " $@
$(Q)$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
all: $(TST) criu-rtc.so all: $(TST) criu-rtc.so
install: all install: all
...@@ -449,7 +436,9 @@ stopped01: CFLAGS += -DZDTM_STOPPED_KILL ...@@ -449,7 +436,9 @@ stopped01: CFLAGS += -DZDTM_STOPPED_KILL
stopped02: CFLAGS += -DZDTM_STOPPED_TKILL stopped02: CFLAGS += -DZDTM_STOPPED_TKILL
stopped12: CFLAGS += -DZDTM_STOPPED_KILL -DZDTM_STOPPED_TKILL stopped12: CFLAGS += -DZDTM_STOPPED_KILL -DZDTM_STOPPED_TKILL
clone_fs: LDLIBS += -pthread clone_fs: LDLIBS += -pthread
netns_sub_veth: CFLAGS += -I/usr/include/libnl3 # As generating dependencies won't work without proper includes,
# we have to explicitly specify both .o and .d for this case:
netns_sub_veth.o netns_sub_veth.d: CPPFLAGS += -I/usr/include/libnl3
netns_sub_veth: LDLIBS += -lnl-3 -l nl-route-3 netns_sub_veth: LDLIBS += -lnl-3 -l nl-route-3
socket-tcp-fin-wait1: CFLAGS += -D ZDTM_TCP_FIN_WAIT1 socket-tcp-fin-wait1: CFLAGS += -D ZDTM_TCP_FIN_WAIT1
...@@ -468,31 +457,21 @@ pty-console: CFLAGS += -D ZDTM_DEV_CONSOLE ...@@ -468,31 +457,21 @@ pty-console: CFLAGS += -D ZDTM_DEV_CONSOLE
$(LIB): force $(LIB): force
$(Q) $(MAKE) -C $(LIBDIR) $(Q) $(MAKE) -C $(LIBDIR)
gitignore-clean: clean-more:
$(RM) -f .gitignore $(RM) criu-rtc.so criu-rtc.pb-c.c criu-rtc.pb-c.h get_smaps_bits.o
.PHONY: clean-more
clean: gitignore-clean clean: clean-more
$(RM) -f $(OBJ) $(TST) *~ criu-rtc.so criu-rtc.pb-c.c criu-rtc.pb-c.h get_smaps_bits.o
cleandep: clean
$(RM) -f $(DEP)
cleanout:
$(RM) -f -r *.pid *.out* *.test* *.state
%.cleanout: %
$(Q) $(RM) -f -r $<.pid* $<.out* *$<.test* $<.*.test $<.*.state $<.state
realclean: cleandep cleanout
rtc.c: criu-rtc.so rtc.c: criu-rtc.so
criu-rtc.pb-c.c: criu-rtc.proto criu-rtc.pb-c.c: criu-rtc.proto
$(Q)echo $@ >> .gitignore $(Q)echo $@ >> .gitignore
$(Q)echo $(@:%.c=%.h) >> .gitignore $(Q)echo $(@:%.c=%.h) >> .gitignore
protoc-c --proto_path=. --c_out=. criu-rtc.proto $(E) " PBCC " $@
$(Q)protoc-c --proto_path=. --c_out=. criu-rtc.proto
criu-rtc.so: criu-rtc.c criu-rtc.pb-c.c criu-rtc.so: criu-rtc.c criu-rtc.pb-c.c
$(CC) -g -Wall -shared -nostartfiles criu-rtc.c criu-rtc.pb-c.c -o criu-rtc.so -iquote ../../../criu/include -fPIC $(filter-out -m32,$(USERCFLAGS)) $(E) " LD " $@
$(Q)$(CC) -g -Wall -shared -nostartfiles criu-rtc.c criu-rtc.pb-c.c -o criu-rtc.so -iquote ../../../criu/include -fPIC $(filter-out -m32,$(USERCFLAGS))
.PHONY: force clean cleandep cleanout realclean start check_start stop wait_stop .PHONY: force start check_start stop wait_stop
include ../Makefile.inc LIBDIR := ../lib
.SUFFIXES: # No implicit rules LIB := $(LIBDIR)/libzdtmtst.a
LDLIBS += $(LIB)
LIBDIR = ../lib
LIB = $(LIBDIR)/libzdtmtst.a
LDLIBS += $(LIBDIR)/libzdtmtst.a
CPPFLAGS += -I$(LIBDIR) CPPFLAGS += -I$(LIBDIR)
CFLAGS = -g -O2 -Wall -Werror -fno-strict-aliasing
CFLAGS += $(USERCFLAGS)
TST_NOFILE = \ TST_NOFILE = \
ipc \ ipc \
...@@ -41,15 +36,7 @@ DEP = $(SRC:%.c=%.d) ...@@ -41,15 +36,7 @@ DEP = $(SRC:%.c=%.d)
PID = $(TST:%=%.pid) PID = $(TST:%=%.pid)
OUT = $(TST:%=%.out) OUT = $(TST:%=%.out)
%.o: %.c include ../Makefile.inc
@echo $@ >> .gitignore
$(E) " CC " $@
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
%: %.o
@echo $@ >> .gitignore
$(E) " LINK " $@
$(Q)$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
all: $(TST) all: $(TST)
install: all install: all
...@@ -99,21 +86,4 @@ thread-bomb: LDFLAGS += -pthread ...@@ -99,21 +86,4 @@ thread-bomb: LDFLAGS += -pthread
$(LIB): force $(LIB): force
$(Q) $(MAKE) -C $(LIBDIR) $(Q) $(MAKE) -C $(LIBDIR)
gitignore-clean: .PHONY: force start check_start stop wait_stop
$(RM) -f .gitignore
clean: gitignore-clean
$(RM) -f $(OBJ) $(TST) *~
cleandep: clean
$(RM) -f $(DEP)
%.cleanout: %
$(Q) $(RM) -f -r $<.pid* $<.out* $<.test* chew_$<.test*
cleanout:
$(RM) -f *.pid *.out* *.test chew*
realclean: cleandep cleanout
.PHONY: force clean cleandep cleanout realclean start check_start stop wait_stop
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