77cda865c4b38df76fdafe338feae873dabde0e6
[samtools.git] / Makefile
1 CC=                     gcc
2 CFLAGS=         -g -Wall -O2 #-m64 #-arch ppc
3 DFLAGS=         -D_FILE_OFFSET_BITS=64 -D_USE_KNETFILE -D_CURSES_LIB=1
4 KNETFILE_O=     knetfile.o
5 LOBJS=          bgzf.o kstring.o bam_aux.o bam.o bam_import.o sam.o bam_index.o \
6                         bam_pileup.o bam_lpileup.o bam_md.o glf.o razf.o faidx.o \
7                         $(KNETFILE_O) bam_sort.o sam_header.o bam_reheader.o
8 AOBJS=          bam_tview.o bam_maqcns.o bam_plcmd.o sam_view.o \
9                         bam_rmdup.o bam_rmdupse.o bam_mate.o bam_stat.o bam_color.o     \
10                         bamtk.o kaln.o bam2bcf.o errmod.o sample.o
11 PROG=           samtools
12 INCLUDES=       -I.
13 SUBDIRS=        . bcftools misc
14 LIBPATH=
15 LIBCURSES=      -lcurses # -lXCurses
16
17 .SUFFIXES:.c .o
18
19 .c.o:
20                 $(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
21
22 all-recur lib-recur clean-recur cleanlocal-recur install-recur:
23                 @target=`echo $@ | sed s/-recur//`; \
24                 wdir=`pwd`; \
25                 list='$(SUBDIRS)'; for subdir in $$list; do \
26                         cd $$subdir; \
27                         $(MAKE) CC="$(CC)" DFLAGS="$(DFLAGS)" CFLAGS="$(CFLAGS)" \
28                                 INCLUDES="$(INCLUDES)" LIBPATH="$(LIBPATH)" $$target || exit 1; \
29                         cd $$wdir; \
30                 done;
31
32 all:$(PROG)
33
34 .PHONY:all lib clean cleanlocal
35 .PHONY:all-recur lib-recur clean-recur cleanlocal-recur install-recur
36
37 lib:libbam.a
38
39 libbam.a:$(LOBJS)
40                 $(AR) -cru $@ $(LOBJS)
41
42 samtools:lib-recur $(AOBJS)
43                 $(CC) $(CFLAGS) -o $@ $(AOBJS) libbam.a -lm $(LIBPATH) $(LIBCURSES) -lz -Lbcftools -lbcf
44
45 razip:razip.o razf.o $(KNETFILE_O)
46                 $(CC) $(CFLAGS) -o $@ razf.o razip.o $(KNETFILE_O) -lz
47
48 bgzip:bgzip.o bgzf.o $(KNETFILE_O)
49                 $(CC) $(CFLAGS) -o $@ bgzf.o bgzip.o $(KNETFILE_O) -lz
50
51 razip.o:razf.h
52 bam.o:bam.h razf.h bam_endian.h kstring.h sam_header.h
53 sam.o:sam.h bam.h
54 bam_import.o:bam.h kseq.h khash.h razf.h
55 bam_pileup.o:bam.h razf.h ksort.h
56 bam_plcmd.o:bam.h faidx.h bam_maqcns.h glf.h bcftools/bcf.h bam2bcf.h
57 bam_index.o:bam.h khash.h ksort.h razf.h bam_endian.h
58 bam_lpileup.o:bam.h ksort.h
59 bam_tview.o:bam.h faidx.h bam_maqcns.h
60 bam_maqcns.o:bam.h ksort.h bam_maqcns.h kaln.h
61 bam_sort.o:bam.h ksort.h razf.h
62 bam_md.o:bam.h faidx.h
63 glf.o:glf.h
64 sam_header.o:sam_header.h khash.h
65 bcf.o:bcftools/bcf.h
66 bam2bcf.o:bam2bcf.h errmod.h bcftools/bcf.h
67 errmod.o:errmod.h
68
69 faidx.o:faidx.h razf.h khash.h
70 faidx_main.o:faidx.h razf.h
71
72
73 libbam.1.dylib-local:$(LOBJS)
74                 libtool -dynamic $(LOBJS) -o libbam.1.dylib -lc -lz
75
76 libbam.so.1-local:$(LOBJS)
77                 $(CC) -shared -Wl,-soname,libbam.so -o libbam.so.1 $(LOBJS) -lc -lz
78
79 dylib:
80                 @$(MAKE) cleanlocal; \
81                 case `uname` in \
82                         Linux) $(MAKE) CFLAGS="$(CFLAGS) -fPIC" libbam.so.1-local;; \
83                         Darwin) $(MAKE) CFLAGS="$(CFLAGS) -fPIC" libbam.1.dylib-local;; \
84                         *) echo 'Unknown OS';; \
85                 esac
86
87
88 cleanlocal:
89                 rm -fr gmon.out *.o a.out *.exe *.dSYM razip bgzip $(PROG) *~ *.a *.so.* *.so *.dylib
90
91 clean:cleanlocal-recur