# Set the following variable correctly (where is the UnitTest++ package?)
UTESTPP_DIR = /home/igv/Code/UnitTest++

OFILES_COMMON = test_utils.o SerializableBase.o SerializableBaseReader.o \
                SerializableDerivedA.o SerializableDerivedB.o \
                SerializableDerivedC.o

OTESTS_FAST = test_ClassId.o test_write_item.o test_ArchiveIO.o \
              test_ColumnBuffer.o test_VarPack.o test_tupleIO.o \
              test_ColumnPacker.o test_RowPacker.o test_CPBuffer.o \
              test_forward_listIO.o test_unorderedIO.o test_inheritance.o \
              test_valarrayIO.o test_compressedIO.o test_pseudoIO.o

# OPTIMIZE = -g

# Use the following switch to support C++11 features in g++
# OPTIMIZE = -g -std=c++0x
OPTIMIZE = -std=c++11 -O3

INCLUDES = -I. -I.. -I$(UTESTPP_DIR)/src
CPPFLAGS = $(OPTIMIZE) $(INCLUDES) -Wall -W -Werror -Wno-unused-parameter

LIBS = -L../geners/.libs -lgeners -L$(UTESTPP_DIR) -lUnitTest++ \
       -L/usr/lib64 -L/usr/local/lib -lbz2 -lz -lm

%.o : %.cc
	g++ -c $(CPPFLAGS) -fPIC -MD $< -o $@
	@sed -i 's,\($*\.o\)[:]*\(.*\),$@: $$\(wildcard\2\)\n\1:\2,g' $*.d

all: fast fast_run

fast: test_main.o $(OTESTS_FAST) $(OFILES_COMMON)
	rm -f $@
	g++ $(OPTIMIZE) -fPIC -o $@ $^ $(LIBS)

fast_run: fast
	./fast

PROGRAMS = hugePack_col.cc hugePackRead_col.cc hugePack_row.cc \
           hugePackRead_row.cc printCatalog.cc searchCatalog.cc

BINARIES = $(PROGRAMS:.cc=)

binaries: $(BINARIES)

$(BINARIES): % : %.o $(OFILES_COMMON); g++ $(OPTIMIZE) -fPIC -o $@ $^ $(LIBS)

clean:
	rm -f fast $(BINARIES) *.out core.* *.o *.d *~ *.gsbd *.gsbmf

-include test_main.d
-include $(OFILES_COMMON:.o=.d)
-include $(OTESTS_FAST:.o=.d)
-include $(PROGRAMS:.cc=.d)
