forked from biod/sambamba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.guix
124 lines (89 loc) · 3.99 KB
/
Makefile.guix
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
# GNU Guix makefile. GNU Guix is the package manager for GNU and we
# use it for sambamba development and deployment. Normally use the
# standard Makefile instead because it compiles into a singleobj which
# gives better performance. This Makefile is for development purposes.
#
# To build sambamba on GNU Guix:
#
# make -f Makefile.guix GUIX=~/opt/sambamba-dev-env
#
# run with
#
# ./bin/sambamba
#
# But it is preferred to run in a Guix environment/container. For more
# information see INSTALL.md
#
D_COMPILER=ldc2
BIOD_PATH=./BioD
DFLAGS = -wi -I. -I$(BIOD_PATH) -J.
# DLIBS = $(LDC_LIB_PATH)/libphobos2-ldc.a $(LDC_LIB_PATH)/libdruntime-ldc.a
# DLIBS_DEBUG = -debuglib=phobos2-ldc-debug,druntime-ldc-debug $(LDC_LIB_PATH)/libphobos2-ldc-debug.a $(LDC_LIB_PATH)/libdruntime-ldc-debug.a -link-debuglib
DLIBS_DEBUG = -debuglib=phobos2-ldc-debug-shared,druntime-ldc-debug-shared -link-debuglib -L-lphobos2-ldc-debug-shared -L-ldruntime-ldc-debug-shared
# RPATH = -L--rpath=$(dir $(realpath $(LDC_LIB_PATH)/libz.so)):$(dir $(realpath $(LDC_LIB_PATH)/liblz4.so))
RPATH = -L--rpath=$(LIBRARY_PATH)
LIBS = htslib/libhts.a -L-L$(LDC_LIB_PATH) -L-lrt -L-lpthread -L-lm -L-lz lz4/lib/liblz4.a
# LIBS = htslib/libhts.a -L-lrt -L-lpthread -L-lm -L-lz -L-llz4
LIBS_STATIC = $(DLIBS) htslib/libhts.a lz4/lib/liblz4.a
SRC = $(wildcard main.d utils/*.d thirdparty/*.d cram/*.d) $(wildcard BioD/contrib/undead/*.d BioD/contrib/undead/*/*.d) $(wildcard BioD/bio/*/*.d BioD/bio/*/*/*.d BioD/bio/*/*/*/*.d BioD/bio/*/*/*/*/*.d BioD/bio/*/*/*/*/*/*/*.d) $(wildcard sambamba/*.d sambamba/*/*.d sambamba/*/*/*.d)
OBJ = $(SRC:.d=.o) utils/ldc_version_info_.o
OUT = bin/sambamba-$(shell cat VERSION)
debug: OUT += -debug
static: OUT += -static
.PHONY: all guix guix-debug debug release static profile clean test
# The Guix targets resolve the RPATH automatically
guix: DFLAGS += -O -release -g # Guix strips debug flags
guix-debug: DFLAGS += -O0 -g -d-debug -unittest
# The following options are run in development from ~/.guix-profile and need to inject the RPATH
debug: DFLAGS += -O0 -g -d-debug $(RPATH) -link-debuglib -unittest
release static: DFLAGS += -O3 -release $(RPATH) -enable-inlining -Hkeep-all-bodies -boundscheck=off
static: DFLAGS += -static -L-Bstatic -L-L/gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glibc-2.25/lib/
profile: DFLAGS += -g -O -profile $(RPATH)
guix release: LIBS += $(DLIBS)
static: LIBS = $(LIBS_STATIC)
guix-debug debug profile: LIBS += $(DLIBS_DEBUG)
all: debug
# bio2/pileup.d: bio2/bam/reader.d
# sambamba/subsample.d: bio2/pileup.d
utils/ldc_version_info_.d:
python3 ./gen_ldc_version_info.py $(shell which ldmd2) > utils/ldc_version_info_.d
cat utils/ldc_version_info_.d
ldc_version_info: utils/ldc_version_info_.d
lz4/lib/liblz4.a: lz4/lib/lz4.c lz4/lib/lz4hc.c lz4/lib/lz4frame.c lz4/lib/xxhash.c
cd lz4/lib && gcc -O3 -c lz4.c lz4hc.c lz4frame.c xxhash.c && $(AR) rcs liblz4.a lz4.o lz4hc.o lz4frame.o xxhash.o
lz4-static: lz4/lib/liblz4.a
build-setup: ldc_version_info lz4-static htslib-static
mkdir -p bin/
# utils/ldc_version_info_.o: utils/ldc_version_info_.d
# $(D_COMPILER) $(DFLAGS) -c utils/ldc_version_info_.d -od=$(dir $@)
guix guix-debug default debug release static profile: ldc_version_info $(OUT)
debug: lz4-static
# ---- Compile step
%.o: %.d
$(D_COMPILER) $(DFLAGS) -c $< -od=$(dir $@)
# ---- Link step
$(OUT): $(OBJ)
cd htslib && $(MAKE)
mkdir -p bin/
$(D_COMPILER) $(DFLAGS) -of=$(OUT) $(OBJ) $(LIBS)
test: clean-tests
./run_tests.sh
biod:
cd $(BIOD_PATH)/src_ragel && make
check: all test
debug-strip: debug
objcopy --only-keep-debug bin/sambamba sambamba.debug
objcopy --strip-debug bin/sambamba
objcopy --add-gnu-debuglink=sambamba.debug bin/sambamba
mv sambamba.debug bin/
install:
install -m 0755 bin/sambamba $(prefix)/bin
clean-c:
cd htslib ; make clean
rm -v lz4/lib/*.[oa]
clean-d:
rm -v $(OBJ) $(OUT) trace.{def,log}
rm -v bin/*
clean-tests:
rm -rf output/*
clean: clean-c clean-d clean-tests