-
Notifications
You must be signed in to change notification settings - Fork 105
/
Makefile.guix
111 lines (76 loc) · 3.74 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
# GNU Guix dev 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.
#
# But it is preferred to run in a Guix environment/container. For more
# information see INSTALL.md
D_COMPILER=ldc2
CC=gcc
CPP=gcc
BIOD_PATH=./BioD:./BioD/contrib/msgpack-d/src
# DLIBS = $(LIBRARY_PATH)/libphobos2-ldc.a $(LIBRARY_PATH)/libdruntime-ldc.a
# DLIBS_DEBUG = $(LIBRARY_PATH)/libphobos2-ldc-debug.a $(LIBRARY_PATH)/libdruntime-ldc-debug.a
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 = -L-L$(LDC_LIB_PATH) -L-lrt -L-lpthread -L-lm -L-lz -L-llz4
LIBS_STATIC = $(DLIBS) -L-lz -L-llz4 -L-lphobos2-ldc -L-ldruntime-ldc -L-lldc-jit-rt
SRC = $(wildcard main.d utils/*.d thirdparty/*.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 BioD/contrib/msgpack-d/src/msgpack/*.d) $(wildcard sambamba/*.d sambamba/*/*.d sambamba/*/*/*.d)
OBJ = $(SRC:.d=.o)
OUT = bin/sambamba-$(shell cat VERSION)
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 -fprofile-instr-generate=profile.raw $(RPATH)
profile: LIBS += -L=-lprofile_rt
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:
python ./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
build-setup: ldc_version_info
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)
# ---- Compile step
%.o: %.d
$(D_COMPILER) $(DFLAGS) -c $< -od=$(dir $@)
# ---- Link step
$(OUT): $(OBJ)
mkdir -p bin/
$(D_COMPILER) $(DFLAGS) -of=$(OUT) $(OBJ) $(LIBS)
test: clean-tests
./run_tests.sh $(OUT)
biod:
cd $(BIOD_PATH)/src_ragel && make
check: all debug test
debug-strip: debug
objcopy --only-keep-debug $(OUT) sambamba.debug
objcopy --strip-debug $(OUT)
objcopy --add-gnu-debuglink=sambamba.debug $(OUT)
mv sambamba.debug bin/
install:
install -m 0755 $(OUT) $(prefix)/bin
clean-c:
clean-d:
rm -v $(OBJ) $(OUT) # trace.{def,log}
rm -v bin/*
clean-tests:
rm -rf output/*
clean: clean-c clean-d clean-tests