-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
133 lines (91 loc) · 2.93 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
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 ngsBriggs using a local htslib installation)
$(info Use `make HTSSRC=systemwide` to build ngsBriggs 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
CPPFLAGS := $(filter-out -DNDEBUG,$(CPPFLAGS))
FLAGS2 = $(CPPFLAGS) $(FLAGS) $(LDFLAGS)
CFLAGS := $(FLAGS2) $(CFLAGS)
CXXFLAGS := $(FLAGS2) $(CXXFLAGS)
OPT=-Wl,-O2
# filter -O2 optimization flag CXXFLAGS
CXXFLAGS := $(filter-out -O2,$(CXXFLAGS))
CXXFLAGS := $(subst $(OPT),,$(CXXFLAGS))
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
PROGRAMS = ngsbriggs
all: $(PROGRAMS) misc
PACKAGE_VERSION = 0.01
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 NGSBRIGS_VERSION "$(PACKAGE_VERSION)"' > $@
.PHONY: all clean install install-all install-misc misc test
-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
ngsbriggs: version.h $(OBJ)
$(CXX) $(FLAGS) -o ngsbriggs *.o $(LIBS)
testclean:
rm -f test/acc2taxid.map.gzf570b1db7c.dedup.filtered.rname.bam.bin
rm -f test/data/f570b1db7c.dedup.filtered.rname.bam
rm -rf test/output test/logfile version.h
clean: testclean
rm -f *.o *.d $(PROGRAMS) version.h *~
test:
echo "Running unit tests for ngsBriggs"
cd test;./testAll.sh
force:
install: all
$(INSTALL_DIR) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) $(PROGRAMS) $(DESTDIR)$(bindir)
install-all: install install-misc