Makefile 12.7 KB
Newer Older
1
# Copyright (C) 2001-2016 Quantum ESPRESSO group
2
# 
3 4 5 6 7 8
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License. See the file `License' in the root directory
# of the present distribution.

9
include make.inc
10

11 12 13 14
# execute a target irrespective of the presence of a file or directory 
# with the same name
.PHONY: install

ballabio's avatar
ballabio committed
15
default :
16 17 18 19 20
	@echo 'to install Quantum ESPRESSO, type at the shell prompt:'
	@echo '  ./configure [--prefix=]'
	@echo '  make [-j] target'
	@echo ' '
	@echo 'where target identifies one or multiple CORE PACKAGES:'
21
	@echo '  pw           basic code for scf, structure optimization, MD'
22
	@echo '  ph           phonon code, Gamma-only and third-order derivatives'
23
	@echo '  hp           calculation of the Hubbard parameters from DFPT'
giannozz's avatar
giannozz committed
24
	@echo '  pwcond       ballistic conductance'
25
	@echo '  neb          code for Nudged Elastic Band method'
26
	@echo '  pp           postprocessing programs'
27
	@echo '  pwall        same as "make pw ph pp pwcond neb"'
28
	@echo '  cp           CP code: Car-Parrinello molecular dynamics'
29 30
	@echo '  tddfpt       time dependent dft code'
	@echo '  gwl          GW with Lanczos chains'
31
	@echo '  ld1          utilities for pseudopotential generation'
32
	@echo '  upf          utilities for pseudopotential conversion'
33 34
	@echo '  xspectra     X-ray core-hole spectroscopy calculations'
	@echo '  couple       Library interface for coupling to external codes'
spigafi's avatar
spigafi committed
35
	@echo '  epw          Electron-Phonon Coupling with wannier functions'
36
	@echo '  gui          Graphical User Interface'
37 38
	@echo '  examples     fetch from web examples for all core packages'
	@echo '  test-suite   run semi-automated test-suite for regression testing'
39
	@echo '  all          same as "make pwall cp ld1 upf tddfpt hp"'
40 41
	@echo ' '
	@echo 'where target identifies one or multiple THIRD-PARTIES PACKAGES:'
giannozz's avatar
giannozz committed
42 43 44
	@echo '  gipaw        NMR and EPR spectra'
	@echo '  w90          Maximally localised Wannier Functions'
	@echo '  want         Quantum Transport with Wannier functions'
45
	@echo '  west         Many-body perturbation corrections Without Empty STates'
46
#	@echo '  SaX          Standard GW-BSE with plane waves'
giannozz's avatar
giannozz committed
47
	@echo '  yambo        electronic excitations with plane waves'
48
	@echo '  yambo-devel  yambo devel version'
49
	@echo '  SternheimerGW calculate GW using Sternheimer equations'
giannozz's avatar
giannozz committed
50
	@echo '  plumed       Metadynamics plugin for pw or cp'
51
	@echo '  d3q          general third-order code and thermal transport codes'
52 53
	@echo ' '
	@echo 'where target is one of the following suite operation:'
54
	@echo '  doc          build documentation'
55
	@echo '  links        create links to all executables in bin/'
56
	@echo '  tar          create a tarball of the source tree'
57 58 59
	@if test -d GUI/; then \
		echo '  tar-gui      create a standalone PWgui tarball from the GUI sources'; \
		echo '  tar-qe-modes create a tarball for QE-modes (Emacs major modes for Quantum ESPRESSO)'; fi
60
	@echo '  clean        remove executables and objects'
61 62
	@echo '  veryclean    remove files produced by "configure" as well'
	@echo '  distclean    revert distribution to the original status'
giannozz's avatar
giannozz committed
63

64 65 66
###########################################################
# Main targets
###########################################################
67

68
# The syntax "( cd PW ; $(MAKE) TLDEPS= all || exit 1)" below
69 70 71
# guarantees that error code 1 is returned in case of error and make stops
# If "|| exit 1" is not present, the error code from make in subdirectories
# is not returned and make goes on even if compilation has failed
72

73
pw : pwlibs
74
	if test -d PW ; then \
75
	( cd PW ; $(MAKE) TLDEPS= all || exit 1) ; fi
giannozz's avatar
giannozz committed
76

77
cp : bindir libs mods
78
	if test -d CPV ; then \
79
	( cd CPV ; $(MAKE) TLDEPS= all || exit 1) ; fi
giannozz's avatar
giannozz committed
80

81
ph : phlibs
spigafi's avatar
spigafi committed
82
	if test -d PHonon; then \
83
	( cd PHonon; $(MAKE) TLDEPS= all || exit 1) ; fi
giannozz's avatar
giannozz committed
84

85 86
hp : hplibs
	if test -d HP; then \
87
	( cd HP; $(MAKE) TLDEPS= all || exit 1) ; fi
88

89
neb : pwlibs
spigafi's avatar
spigafi committed
90
	if test -d NEB; then \
91
	( cd NEB; $(MAKE) TLDEPS= all || exit 1) ; fi
92

93
tddfpt : phlibs
spigafi's avatar
spigafi committed
94
	if test -d TDDFPT; then \
95
	( cd TDDFPT; $(MAKE) TLDEPS= all || exit 1) ; fi
96

97
pp : pwlibs
98
	if test -d PP ; then \
99
	( cd PP ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
100

101
pwcond : pwlibs
spigafi's avatar
spigafi committed
102 103
	if test -d PWCOND ; then \
	( cd PWCOND ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
giannozz's avatar
giannozz committed
104

105
acfdt : phlibs
106
	if test -d ACFDT ; then \
107
	( cd ACFDT ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
108

109 110 111 112
# target still present for backward compatibility
gww:
	@echo '"make gww" is obsolete, use "make gwl" instead '

113
gwl : phlibs
114
	if test -d GWW ; then \
115
	( cd GWW ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
116

117
gipaw : pwlibs
118
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
119

120
d3q : phlibs
121 122
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )

123
ld1 : bindir libs mods
spigafi's avatar
spigafi committed
124 125
	if test -d atomic ; then \
	( cd atomic ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
giannozz's avatar
giannozz committed
126

127
upf : libs mods
128
	if test -d upftools ; then \
129
	( cd upftools ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
130

131
xspectra : pwlibs
spigafi's avatar
spigafi committed
132 133
	if test -d XSpectra ; then \
	( cd XSpectra ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
134

135 136
couple : pw cp
	if test -d COUPLE ; then \
137
	( cd COUPLE ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
138

139
epw: phlibs
spigafi's avatar
spigafi committed
140
	if test -d EPW ; then \
141
	( cd EPW ; $(MAKE) all || exit 1; \
142
		cd ../bin; ln -fs ../EPW/bin/epw.x . ); fi
spigafi's avatar
spigafi committed
143

sponce's avatar
sponce committed
144 145 146 147
travis : pwall epw
	if test -d test-suite ; then \
	( cd test-suite ; make run-travis || exit 1 ) ; fi

148 149
gui :
	@echo 'Check "GUI/README" how to access the Graphical User Interface'
spigafi's avatar
spigafi committed
150
#@echo 'Check "PWgui-X.Y/README" how to access the Graphical User Interface'
151

152
examples :
153
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
154

marsamos's avatar
marsamos committed
155
pwall : pw neb ph pp pwcond acfdt
156

157
all   : pwall cp ld1 upf tddfpt hp xspectra gwl 
giannozz's avatar
giannozz committed
158

159 160 161 162
###########################################################
# Auxiliary targets used by main targets:
# compile modules, libraries, directory for binaries, etc
###########################################################
163

164 165 166 167 168 169 170 171
pwlibs: bindir libs mods libks_solvers dftd3
	if test -d PW ; then \
	( cd PW ; $(MAKE) pw-lib || exit 1) ; fi

phlibs: pwlibs lrmods
	if test -d PHonon; then \
	( cd PHonon; $(MAKE) ph-lib || exit 1) ; fi

172 173 174 175
hplibs: pwlibs lrmods
	if test -d HP; then \
	( cd HP; $(MAKE) hp-lib || exit 1) ; fi

176 177 178 179 180 181 182 183
gwwlib : phlibs
	if test -d GWW ; then \
	( cd GWW ; $(MAKE) gwwa || exit 1 ) ; fi

pw4gwwlib : phlibs
	if test -d GWW ; then \
	( cd GWW ; $(MAKE) pw4gwwa || exit 1 ) ; fi

184 185 186
mods : libiotk libfox libutil libla libfft
	( cd Modules ; $(MAKE) TLDEPS= all || exit 1 )

187 188
libks_solvers : libs libutil libla
	( cd KS_Solvers ; $(MAKE) TLDEPS= all || exit 1 )
189

190
libla : liblapack libutil libcuda
ccavazzoni's avatar
ccavazzoni committed
191 192
	( cd LAXlib ; $(MAKE) TLDEPS= all || exit 1 )

193
libfft : 
194
	( cd FFTXlib ; $(MAKE) TLDEPS= all || exit 1 )
195

196
libutil : 
197 198
	( cd UtilXlib ; $(MAKE) TLDEPS= all || exit 1 )

199
libs :
200
	( cd clib ; $(MAKE) TLDEPS= all || exit 1 )
201

202
lrmods : mods pwlibs
spigafi's avatar
spigafi committed
203
	( cd LR_Modules ; $(MAKE) TLDEPS= all || exit 1 )
204

205 206 207
dftd3 : mods
	( cd dft-d3 ; $(MAKE) TLDEPS= all || exit 1 )

208 209
bindir :
	test -d bin || mkdir bin
210

211
#############################################################
212
# Targets for external libraries
213
############################################################
214

215
libblas : 
216
	cd install ; $(MAKE) -f extlibs_makefile $@
217

218
liblapack: 
219
	cd install ; $(MAKE) -f extlibs_makefile $@
220

221
libiotk: 
222
	cd install ; $(MAKE) -f extlibs_makefile $@
223
libfox: 
224
	cd install ; $(MAKE) -f extlibs_makefile $@
225

226
libcuda: 
227
	cd install ; $(MAKE) -f extlibs_makefile $@
giannozz's avatar
giannozz committed
228 229
# In case of trouble with iotk and compilers, add
# FFLAGS="$(FFLAGS_NOOPT)" after $(MFLAGS)
230

231 232 233 234
#########################################################
# plugins
#########################################################

235
w90: bindir liblapack
236
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
237

238
want : 
239
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
marsamos's avatar
marsamos committed
240

241
SaX : 
spigafi's avatar
spigafi committed
242 243
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )

244
yambo: 
245
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
spigafi's avatar
spigafi committed
246

247
yambo-devel: 
248
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
249

250
plumed: 
251
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
252

253
west: pw
spigafi's avatar
spigafi committed
254 255
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )

256
SternheimerGW: lrmods 
257 258
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )

259
#########################################################
260
# "make links" produces links to all executables in bin/
261
#########################################################
262

263
# Contains workaround for name conflicts (dos.x and bands.x) with WANT
264 265
links : bindir
	( cd bin/ ; \
nn245's avatar
nn245 committed
266
	rm -f *.x ; \
267
	for exe in ../*/*/*.x ../*/bin/* ; do \
nn245's avatar
nn245 committed
268
	    if test ! -L $$exe ; then ln -fs $$exe . ; fi \
269
	done ; \
270 271 272 273 274 275
	[ -f ../WANT/wannier/dos.x ] && \
		ln -fs ../WANT/wannier/dos.x ../bin/dos_want.x ; \
	[ -f ../PP/src/dos.x ] &&  \
		ln -fs ../PP/src/dos.x ../bin/dos.x ; \
	[ -f ../WANT/wannier/bands.x ] && \
		ln -fs ../WANT/wannier/bands.x ../bin/bands_want.x ; \
276
	[ -f ../PP/src/dos.x ] &&  ln -fs ../PP/src/bands.x ../bin/bands.x ; \
277
	[ -f ../W90/wannier90.x ] &&  ln -fs ../W90/wannier90.x ../bin/wannier90.x ;\
278 279
	)

280
#############################################################
giannozz's avatar
giannozz committed
281
# 'make install' works with "configure --prefix=PREFIX"
282 283
# - If the PREFIX/bin directory does not exists it creates it
#############################################################
spigafi's avatar
spigafi committed
284

285
install : 
286
	mkdir -p $(PREFIX)/bin ; \
287
	for x in `find * ! -path "test-suite/*" -name *.x -type f` ; do \
288 289
		cp -v $$x $(PREFIX)/bin/ ; done
	@echo -e '\nQuantum ESPRESSO binaries are installed in $(PREFIX)/bin\n'
spigafi's avatar
spigafi committed
290

291 292
#########################################################
# Run test-suite for numerical regression testing
293
# NB: it is assumed that reference outputs have been 
294 295 296
#     already computed once (usualy during release)
#########################################################

297
test-suite: pw cp 
298
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
299 300 301 302

#########################################################
# Other targets: clean up
#########################################################
303

304
# remove object files and executables
305 306
clean : 
	touch make.inc 
ballabio's avatar
ballabio committed
307
	for dir in \
308
		CPV LAXlib FFTXlib UtilXlib Modules PP PW EPW KS_Solvers \
giannozz's avatar
giannozz committed
309
		NEB ACFDT COUPLE GWW XSpectra PWCOND dft-d3 \
310
		atomic clib LR_Modules pwtools upftools \
311
		dev-tools extlibs Environ TDDFPT PHonon HP GWW \
ballabio's avatar
ballabio committed
312
	; do \
ballabio's avatar
ballabio committed
313
	    if test -d $$dir ; then \
314
		( cd $$dir ; \
315
		$(MAKE) TLDEPS= clean ) \
ballabio's avatar
ballabio committed
316
	    fi \
317
	done
318 319
	- @(cd install ; $(MAKE) -f plugins_makefile clean)
	- @(cd install ; $(MAKE) -f extlibs_makefile clean)
320
	- /bin/rm -rf bin/*.x tempdir
321

322 323
# remove files produced by "configure" as well
veryclean : clean
324 325
	- @(cd install ; $(MAKE) -f plugins_makefile veryclean)
	- @(cd install ; $(MAKE) -f extlibs_makefile veryclean)
326
	- rm -rf install/patch-plumed
327
	- cd install ; rm -f config.log configure.msg config.status \
328
		CPV/version.h ChangeLog* intel.pcl */intel.pcl
329
	- rm -rf include/configure.h install/make_wannier90.inc
330
	- cd install ; rm -fr autom4te.cache
331 332
	- cd install; ./clean.sh ; cd -
	- cd include; ./clean.sh ; cd -
333 334 335
	- rm -f espresso.tar.gz -
	- rm -rf make.inc -
	- rm -rf FoX
336
# remove everything not in the original distribution
337
distclean : veryclean
338
	- cd pseudo; ./clean_ps ; cd -
339 340
	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )

ballabio's avatar
ballabio committed
341
tar :
342
	@if test -f espresso.tar.gz ; then /bin/rm espresso.tar.gz ; fi
343
	# do not include unneeded stuff 
344
	find ./ -type f | grep -v -e /.svn/ -e'/\.' -e'\.o$$' -e'\.mod$$'\
345 346
		-e /.git/ -e'\.a$$' -e'\.d$$' -e'\.i$$' -e'_tmp\.f90$$' -e'\.x$$' \
		-e'~$$' -e'\./GUI' -e '\./tempdir' | xargs tar rvf espresso.tar
ballabio's avatar
ballabio committed
347
	gzip espresso.tar
348

349 350 351
#########################################################
# Tools for the developers
#########################################################
kokalj's avatar
kokalj committed
352
tar-gui :
353
	@if test -d GUI/PWgui ; then \
ballabio's avatar
ballabio committed
354
	    cd GUI/PWgui ; \
355
	    $(MAKE) TLDEPS= clean svninit pwgui-source; \
ballabio's avatar
ballabio committed
356
	    mv PWgui-*.tgz ../.. ; \
kokalj's avatar
kokalj committed
357
	else \
ballabio's avatar
ballabio committed
358
	    echo ; \
359
	    echo "  Sorry, tar-gui works only for svn sources !!!" ; \
ballabio's avatar
ballabio committed
360
	    echo ; \
kokalj's avatar
kokalj committed
361
	fi
362

363 364 365 366 367 368 369 370 371 372 373
tar-qe-modes :
	@if test -d GUI/QE-modes ; then \
	    cd GUI/QE-modes ; \
	    $(MAKE) TLDEPS= veryclean tar; \
	    mv QE-modes-*.tar.gz ../.. ; \
	else \
	    echo ; \
	    echo "  Sorry, tar-qe-modes works only for svn sources !!!" ; \
	    echo ; \
	fi

374 375 376 377 378
# NOTICE about "make doc": in order to build the .html and .txt
# documentation in Doc, "tcl", "tcllib", "xsltproc" are needed;
# in order to build the .pdf files in Doc, "pdflatex" is needed;
# in order to build html files for user guide and developer manual,
# "latex2html" and "convert" (from Image-Magick) are needed.
379
doc : 
380
	if test -d Doc ; then \
381 382 383 384 385 386 387 388
	( cd Doc ; $(MAKE) TLDEPS= all ) ; fi
	for dir in */Doc; do \
	( if test -f $$dir/Makefile ; then \
	( cd $$dir; $(MAKE) TLDEPS= all ) ; fi ) ;  done

doc_clean :
	if test -d Doc ; then \
	( cd Doc ; $(MAKE) TLDEPS= clean ) ; fi
389
	for dir in */Doc; do \
390
	( if test -f $$dir/Makefile ; then \
391
	( cd $$dir; $(MAKE) TLDEPS= clean ) ; fi ) ;  done
392

393
depend: libiotk
394
	@echo 'Checking dependencies...'
395
	- ( if test -x install/makedeps.sh ; then install/makedeps.sh ; fi)