Makefile 5.79 KB
Newer Older
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
1 2 3
# On OSX do:
#   make OSX=OSX

4 5 6 7 8
# For verbose output do
#   make VERBOSE=1
# For very verbose output do 
#   make VERBOSE=2

Rich Prohaska's avatar
Rich Prohaska committed
9
ifdef BDBDIR
10
BDB_CPPFLAGS = -I$(BDBDIR)/include
Rich Prohaska's avatar
Rich Prohaska committed
11 12
BDB_LDFLAGS = -L$(BDBDIR)/lib -ldb
endif
13

14
ifneq ($(OSX),)
Yoni Fogel's avatar
Yoni Fogel committed
15
#Note: OSX 10.4 needs DYLD_LIBRARY_PATH.  OSX 10.5 claims to support -rpath.
Yoni Fogel's avatar
Yoni Fogel committed
16
 CFLAGS = -DOSX
17 18 19
 LIBEXT=dylib
 VGRIND=
 BDB_SUPPRESSIONS=
20
 TDB_LOADLIBES = -L../ -ltokudb
21 22
 SETTOKUENV=export DYLD_LIBRARY_PATH=.. ;
 UNSETTOKUENV=unset DYLD_LIBRARY_PATH ;
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
23
else
Yoni Fogel's avatar
Yoni Fogel committed
24
 CFLAGS =
25 26 27 28
 SETTOKUENV=
 UNSETTOKUENV=
 LIBEXT=so
 ifdef BDBDIR
29
  BDB_LDFLAGS += -Wl,-rpath,$(BDBDIR)/lib
30
 endif
31
 BDB_LDFLAGS += -lpthread
32
 TDB_LOADLIBES = -L../ -ltokudb -Wl,-rpath,.. -lpthread
33
 VGRIND=valgrind --quiet --error-exitcode=1 --leak-check=yes
Rich Prohaska's avatar
Rich Prohaska committed
34
endif
35 36 37 38
ifeq ($(VGRIND),)
  BDB_SUPPRESSIONS =
else
  BDB_SUPPRESSIONS = --suppressions=bdb.supressions --gen-suppressions=all
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
39 40
endif

41 42
# VERBOSE=true

Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
43
LIBNAME=libdb.$(LIBEXT)
44
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage
Yoni Fogel's avatar
Yoni Fogel committed
45
CFLAGS += -Wall -Werror $(OPTFLAGS) -g3 -ggdb3 $(GCOV_FLAGS)
46
TDB_CPPFLAGS = -I../../include
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
47

48

Yoni Fogel's avatar
Yoni Fogel committed
49
SRCS = $(sort $(wildcard *.c))
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
50

51 52
TDB_TESTS = $(patsubst %.c,%.tdb,$(SRCS))
BDB_TESTS = $(patsubst %.c,%.bdb,$(SRCS))
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
53

54
ALL_TESTS = $(TDB_TESTS) $(BDB_TESTS)
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
55

56 57 58
RUN_TDB_TESTS = $(patsubst %.tdb,%.tdbrun,$(TDB_TESTS))
RUN_BDB_TESTS = $(patsubst %.bdb,%.bdbrun,$(BDB_TESTS))
RUN_ALL_TESTS = $(RUN_TDB_TESTS) $(RUN_BDB_TESTS)
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
59

60

61 62 63 64 65 66 67
all: make_libs $(ALL_TESTS)

foo:
	echo RUN_TDB_TESTS: $(RUN_TDB_TESTS)
	echo ALL_TESTS: $(ALL_TESTS)

.PHONY: check check.bdb check.tdb
68
check: check.bdb check.tdb all.recover test_db_assoc3.tdbrun_wasbad
69
	@ echo ok
Yoni Fogel's avatar
Yoni Fogel committed
70 71 72 73
tests.bdb: make_libs $(BDB_TESTS)
check.bdb: make_libs $(RUN_BDB_TESTS)
tests.tdb: make_libs $(TDB_TESTS)
check.tdb: make_libs $(RUN_TDB_TESTS)
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
74

75
# Need these rule so that Make knows about all the file names
76
.PHONY: %.bdbrun %.tdbrun %.run
77 78
$(RUN_ALL_TESTS):
$(ALL_TESTS):
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
79

80
%.run: %.bdbrun %.tdbrun
81
	@ echo ok
82

83 84
ifeq ($(VERBOSE),2)
VERBVERBOSE=-v
85
MAYBEATSIGN= 
86
VERBQUIET=
87 88 89 90
else
 ifeq ($(VERBOSE),1)
  VERBVERBOSE=
  MAYBEATSIGN=
91
  VERBQUIET=
92 93 94
 else
  VERBVERBOSE=
  MAYBEATSIGN=@
95
  VERBQUIET=--quiet
96
 endif
97 98
endif

99
# The @ sign makes the make quiet.  If there is an error there is enough info to tell what test failed.
100 101 102 103 104
# Give up VGRIND of bdbrun
# It was this:
#%.bdbrun: %.bdb
#	$(MAYBEATSIGN) $(UNSETTOKUENV) $(VGRIND) $(BDB_SUPPRESSIONS) ./$< $(VERBVERBOSE)
# Now thiss:
105
%.bdbrun: %.bdb
106
	$(MAYBEATSIGN) $(UNSETTOKUENV) ./$< $(VERBVERBOSE)
107
%.tdbrun: %.tdb
108
	$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(VERBVERBOSE)
109

