NEWBRT_REGRESSION_TESTS = \
	brt-serialize-test \
	brt-test \
	brt-test-cursor \
	brt-test-cursor-2 \
	brt-test-named-db \
	brt-test0 \
	brt-test1 \
	brt-test2 \
	brt-test3 \
	brt-test4 \
	brt-test5 \
	cachetable-test \
	cachetable-test2 \
	fifo-test \
	list-test \
	log-test \
	log-test2 \
	log-test3 \
	log-test4 \
	log-test5 \
	log-test6 \
	omt-test \
	test-assert \
	test-brt-delete-both \
	test-brt-overflow \
	test-del-inorder \
	test-inc-split \
	test-primes \
	test_oexcl \
	test_toku_malloc_plain_free \
	ybt-test \
# This line intentially kept commented so I can have a \ on the end of the previous line

NEWBRT_BINS = $(NEWBRT_REGRESSION_TESTS) \
        benchmark-test \
        brtdump \
        tdb_logprint \
# This line intentially kept commented so I can have a \ on the end of the previous line

NEWBRT_HERE = $(ROOT)newbrt

NEWBRT_RBINS = $(patsubst %,$(NEWBRT_HERE)/%,$(NEWBRT_BINS))

BINS += $(NEWBRT_RBINS)

# Must include crc first
NEWBRT_FILES = \
  crc \
  brt-serialize \
  brt-verify \
  brt \
  cachetable \
  fifo \
  fingerprint \
  key \
  leafentry \
  log \
  log_code \
  memory \
  mempool \
  omt \
  primes \
  recover \
  roll \
  toku_assert \
  ybt \
# keep this line so I can have a \ on the previous line

OFILES += $(NEWBRT_HERE)/newbrt.o

$(NEWBRT_HERE)/newbrt.o: CPPFLAGS += -I$(NEWBRT_HERE)
$(NEWBRT_HERE)/newbrt.o: $(patsubst %,$(NEWBRT_HERE)/%.c,$(NEWBRT_FILES))
	cd $(NEWBRT_HERE);$(CC) -combine $(CFLAGS) $(CPPFLAGS) $(patsubst %,%.c,$(NEWBRT_FILES)) -c -o $@

$(NEWBRT_RBINS): $(NEWBRT_HERE)/newbrt.o
NEWBRT_NEED_HELPERS = test-inc-split test-del-inorder
$(patsubst %,$(NEWBRT_HERE)/%, $(NEWBRT_NEED_HELPERS)): $(NEWBRT_HERE)/brt-test-helpers.o

# Put the benchmarktest_256 first since it takes a long time (and we want to use parallelism in the make)
NEWBRT_CHECKS = \
 benchmarktest_256 \
 $(NEWBRT_REGRESSION_TESTS) \
# This line intentially kept commented so I can have a \ on the previous line

newbrt.checkdir: $(patsubst %,$(NEWBRT_HERE)/%.check, $(NEWBRT_CHECKS))
newbrt.builddir: $(OFILES) $(NEWBRT_RBINS)

$(NEWBRT_HERE)/benchmarktest_256.check: $(NEWBRT_HERE)/benchmark-test
	cd $(NEWBRT_HERE); $(VGRIND) ./benchmark-test $(VERBVERBOSE) --valsize 256 --verify 1

#foo:
#	echo $(NEWBRT_HERE)/benchmarktest_256.check

$(NEWBRT_HERE)/test-assert.check: $(NEWBRT_HERE)/test-assert
	@# no arguments, should err
	cd $(NEWBRT_HERE); $(VGRIND) ./test-assert > /dev/null 2>&1 ; test \($$?\)
	@# one argument, not "ok" should err
	@echo Expect an abort message:
	$(NEWBRT_HERE); ($(VGRIND) ./test-assert notok) > test-assert.out 2>&1 ; test \($$?\)
	@fgrep failed test-assert.out > /dev/null
	@rm test-assert.out
	@# one argument, "ok" should not error
	$(NEWBRT_HERE)/ $(VGRIND) ./test-assert ok
