Makefile 3.12 KB
Newer Older
1
# -*- Mode: Makefile -*-
2
CPPFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
Yoni Fogel's avatar
Yoni Fogel committed
3
CPPFLAGS += -I../../toku_include -I.. -I.
4
OPTFLAGS = -O0 
5
CFLAGS = -Wall -Werror -g $(OPTFLAGS) -std=c99
6 7 8
ifeq ($(GCCVERSION),4.4.4)
	CFLAGS += -Wno-deprecated
else ifeq ($(GCCVERSION),4.4.2)
9
	CFLAGS += -Wno-deprecated
10 11
else ifeq ($(GCCVERSION),4.4.1)
	CFLAGS += -Wno-deprecated
12 13
else ifeq ($(GCCVERSION),4.4.0)
	CFLAGS += -Wno-deprecated
14
endif
15 16 17
ifneq ($(GCOV),)
	CFLAGS += -fprofile-arcs -ftest-coverage -DGCOV
endif
18
LDFLAGS = ../libtokuportability.a -lpthread
Yoni Fogel's avatar
Yoni Fogel committed
19
SRCS=$(sort $(filter-out dir.%.c,$(wildcard *.c)))
20
TARGETS = $(patsubst %.c,%,$(SRCS))
21 22
RUNTARGETS = $(patsubst %,%.tdbrun,$(TARGETS))
VGRIND = valgrind
23

24 25 26 27
ifeq ($(CC),icc)
	CFLAGS += -diag-disable 981
endif

28 29 30 31 32 33 34
HERE=linux/tests
ifeq ($(SUMMARIZE),1)
SUMMARIZE_CMD = ;if test $$? = 0; then printf "%-60sPASS\n" $(HERE)/$@; else printf "%-60sFAIL\n" $(HERE)/$@ ; test 0 = 1; fi
SUMMARIZE_SHOULD_FAIL= ;if test $$? = 0; then printf "%-60sXFAIL\n" $(HERE)/$@; else printf "%-60sXPASS\n" $(HERE)/$@ ; test 0 = 1; fi
else
SUMMARIZE_CMD =
endif
35
INVERTER=;test $$? -ne 0
36

37 38 39
all: $(TARGETS)

%: %.c
40 41
	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) -lrt

42 43
.PHONY: check build
build: $(TARGETS)
44
check: $(TARGETS) $(RUNTARGETS);
45

46 47 48
test-rwlock: OPTFLAGS=-O3
test-rwlock: ../toku_pthread.h

49 50
# pwrite4g needs an argument to tell it which directory to write temporary files
test-pwrite4g.tdbrun: TEST_EXTRA_ARGS=.
51
%.tdbrun: %
52
ifeq ($(VGRIND),)
53
	./$< $(TEST_EXTRA_ARGS) $(SUMMARIZE_CMD)
54
else
55
	$(VGRIND) --error-exitcode=1 --quiet --leak-check=full --show-reachable=yes --log-file=$<.check.valgrind ./$< $(TEST_EXTRA_ARGS) >$<.check.output 2>&1; \
56
	if [ $$? = 0 ] ; then \
57 58 59
		lines=`cat $<.check.valgrind | wc -l`; \
		if [ $$lines -ne 0 ] ; then cat $<.check.valgrind; test 0 = 1; fi \
	else \
60
	        cat $<.check.valgrind; test 0 = 1; \
61 62
	fi \
	$(SUMMARIZE_CMD)
63
endif
64

65
# check to see if that logic makes an error when there is a leak.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
try-leak-lost.tdbrun: try-leak-lost
ifeq ($(VGRIND),)
	./$< $(SUMMARIZE_SHOULD_FAIL)
else
	$(VGRIND) --error-exitcode=1 --quiet --leak-check=full --show-reachable=yes --log-file=$<.check.valgrind ./$< >$<.check.output 2>&1; \
	if [ $$? = 0 ] ; then \
		lines=`cat $<.check.valgrind | wc -l`; \
		if [ $$lines -ne 0 ] ; then cat $<.check.valgrind; test 0 = 1; fi \
	else \
	        test 0 = 1; \
	fi \
	$(INVERTER) \
	$(SUMMARIZE_SHOULD_FAIL)
endif

try-leak-reachable.tdbrun: try-leak-reachable
82
ifeq ($(VGRIND),)
83
	./$< $(SUMMARIZE_SHOULD_FAIL)
84
else
85
	$(VGRIND) --error-exitcode=1 --quiet --leak-check=full --show-reachable=yes --log-file=$<.check.valgrind ./$< >$<.check.output 2>&1; \
86 87 88 89 90 91 92
	if [ $$? = 0 ] ; then \
		lines=`cat $<.check.valgrind | wc -l`; \
		if [ $$lines -ne 0 ] ; then cat $<.check.valgrind; test 0 = 1; fi \
	else \
	        test 0 = 1; \
	fi \
	$(INVERTER) \
93
	$(SUMMARIZE_SHOULD_FAIL)
94 95 96
endif

try-assert0.tdbrun: try-assert0
97
	./$< 2> /dev/null $(INVERTER) $(SUMMARIZE_SHOULD_FAIL)
98

99 100 101
try-assert-zero.tdbrun: try-assert-zero
	./$< 2> /dev/null $(INVERTER) $(SUMMARIZE_SHOULD_FAIL)

102
clean:
103
	rm -rf $(TARGETS) *.check.output *.check.valgrind pwrite4g.data testdir dir.*.c
104

105 106 107 108 109
try-assert0.tdbrun:


foo:
	echo $(TARGETS)