forked from merzlab/QUICK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
301 lines (247 loc) · 13.1 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# !---------------------------------------------------------------------!
# ! Written by Madu Manathunga on 07/17/2020 !
# ! !
# ! Copyright (C) 2020-2021 Merz lab !
# ! Copyright (C) 2020-2021 Götz lab !
# ! !
# ! This Source Code Form is subject to the terms of the Mozilla Public !
# ! License, v. 2.0. If a copy of the MPL was not distributed with this !
# ! file, You can obtain one at http://mozilla.org/MPL/2.0/. !
# !_____________________________________________________________________!
#
# !---------------------------------------------------------------------!
# ! This is the main Makefile for compiling QUICK source code !
# !---------------------------------------------------------------------!
MAKEIN=./make.in
include $(MAKEIN)
ifeq "$(SHARED)" 'yes'
libsuffix = "so"
else
libsuffix = "a"
endif
# !---------------------------------------------------------------------!
# ! Build targets !
# !---------------------------------------------------------------------!
.PHONY: nobuildtypes serial mpi cuda cudampi hip hipmpi all
all:$(BUILDTYPES)
@echo "Building successful."
nobuildtypes:
@echo "Error: No build type found. Plesae run configure script first."
serial: checkfolders
@echo "Building serial version.."
@cp -f $(buildfolder)/make.serial.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory serial
@mv -f $(exefolder)/test-api $(homefolder)/test/
mpi: checkfolders
@echo "Building mpi version.."
@cp -f $(buildfolder)/make.mpi.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory mpi
@mv -f $(exefolder)/test-api.MPI $(homefolder)/test/
cuda: checkfolders
@echo "Building cuda version.."
@cp -f $(buildfolder)/make.cuda.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory cuda
@mv -f $(exefolder)/test-api.cuda $(homefolder)/test/
cudampi: checkfolders
@echo "Building cuda-mpi version.."
@cp -f $(buildfolder)/make.cudampi.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory cudampi
@mv -f $(exefolder)/test-api.cuda.MPI $(homefolder)/test/
hip: checkfolders
@echo "Building hip version.."
@cp -f $(buildfolder)/make.hip.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory hip
@mv -f $(exefolder)/test-api.hip $(homefolder)/test/
hipmpi: checkfolders
@echo "Building hip-mpi version.."
@cp -f $(buildfolder)/make.hipmpi.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory hipmpi
@mv -f $(exefolder)/test-api.hip.MPI $(homefolder)/test/
checkfolders:
@if [ ! -d $(exefolder) ]; then echo "Error: $(exefolder) not found. Please configure first."; \
exit 1; fi
@if [ ! -d $(buildfolder) ]; then echo "Error: $(buildfolder) not found. Please configure first."; \
exit 1; fi
# !---------------------------------------------------------------------!
# ! Installation targets !
# !---------------------------------------------------------------------!
.PHONY: noinstall install serialinstall mpiinstall cudainstall cudampiinstall hipinstall hipmpiinstall aminstall
install: $(INSTALLTYPES)
@echo "Installation sucessful."
@echo ""
@echo "Please run the following command to set environment variables."
@echo " source $(installfolder)/quick.rc"
noinstall: all
@echo "Please find QUICK executables in $(exefolder)."
serialinstall: serial
@if [ -x $(exefolder)/quick ]; then cp -f $(exefolder)/quick $(installfolder)/bin; \
cp -f $(homefolder)/test/test-api $(installfolder)/test; \
else echo "Error: Executable not found. You must run 'make' before running 'make install'."; \
exit 1; fi
@cp -f $(buildfolder)/include/serial/* $(installfolder)/include/serial
@cp -f $(buildfolder)/lib/serial/* $(installfolder)/lib/serial
@cp -f $(toolsfolder)/sadguess $(installfolder)/bin
mpiinstall: mpi
@if [ -x $(exefolder)/quick.MPI ]; then cp -f $(exefolder)/quick.MPI $(installfolder)/bin; \
cp -f $(homefolder)/test/test-api.MPI $(installfolder)/test; \
else echo "Error: Executable not found. You must run 'make' before running 'make install'."; \
exit 1; fi
@cp -f $(buildfolder)/include/mpi/* $(installfolder)/include/mpi
@cp -f $(buildfolder)/lib/mpi/* $(installfolder)/lib/mpi
cudainstall: cuda
@if [ -x $(exefolder)/quick.cuda ]; then cp -f $(exefolder)/quick.cuda $(installfolder)/bin; \
cp -f $(homefolder)/test/test-api.cuda $(installfolder)/test; \
else echo "Error: Executable not found. You must run 'make' before running 'make install'."; \
exit 1; fi
@cp -f $(exefolder)/quick.cuda $(installfolder)/bin
@cp -f $(buildfolder)/include/cuda/* $(installfolder)/include/cuda
@cp -f $(buildfolder)/lib/cuda/* $(installfolder)/lib/cuda
cudampiinstall: cudampi
@if [ -x $(exefolder)/quick.cuda.MPI ]; then cp -f $(exefolder)/quick.cuda.MPI $(installfolder)/bin; \
cp -f $(homefolder)/test/test-api.cuda.MPI $(installfolder)/test; \
else echo "Error: Executable not found. You must run 'make' before running 'make install'."; \
exit 1; fi
@cp -f $(exefolder)/quick.cuda.MPI $(installfolder)/bin
@cp -f $(buildfolder)/include/cudampi/* $(installfolder)/include/cudampi
@cp -f $(buildfolder)/lib/cudampi/* $(installfolder)/lib/cudampi
hipinstall: hip
@if [ -x $(exefolder)/quick.hip ]; then cp -f $(exefolder)/quick.hip $(installfolder)/bin; \
cp -f $(homefolder)/test/test-api.hip $(installfolder)/test; \
else echo "Error: Executable not found. You must run 'make' before running 'make install'."; \
exit 1; fi
@cp -f $(exefolder)/quick.hip $(installfolder)/bin
@cp -f $(buildfolder)/include/hip/* $(installfolder)/include/hip
@cp -f $(buildfolder)/lib/hip/* $(installfolder)/lib/hip
hipmpiinstall: hipmpi
@if [ -x $(exefolder)/quick.hip.MPI ]; then cp -f $(exefolder)/quick.hip.MPI $(installfolder)/bin; \
cp -f $(homefolder)/test/test-api.hip.MPI $(installfolder)/test; \
else echo "Error: Executable not found. You must run 'make' before running 'make install'."; \
exit 1; fi
@cp -f $(exefolder)/quick.hip.MPI $(installfolder)/bin
@cp -f $(buildfolder)/include/hipmpi/* $(installfolder)/include/hipmpi
@cp -f $(buildfolder)/lib/hipmpi/* $(installfolder)/lib/hipmpi
aminstall: all
@if [ -d $(installfolder)/lib ]; then \
if [ -e $(buildfolder)/lib/serial/libquick.$(libsuffix) ]; then mv $(buildfolder)/lib/serial/libquick.$(libsuffix) $(installfolder)/lib/libquick.$(libsuffix); \
mv $(buildfolder)/lib/serial/libxc.$(libsuffix) $(installfolder)/lib/libxc.$(libsuffix); fi; \
if [ -e $(buildfolder)/lib/serial/libblas-quick.$(libsuffix) ]; then mv $(buildfolder)/lib/serial/libblas-quick.$(libsuffix) $(installfolder)/lib/libblas-quick.$(libsuffix); fi; \
if [ -e $(buildfolder)/lib/mpi/libquick-mpi.$(libsuffix) ]; then mv $(buildfolder)/lib/mpi/libquick-mpi.$(libsuffix) $(installfolder)/lib/libquick-mpi.$(libsuffix); \
mv $(buildfolder)/lib/mpi/libxc.$(libsuffix) $(installfolder)/lib/libxc.$(libsuffix); fi; \
if [ -e $(buildfolder)/lib/mpi/libblas-quick.$(libsuffix) ]; then mv $(buildfolder)/lib/mpi/libblas-quick.$(libsuffix) $(installfolder)/lib/libblas-quick.$(libsuffix); fi; \
if [ -e $(buildfolder)/lib/cuda/libquick-cuda.$(libsuffix) ]; then mv $(buildfolder)/lib/cuda/libquick-cuda.$(libsuffix) $(installfolder)/lib/libquick-cuda.$(libsuffix); \
mv $(buildfolder)/lib/cuda/libxc-cuda.$(libsuffix) $(installfolder)/lib/libxc-cuda.$(libsuffix); fi; \
if [ -e $(buildfolder)/lib/cudampi/libquick-cudampi.$(libsuffix) ]; then mv $(buildfolder)/lib/cudampi/libquick-cudampi.$(libsuffix) $(installfolder)/lib/libquick-cudampi.$(libsuffix); \
mv $(buildfolder)/lib/cudampi/libxc-cuda.$(libsuffix) $(installfolder)/lib/libxc-cuda.$(libsuffix); fi; echo "Successfully installed QUICK libraries in $(installfolder)/lib folder.";\
else echo "Error: $(installfolder)/lib folder not found."; exit 1; fi
@if [ -d $(installfolder)/bin ]; then \
for i in quick quick.MPI quick.cuda quick.cuda.MPI; do if [ -x $(exefolder)/$$i ]; then mv $(exefolder)/$$i $(installfolder)/bin/; fi; done; \
echo "Successfully installed QUICK executables in $(installfolder)/bin folder."; \
else echo "Error: $(installfolder)/bin folder not found."; exit 1; fi
# !---------------------------------------------------------------------!
# ! Installation targets !
# !---------------------------------------------------------------------!
.PHONY: test buildtest installtest fulltest
test:$(TESTTYPE)
buildtest:
@cp $(toolsfolder)/runtest $(homefolder)
@$(homefolder)/runtest
installtest:
@if [ ! -x $(installfolder)/bin/quick ] && [ ! -x $(installfolder)/bin/quick.MPI ] && [ ! -x $(installfolder)/bin/quick.cuda ] && [ ! -x $(installfolder)/bin/quick.cuda.MPI && \
[ ! -x $(installfolder)/bin/quick.hip ] && [ ! -x $(installfolder)/bin/quick.hip.MPI ]; then \
echo "Error: Executables not found. You must run 'make install' before running 'make test'."; \
exit 1; fi
@cp $(toolsfolder)/runtest $(installfolder)
@cd $(installfolder) && ./runtest
fulltest:
@if [ ! -x $(installfolder)/bin/quick ] && [ ! -x $(installfolder)/bin/quick.MPI ] && [ ! -x $(installfolder)/bin/quick.cuda ] && [ ! -x $(installfolder)/bin/quick.cuda.MPI && \
[ ! -x $(installfolder)/bin/quick.hip ] && [ ! -x $(installfolder)/bin/quick.hip.MPI ]; then \
echo "Error: Executables not found."; \
exit 1; fi
@cp $(toolsfolder)/runtest $(installfolder)
@cd $(installfolder) && ./runtest --full
# !---------------------------------------------------------------------!
# ! Cleaning targets !
# !---------------------------------------------------------------------!
.PHONY:serialclean mpiclean cudaclean cudampiclean hipclean hipmpiclean makeinclean
clean:$(CLEANTYPES)
@-rm -f $(homefolder)/runtest
@-rm -f $(homefolder)/build/include/common/*
@echo "Cleaned up successfully."
serialclean:
@cp -f $(buildfolder)/make.serial.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory clean
mpiclean:
@cp -f $(buildfolder)/make.mpi.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory clean
cudaclean:
@cp -f $(buildfolder)/make.cuda.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory clean
cudampiclean:
@cp -f $(buildfolder)/make.cudampi.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory clean
hipclean:
@cp -f $(buildfolder)/make.hip.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory clean
hipmpiclean:
@cp -f $(buildfolder)/make.hipmpi.in $(buildfolder)/make.in
@cd $(buildfolder) && make --no-print-directory clean
distclean: makeinclean
@-rm -f $(homefolder)/runtest
@-rm -rf $(buildfolder) $(exefolder)
@-rm -f $(homefolder)/quick.rc
@echo "Removed build and bin directories."
makeinclean:
@-rm -f $(libxcfolder)/make.in
@-rm -f $(libxcfolder)/maple2c_device/make.in
@-rm -f $(subfolder)/make.in
@-rm -f $(modfolder)/make.in
@-rm -f $(octfolder)/make.in
@-rm -f $(blasfolder)/make.in
@-rm -f $(cudafolder)/make.in
@-rm -f $(hipfolder)/make.in
# !---------------------------------------------------------------------!
# ! Uninstall targets !
# !---------------------------------------------------------------------!
.PHONY: nouninstall uninstall serialuninstall mpiuninstall cudauninstall cudampiuninstall hipuninstall hipmpiuninstall amuninstall
uninstall: $(UNINSTALLTYPES)
@if [ "$(TESTTYPE)" = 'installtest' ]; then rm -rf $(installfolder)/basis; \
rm -rf $(installfolder)/test; fi
@-rm -f $(installfolder)/runtest
@-rm -f $(installfolder)/quick.rc
@-rm -rf $(installfolder)/include/common
@echo "Uninstallation sucessful."
nouninstall:
@echo "Nothing to uninstall."
serialuninstall:
@-rm -f $(installfolder)/bin/quick
@-rm -rf $(installfolder)/include/serial
@-rm -rf $(installfolder)/lib/serial
mpiuninstall:
@-rm -f $(installfolder)/bin/quick.MPI
@-rm -rf $(installfolder)/include/mpi
@-rm -rf $(installfolder)/lib/mpi
cudauninstall:
@-rm -f $(installfolder)/bin/quick.cuda
@-rm -rf $(installfolder)/include/cuda
@-rm -rf $(installfolder)/lib/cuda
cudampiuninstall:
@-rm -f $(installfolder)/bin/quick.cuda.MPI
@-rm -rf $(installfolder)/include/cudampi
@-rm -rf $(installfolder)/lib/cudampi
hipuninstall:
@-rm -f $(installfolder)/bin/quick.hip
@-rm -rf $(installfolder)/include/hip
@-rm -rf $(installfolder)/lib/hip
hipmpiuninstall:
@-rm -f $(installfolder)/bin/quick.hip.MPI
@-rm -rf $(installfolder)/include/hipmpi
@-rm -rf $(installfolder)/lib/hipmpi
amuninstall:
@-rm -f $(installfolder)/bin/quick
@-rm -f $(installfolder)/bin/quick.MPI
@-rm -f $(installfolder)/bin/quick.cuda
@-rm -f $(installfolder)/bin/quick.cuda.MPI
@-rm -f $(installfolder)/lib/libquick*
@-rm -f $(installfolder)/lib/libxc.*
@-rm -f $(installfolder)/lib/libxc-cuda.*
@echo "Successfully removed QUICK executables and libraries from $(installfolder) folder."