include newbrt/tests/make.include

NEWBRT_BINS = $(patsubst %,newbrt/%$(BINSUF),$(BINS_RAW))

TEST_NEWBRT = newbrt/brt-test-helpers.$(OEXT)

# This version runs logformat twice.  There is something screwing in make that if you have a pattern form with two outputs
# then it runs the thing only once, but if it has no % symbols it runs it twice.
## log_header.h log_code.c: logformat$(BINSUF)
##	./logformat
# So we do it this way
newbrt/log_print.c newbrt/log_header.h newbrt/log_code.c: newbrt/logformat$(BINSUF)
	newbrt/logformat$(BINSUF) newbrt
.PRECIOUS: newbrt/log_print.c newbrt/log_header.h newbrt/log_code.c

NEWBRT_A        = newbrt/newbrt.$(AEXT)

BRT_SOURCES = \
  block_allocator \
  block_table \
  bread \
  brt-serialize \
  brt-verify \
  brt \
  brt_msg \
  brt-test-helpers \
  cachetable \
  checkpoint \
  fifo \
  fingerprint \
  key \
  leafentry \
  leaflock \
  logfilemgr \
  logger \
  log_code \
  log_print \
  logcursor \
  memarena \
  mempool \
  minicron \
  omt \
  recover \
  roll \
  rollback \
  ule \
  threadpool \
  toku_worker \
  trace_mem \
  txn \
  x1764 \
  xids \
  ybt \
# keep this line so I can have a \ on the previous line

BRT_C_FILES = $(patsubst %,newbrt/%.c,$(BRT_SOURCES))
BRT_O_FILES = $(patsubst %,newbrt/%.$(OEXT),$(BRT_SOURCES))

$(TEST_NEWBRT): newbrt/log_header.h
$(TEST_NEWBRT) $(BRT_O_FILES) newbrt/newbrt.$(OEXT): CPPFLAGS_DIRECTORY = -Inewbrt -Iinclude
newbrt/newbrt.$(OEXT): $(BRT_C_FILES) $(DEPEND_COMPILE)
	$(CC) -c $(BRT_C_FILES) $(COMBINE_C) $(CPPFLAGS) $(CPPFLAGS_DIRECTORY) $(CFLAGS) $(CFLAGS_DIRECTORY) $(OOUTPUT)$@

ifneq ($(CYGWIN),)
NEWBRT_O_FILES = $(BRT_O_FILES)
else ifeq ($(CC),icc)
NEWBRT_O_FILES = $(BRT_O_FILES)
else ifeq ($(COMBINE),0)
NEWBRT_O_FILES = $(BRT_O_FILES)
else
NEWBRT_O_FILES = newbrt/newbrt.o
endif

NEWBRT_O_FILES += newbrt/brtloader.o

$(NEWBRT_O_FILES): VISIBILITY=-fvisibility=default
$(NEWBRT_O_FILES): CPPFLAGS_DIRECTORY=-Iinclude -Itoku_include -I$(OS)
$(NEWBRT_O_FILES): SHADOW=
$(NEWBRT_A): $(NEWBRT_O_FILES)
newbrt/libnewbrt.$(SOEXT): $(NEWBRT_O_FILES)
newbrt/libnewbrt.$(SOEXT): VISIBILITY=-fvisibility=default
newbrt/libnewbrt.$(SOEXT): LOADLIBES_DIRECTORY=-lz -Llib -ltokuportability
newbrt/libnewbrt.$(SOEXT): CFLAGS_DIRECTORY=-lpthread
newbrt/brtloader.$(OEXT): CPPFLAGS_DIRECTORY=-Iinclude
newbrt/logformat$(BINSUF): CPPFLAGS_DIRECTORY=-Iinclude -Itoku_include -I$(OS)

newbrt/build: newbrt/bins newbrt/libs $(TEST_NEWBRT) newbrt/tests/build
newbrt/check: newbrt/tests/check
newbrt/bins: $(NEWBRT_BINS)
newbrt/libs: $(NEWBRT_A)
.PHONY: newbrt/build newbrt/bins newbrt/libs