<commit_before># On OSX do:
#   make OSX=OSX

# For verbose output do
#   make VERBOSE=1
# For very verbose output do 
#   make VERBOSE=2

ifdef BDBDIR
BDB_CPPFLAGS = -I$(BDBDIR)/include
BDB_LDFLAGS = -L$(BDBDIR)/lib -ldb
endif

ifeq ($(OSX),OSX)
#Note: OSX 10.4 needs DYLD_LIBRARY_PATH.  OSX 10.5 claims to support -rpath.
 LIBEXT=dylib
 VGRIND=
 BDB_SUPPRESSIONS=
 TDB_LOADLIBES = -L../ -ldb
 SETTOKUENV=export DYLD_LIBRARY_PATH=.. ;
 UNSETTOKUENV=unset DYLD_LIBRARY_PATH ;
else
 SETTOKUENV=
 UNSETTOKUENV=
 LIBEXT=so
 ifdef BDBDIR
  BDB_LDFLAGS += -Wl,-rpath,$(BDBDIR)/lib
 endif
 BDB_LDFLAGS += -lpthread
 TDB_LOADLIBES = -L../ -ldb -Wl,-rpath,.. -lpthread
 VGRIND=valgrind --quiet --error-exitcode=1 --leak-check=yes
endif
ifeq ($(VGRIND),)
  BDB_SUPPRESSIONS =
else
  BDB_SUPPRESSIONS = --suppressions=bdb.supressions --gen-suppressions=all
endif

# VERBOSE=true

LIBNAME=libdb.$(LIBEXT)
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CFLAGS = -Wall -Werror $(OPTFLAGS) -g $(GCOV_FLAGS)
TDB_CPPFLAGS = -I../../include


SRCS = $(wildcard *.c)

TDB_TESTS = $(patsubst %.c,%.tdb,$(SRCS))
BDB_TESTS = $(patsubst %.c,%.bdb,$(SRCS))

ALL_TESTS = $(TDB_TESTS) $(BDB_TESTS)

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)


all: make_libs $(ALL_TESTS)

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

.PHONY: check check.bdb check.tdb
check: check.bdb check.tdb all.recover test_db_assoc3.tdbrun_wasbad
	@ echo ok
tests.bdb: $(BDB_TESTS)
check.bdb: $(RUN_BDB_TESTS)
tests.tdb: $(TDB_TESTS)
check.tdb: $(RUN_TDB_TESTS)

# Need these rule so that Make knows about all the file names
.PHONY: %.bdbrun %.tdbrun %.run
$(RUN_ALL_TESTS):
$(ALL_TESTS):

%.run: %.bdbrun %.tdbrun
	@ echo ok

ifeq ($(VERBOSE),2)
VERBVERBOSE=-v
MAYBEATSIGN= 
VERBQUIET=
else
 ifeq ($(VERBOSE),1)
  VERBVERBOSE=
  MAYBEATSIGN=
  VERBQUIET=
 else
  VERBVERBOSE=
  MAYBEATSIGN=@
  VERBQUIET=--quiet
 endif
endif

# The @ sign makes the make quiet.  If there is an error there is enough info to tell what test failed.
%.bdbrun: %.bdb
	$(MAYBEATSIGN) $(UNSETTOKUENV) $(VGRIND) $(BDB_SUPPRESSIONS) ./$< $(VERBVERBOSE)
%.tdbrun: %.tdb
	$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(VERBVERBOSE)

# For a few of the tests bdb is making valgrind unhappy.
FOO_NO_VGRIND = \
  db_already_exists \
  db_curs2 \
  db_dbt_appmalloc \
  db_dbt_mem_behavior \
  db_dup \
  db_env_open_nocreate \
  db_env_open_open_close \
  db_open_notexist_reopen \
  db_remove_subdb \
  db_subdb \
  db_thread_insert \
  dup_delete \
  dup_flags \
  dup_insert \
  dup_search \
  kv_limits \
  log4 \
  rand_insert \
  reverse_compare_fun \
  # Comment to terminate list so the previous line can end with a slash
 
NO_VGRIND = \
  db_dbt_appmalloc \
  db_dbt_mem_behavior \
  db_assoc3 \
  db_curs2 \
  db_delete \
  db_env_open_nocreate \
  db_env_open_open_close \
  db_open_notexist_reopen \
  db_remove_subdb \
  log4 \
  log5 \
  # Comment to terminate list so the previous line can end with a slash

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

libs:
	cd ..;make

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

.PHONY: %.recover<commit_msg>Berkeley DB on Fedora 8 has lots more complaints.  Found while working on Addresses #27.<commit_after># On OSX do:
#   make OSX=OSX

# For verbose output do
#   make VERBOSE=1
# For very verbose output do 
#   make VERBOSE=2

ifdef BDBDIR
BDB_CPPFLAGS = -I$(BDBDIR)/include
BDB_LDFLAGS = -L$(BDBDIR)/lib -ldb
endif

