1# Copyright (C) 2001-2020 Quantum ESPRESSO Foundation
2#
3# This program is free software; you can redistribute it and/or
4# modify it under the terms of the GNU General Public License
5# as published by the Free Software Foundation; either version 2
6# of the License. See the file `License' in the root directory
7# of the present distribution.
8
9include make.inc
10
11# execute a target irrespective of the presence of a file or directory
12# with the same name
13.PHONY: install
14
15default :
16	@echo 'to install Quantum ESPRESSO, type at the shell prompt:'
17	@echo '  ./configure [--prefix=]'
18	@echo '  make [-j] target'
19	@echo ' '
20	@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'
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	@echo '  tddfpt       time dependent dft code'
30	@echo '  gwl          GW with Lanczos chains'
31	@echo '  ld1          utilities for pseudopotential generation'
32	@echo '  xspectra     X-ray core-hole spectroscopy calculations'
33	@echo '  couple       Library interface for coupling to external codes'
34	@echo '  epw          Electron-Phonon Coupling with wannier functions'
35	@echo '  gui          Graphical User Interface'
36	@echo '  all          same as "make pwall cp ld1 tddfpt hp"'
37	@echo ' '
38	@echo 'where target identifies one or multiple THIRD-PARTIES PACKAGES:'
39	@echo '  gipaw        NMR and EPR spectra'
40	@echo '  w90          Maximally localised Wannier Functions'
41	@echo '  want         Quantum Transport with Wannier functions'
42	@echo '  yambo        electronic excitations with plane waves'
43	@echo '  d3q          general third-order code and thermal transport codes'
44	@echo ' '
45	@echo 'where target is one of the following suite operation:'
46	@echo '  doc          build documentation'
47	@echo '  links        create links to all executables in bin/'
48	@echo '  tar          create a tarball of the source tree'
49	@if test -d GUI/; then \
50		echo '  tar-gui      create a standalone PWgui tarball from the GUI sources'; \
51		echo '  tar-qe-modes create a tarball for QE-modes (Emacs major modes for Quantum ESPRESSO)'; fi
52	@echo '  clean        remove executables and objects'
53	@echo '  veryclean    remove files produced by "configure" as well'
54	@echo '  distclean    revert distribution to the original status'
55
56###########################################################
57# Main targets
58###########################################################
59
60# The syntax "( cd PW ; $(MAKE) TLDEPS= all || exit 1)" below
61# guarantees that error code 1 is returned in case of error and make stops
62# If "|| exit 1" is not present, the error code from make in subdirectories
63# is not returned and make goes on even if compilation has failed
64
65pw : pwlibs
66	if test -d PW ; then \
67	( cd PW ; $(MAKE) TLDEPS= all || exit 1) ; fi
68
69cp : bindir libs mods
70	if test -d CPV ; then \
71	( cd CPV ; $(MAKE) TLDEPS= all || exit 1) ; fi
72
73ph : phlibs
74	if test -d PHonon; then \
75	( cd PHonon; $(MAKE) TLDEPS= all || exit 1) ; fi
76
77hp : hplibs
78	if test -d HP; then \
79	( cd HP; $(MAKE) TLDEPS= all || exit 1) ; fi
80
81neb : pwlibs
82	if test -d NEB; then \
83	( cd NEB; $(MAKE) TLDEPS= all || exit 1) ; fi
84
85tddfpt : lrmods
86	if test -d TDDFPT; then \
87	( cd TDDFPT; $(MAKE) TLDEPS= all || exit 1) ; fi
88
89pp : pwlibs
90	if test -d PP ; then \
91	( cd PP ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
92
93pwcond : pwlibs
94	if test -d PWCOND ; then \
95	( cd PWCOND ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
96
97acfdt : phlibs
98	if test -d ACFDT ; then \
99	( cd ACFDT ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
100
101gwl : phlibs
102	if test -d GWW ; then \
103	( cd GWW ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
104
105gipaw : pwlibs
106	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
107
108d3q : phlibs
109	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
110
111ld1 : bindir libs mods
112	if test -d atomic ; then \
113	( cd atomic ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
114
115xspectra : pwlibs
116	if test -d XSpectra ; then \
117	( cd XSpectra ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
118
119couple : pw cp
120	if test -d COUPLE ; then \
121	( cd COUPLE ; $(MAKE) TLDEPS= all || exit 1 ) ; fi
122
123epw: phlibs
124	if test -d EPW ; then \
125	( cd EPW ; $(MAKE) all || exit 1; \
126		cd ../bin; ln -fs ../EPW/bin/epw.x . ); fi
127
128travis : pwall epw
129	if test -d test-suite ; then \
130	( cd test-suite ; make run-travis || exit 1 ) ; fi
131
132gui :
133	@if test -d GUI/PWgui ; then \
134	    cd GUI/PWgui ; \
135	    $(MAKE) TLDEPS= init; \
136	    echo ; \
137	    echo "  PWgui has been built in ./GUI/PWgui/. You may try it either as:  "; \
138	    echo "         ./GUI/PWgui/pwgui" ; \
139	    echo "     or"; \
140	    echo "         cd ./GUI/PWgui";\
141	    echo "         ./pwgui" ; \
142	    echo ; \
143	else \
144	    echo ; \
145	    echo "  Sorry, gui works only for git sources !!!" ; \
146	    echo ; \
147	fi
148
149pwall : pw neb ph pp pwcond acfdt
150
151all   : pwall cp ld1 tddfpt hp xspectra gwl
152
153###########################################################
154# Auxiliary targets used by main targets:
155# compile modules, libraries, directory for binaries, etc
156###########################################################
157
158pwlibs: bindir libs mods libks_solvers dftd3
159	if test -d PW ; then \
160	( cd PW ; $(MAKE) pw-lib || exit 1) ; fi
161
162phlibs: pwlibs lrmods
163	if test -d PHonon; then \
164	( cd PHonon; $(MAKE) ph-lib || exit 1) ; fi
165
166hplibs: pwlibs lrmods
167	if test -d HP; then \
168	( cd HP; $(MAKE) hp-lib || exit 1) ; fi
169
170gwwlib : phlibs
171	if test -d GWW ; then \
172	( cd GWW ; $(MAKE) gwwa || exit 1 ) ; fi
173
174pw4gwwlib : phlibs
175	if test -d GWW ; then \
176	( cd GWW ; $(MAKE) pw4gwwa || exit 1 ) ; fi
177
178mods : libfox libutil libla libfft libupf libbeef
179	( cd Modules ; $(MAKE) TLDEPS= all || exit 1 )
180
181libks_solvers : libs libutil libla
182	( cd KS_Solvers ; $(MAKE) TLDEPS= all || exit 1 )
183
184libla : liblapack libutil libcuda
185	( cd LAXlib ; $(MAKE) TLDEPS= all || exit 1 )
186
187libfft :
188	( cd FFTXlib ; $(MAKE) TLDEPS= all || exit 1 )
189
190libutil :
191	( cd UtilXlib ; $(MAKE) TLDEPS= all || exit 1 )
192
193libupf : libfox libutil
194	( cd upflib ; $(MAKE) TLDEPS= all || exit 1 )
195
196libs :
197	( cd clib ; $(MAKE) TLDEPS= all || exit 1 )
198
199lrmods : mods pwlibs
200	( cd LR_Modules ; $(MAKE) TLDEPS= all || exit 1 )
201
202dftd3 : mods
203	( cd dft-d3 ; $(MAKE) TLDEPS= all || exit 1 )
204
205bindir :
206	test -d bin || mkdir bin
207
208#############################################################
209# Targets for external libraries
210############################################################
211
212liblapack:
213	cd install ; $(MAKE) -f extlibs_makefile $@
214
215libfox:
216	cd install ; $(MAKE) -f extlibs_makefile $@
217
218libcuda:
219	cd install ; $(MAKE) -f extlibs_makefile $@
220
221libbeef:
222	cd install ; $(MAKE) -f extlibs_makefile $@
223
224#########################################################
225# plugins
226#########################################################
227
228w90: bindir liblapack
229	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
230
231want: liblapack
232	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
233
234yambo: liblapack
235	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
236
237#########################################################
238# "make links" produces links to all executables in bin/
239#########################################################
240
241# Contains workaround for name conflicts (dos.x and bands.x) with WANT
242links : bindir
243	( cd bin/ ; \
244	rm -f *.x ; \
245	for exe in ../*/*/*.x ../*/bin/* ; do \
246	    if test ! -L $$exe ; then ln -fs $$exe . ; fi \
247	done ; \
248	[ -f ../WANT/wannier/dos.x ] && \
249		ln -fs ../WANT/wannier/dos.x ../bin/dos_want.x ; \
250	[ -f ../PP/src/dos.x ] &&  \
251		ln -fs ../PP/src/dos.x ../bin/dos.x ; \
252	[ -f ../WANT/wannier/bands.x ] && \
253		ln -fs ../WANT/wannier/bands.x ../bin/bands_want.x ; \
254	[ -f ../PP/src/dos.x ] &&  ln -fs ../PP/src/bands.x ../bin/bands.x ; \
255	[ -f ../W90/wannier90.x ] &&  ln -fs ../W90/wannier90.x ../bin/wannier90.x ;\
256	)
257
258#############################################################
259# 'make install' works with "configure --prefix=PREFIX"
260# - If the PREFIX/bin directory does not exists it creates it
261#############################################################
262
263install :
264	mkdir -p $(DESTDIR)$(PREFIX)/bin ; \
265	for x in `find * ! -path "test-suite/*" -name *.x -type f` ; do \
266		cp -v $$x $(DESTDIR)$(PREFIX)/bin/ ; done
267	@echo -e '\nQuantum ESPRESSO binaries are installed in $(DESTDIR)$(PREFIX)/bin\n'
268
269#########################################################
270# Other targets: clean up
271#########################################################
272
273# remove object files and executables
274clean :
275	touch make.inc
276	for dir in \
277		CPV LAXlib FFTXlib UtilXlib upflib Modules PP PW EPW KS_Solvers \
278		NEB ACFDT COUPLE GWW XSpectra PWCOND dft-d3 \
279		atomic clib LR_Modules pwtools upflib \
280		dev-tools extlibs Environ TDDFPT PHonon HP GWW Doc GUI \
281	; do \
282	    if test -d $$dir ; then \
283		( cd $$dir ; \
284		$(MAKE) TLDEPS= clean ) \
285	    fi \
286	done
287	- @(cd install ; $(MAKE) -f plugins_makefile clean)
288	- @(cd install ; $(MAKE) -f extlibs_makefile clean)
289	- /bin/rm -rf bin/*.x tempdir
290
291# remove files produced by "configure" as well
292veryclean : clean
293	- @(cd install ; $(MAKE) -f plugins_makefile veryclean)
294	- @(cd install ; $(MAKE) -f extlibs_makefile veryclean)
295	- (cd install ; rm -rf config.log configure.msg config.status \
296		configure.h make_wannier90.inc autom4te.cache )
297	- (cd include; rm -rf configure.in qe_cdefs.h )
298	- rm -f espresso.tar.gz
299	- rm -rf make.inc
300	- rm -rf FoX
301# remove everything not in the original distribution
302distclean : veryclean
303	- cd pseudo; ./clean_ps ; cd -
304	( cd install ; $(MAKE) -f plugins_makefile $@ || exit 1 )
305
306tar :
307	@if test -f espresso.tar.gz ; then /bin/rm espresso.tar.gz ; fi
308	# do not include unneeded stuff
309	find ./ -type f | grep -v -e /.svn/ -e'/\.' -e'\.o$$' -e'\.mod$$'\
310		-e /.git/ -e'\.a$$' -e'\.d$$' -e'\.i$$' -e'_tmp\.f90$$' -e'\.x$$' \
311		-e'~$$' -e'\./GUI' -e '\./tempdir' | xargs tar rvf espresso.tar
312	gzip espresso.tar
313
314#########################################################
315# Tools for the developers
316#########################################################
317tar-gui :
318	@if test -d GUI/PWgui ; then \
319	    cd GUI/PWgui ; \
320	    $(MAKE) TLDEPS= clean init pwgui-source; \
321	    mv PWgui-*.tgz ../.. ; \
322	else \
323	    echo ; \
324	    echo "  Sorry, tar-gui works only for git sources !!!" ; \
325	    echo ; \
326	fi
327
328tar-qe-modes :
329	@if test -d GUI/QE-modes ; then \
330	    cd GUI/QE-modes ; \
331	    $(MAKE) TLDEPS= veryclean tar; \
332	    mv QE-modes-*.tar.gz ../.. ; \
333	else \
334	    echo ; \
335	    echo "  Sorry, tar-qe-modes works only for git sources !!!" ; \
336	    echo ; \
337	fi
338
339# NOTICE about "make doc": in order to build the .html and .txt
340# documentation in Doc, "tcl", "tcllib", "xsltproc" are needed;
341# in order to build the .pdf files in Doc, "pdflatex" is needed;
342# in order to build html files for the user guide,
343# "latex2html" and "convert" (from Image-Magick) are needed.
344doc :
345	if test -d Doc ; then \
346	( cd Doc ; $(MAKE) VERSION=6.6 TLDEPS= all ) ; fi
347	for dir in */Doc; do \
348	( if test -f $$dir/Makefile ; then \
349	( cd $$dir; $(MAKE) VERSION=6.6 TLDEPS= all ) ; fi ) ;  done
350
351doc_clean :
352	if test -d Doc ; then \
353	( cd Doc ; $(MAKE) TLDEPS= clean ) ; fi
354	for dir in */Doc; do \
355	( if test -f $$dir/Makefile ; then \
356	( cd $$dir; $(MAKE) TLDEPS= clean ) ; fi ) ;  done
357
358depend:
359	@echo 'Checking dependencies...'
360	- ( if test -x install/makedeps.sh ; then install/makedeps.sh ; fi)
361