-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
82 lines (63 loc) · 2.94 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
SDSL_DIR=../sdsl-lite
include $(SDSL_DIR)/Make.helper
BUILD_BIN=bin
BUILD_LIB=lib
BUILD_OBJ=obj
SOURCE_DIR=src
# Multithreading with OpenMP.
PARALLEL_FLAGS=-fopenmp -pthread
LIBS=-L$(LIB_DIR) -lsdsl -ldivsufsort -ldivsufsort64
# Apple Clang does not support OpenMP directly, so we need special handling.
ifeq ($(shell uname -s), Darwin)
# The compiler complains about -fopenmp instead of missing input.
ifeq ($(strip $(shell $(MY_CXX) -fopenmp /dev/null -o/dev/null 2>&1 | grep fopenmp | wc -l)), 1)
$(info The compiler is Apple Clang that needs libomp for OpenMP support.)
# The compiler only needs to do the preprocessing.
PARALLEL_FLAGS = -Xpreprocessor -fopenmp -pthread
# Find libomp installed by Homebrew or MacPorts.
ifeq ($(shell if [ -e $(HOMEBREW_PREFIX)/include/omp.h ]; then echo 1; else echo 0; fi), 1)
$(info Found libomp installed by Homebrew and linked to $(HOMEBREW_PREFIX).)
PARALLEL_FLAGS += -I$(HOMEBREW_PREFIX)/include
LIBS += -L$(HOMEBREW_PREFIX)/lib
else ifeq ($(shell if [ -d $(HOMEBREW_PREFIX)/opt/libomp/include ]; then echo 1; else echo 0; fi), 1)
$(info Found a keg-only libomp installed by Homebrew at $(HOMEBREW_PREFIX)/opt/libomp.)
PARALLEL_FLAGS += -I$(HOMEBREW_PREFIX)/opt/libomp/include
LIBS += -L$(HOMEBREW_PREFIX)/opt/libomp/lib
else ifeq ($(shell if [ -d /opt/local/lib/libomp ]; then echo 1; else echo 0; fi), 1)
$(info Found libomp installed by MacPorts at /opt/local.)
PARALLEL_FLAGS += -I/opt/local/include/libomp
LIBS += -L/opt/local/lib/libomp
else
$(error Could not find libomp. Please install it using Homebrew or MacPorts.)
endif
# We also need to link it.
LIBS += -lomp
endif
endif
CXX_FLAGS=$(MY_CXX_FLAGS) $(PARALLEL_FLAGS) $(MY_CXX_OPT_FLAGS) -Iinclude -I$(INC_DIR)
HEADERS=$(wildcard include/gbwt/*.h)
LIBOBJS=$(addprefix $(BUILD_OBJ)/,algorithms.o bwtmerge.o cached_gbwt.o dynamic_gbwt.o fast_locate.o files.o gbwt.o internal.o metadata.o support.o test.o utils.o variants.o)
LIBRARY=$(BUILD_LIB)/libgbwt.a
PROGRAMS=$(addprefix $(BUILD_BIN)/,build_gbwt build_ri merge_gbwt benchmark metadata_tool remove_seq)
OBSOLETE=build_gbwt build_ri merge_gbwt benchmark metadata_tool remove_seq
.PHONY: all clean directories test
all: directories $(LIBRARY) $(PROGRAMS)
directories: $(BUILD_BIN) $(BUILD_LIB) $(BUILD_OBJ)
$(BUILD_BIN):
mkdir -p $@
$(BUILD_LIB):
mkdir -p $@
$(BUILD_OBJ):
mkdir -p $@
$(BUILD_OBJ)/%.o:$(SOURCE_DIR)/%.cpp $(HEADERS)
$(MY_CXX) $(CPPFLAGS) $(CXXFLAGS) $(CXX_FLAGS) -c -o $@ $<
$(LIBRARY):$(LIBOBJS)
ar rcs $@ $(LIBOBJS)
$(BUILD_BIN)/%:$(BUILD_OBJ)/%.o $(LIBRARY)
$(MY_CXX) $(LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(CXX_FLAGS) -o $@ $< $(LIBRARY) $(LIBS)
test:$(LIBRARY)
cd tests && $(MAKE) test
clean:
rm -rf $(BUILD_BIN) $(BUILD_LIB) $(BUILD_OBJ)
rm -f *.o *.a $(OBSOLETE)
cd tests && $(MAKE) clean