include ../Makefile.toolchain
#
# Goncalo's Generic Makefile -- Compiles and installs a Generic Goncalo Tool
# (c) 2000-2007 Goncalo Abecasis
#

# version information
TOOL = bam
# 0.0.1 - Initial version
VERSION = 0.0.1
SOURCES = Main.cpp
OPTFLAG?=-ggdb -O0 -fno-rtti

# default installation directory
#INSTALLDIR=/usr/local/bin

DATE=$(shell date)
NODE=$(shell uname -n)
#
# default compilation flags are 
#
# CFLAGS=-02 -I./libsrc/ -I./$(TOOL)
# 
# The following special options may also be added to the default
# 
#      Option                        Effect
#      -D_FILE_OFFSET_BITS=64        Enables support for swapfiles larger
#                                    than 2GB on supported systems (tested
#                                    on Linux)
#      -D__USE_LONG_INT              Enables support for markers with up
#                                    to 64 alleles (default is 32). Tested
#                                    on systems where gcc supports the long
#                                    long data type and on Windows.
# 

CFLAGS= -Wall  $(OPTFLAG) -I../libcsg -I../thirdParty/samtools -D__ZLIB_AVAILABLE__  -D_FILE_OFFSET_BITS=64 -D__STDC_LIMIT_MACROS

# executable file names and locations
TARGET = $(TOOL)

# Source File Set
# For best results, consider editing this manually ...
TOOLBASE = SamFileHeader SamFile GenericSamInterface SamInterface BamInterface SamRecord BamIndex SamHeaderHD SamHeaderPG SamHeaderRecord SamHeaderSQ SamHeaderRG SamHeaderTag SamValidation SamStatus SamFlag SamStatistics Validate Convert DumpHeader SplitChromosome WriteRegion DumpIndex ReadIndexedBam PileupReader DumpRefInfo
TOOLHDR = $(TOOLBASE:=.h)
TOOLONLYSRC = $(TOOLBASE:=.cpp)
TOOLSRC = $(TOOLBASE:=.cpp) Main.cpp
TOOLOBJ = $(TOOLSRC:.cpp=.o)
TOOLONLYOBJ = $(TOOLONLYSRC:.cpp=.o)
HDRONLY = 


# Utility Library File Set
LIBRARY = ../libcsg/libcsg.a ../thirdParty/samtools/libbam.a
 
NEWLIBRARY=libbam.a


# make everything
all : $(TARGET) $(NEWLIBRARY)

# dependencies for executables
$(TARGET) : $(LIBRARY) $(TOOLOBJ) $(BINDIR)
	$(CXX) $(CFLAGS) -o $@ $(TOOLOBJ) $(LIBRARY) -lm -lz -lssl

$(TOOLOBJ): $(TOOLHDR) $(LIBHDR) $(HDRONLY)


$(NEWLIBRARY) : $(TOOLONLYOBJ)
	ar -cr $@ $(TOOLONLYOBJ)
	ranlib $@

clean :
	-rm -f *.o $(TARGET) *~ $(NEWLIBRARY)
	(cd test; $(MAKE) $(PARALLEL_MAKE) OPTFLAG="$(OPTFLAG)" --no-print-directory $@);

test: all
	(cd test; $(MAKE) $(PARALLEL_MAKE) OPTFLAG="$(OPTFLAG)" --no-print-directory $@);

.c.o :
	$(CXX) $(CFLAGS) -o $@ -c $*.c 

.cpp.o : 
	$(CXX) $(CFLAGS) -o $@ -c $*.cpp -DVERSION="\"$(VERSION)\""



.SUFFIXES : .cpp .c .o .X.o $(SUFFIXES)

DFLAGS=-Y

cleandepend:
	        makedepend -- $(DFLAGS) --

depend:
	        makedepend -- $(DFLAGS) -- $(TOOLSRC) >/dev/null 2>&1

# DO NOT DELETE THIS LINE -- make depend depends on it
