forked from cbalint13/pba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
72 lines (54 loc) · 2.11 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
#To use AVX instead of SSE, you need to add -DCPUPBA_USE_AVX to CFLAGS
#################################################################
CUDA_INSTALL_PATH = /usr/local/cuda
CUDA_LIB_PATH = $(CUDA_INSTALL_PATH)/lib64
ifdef CUDA_BIN_PATH
NVCC = $(CUDA_BIN_PATH)/nvcc
else
NVCC = $(CUDA_INSTALL_PATH)/bin/nvcc
endif
ifndef CUDA_INC_PATH
CUDA_INC_PATH = $(CUDA_INSTALL_PATH)/include
endif
#################################################################
# detect OS
OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:])
OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:])
DARWIN = $(strip $(findstring DARWIN, $(OSUPPER)))
SHELL = /bin/sh
BIN_DIR = ./bin
SRC_PBA = ./src/pba
SRC_DRIVER = ./src/driver
OUT_PBA = ./bin/out
CC = g++
CFLAGS = -I$(CUDA_INC_PATH) -L$(CUDA_LIB_PATH) -fPIC -L/usr/lib64 -L/usr/lib -L$(BIN_DIR) -O2 -Wall -Wno-deprecated -pthread -march=native -mfpmath=sse -fpermissive
NVCC_FLAGS = -I$(CUDA_INC_PATH) -O2 -Xcompiler -fPIC
# siftgpu header files
_HEADER_PBA = pba.h ConfigBA.h CuTexImage.h DataInterface.h ProgramCU.h SparseBundleCU.h
_HEADER_PBA_LIB = pba.h
_OBJ_PBA = pba.o CuTexImage.o ConfigBA.o SparseBundleCU.o SparseBundleCPU.o
all: makepath pba driver
#the dependencies of SiftGPU library
DEPS_PBA = $(patsubst %, $(SRC_PBA)/%, $(_HEADER_PBA))
#rules for the rest of the object files
$(OUT_PBA)/%.o: $(SRC_PBA)/%.cpp $(DEPS_PBA)
$(CC) -o $@ $< $(CFLAGS) -c
#build rule for CUDA
$(OUT_PBA)/ProgramCU.o: $(SRC_PBA)/ProgramCU.cu $(DEPS_PBA)
$(NVCC) $(NVCC_FLAGS) -o $@ $< -c
_OBJ_PBA += ProgramCU.o
OBJ_PBA = $(patsubst %,$(OUT_PBA)/%,$(_OBJ_PBA))
LIBS_DRIVER = $(BIN_DIR)/libpba.a $(LIBS_PBA)
pba: makepath $(OBJ_PBA)
ar rcs $(BIN_DIR)/libpba.a $(OBJ_PBA)
$(CC) -o $(BIN_DIR)/libpba.so $(OBJ_PBA) $(LIBS_PBA) $(CFLAGS) -lcudart -shared -fPIC
driver: makepath
$(CC) -o $(BIN_DIR)/driver $(SRC_DRIVER)/driver.cpp -lpba -lcudart $(CFLAGS)
makepath:
mkdir -p $(OUT_PBA)
mkdir -p $(BIN_DIR)
clean:
rm -f $(OUT_PBA)/*.o
rm -f $(BIN_DIR)/libpba.a
rm -f $(BIN_DIR)/libpba.so
rm -f $(BIN_DIR)/driver