ifeq ($(OSX),OSX)
#Note: OSX 10.4 needs DYLD_LIBRARY_PATH.  OSX 10.5 claims to support -rpath.
 LIBEXT=dylib
 VGRIND=
 BDB_SUPPRESSIONS=
 TDB_LOADLIBES = -L../ -ldb
 SETTOKUENV=export DYLD_LIBRARY_PATH=.. ;
 UNSETTOKUENV=unset DYLD_LIBRARY_PATH ;
else
 SETTOKUENV=
 UNSETTOKUENV=
 LIBEXT=so
 ifdef BDBDIR
  BDB_LDFLAGS += -Wl,-rpath,$(BDBDIR)/lib
 endif
 BDB_LDFLAGS += -lpthread
 TDB_LOADLIBES = -L../ -ldb -Wl,-rpath,.. -lpthread
 VGRIND=valgrind --quiet --error-exitcode=1 --leak-check=yes
endif
ifeq ($(VGRIND),)
  BDB_SUPPRESSIONS =
else
  BDB_SUPPRESSIONS = --suppressions=bdb.supressions --gen-suppressions=all
endif

# VERBOSE=true

LIBNAME=libdb.$(LIBEXT)
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CFLAGS = -Wall -Werror $(OPTFLAGS) -g $(GCOV_FLAGS)
TDB_CPPFLAGS = -I../../include


SRCS = $(wildcard *.c)

TDB_TESTS = $(patsubst %.c,%.tdb,$(SRCS))
BDB_TESTS = $(patsubst %.c,%.bdb,$(SRCS))

ALL_TESTS = $(TDB_TESTS) $(BDB_TESTS)

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)


all: make_libs $(ALL_TESTS)

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

.PHONY: check check.bdb check.tdb
check: check.bdb check.tdb all.recover test_db_assoc3.tdbrun_wasbad
	@ echo ok
tests.bdb: $(BDB_TESTS)
check.bdb: $(RUN_BDB_TESTS)
tests.tdb: $(TDB_TESTS)
check.tdb: $(RUN_TDB_TESTS)

# Need these rule so that Make knows about all the file names
.PHONY: %.bdbrun %.tdbrun %.run
$(RUN_ALL_TESTS):
$(ALL_TESTS):

%.run: %.bdbrun %.tdbrun
	@ echo ok

ifeq ($(VERBOSE),2)
VERBVERBOSE=-v
MAYBEATSIGN= 
VERBQUIET=
else
 ifeq ($(VERBOSE),1)
  VERBVERBOSE=
  MAYBEATSIGN=
  VERBQUIET=
 else
  VERBVERBOSE=
  MAYBEATSIGN=@
  VERBQUIET=--quiet
 endif
endif

# The @ sign makes the make quiet.  If there is an error there is enough info to tell what test failed.
%.bdbrun: %.bdb
	$(MAYBEATSIGN) $(UNSETTOKUENV) $(VGRIND) $(BDB_SUPPRESSIONS) ./$< $(VERBVERBOSE)
%.tdbrun: %.tdb
	$(MAYBEATSIGN) $(SETTOKUENV) $(VGRIND) ./$< $(VERBVERBOSE)

# For a few of the tests bdb is making valgrind unhappy.
FOO_NO_VGRIND = \
  db_already_exists \
  db_curs2 \
  db_dbt_appmalloc \
  db_dbt_mem_behavior \
  db_dup \
  db_env_open_nocreate \
  db_env_open_open_close \
  db_open_notexist_reopen \
  db_remove_subdb \
  db_subdb \
  db_thread_insert \
  dup_delete \
  dup_flags \
  dup_insert \
  dup_search \
  kv_limits \
  log4 \
  rand_insert \
  reverse_compare_fun \
  # Comment to terminate list so the previous line can end with a slash
 
# For BDB, VGRIND isn't happy
NO_VGRIND = \
  abort1 \
  cursor_delete \
  cursor_delete_next \
  cursor_flags \
  cursor_db_current \
  cursor_nonleaf_expand \
  cursor_stickyness \
  db_already_exists \
  db_assoc3 \
  db_dbt_appmalloc \
  db_dbt_mem_behavior \
  db_donotindex \
  db_curs2 \
  db_delete \
  db_env_open_nocreate \
  db_env_open_open_close \
  db_open_notexist_reopen \
  db_remove_subdb \
  db_set_flags \
  db_subdb \
  dup_delete \
  dup_dup \
  dup_flags \
  dup_insert \
  log4 \
  log5 \
  # Comment to terminate list so the previous line can end with a slash

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

libs:
	cd ..;make

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

.PHONY: %.recover
{'fraction_non_alphanumeric': 0.13822571893651656, 'fraction_numerical': 0.005968529571351058, 'mean_word_length': 3.9383791024782315, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4182703', 'n_tokens_mistral': 3384, 'n_tokens_neox': 3306, 'n_words': 669}