Makefile 6.22 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=
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
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
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
69
	@ echo ok $@
Yoni Fogel's avatar
Yoni Fogel committed
70
tests.bdb: make_libs $(BDB_TESTS)
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
71
	@ echo ok $@
Yoni Fogel's avatar
Yoni Fogel committed
72
check.bdb: make_libs $(RUN_BDB_TESTS)
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
73
	@ echo ok $@
Yoni Fogel's avatar
Yoni Fogel committed
74
tests.tdb: make_libs $(TDB_TESTS)
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
75
	@ echo ok $@
Yoni Fogel's avatar
Yoni Fogel committed
76
check.tdb: make_libs $(RUN_TDB_TESTS)
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
77
	@ echo ok $@
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
78

79
# Need these rule so that Make knows about all the file names
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
80
.PHONY: %.run
81 82
$(RUN_ALL_TESTS):
$(ALL_TESTS):
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
83

84
%.run: %.bdbrun %.tdbrun
85
	@ echo ok
86

87 88
ifeq ($(VERBOSE),2)
VERBVERBOSE=-v
89
MAYBEATSIGN= 
90
VERBQUIET=
91 92 93 94
else
 ifeq ($(VERBOSE),1)
  VERBVERBOSE=
  MAYBEATSIGN=
95
  VERBQUIET=
96 97 98
 else
  VERBVERBOSE=
  MAYBEATSIGN=@
99
  VERBQUIET=--quiet
100
 endif
101 102
endif

103
# The @ sign makes the make quiet.  If there is an error there is enough info to tell what test failed.
104 105 106 107 108
# Give up VGRIND of bdbrun
# It was this:
#%.bdbrun: %.bdb
#	$(MAYBEATSIGN) $(UNSETTOKUENV) $(VGRIND) $(BDB_SUPPRESSIONS) ./$< $(VERBVERBOSE)
# Now thiss:
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
109
%.bdbrun: %.bdb ../libtokudb.$(LIBEXT)
110
	$(MAYBEATSIGN) $(UNSETTOKUENV) ./$< $(VERBVERBOSE)
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
111
%.tdbrun: %.tdb ../libtokudb.$(LIBEXT)
112
	$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(VERBVERBOSE)
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
113
	@ touch $@
114

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

$(patsubst %,test_%.bdbrun,$(NO_VGRIND)): VGRIND=
165
$(patsubst %,test_%.bdbrun,$(NO_VGRIND)): BDB_SUPPRESSIONS=
166

167 168 169
libs:
	cd ..;make

170
%.bdb: %.c
171
	$(UNSETTOKUENV) cc  -DDIR=\"dir.$<.bdb\" $(BDB_CPPFLAGS) -DUSE_BDB -DIS_TDB=0 $(CFLAGS) $< $(BDB_LDFLAGS) -ldb -o $@
172
%.tdb: %.c
173
	$(SETTOKUENV) cc  -DDIR=\"dir.$<.tdb\" -DUSE_TDB -DIS_TDB=1 $(CFLAGS) $(TDB_CPPFLAGS) $(TDB_LOADLIBES) $< -o $@
174

175
.PHONY: %.recover
176
all.recover: test_log2.recover test_log3.recover test_log4.recover test_log5.recover
177
%.recover: %.tdb
178
	$(MAYBEATSIGN) cd ../../newbrt;make $(VERBQUIET) recover;make $(VERBQUIET)
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
179 180 181 182 183 184 185
	$(MAYBEATSIGN) $(SETTOKUENV) cd ..;make $(VERBQUIET)
	$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$<
	$(MAYBEATSIGN) $(SETTOKUENV) (cd dir.$(patsubst %.tdb,%.c.tdb,$<);pwd;cat log*| ../../../newbrt/tdb_logprint |wc -c)
	$(MAYBEATSIGN) $(SETTOKUENV) rm -rf dir.$(patsubst %.tdb,%.c.tdb,$<).recover
	$(MAYBEATSIGN) $(SETTOKUENV) mkdir dir.$(patsubst %.tdb,%.c.tdb,$<).recover
	$(MAYBEATSIGN) $(SETTOKUENV) cd dir.$(patsubst %.tdb,%.c.tdb,$<).recover; $(VGRIND) ../../../newbrt/recover ../dir.$(patsubst %.tdb,%.c.tdb,$<)
	$(MAYBEATSIGN) $(SETTOKUENV) diff dir.$(patsubst %.tdb,%.c.tdb,$<) dir.$(patsubst %.tdb,%.c.tdb,$<).recover/foo.db
186

187 188
make_libs:
	cd ..;make
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
189

Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
190 191
.PHONY: clean cleanall

Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
192
clean:
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
193
	rm -f $(ALL_TESTS) *.o *.gcno *.gcda *.gcov 
194
	rm -rf dir.*.tdb dir.*.bdb
195

Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
196 197 198
cleanall: clean
	rm -f *.tdbrun

199
test_db_curs4.tdb: trace.h
200
test_db_curs4.bdb: trace.h
201
test_db_assoc3.tdb test_db_assoc3.bdb: test.h
202

203

204 205
# 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
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
206 207 208 209 210 211 212
	$(MAYBEATSIGN) $(SETTOKUENV) ./test_db_assoc3.tdb --seed=1 --count=200
	$(MAYBEATSIGN) $(SETTOKUENV) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) $(SETTOKUENV) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) $(SETTOKUENV) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) $(SETTOKUENV) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) $(SETTOKUENV) ./test_db_assoc3.tdb --seed=1 --count=200 --more
	$(MAYBEATSIGN) $(SETTOKUENV) ./test_db_assoc3.tdb --seed=1 --count=200 --more
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
213
	@ touch $@
214 215

test_db_assoc3.tdbrun: test_db_assoc3.tdb
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
216 217
	$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./test_db_assoc3.tdb --seed=2 --count=100000 $(VERBVERBOSE)
	$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./test_db_assoc3.tdb --seed=2 --count=100000 --more $(VERBVERBOSE)
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
218
	@ touch $@
219

220
# Give up on VGRIND for bdbrun
221
test_db_assoc3.bdbrun: test_db_assoc3.bdb
Vincenzo Liberatore's avatar
Vincenzo Liberatore committed
222 223
	$(MAYBEATSIGN) $(UNSETTOKUENV) ./test_db_assoc3.bdb --seed=2 --count=100000 $(VERBVERBOSE)
	$(MAYBEATSIGN) $(UNSETTOKUENV) ./test_db_assoc3.bdb --seed=2 --count=100000 --more $(VERBVERBOSE)
224 225 226

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