110
# For BDB, VGRIND isn't happy
111
NO_VGRIND = \
112 113 114 115 116 117 118 119 120
  abort1 \
  cursor_delete \
  cursor_delete_next \
  cursor_flags \
  cursor_db_current \
  cursor_nonleaf_expand \
  cursor_stickyness \
  db_already_exists \
  db_assoc3 \
121 122
  db_dbt_appmalloc \
  db_dbt_mem_behavior \
123
  db_curs2 \
124
  db_delete \
125
  db_donotindex \
126
  db_env_open_nocreate \
127 128 129
  db_env_open_open_close \
  db_open_notexist_reopen \
  db_remove_subdb \
130 131 132 133 134 135
  db_set_flags \
  db_subdb \
  dup_delete \
  dup_dup \
  dup_flags \
  dup_insert \
136 137
  dup_next \
  dup_search \
138 139
  dupsort_delete \
  dupsort_get \
140
  dupsort_get_both \
141 142 143
  dupsort_get_both_range \
  dupsort_set \
  dupsort_set_range \
144 145 146 147 148
  get_zeroed_dbt \
  hsoc \
  insert_cursor_delete_insert \
  insert_memleak \
  kv_limits \
149 150 151 152
  log0 \
  log1 \
  log2 \
  log3 \
153
  log4 \
154
  log5 \
155
  nodup_set \
156
  thread_insert \
157
  # Comment to terminate list so the previous line can end with a slash
158 159

$(patsubst %,test_%.bdbrun,$(NO_VGRIND)): VGRIND=
160
$(patsubst %,test_%.bdbrun,$(NO_VGRIND)): BDB_SUPPRESSIONS=
161

162 163 164
libs:
	cd ..;make

165
%.bdb: %.c
166
	$(UNSETTOKUENV) cc  -DDIR=\"dir.$<.bdb\" $(BDB_CPPFLAGS) -DUSE_BDB -DIS_TDB=0 $(CFLAGS) $< $(BDB_LDFLAGS) -ldb -o $@
167
%.tdb: %.c
168
	$(SETTOKUENV) cc  -DDIR=\"dir.$<.tdb\" -DUSE_TDB -DIS_TDB=1 $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_LOADLIBES) $< -o $@
169

170
.PHONY: %.recover
171
all.recover: test_log2.recover test_log3.recover test_log4.recover test_log5.recover
172
%.recover: %.tdb
173
	$(MAYBEATSIGN) cd ../../newbrt;make $(VERBQUIET) recover;make $(VERBQUIET)
174
	$(MAYBEATSIGN) cd ..;make $(VERBQUIET)
175
	$(MAYBEATSIGN) $(VGRIND) ./$<
176
	$(MAYBEATSIGN) (cd dir.$(patsubst %.tdb,%.c.tdb,$<);pwd;cat log*| ../../../newbrt/tdb_logprint |wc -c)
177 178
	$(MAYBEATSIGN) rm -rf dir.$(patsubst %.tdb,%.c.tdb,$<).recover
	$(MAYBEATSIGN) mkdir dir.$(patsubst %.tdb,%.c.tdb,$<).recover
179
	$(MAYBEATSIGN) cd dir.$(patsubst %.tdb,%.c.tdb,$<).recover;$(VGRIND) ../../../newbrt/recover ../dir.$(patsubst %.tdb,%.c.tdb,$<)
180
	$(MAYBEATSIGN) diff dir.$(patsubst %.tdb,%.c.tdb,$<) dir.$(patsubst %.tdb,%.c.tdb,$<).recover/foo.db
181

182 183
make_libs:
	cd ..;make
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
184

Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
185
clean:
186
	rm -f $(ALL_TESTS) *.o *.gcno *.gcda *.gcov
187
	rm -rf dir.*.tdb dir.*.bdb
188 189

test_db_curs4.tdb: trace.h
190
test_db_curs4.bdb: trace.h
191
test_db_assoc3.tdb test_db_assoc3.bdb: test.h
192

193

194 195
# This one failed in both BDB and TokuDB, in the same way.  It was a program error.  Now it works
test_db_assoc3.tdbrun_wasbad: test_db_assoc3.tdb
196 197 198 199 200 201 202
	$(MAYBEATSIGN) ./test_db_assoc3.tdb --seed=1 --count=200
	$(MAYBEATSIGN) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) ./test_db_assoc3.tdb --seed=1 --count=200 --more
203 204

test_db_assoc3.tdbrun: test_db_assoc3.tdb
205 206
	$(MAYBEATSIGN) $(VGRIND) ./test_db_assoc3.tdb --seed=2 --count=100000 $(VERBVERBOSE)
	$(MAYBEATSIGN) $(VGRIND) ./test_db_assoc3.tdb --seed=2 --count=100000 --more $(VERBVERBOSE)
207

208
# Give up on VGRIND for bdbrun
209
test_db_assoc3.bdbrun: test_db_assoc3.bdb
210 211
	$(MAYBEATSIGN) ./test_db_assoc3.bdb --seed=2 --count=100000 $(VERBVERBOSE)
	$(MAYBEATSIGN) ./test_db_assoc3.bdb --seed=2 --count=100000 --more $(VERBVERBOSE)
212 213 214

dumpit:
	../../newbrt/brtdump  dir.test_log5.c.tdb.recover/foo.db > dump.r && ../../newbrt/brtdump  dir.test_log5.c.tdb/foo.db > dump.o && diff dump.o dump.r