-
Notifications
You must be signed in to change notification settings - Fork 81
/
Makefile
55 lines (39 loc) · 1.22 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
include Makefile.config
DEBUG ?= 0
RELEASE ?= 0
ifeq ($(DEBUG), 1)
CXXFLAGS += -O0 -g #-ggdb
LDFLAGS += -O0 -g -ggdb
else
CXXFLAGS += -O3
LDFLAGS += -O3
endif
TARGET = ray
CXX = g++
CXXFLAGS += -std=c++11
WARNING = -Wall -W
SOURCE_DIR = ./src
OBJECT_DIR = ./obj
INCLUDE_DIR = ./include
SOURCES = $(shell find $(SOURCE_DIR) -name '*.cpp')
OBJECTS = $(subst $(SOURCE_DIR), $(OBJECT_DIR), $(SOURCES))
OBJECTS := $(subst .cpp,.o,$(OBJECTS))
OBJECTS := $(subst .cu,.o,$(OBJECTS))
DEPENDS = $(OBJECTS:.o=.d)
INCLUDE += -I$(INCLUDE_DIR)
ifeq ($(RELEASE), 1)
LDFLAGS += -static -lm -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
else
LDFLAGS += -lm -lpthread
endif
$(TARGET): $(OBJECTS)
$(CXX) -o $@ $^ $(LDFLAGS) $(LIB_CUDA) $(LIB_REDIS)
$(SOURCE_DIR)/%.cpp: $(SOURCE_DIR)/%.cu
$(NVCC) $(NVCCFLAGS) $(INCLUDE) --cuda $< -o $@
$(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.cpp
@if [ ! -e `dirname $@` ]; then mkdir -p `dirname $@`; fi
$(CXX) $(WARNING) $(CXXFLAGS) $(INCLUDE) -o $@ -c $<
all: clean $(TARGET)
clean:
-rm -f *~ $(TARGET) $(OBJECTS) $(SOURCE_DIR)/*~ $(SOURCE_DIR)/*/*~ $(SOURCE_DIR)/*/*/*~ $(SOURCE_DIR)/*/*/*/*~ $(INCLUDE_DIR)/*~ $(INCLUDE_DIR)/*/*~ $(INCLUDE_DIR)/*/*/*~ $(INCLUDE_DIR)/*/*/*/*~
-include $(DEPENDS)