forked from preda/gpuowl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
120 lines (92 loc) · 3.24 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
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
BIN=build
CXXFLAGS = -Wall -g -O3 -std=gnu++17
CPPFLAGS = -I$(BIN) -I.
ifeq (MSWindows,$(OS))
EXE=gpuowl-win.exe
O=obj
else
ifneq (,$(shell which uname && uname -o 2>>/dev/null | fgrep -i linux))
EXE=gpuowl
O=o
else
ifneq (,$(shell which uname && uname -o 2>>/dev/null | fgrep -i cygwin))
EXE=gpuowl-cygwin.exe
O=obj
else
EXE=gpuowl-win.exe
O=obj
endif
endif
endif
ifeq (yes,$(shell test -d /usr/local/cuda-11 && echo 'yes'))
CUDA_LIBS = -fPIC -L/usr/local/cuda-11/lib64 -lcudart -lOpenCL
CUDA_INCL = -I/usr/local/cuda-11/include
endif
ifeq (yes,$(shell test -d /usr/local/cuda-10 && echo 'yes'))
CUDA_LIBS = -fPIC -L/usr/local/cuda-10/lib64 -lcudart -lOpenCL
CUDA_INCL = -I/usr/local/cuda-10/include
endif
ifeq (,$(CUDA_LIBS))
# default
CUDA_LIBS = -L/opt/rocm-5.1.1/opencl/lib -L/opt/rocm-4.0.0/opencl/lib -L/opt/rocm-3.3.0/opencl/lib/x86_64 -L/opt/rocm/opencl/lib -L/opt/rocm/opencl/lib/x86_64 -L/opt/amdgpu-pro/lib/x86_64-linux-gnu -lOpenCL
endif
ifeq (,$(CUDA_INCL))
CUDA_INCL = -IdefaultCUDA_LIBS
endif
LIBPATH = $(CUDA_LIBS) -L.
LDFLAGS = -lstdc++fs $(LIBPATH) -lgmp -pthread
LINK = $(CXX) $(CXXFLAGS)
SRCS=$(wildcard $(BIN)/*.cpp src/*.cpp)
SRCS1=$(filter-out src/sine_compare.cpp src/qdcheb.cpp,$(SRCS))
OBJS = $(SRCS1:%.cpp=%.$(O))
OWL_OBJS=$(filter-out D.$(O) $(BIN)/sine_compare.$(O) $(BIN)/qdcheb.$(O),$(OBJS))
DEPDIR := .d
$(shell mkdir -p $(DEPDIR)/src >/dev/null)
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
POSTCOMPILE = @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
all: .d $(BIN)/version.inc $(BIN)/gpuowl-wrap.cpp $(EXE)
echo $@ > $@
gpuowl: $(OWL_OBJS) $(BIN)/gpuowl-wrap.$(O)
$(LINK) $^ -o $@ $(LDFLAGS)
#!!wedgingt gpuowl-cygwin.exe: $(OWL_OBJS) gpuowl-wrap.$(O)
#!!wedgingt $(LINK) -static $^ -o $@ $(LDFLAGS)
$(BIN)/gpuowl: ${OBJS}
${LINK}
gpuowl-win.exe: $(OWL_OBJS) gpuowl-wrap.$(O)
$(LINK) -static $^ -o $@ $(LDFLAGS)
strip $@
D: D.$(O) Pm1Plan.$(O) log.$(O) common.$(O) timeutil.$(O)
$(LINK) $^ -o $@ $(LDFLAGS)
clean:
rm -f *.$(O) gpuowl gpuowl-win.exe gpuowl-wrap.cpp
rm -f all gpuowl-expanded.cl gpuowl-cygwin.exe D
rm -f $(BIN)/version.inc install FORCE clean
rm -rf $(BIN) $(DEPDIR)
$(BIN)/gpuowl-wrap.o : $(BIN)/gpuowl-wrap.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUTPUT_OPTION) $<
$(BIN)/%.o: src/%.cpp $(DEPDIR)/%.d $(BIN)/version.inc
$(COMPILE.cc) $(OUTPUT_OPTION) $<
$(POSTCOMPILE)
$(BIN)/%.obj: src/%.cpp $(DEPDIR)/%.d $(BIN)/version.inc
$(COMPILE.cc) $(OUTPUT_OPTION) $<
$(POSTCOMPILE)
$(DEPDIR)/%.d: %.cpp ;
.PRECIOUS: $(DEPDIR)/%.d
$(DEPDIR):
mkdir -p $(DEPDIR)
$(BIN)/version.h: $(BIN)/version.inc
touch $@
$(BIN)/version.inc: FORCE
echo \"`git describe --tags --long --dirty --always`\" > $(BIN)/version.new
diff -q -N $(BIN)/version.new $(BIN)/version.inc >/dev/null || mv $(BIN)/version.new $(BIN)/version.inc
echo Version: `cat $(BIN)/version.inc`
gpuowl-expanded.cl: gpuowl.cl tools/expand.py
python3 ./tools/expand.py < gpuowl.cl > gpuowl-expanded.cl
$(BIN)/gpuowl-wrap.cpp: src/gpuowl.cl
python3 tools/expand.py src/gpuowl.cl $(BIN)/gpuowl-wrap.cpp
install: $(EXE)
install -m 555 $(EXE) ../
FORCE:
include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS1))))
# include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename D.cpp)))