-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
56 lines (45 loc) · 1.66 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
rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst *,%,$2),$d))
UNAME := $(shell uname -s | tr "[:upper:]" "[:lower:]")
SOURCES := $(call rwildcard, src/, *.cpp)
OBJS := $(subst src/,build/,$(SOURCES:.cpp=.o))
CU_SOURCES := $(call rwildcard, src/, *.cu)
CU_OBJS := $(subst src/,build/,$(CU_SOURCES:.cu=.cu.o))
CFLAGS = -isystem include -Isrc -std=c++14 -Wpedantic -Wall -Wextra -Werror -Ofast -fopenmp -x c++
LDFLAGS =
TARGET = valo
# these might be needed
# -lXrandr -lXi -lXcursor -lXinerama
# -fopt-info-vec -fopt-info-vec-missed
# linux
ifneq "$(findstring linux,$(UNAME))" ""
LDFLAGS += -lstdc++ -ldl -lm -lpthread -lGL -lglfw -lboost_system -lboost_filesystem -lboost_program_options
endif
# mac
ifneq "$(findstring darwin,$(UNAME))" ""
CFLAGS += -isystem /opt/local/include -isystem /opt/local/include/libomp -mmacosx-version-min=10.9
LDFLAGS += -L/opt/local/lib -L/opt/local/lib/libomp -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -lstdc++ -lglfw -lboost_system-mt -lboost_filesystem-mt -lboost_program_options-mt
endif
ifdef NATIVE
CFLAGS += -march=native
endif
ifdef CUDA
CXX = nvcc
CFLAGS += -DUSE_CUDA
CFLAGS := --std c++11 --machine 64 --gpu-architecture=sm_52 --use_fast_math --cudart static -DUSE_CUDA -Xcompiler "$(CFLAGS)"
endif
default: valo
valo: $(OBJS) $(CU_OBJS)
@mkdir -p bin
@echo "Linking $@"
@$(CXX) $(OBJS) $(CU_OBJS) $(CFLAGS) $(LDFLAGS) -o bin/$(TARGET)
@platform/linux/post-build.sh
build/%.o: src/%.cpp
@mkdir -p $(@D)
@echo "Compiling $<"
@$(CXX) $(CFLAGS) -c -o $@ $<
build/%.cu.o: src/%.cu
@mkdir -p $(@D)
@echo "Compiling $<"
@$(CXX) $(CFLAGS) -c -o $@ $<
clean:
@rm -rf bin build