]> git.donarmstrong.com Git - samtools.git/blob - Makefile
Merge pull request #44 from peterjc/check_bins
[samtools.git] / Makefile
1 # The default version string in bam.h and bcftools/bcf.h can be overriden directly
2 #   make VERSION="-DVERSION='\\\"my-version\\\"'"
3 # or using the git-stamp rule
4 #   make git-stamp
5 VERSION=
6
7 CC=                     gcc
8 CFLAGS=         -g -Wall $(VERSION) -O2
9 #LDFLAGS=               -Wl,-rpath,\$$ORIGIN/../lib
10 DFLAGS=         -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -D_CURSES_LIB=1
11 KNETFILE_O=     knetfile.o
12 LOBJS=          bgzf.o kstring.o bam_aux.o bam.o bam_import.o sam.o bam_index.o \
13                         bam_pileup.o bam_lpileup.o bam_md.o razf.o faidx.o bedidx.o \
14                         $(KNETFILE_O) bam_sort.o sam_header.o bam_reheader.o kprobaln.o bam_cat.o
15 AOBJS=          bam_tview.o bam_plcmd.o sam_view.o \
16                         bam_rmdup.o bam_rmdupse.o bam_mate.o bam_stat.o bam_color.o \
17                         bamtk.o kaln.o bam2bcf.o bam2bcf_indel.o errmod.o sample.o \
18                         cut_target.o phase.o bam2depth.o padding.o bedcov.o bamshuf.o \
19                         bam_tview_curses.o bam_tview_html.o
20 PROG=           samtools
21 INCLUDES=       -I.
22 SUBDIRS=        . bcftools misc
23 LIBPATH=
24 LIBCURSES=      -lcurses # -lXCurses
25
26
27 .SUFFIXES:.c .o
28 .PHONY: all lib
29
30 .c.o:
31                 $(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
32
33 all-recur lib-recur clean-recur cleanlocal-recur install-recur:
34                 @target=`echo $@ | sed s/-recur//`; \
35                 wdir=`pwd`; \
36                 list='$(SUBDIRS)'; for subdir in $$list; do \
37                         cd $$subdir; \
38                         $(MAKE) CC="$(CC)" DFLAGS="$(DFLAGS)" CFLAGS="$(CFLAGS)" \
39                                 INCLUDES="$(INCLUDES)" LIBPATH="$(LIBPATH)" $$target || exit 1; \
40                         cd $$wdir; \
41                 done;
42
43 all:$(PROG)
44
45 git-stamp:
46                 make VERSION="-DVERSION='\\\"`git describe --always --dirty`\\\"'"
47
48 .PHONY:all lib clean cleanlocal
49 .PHONY:all-recur lib-recur clean-recur cleanlocal-recur install-recur
50
51 lib:libbam.a
52
53 libbam.a:$(LOBJS)
54                 $(AR) -csru $@ $(LOBJS)
55
56 samtools:lib-recur $(AOBJS)
57                 $(CC) $(CFLAGS) -o $@ $(AOBJS) $(LDFLAGS) libbam.a -Lbcftools -lbcf $(LIBPATH) $(LIBCURSES) -lm -lz -lpthread
58
59 razip:razip.o razf.o $(KNETFILE_O)
60                 $(CC) $(CFLAGS) -o $@ $^ -lz
61
62 bgzip:bgzip.o bgzf.o $(KNETFILE_O)
63                 $(CC) $(CFLAGS) -o $@ $^ -lz -lpthread
64
65 bgzf.o:bgzf.c bgzf.h
66                 $(CC) -c $(CFLAGS) $(DFLAGS) -DBGZF_CACHE $(INCLUDES) bgzf.c -o $@
67
68 razip.o:razf.h
69 bam.o:bam.h razf.h bam_endian.h kstring.h sam_header.h
70 sam.o:sam.h bam.h
71 bam_import.o:bam.h kseq.h khash.h razf.h
72 bam_pileup.o:bam.h razf.h ksort.h
73 bam_plcmd.o:bam.h faidx.h bcftools/bcf.h bam2bcf.h
74 bam_index.o:bam.h khash.h ksort.h razf.h bam_endian.h
75 bam_lpileup.o:bam.h ksort.h
76 bam_tview.o:bam.h faidx.h bam_tview.h
77 bam_tview_curses.o:bam.h faidx.h bam_tview.h
78 bam_tview_html.o:bam.h faidx.h bam_tview.h
79 bam_sort.o:bam.h ksort.h razf.h
80 bam_md.o:bam.h faidx.h
81 sam_header.o:sam_header.h khash.h
82 bcf.o:bcftools/bcf.h
83 bam2bcf.o:bam2bcf.h errmod.h bcftools/bcf.h
84 bam2bcf_indel.o:bam2bcf.h
85 errmod.o:errmod.h
86 phase.o:bam.h khash.h ksort.h
87 bamtk.o:bam.h
88
89 faidx.o:faidx.h razf.h khash.h
90 faidx_main.o:faidx.h razf.h
91
92
93 libbam.1.dylib-local:$(LOBJS)
94                 libtool -dynamic $(LOBJS) -o libbam.1.dylib -lc -lz
95
96 libbam.so.1-local:$(LOBJS)
97                 $(CC) -shared -Wl,-soname,libbam.so -o libbam.so.1 $(LOBJS) -lc -lz
98
99 dylib:
100                 @$(MAKE) cleanlocal; \
101                 case `uname` in \
102                         Linux) $(MAKE) CFLAGS="$(CFLAGS) -fPIC" libbam.so.1-local;; \
103                         Darwin) $(MAKE) CFLAGS="$(CFLAGS) -fPIC" libbam.1.dylib-local;; \
104                         *) echo 'Unknown OS';; \
105                 esac
106
107
108 cleanlocal:
109                 rm -fr gmon.out *.o a.out *.exe *.dSYM razip bgzip $(PROG) *~ *.a *.so.* *.so *.dylib
110
111 clean:cleanlocal-recur