

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 += -Inewbrt -Iinclude
newbrt/newbrt.$(OEXT): $(BRT_C_FILES) $(DEPEND_COMPILE)
	$(CC) -c $(BRT_C_FILES) $(COMBINE_C) $(CPPFLAGS) $(CFLAGS) $(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_A): $(NEWBRT_O_FILES)

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

