-
Notifications
You must be signed in to change notification settings - Fork 107
/
Makefile
130 lines (101 loc) · 3.67 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
# This is a minimalistic make file to build sambamba with ldc2 as per instructions on
# https://github.com/biod/sambamba#compiling-sambamba
#
# Note that this make file generates the most optimal binary for
# sambamba (as a single run of ldc2 with aggressive inlining). For
# development you may want to opt for meson+ninja or Makefile.guix instead.
#
# Targets (64-bit):
#
# Linux
# OSX
#
# Typical usage:
#
# make LIBRARY_PATH=~/opt/ldc2-$ver-linux-x86_64/lib debug|profile|release|static
#
# Example with GNU Guix
#
# env CC=gcc make VERBOSE=1 LIBRARY_PATH=/gnu/store/milyb96bnbnz7a107h7imswq1y5qhhk4-ldc-1.32.2/lib:$GUIX_ENVIRONMENT/lib static
#
# (note that we use gcc for linking and it requires setting the lib path to find D's static libs)
#
# Static release with optimization (for releases):
#
# env CC=gcc make static
#
# Debug version
#
# make debug VERBOSE=1
#
D_COMPILER=ldc2
CC=gcc
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SYS = OSX
else
SYS = LINUX
endif
BIOD_PATH=./BioD:./BioD/contrib/msgpack-d/src
DFLAGS = -wi -I. -I$(BIOD_PATH) -g -J.
LDFLAGS = -L=-flto=full
PREFIX = /usr/local
# 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
# LIBS = -L-L$(LIBRARY_PATH) -L-lpthread -L-lm -L-lz -L-llz4
LIBS = -L-lz -L-llz4
LIBS_STATIC = -L-lz -L-llz4 -L-L$(LIBRARY_PATH) -L-lphobos2-ldc -L-ldruntime-ldc
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)
.PHONY: all debug release static clean test
all: release
debug: DFLAGS += -O0 -d-debug -link-debuglib
profile: DFLAGS += -fprofile-instr-generate=profile.raw
coverage: DFLAGS += -cov
release static pgo-static: DFLAGS += -O3 -release -enable-inlining -boundscheck=off
static: DFLAGS += -static -L-Bstatic -link-defaultlib-shared=false $(LIBS_STATIC)
pgo-static: DFLAGS += -fprofile-instr-use=profile.data
# note use python3 for github CI:
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
build-setup: ldc_version_info
mkdir -p bin/
default debug release static: $(OUT)
coverage: debug
profile: debug
$(OUT) sort /gnu/data/in_raw.bam -p > /dev/null
ldc-profdata merge -output=profile.data profile.raw
rm $(OUT) ./bin/sambamba.o # trigger rebuild
default: all
# ---- Compile step
%.o: %.d
$(D_COMPILER) $(DFLAGS) -c $< -od=$(dir $@)
singleobj: build-setup
$(info compile single object...)
$(D_COMPILER) -singleobj $(DFLAGS) -c -of=$(OUT).o $(SRC)
# ---- Link step
$(OUT): singleobj
$(info linking...)
$(D_COMPILER) $(DFLAGS) $(LDFLAGS) -of=$(OUT) $(OUT).o $(LINK_OBJ) $(LIBS)
test: $(OUT)
$(OUT) --version
./run_tests.sh $(OUT)
check: test
debug-strip:
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/
pgo-static: static debug-strip
install:
install -m 0755 $(OUT) $(PREFIX)/bin
clean: clean-d
rm -f profile.data
rm -f profile.raw
clean-d:
rm -rf bin/*
rm -vf utils/ldc_version_info_.d
rm -f $(OBJ) $(OUT) trace.{def,log}