1
2# Use ?= to allow override from the env or command-line.
3
4CC?=		gcc
5CXX?= 		g++
6CXXFLAGS?=	-g -Wall -O2 -fPIC #-m64 #-arch ppc
7INCLUDES?=	-Ihtslib
8HTS_HEADERS?=	htslib/htslib/bgzf.h htslib/htslib/tbx.h
9HTS_LIB?=	htslib/libhts.a
10LIBPATH?=	-L. -Lhtslib
11
12DFLAGS=		-D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE
13PROG=		tabix++
14SUBDIRS=.
15
16.SUFFIXES:.c .o
17
18.c.o:
19	$(CC) -c $(CXXFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
20
21all-recur lib-recur clean-recur cleanlocal-recur install-recur:
22	@target=`echo $@ | sed s/-recur//`; \
23	wdir=`pwd`; \
24	list='$(SUBDIRS)'; for subdir in $$list; do \
25		cd $$subdir; \
26		$(MAKE) CC="$(CC)" DFLAGS="$(DFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
27			INCLUDES="$(INCLUDES)" LIBPATH="$(LIBPATH)" $$target \
28			|| exit 1; \
29		cd $$wdir; \
30	done;
31
32all:	$(PROG)
33
34tabix.o: $(HTS_HEADERS) tabix.cpp tabix.hpp
35	$(CXX) $(CXXFLAGS) -c tabix.cpp $(INCLUDES)
36
37htslib/libhts.a:
38	cd htslib && $(MAKE) lib-static
39
40tabix++: tabix.o main.cpp $(HTS_LIB)
41	$(CXX) $(CXXFLAGS) -o $@ main.cpp tabix.o $(INCLUDES) $(LIBPATH) \
42		-lhts -lpthread -lm -lbz2 -llzma -lz
43
44cleanlocal:
45	rm -fr gmon.out *.o a.out *.dSYM $(PROG) *~ *.a tabix.aux tabix.log \
46		tabix.pdf *.class libtabix.*.dylib libtabix.so*
47	cd htslib && $(MAKE) clean
48
49clean:cleanlocal-recur
50