-
Notifications
You must be signed in to change notification settings - Fork 51
/
Makefile
146 lines (100 loc) · 3.22 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
CC ?= gcc
CXX ?= g++
LIBS = -lz -lm -lbz2 -llzma -lpthread -lcurl
CRYPTO_TRY=$(shell echo 'int main(){}'|$(CXX) -x c++ - -lcrypto 2>/dev/null -o /dev/null; echo $$?)
ifeq "$(CRYPTO_TRY)" "0"
$(info Crypto library is available to link; adding -lcrypto to LIBS)
LIBS += -lcrypto
else
$(info Crypto library is not available to link; will not use -lcrypto)
endif
#if htslib source is defined
ifdef HTSSRC
#if hts source is set to systemwide
ifeq ($(HTSSRC),systemwide)
$(info HTSSRC set to systemwide; assuming systemwide installation)
LIBS += -lhts
else
#if hts source path is given
# Adjust $(HTSSRC) to point to your top-level htslib directory
$(info HTSSRC defined: $(HTSSRC))
CPPFLAGS += -I"$(realpath $(HTSSRC))"
LIBHTS := $(HTSSRC)/libhts.a
LIBS := $(LIBHTS) $(LIBS)
endif
#if htssrc not defined
else
$(info HTSSRC not defined; using htslib submodule)
$(info Use `make HTSSRC=/path/to/htslib` to build angsd using a local htslib installation)
$(info Use `make HTSSRC=systemwide` to build angsd using the systemwide htslib installation)
HTSSRC := $(CURDIR)/htslib
CPPFLAGS += -I$(HTSSRC)
LIBHTS := $(HTSSRC)/libhts.a
LIBS := $(LIBHTS) $(LIBS)
all: .activate_module
endif
.PHONY: .activate_module
.activate_module:
git submodule update --init --recursive
$(MAKE) -C $(HTSSRC)
#modied from htslib makefile
FLAGS = -O3 -D__STDC_FORMAT_MACROS
CPPFLAGS := $(filter-out -DNDEBUG,$(CPPFLAGS))
FLAGS2 = $(CPPFLAGS) $(FLAGS) $(LDFLAGS)
CFLAGS := $(FLAGS2) $(CFLAGS)
CXXFLAGS := $(FLAGS2) $(CXXFLAGS)
#for compiling with ZSTD which is used for .bgen file format
ifeq ($(WITH_ZSTD),1)
LIBS += -lzstd
CXXFLAGS += -D__ZSTD__
endif
CSRC = $(wildcard *.c)
CXXSRC = $(wildcard *.cpp)
OBJ = $(CSRC:.c=.o) $(CXXSRC:.cpp=.o)
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
INSTALL = install
INSTALL_DIR = $(INSTALL) -dm0755
INSTALL_PROGRAM = $(INSTALL) -m0755
#$(info CFLAGS=$(CFLAGS))
#$(info CXXFLAGS=$(CXXFLAGS))
PROGRAMS = angsd
all: $(PROGRAMS) misc
BAMDIR=""
BDIR=$(realpath $(BAMDIR))
PACKAGE_VERSION = 0.941
ifneq "$(wildcard .git)" ""
PACKAGE_VERSION := $(shell git describe --always --dirty)
version.h: $(if $(wildcard version.h),$(if $(findstring "$(PACKAGE_VERSION)",$(shell cat version.h)),,force))
endif
version.h:
echo '#define ANGSD_VERSION "$(PACKAGE_VERSION)"' > $@
.PHONY: all clean install install-all install-misc misc test
misc: analysisFunction.o bfgs.o prep_sites.o aio.o chisquare.o
$(MAKE) -C misc HTSSRC="$(realpath $(HTSSRC))"
-include $(OBJ:.o=.d)
%.o: %.c
$(CC) -c $(CFLAGS) $*.c
$(CC) -MM $(CFLAGS) $*.c >$*.d
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $*.cpp
$(CXX) -MM $(CXXFLAGS) $*.cpp >$*.d
angsd: version.h $(OBJ)
$(CXX) $(FLAGS) -o angsd *.o $(LIBS)
testclean:
rm -rf test/sfstest/output test/tajima/output test/*.log version.h test/temp.txt
clean: testclean
rm -f *.o *.d $(PROGRAMS) version.h *~
$(MAKE) -C misc clean
test:
echo "Only subset of analyses is being tested"
cd test;./testAll.sh ../angsd $(BDIR)
force:
install: all
$(INSTALL_DIR) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) $(PROGRAMS) $(DESTDIR)$(bindir)
$(MAKE) -C misc HTSSRC="$(realpath $(HTSSRC))" install
install-misc: misc
$(MAKE) -C misc HTSSRC="$(realpath $(HTSSRC))" install-misc
install-all: install install-misc