forked from amazon-archives/amazon-dsstne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
77 lines (61 loc) · 1.63 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
MODULE_ROOT = $(shell pwd)
BUILD_DIR ?= ../build
DSSTNE_SRC_DIR = ../src/amazon/dsstne
SOURCES_DIR = src/main/native
TEST_DIR = src/test/native
OBJECTS_DIR = target/native/build
LIBRARY_DIR = target/lib
BIN_DIR = target/bin
LIBRARY = $(LIBRARY_DIR)/libdsstne_java.so
MAIN = main.o
INC = \
/usr/lib/jvm/java-1.8.0-openjdk-amd64/include \
/usr/lib/jvm/java-8-openjdk-amd64/include/linux \
/usr/local/cuda/include \
/usr/include/jsoncpp \
/usr/lib/openmpi/include \
/usr/lib/openmpi/include/openmpi \
../src # dsstne headers
INCLUDES ?= $(INC:%=-I%)
LIB = \
$(BUILD_DIR)/lib \
/usr/local/cuda/lib64 \
/usr/lib/openmpi/lib
LIBS ?= $(LIB:%=-L%)
LLIB = \
cudnn \
curand \
cublas \
cudart \
jsoncpp \
netcdf \
netcdf_c++4 \
blas \
dl \
stdc++ \
mpi_cxx \
mpi \
dsstne_engine \
dsstne_runtime
LOAD_LIBS = $(LLIB:%=-l%)
SOURCES=$(shell find '$(SOURCES_DIR)' -type f -name '*.cpp')
OBJECTS=$(SOURCES:$(SOURCES_DIR)/%.cpp=$(OBJECTS_DIR)/%.o)
CC = g++
CFLAGS ?=-Wall -fPIC -std=c++11 -pthread -O3
LDFLAGS ?= -fPIC
all: $(LIBRARY)
mkdir -p $(BUILD_DIR)/lib
cp -fp $(LIBRARY) $(BUILD_DIR)/lib
main:
$(info ========== Building main =============)
mkdir -p $(BIN_DIR)
$(CC) -g $(CFLAGS) -Wl,-rpath=/usr/local/cuda/lib64 $(INCLUDES) $(LIBS) src/test/native/main.cpp -o $(BIN_DIR)/main.o $(LOAD_LIBS)
$(LIBRARY): $(OBJECTS) $(LIB_DSSTNE)
$(info ========== Building JNI Libs ==========)
mkdir -p $(LIBRARY_DIR)
$(CC) -shared $(LDFLAGS) $(LIBS) $(OBJECTS) -o $@ $(LOAD_LIBS)
$(OBJECTS_DIR)/%.o: $(SOURCES_DIR)/%.cpp
mkdir -p $(OBJECTS_DIR)
$(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@
clean:
rm -rf $(OBJECTS_DIR) $(LIBRARY) $(BIN_DIR)