-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile_legacy
202 lines (164 loc) · 10.2 KB
/
Makefile_legacy
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#for libdivsufsort, cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="../../lib" .. -DBUILD_DIVSUFSORT64:BOOL=ON
#when calling, allow for setting the DESTDIR env variable
#when calling, allow for the #DONT_INSTALL_DIVSUFSORT env variable
#todo: documentation for calling git clone with --recurse-submodules or use git submodule init & git submodule update
SHELL = /bin/sh
PREFIX = /usr/local
AWFMINDEX_PROJECT_NAME = awfmindex
AWFMINDEX_MAJOR_VERSION_NUM = 2
AWFMINDEX_MINOR_VERSION_NUM = 0
AWFMINDEX_VERSION = $(MAJOR).$(MINOR)
#filenames
AWFMINDEX_HEADER_FILENAME = AwFmIndex.h
AWFMINDEX_SHARED_LIB_FILENAME = libawfmindex.so
AWFMINDEX_STATIC_LIB_FILENAME = libawfmindex.a
LIBDIVSUFSORT_HEADER_FILENAME = divsufsort64.h
LIBDIVSUFSORT_STATIC_LIB_FILENAME = libdivsufsort64.a
FASTA_VECTOR_HEADER_FILENAME = FastaVector.h
FASTA_VECTOR_STRING_HEADER_FILENAME = FastaVectorString.h
FASTA_VECTOR_METADATA_HEADER_FILENAME = FastaVectorMetadataVector.h
FASTA_VECTOR_STATIC_LIB_FILENAME = libfastavector.a
#determine the current operating system and architecture.
OS_NAME = $(shell uname -s)
ARCH_NAME = $(shell uname -p) #currently unused.
ifeq ($(OS_NAME), Darwin)
AWFMINDEX_SHARED_LIB_FILENAME = libawfmindex.dylib
endif
#directories
AWFMINDEX_PROJECT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
AWFMINDEX_BUILD_DIR = $(AWFMINDEX_PROJECT_DIR)/build
AWFMINDEX_SRC_DIR = $(AWFMINDEX_PROJECT_DIR)/src
AWFMINDEX_BUILD_INCLUDE_DIR = $(AWFMINDEX_BUILD_DIR)/include
AWFMINDEX_BUILD_LIBRARY_DIR = $(AWFMINDEX_BUILD_DIR)/lib
AWFMINDEX_INSTALL_INCLUDE_DIR = $(DESTDIR)$(PREFIX)/include
AWFMINDEX_INSTALL_LIBRARY_DIR = $(DESTDIR)$(PREFIX)/lib
LIBDIVSUFSORT_PROJECT_DIR = $(AWFMINDEX_PROJECT_DIR)/lib/libdivsufsort
LIBDIVSUFSORT_BUILD_DIR = $(LIBDIVSUFSORT_PROJECT_DIR)/build
LIBDIVSUFSORT_BUILD_INCLUDE_DIR = $(LIBDIVSUFSORT_BUILD_DIR)/include
LIBDIVSUFSORT_BUILD_LIBRARY_DIR = $(LIBDIVSUFSORT_BUILD_DIR)/lib
FASTA_VECTOR_PROJECT_DIR = $(AWFMINDEX_PROJECT_DIR)/lib/FastaVector
FASTA_VECTOR_SRC_DIR = $(FASTA_VECTOR_PROJECT_DIR)/src
FASTA_VECTOR_BUILD_DIR = $(FASTA_VECTOR_PROJECT_DIR)/build
FASTA_VECTOR_BUILD_INCLUDE_DIR = $(FASTA_VECTOR_BUILD_DIR)/include
FASTA_VECTOR_BUILD_LIB_DIR = $(FASTA_VECTOR_BUILD_DIR)/lib
#file locations
AWFMINDEX_SRC_HEADER_FILE = $(AWFMINDEX_SRC_DIR)/$(AWFMINDEX_HEADER_FILENAME)
AWFMINDEX_BUILD_HEADER_FILE = $(AWFMINDEX_BUILD_INCLUDE_DIR)/$(AWFMINDEX_HEADER_FILENAME)
AWFMINDEX_BUILD_SHARED_LIB_FILE = $(AWFMINDEX_BUILD_LIBRARY_DIR)/$(AWFMINDEX_SHARED_LIB_FILENAME)
AWFMINDEX_BUILD_STATIC_LIB_FILE = $(AWFMINDEX_BUILD_LIBRARY_DIR)/$(AWFMINDEX_STATIC_LIB_FILENAME)
AWFMINDEX_INSTALL_HEADER_FILE = $(AWFMINDEX_INSTALL_INCLUDE_DIR)/$(AWFMINDEX_HEADER_FILENAME)
AWFMINDEX_INSTALL_STATIC_LIB_FILE = $(AWFMINDEX_INSTALL_LIBRARY_DIR)/$(AWFMINDEX_STATIC_LIB_FILENAME)
AWFMINDEX_INSTALL_SHARED_LIB_FILE = $(AWFMINDEX_INSTALL_LIBRARY_DIR)/$(AWFMINDEX_SHARED_LIB_FILENAME)
LIBDIVSUFSORT_BUILD_HEADER_FILE = $(LIBDIVSUFSORT_BUILD_INCLUDE_DIR)/$(LIBDIVSUFSORT_HEADER_FILENAME)
LIBDIVSUFSORT_BUILD_STATIC_LIBRARY_FILE = $(LIBDIVSUFSORT_BUILD_LIBRARY_DIR)/$(LIBDIVSUFSORT_STATIC_LIB_FILENAME)
LIBDIVSUFSORT_INSTALL_HEADER_FILE = $(AWFMINDEX_INSTALL_INCLUDE_DIR)/$(LIBDIVSUFSORT_HEADER_FILENAME)
FASTA_VECTOR_BUILD_HEADER_FILE = $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_HEADER_FILENAME)
FASTA_VECTOR_BUILD_STRING_HEADER_FILE = $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_STRING_HEADER_FILENAME)
FASTA_VECTOR_BUILD_METADATA_HEADER_FILE = $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_METADATA_HEADER_FILENAME)
FASTA_VECTOR_BUILD_STATIC_LIBRARY_FILE = $(FASTA_VECTOR_BUILD_LIB_DIR)/$(FASTA_VECTOR_STATIC_LIB_FILENAME)
FASTA_VECTOR_INSTALL_HEADER_FILE = $(AWFMINDEX_INSTALL_INCLUDE_DIR)/$(FASTA_VECTOR_HEADER_FILENAME)
FASTA_VECTOR_INSTALL_STRING_HEADER_FILE = $(AWFMINDEX_INSTALL_INCLUDE_DIR)/$(FASTA_VECTOR_STRING_HEADER_FILENAME)
FASTA_VECTOR_INSTALL_METADATA_HEADER_FILE = $(AWFMINDEX_INSTALL_INCLUDE_DIR)/$(FASTA_VECTOR_METADATA_HEADER_FILENAME)
LIBDIVSUFSORT_BUILD_HEADER_FILE_STATIC_DEST = $(AWFMINDEX_BUILD_INCLUDE_DIR)/$(LIBDIVSUFSORT_HEADER_FILENAME)
FASTA_VECTOR_BUILD_HEADER_FILE_DEST = $(AWFMINDEX_BUILD_INCLUDE_DIR)/$(FASTA_VECTOR_HEADER_FILENAME)
FASTA_VECTOR_BUILD_STRING_HEADER_FILE_DEST = $(AWFMINDEX_BUILD_INCLUDE_DIR)/$(FASTA_VECTOR_STRING_HEADER_FILENAME)
FASTA_VECTOR_BUILD_STRING_METADATA_FILE_DEST = $(AWFMINDEX_BUILD_INCLUDE_DIR)/$(FASTA_VECTOR_METADATA_HEADER_FILENAME)
LIBDIVSUFSORT_BUILD_STATIC_LIBRARY_FILE_DEST = $(AWFMINDEX_BUILD_LIBRARY_DIR)/$(LIBDIVSUFSORT_STATIC_LIB_FILENAME)
FASTA_VECTOR_BUILD_STATIC_LIBRARY_FILE_DEST = $(AWFMINDEX_BUILD_LIBRARY_DIR)/$(FASTA_VECTOR_STATIC_LIB_FILENAME)
LIBDIVSUFSORT_BUILD_SHARED_LIBRARY_FILE_DEST = $(AWFMINDEX_BUILD_LIBRARY_DIR)/$()
#if on a Mac system, CC may need to be overwritten with a makefile argument to compile with
#an actual GCC compiler instead of the clang that ships native with mac.
ARCH = $(shell uname -m)
CC ?= gcc
ifeq ($(ARCH),x86_64)
CFLAGS = -std=gnu11 -fpic -O3 -mtune=native -march=native -Wall -Wextra -fopenmp -mavx2
else
CFLAGS = -std=gnu11 -fpic -O3 -mtune=native -march=native -Wall -Wextra -fopenmp
endif
LDFLAGS = -shared -L$(LIBDIVSUFSORT_BUILD_LIBRARY_DIR) -L$(FASTA_VECTOR_BUILD_LIB_DIR) -I$(LIBDIVSUFSORT_BUILD_INCLUDE_DIR) -ldivsufsort64 -lfastavector # linking flags
SOURCE_FILES := $(wildcard $(AWFMINDEX_SRC_DIR)/*.c)
OBJECT_FILES := $(patsubst $(AWFMINDEX_SRC_DIR)/%, $(AWFMINDEX_BUILD_DIR)/%, $(SOURCE_FILES:.c=.o))
#rules
.PHONY: all
all: $(LIBDIVSUFSORT_BUILD_STATIC_LIBRARY_FILE) $(FASTA_VECTOR_BUILD_STATIC_LIBRARY_FILE) $(AWFMINDEX_BUILD_LIBRARY_DIR) $(OBJECT_FILES) $(AWFMINDEX_BUILD_HEADER_FILE)
$(CC) -fpic -fopenmp -o $(AWFMINDEX_BUILD_SHARED_LIB_FILE) $(OBJECT_FILES) $(LDFLAGS)
cp $(LIBDIVSUFSORT_BUILD_HEADER_FILE) $(LIBDIVSUFSORT_BUILD_HEADER_FILE_STATIC_DEST)
cp $(FASTA_VECTOR_BUILD_HEADER_FILE) $(FASTA_VECTOR_BUILD_HEADER_FILE_DEST)
cp $(FASTA_VECTOR_BUILD_STRING_HEADER_FILE) $(FASTA_VECTOR_BUILD_STRING_HEADER_FILE_DEST)gy
cp $(FASTA_VECTOR_BUILD_METADATA_HEADER_FILE) $(FASTA_VECTOR_BUILD_STRING_METADATA_FILE_DEST)
.PHONY: install
install:
mkdir -p $(DESTDIR)$(PREFIX)/lib
mkdir -p $(DESTDIR)$(PREFIX)/include
cp $(LIBDIVSUFSORT_BUILD_HEADER_FILE) $(LIBDIVSUFSORT_INSTALL_HEADER_FILE)
cp $(AWFMINDEX_SRC_HEADER_FILE) $(AWFMINDEX_INSTALL_HEADER_FILE)
cp $(FASTA_VECTOR_BUILD_HEADER_FILE) $(FASTA_VECTOR_INSTALL_HEADER_FILE)
cp $(FASTA_VECTOR_BUILD_STRING_HEADER_FILE) $(FASTA_VECTOR_INSTALL_STRING_HEADER_FILE)
cp $(FASTA_VECTOR_BUILD_METADATA_HEADER_FILE) $(FASTA_VECTOR_INSTALL_METADATA_HEADER_FILE)
ifneq ("$(wildcard $(AWFMINDEX_BUILD_SHARED_LIB_FILE))","")
cp $(AWFMINDEX_BUILD_SHARED_LIB_FILE) $(AWFMINDEX_INSTALL_SHARED_LIB_FILE)
endif
ifneq ("$(wildcard $(AWFMINDEX_BUILD_STATIC_LIB_FILE))","")
cp $(AWFMINDEX_BUILD_STATIC_LIB_FILE) $(AWFMINDEX_INSTALL_STATIC_LIB_FILE)
endif
#make the static libs
.PHONY: static
static: $(LIBDIVSUFSORT_BUILD_STATIC_LIBRARY_FILE) $(FASTA_VECTOR_BUILD_STATIC_LIBRARY_FILE) $(AWFMINDEX_BUILD_LIBRARY_DIR) $(OBJECT_FILES) $(AWFMINDEX_BUILD_HEADER_FILE)
ar rcs $(AWFMINDEX_BUILD_STATIC_LIB_FILE) $(OBJECT_FILES)
#make the libdivsufsort static lib copy in the build directory
cp $(LIBDIVSUFSORT_BUILD_HEADER_FILE) $(LIBDIVSUFSORT_BUILD_HEADER_FILE_STATIC_DEST)
cp $(FASTA_VECTOR_BUILD_HEADER_FILE) $(FASTA_VECTOR_BUILD_HEADER_FILE_DEST)
cp $(FASTA_VECTOR_BUILD_STRING_HEADER_FILE) $(FASTA_VECTOR_BUILD_STRING_HEADER_FILE_DEST)
cp $(FASTA_VECTOR_BUILD_METADATA_HEADER_FILE) $(FASTA_VECTOR_BUILD_STRING_METADATA_FILE_DEST)
cp $(LIBDIVSUFSORT_BUILD_STATIC_LIBRARY_FILE) $(LIBDIVSUFSORT_BUILD_STATIC_LIBRARY_FILE_DEST)
cp $(FASTA_VECTOR_BUILD_STATIC_LIBRARY_FILE) $(FASTA_VECTOR_BUILD_STATIC_LIBRARY_FILE_DEST)
clean:
rm -rf $(AWFMINDEX_BUILD_DIR)
cd $(LIBDIVSUFSORT_BUILD_DIR) && make clean
.PHONY: uninstall
uninstall:
rm -f $(AWFMINDEX_INSTALL_SHARED_LIB_FILE)
rm -f $(AWFMINDEX_INSTALL_STATIC_LIB_FILE)
rm -f $(AWFMINDEX_INSTALL_HEADER_FILE)
rm -f $(LIBDIVSUFSORT_INSTALL_HEADER_FILE)
rm -f $(FASTA_VECTOR_INSTALL_HEADER_FILE)
rm -f $(FASTA_VECTOR_INSTALL_STRING_HEADER_FILE)
rm -f $(FASTA_VECTOR_INSTALL_METADATA_HEADER_FILE)
rm -f $(LIBDIVSUFSORT_BUILD_HEADER_FILE_STATIC_DEST)
rm -f $(FASTA_VECTOR_BUILD_HEADER_FILE_DEST)
rm -f $(FASTA_VECTOR_BUILD_STRING_HEADER_FILE_DEST)
rm -f $(FASTA_VECTOR_BUILD_STRING_METADATA_FILE_DEST)
rm -f $(LIBDIVSUFSORT_BUILD_STATIC_LIBRARY_FILE_DEST)
rm -f $(FASTA_VECTOR_BUILD_STATIC_LIBRARY_FILE_DEST)
cd $(LIBDIVSUFSORT_BUILD_DIR) && make uninstall
cd $(FASTA_VECTOR_PROJECT_DIR) && make uninstall
# builds libdivsufsort into a static library
$(LIBDIVSUFSORT_BUILD_STATIC_LIBRARY_FILE): $(LIBDIVSUFSORT_PROJECT_DIR)/.git $(LIBDIVSUFSORT_BUILD_DIR) $(LIBDIVSUFSORT_PROJECT_DIR) $(AWFMINDEX_BUILD_DIR)
cd $(LIBDIVSUFSORT_BUILD_DIR) && cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE="Release" -DUSE_OPENMP="ON" -DBUILD_SHARED_LIBS="OFF" -DBUILD_DIVSUFSORT64:BOOL=ON -DCMAKE_INSTALL_PREFIX="$(AWFMINDEX_BUILD_DIR)" .. && make
$(FASTA_VECTOR_BUILD_STATIC_LIBRARY_FILE): $(FASTA_VECTOR_PROJECT_DIR)/.git
cd $(FASTA_VECTOR_PROJECT_DIR) && make -f Makefile_legacy static
#create the object files from each c file in the src directory
$(AWFMINDEX_BUILD_DIR)/%.o: $(AWFMINDEX_SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@ -I $(LIBDIVSUFSORT_BUILD_INCLUDE_DIR) -I $(FASTA_VECTOR_BUILD_INCLUDE_DIR)
#initialize the libdivsufsort project submodule if not already done
$(LIBDIVSUFSORT_PROJECT_DIR)/.git:
git submodule init
git submodule update
$(FASTA_VECTOR_PROJECT_DIR)/.git:
git submodule init
git submodule update
#copy the AwFmIndex.h header to the build directory
$(AWFMINDEX_BUILD_HEADER_FILE): $(AWFMINDEX_BUILD_INCLUDE_DIR)
cp $(AWFMINDEX_SRC_HEADER_FILE) $(AWFMINDEX_BUILD_HEADER_FILE)
#make the libdivsufsort build directory if not already done
$(LIBDIVSUFSORT_BUILD_DIR): $(LIBDIVSUFSORT_PROJECT_DIR)/.git
mkdir -p $(LIBDIVSUFSORT_BUILD_DIR)
#make the AwFmIndex build lib directory
$(AWFMINDEX_BUILD_LIBRARY_DIR):
mkdir -p $(AWFMINDEX_BUILD_LIBRARY_DIR)
#make the AwFmIndex build lib directory
$(AWFMINDEX_BUILD_DIR):
mkdir -p $(AWFMINDEX_BUILD_DIR)
#make the AwFmIndex build include directory
$(AWFMINDEX_BUILD_INCLUDE_DIR):
mkdir -p $(AWFMINDEX_BUILD_INCLUDE_DIR)