-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
133 lines (101 loc) · 4.13 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
CAVEMAN_VERSION=1.15.5
TEST_REF?=""
#Compiler
CC = gcc -DCAVEMAN_VERSION='"$(CAVEMAN_VERSION)"' -DTEST_REF='"$(TEST_REF)"'
#debug compiler
#CC = gcc -O3 -DCAVEMAN_VERSION='"$(CAVEMAN_VERSION)"' -g
#compiler flags
# -g adds debug info to the executable file
# -Wall turns on most warnings from compiler
CFLAGS = -Wall
ifneq ($(DEBUG),)
CFLAGS += -O3 # Optimise
else
CFLAGS += -g -O0 # Debug
endif
HTSLOC?=$(HTSLIB)
HTSTMP?=./caveman_tmp
prefix=?/usr/local/
#Define locations of header files
OPTINC?=-I$(HTSLOC)/ -I$(LINASM_INC)
INCLUDES= -Isrc $(OPTINC) -rdynamic
JOIN_INCLUDES= -I$(prefix)/include
CAT_LFLAGS= -L$(prefix)/lib
# define library paths in addition to /usr/lib
# if I wanted to include libraries not in /usr/lib I'd specify
# their path using -Lpath, something like:
LFLAGS?=-L$(HTSTMP) -L$(LINASM_LIB)
# define any libraries to link into executable:
# if I want to link in libraries (libx.so or libx.a) I use the -llibname
# option, something like (this will link in libmylib.so and libm.so:
LIBS =-lhts -lpthread -lz -lm -ldl -llinasm -llzma -lbz2 -lcurl
# define the C source files
SRCS = ./src/file_tests.c ./src/List.c ./src/List_algos.c ./src/bam_access.c ./src/config_file_access.c ./src/fai_access.c ./src/ignore_reg_access.c ./src/alg_bean.c ./src/split_access.c ./src/covs_access.c ./src/cn_access.c ./src/genotype.c ./src/algos.c ./src/output.c ./src/setup.c ./src/split.c ./src/mstep.c ./src/merge.c ./src/estep.c
#Define test sources
TEST_SRC=$(wildcard ./tests/*_tests.c)
TESTS=$(patsubst %.c,%,$(TEST_SRC))
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
# Below we are replacing the suffix .c of all words in the macro SRCS
# with the .o suffix
#
OBJS = $(SRCS:.c=.o)
MD := mkdir
#Build target executable
CAVEMAN_TARGET=./bin/caveman
UMNORM_TARGET=./bin/generateCavemanUMNormVCF
#
# The following part of the makefile is generic; it can be used to
# build any executable just by changing the definitions above and by
# deleting dependencies appended to the file from 'make depend'
#
.PHONY: depend clean coverage copyscript test make_htslib_tmp remove_htslib_tmp
.NOTPARALLEL: test
all: clean make_bin make_htslib_tmp $(CAVEMAN_TARGET) $(UMNORM_TARGET) copyscript test remove_htslib_tmp
@echo Binaries have been compiled.
$(UMNORM_TARGET): $(OBJS)
$(CC) $(JOIN_INCLUDES) $(INCLUDES) $(CFLAGS) -o $(UMNORM_TARGET) $(OBJS) $(LFLAGS) $(CAT_LFLAGS) $(LIBS) ./src/generateCavemanVCFUnmatchedNormalPanel.c
ifneq ($(DEBUG),)
$(CAVEMAN_TARGET): $(OBJS)
$(CC) $(JOIN_INCLUDES) $(INCLUDES) $(CFLAGS) -o $(CAVEMAN_TARGET) $(OBJS) $(LFLAGS) $(CAT_LFLAGS) $(LIBS) ./src/caveman.c
else
$(CAVEMAN_TARGET): $(OBJS)
$(CC) $(JOIN_INCLUDES) $(INCLUDES) $(CFLAGS) -o $(CAVEMAN_TARGET) $(OBJS) $(LFLAGS) $(CAT_LFLAGS) $(LIBS) ./src/caveman.c
strip $(CAVEMAN_TARGET)
endif
#Unit Tests
test: $(CAVEMAN_TARGET)
test: CFLAGS += $(JOIN_INCLUDES) $(INCLUDES) $(OBJS) $(LFLAGS) $(LIBS) $(CAT_LFLAGS)
test: $(TESTS)
sh ./tests/runtests.sh
#Unit tests with coverage
coverage: CFLAGS += --coverage
coverage: test
make_bin:
$(MD) ./bin
make_htslib_tmp:
$(MD) $(HTSTMP)
#Do some magic to ensure we compile CaVEMan with the static libhts.a rather than libhts.so
ln -s $(HTSLOC)/libhts.a $(HTSTMP)/libhts.a
remove_htslib_tmp:
rm -rf $(HTSTMP)
copyscript:
cp ./scripts/mergeCavemanResults ./bin/
chmod 755 ./bin/*
valgrind:
VALGRIND="valgrind --log-file=/tmp/valgrind-%p.log" $(MAKE)
# this is a suffix replacement rule for building .o's from .c's
# it uses automatic variables $<: the name of the prerequisite of
# the rule(a .c file) and $@: the name of the target of the rule (a .o file)
# (see the gnu make manual section about automatic variables)
.c.o:
$(CC) $(CFLAGS) $(JOIN_INCLUDES) $(INCLUDES) -c $< -o $@
clean:
rm -rf ./bin $(HTSTMP) ./tests/*.dSYM
$(RM) ./src/*.o *~ $(CAVEMAN_TARGET) $(UMNORM_TARGET) ./tests/tests_log $(TESTS) ./src/*.gcda ./src/*.gcov ./src/*.gcno *.gcda *.gcov *.gcno ./tests/*.gcda ./tests/*.gcov ./tests/*.gcno
depend: $(SRCS)
makedepend $(INCLUDES) $^
# DO NOT DELETE THIS LINE -- make depend needs it