-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
executable file
·138 lines (92 loc) · 4.26 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
134
135
136
137
BIN_NAME=minialign
BIN_DEBUG = ./bin/$(BIN_NAME)
BIN_LINUX = ./bin/$(BIN_NAME)
BIN_MAC = ./bin/$(BIN_NAME)-mac
OBJ_DEBUG = ./obj_debug
OBJ_LINUX = ./obj_linux
OBJ_MAC = ./obj_mac
SOURCE = src
CODEBASE = codebase
# This finds all 'src' folders at maximum depth 2 (level one inside each submodule's folder).
CODEBASE_SRC_FOLDERS = $(shell find $(CODEBASE) -maxdepth 2 -type d -name "src" -exec echo "-I"{} \;)
# ? allows override by user using env var
GCC ?= g++
# define variables for GCC version check here
GCC_MAJOR_VERSION_GE_4 := $(shell expr `$(GCC) -dumpversion | cut -f1 -d.` \>= 4)
GCC_MINOR_VERSION_GE_7 := $(shell expr `$(GCC) -dumpversion | cut -f2 -d.` \>= 7)
GCC_MAC ?= /opt/local/bin/g++-mp-4.8
CPP_FILES := $(wildcard $(CODEBASE)/*/src/*.cpp) $(wildcard $(CODEBASE)/*/src/*/*.cpp) $(wildcard $(SOURCE)/*/*.cpp) $(wildcard $(SOURCE)/*.cpp)
CC_FILES := $(wildcard $(CODEBASE)/*/src/*.cc) $(wildcard $(CODEBASE)/*/src/*/*.cc) $(wildcard $(SOURCE)/*/*.cc) $(wildcard $(SOURCE)/*.cc)
H_FILES := $(wildcard $(CODEBASE)/*/src/*.h) $(wildcard $(CODEBASE)/*/src/*/*.h) $(wildcard $(SOURCE)/*/*.h) $(wildcard $(SOURCE)/*.h) $(wildcard $(CODEBASE)/*/src/*.hpp) $(wildcard $(CODEBASE)/*/src/*/*.hpp) $(wildcard $(SOURCE)/*/*.hpp) $(wildcard $(SOURCE)/*.hpp)
OBJ_FILES := $(CPP_FILES:.cpp=.o) $(CC_FILES:.cc=.o)
OBJ_FILES_FOLDER_DEBUG := $(addprefix $(OBJ_DEBUG)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_LINUX := $(addprefix $(OBJ_LINUX)/,$(OBJ_FILES))
OBJ_FILES_FOLDER_MAC := $(addprefix $(OBJ_MAC)/,$(OBJ_FILES))
LIB_DIRS = -L"/usr/local/lib"
CC_LIBS = -static-libgcc -static-libstdc++ -D__cplusplus=201103L
INCLUDE = -I"./src/" -I"/usr/include/" $(CODEBASE_SRC_FOLDERS)
# -I"codebase/.*/src/"
# -I$(wildcard $(CODEBASE)/*/src/)
# -I"codebase/seqlib/src/"
CC_FLAGS_DEBUG = -O0 -g -rdynamic -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -pthread -march=native
CC_FLAGS_RELEASE = -O3 -fdata-sections -ffunction-sections -c -fmessage-length=0 -ffreestanding -fopenmp -m64 -std=c++11 -Werror=return-type -pthread -march=native
LD_FLAGS = -static-libgcc -static-libstdc++ -m64 -ffreestanding
LD_LIBS = -lpthread -lgomp -lm -lz
all: gcc_version_check linux
modules:
git submodule update --init --recursive
# git submodule foreach git pull origin master
gcc_version_check:
ifneq ($(GCC_MAJOR_VERSION_GE_4), 1)
$(warning "*** WARNING $(GCC) major version <4 ***")
endif
ifneq ($(GCC_MINOR_VERSION_GE_7), 1)
$(warning "*** WARNING $(GCC) minor version <7 ***")
endif
tools:
mkdir -p tools; cd tools && git clone https://github.com/lh3/minimap.git && cd minimap && make
debug: $(OBJ_FILES_FOLDER_DEBUG)
mkdir -p $(dir $(BIN_DEBUG))
$(GCC) $(LD_FLAGS) $(LIB_DIRS) -o $(BIN_DEBUG) $(OBJ_FILES_FOLDER_DEBUG) $(LD_LIBS)
obj_debug/%.o: %.cc $(H_FILES)
mkdir -p $(dir $@)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_DEBUG) -o $@ $<
obj_debug/%.o: %.cpp $(H_FILES)
mkdir -p $(dir $@)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_DEBUG) -o $@ $<
linux: $(OBJ_FILES_FOLDER_LINUX)
mkdir -p $(dir $(BIN_LINUX))
$(GCC) $(LD_FLAGS) $(LIB_DIRS) -o $(BIN_LINUX) $(OBJ_FILES_FOLDER_LINUX) $(LD_LIBS)
obj_linux/%.o: %.cc $(H_FILES)
mkdir -p $(dir $@)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_RELEASE) -o $@ $<
obj_linux/%.o: %.cpp $(H_FILES)
mkdir -p $(dir $@)
$(GCC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_RELEASE) -o $@ $<
mac: $(OBJ_FILES_FOLDER_MAC)
mkdir -p $(dir $(BIN_MAC))
$(GCC_MAC) $(LD_FLAGS) $(LIB_DIRS) -o $(BIN_MAC) $(OBJ_FILES_FOLDER_MAC) $(LD_LIBS)
obj_mac/%.o: %.cc $(H_FILES)
mkdir -p $(dir $@)
$(GCC_MAC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_RELEASE) -o $@ $<
obj_mac/%.o: %.cpp $(H_FILES)
mkdir -p $(dir $@)
$(GCC_MAC) $(CC_LIBS) $(INCLUDE) $(CC_FLAGS_RELEASE) -o $@ $<
deps:
cd libs; cd libdivsufsort-2.0.1; make clean; rm -rf build; ./configure; mkdir build ;cd build; cmake -DBUILD_DIVSUFSORT64:BOOL=ON -DCMAKE_BUILD_TYPE="Release" -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX="/usr/local" .. ; make
clean: cleanall
cleandebug:
-rm -rf $(OBJ_DEBUG) $(BIN_DEBUG)
cleanlinux:
-rm -rf $(OBJ_LINUX) $(BIN_LINUX)
cleanmac:
-rm -rf $(OBJ_MAC) $(BIN_MAC)
cleanbin:
-rm -rf bin/
cleanall: cleanlinux cleandebug cleanmac cleanbin
rebuild: clean all
rebuilddebug: cleandebug debug
rebuildlinux: cleanlinux linux
rebuildmac: cleanmac mac
divsufsort:
cd libs; ./build-libdivsufsort.sh