xref: /petsc/makefile (revision c4762a1b19cd2af06abeed90e8f9d34fb975dd94)
1#
2# This is the makefile for compiling PETSc. See
3# http://www.mcs.anl.gov/petsc/documentation/installation.html for directions on installing PETSc.
4# See also conf for additional commands.
5#
6ALL: all
7LOCDIR	 = ./
8DIRS	 = src include tutorials interfaces share/petsc/matlab
9CFLAGS	 =
10FFLAGS	 =
11CPPFLAGS =
12FPPFLAGS =
13
14# next line defines PETSC_DIR and PETSC_ARCH if they are not set
15include ././${PETSC_ARCH}/lib/petsc/conf/petscvariables
16include ${PETSC_DIR}/lib/petsc/conf/variables
17include ${PETSC_DIR}/lib/petsc/conf/rules
18include ${PETSC_DIR}/lib/petsc/conf/test.common
19
20# This makefile contains a lot of PHONY targets with improperly specified prerequisites
21# where correct execution instead depends on the targets being processed in the correct
22# order.  This is gross, but this makefile doesn't really do any work.  Sub-makes still
23# benefit from parallelism.
24.NOTPARALLEL:
25
26#
27# Basic targets to build PETSc libraries.
28#
29all:
30	+@${OMAKE}  PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} chk_petscdir chk_upgrade | tee ${PETSC_ARCH}/lib/petsc/conf/make.log
31	@ln -sf ${PETSC_ARCH}/lib/petsc/conf/make.log make.log
32	+@${OMAKE_PRINTDIR} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} all-local 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;
33	@egrep -i "( error | error: |no such file or directory)" ${PETSC_ARCH}/lib/petsc/conf/make.log | tee ${PETSC_ARCH}/lib/petsc/conf/error.log > /dev/null
34	+@if test -s ${PETSC_ARCH}/lib/petsc/conf/error.log; then \
35           printf ${PETSC_TEXT_HILIGHT}"**************************ERROR*************************************\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \
36           echo "  Error during compile, check ${PETSC_ARCH}/lib/petsc/conf/make.log" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \
37           echo "  Send it and ${PETSC_ARCH}/lib/petsc/conf/configure.log to petsc-maint@mcs.anl.gov" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\
38           printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\
39	 else \
40	  ${OMAKE} print_mesg_after_build PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log ;\
41        fi #solaris make likes to print the whole command that gave error. So split this up into the smallest chunk below
42	@echo "Finishing make run at `date +'%a, %d %b %Y %H:%M:%S %z'`" >> ${PETSC_ARCH}/lib/petsc/conf/make.log
43	@if test -s ${PETSC_ARCH}/lib/petsc/conf/error.log; then exit 1; fi
44
45all-local: info libs matlabbin mpi4py-build petsc4py-build libmesh-build mfem-build slepc-build hpddm-build amrex-build
46
47#
48# Prints information about the system and version of PETSc being compiled
49#
50info:
51	-@echo "=========================================="
52	-@echo " "
53	-@echo "See documentation/faq.html and documentation/bugreporting.html"
54	-@echo "for help with installation problems.  Please send EVERYTHING"
55	-@echo "printed out below when reporting problems.  Please check the"
56	-@echo "mailing list archives and consider subscribing."
57	-@echo " "
58	-@echo "  http://www.mcs.anl.gov/petsc/miscellaneous/mailing-lists.html"
59	-@echo " "
60	-@echo "=========================================="
61	-@echo Starting make run on `hostname` at `date +'%a, %d %b %Y %H:%M:%S %z'`
62	-@echo Machine characteristics: `uname -a`
63	-@echo "-----------------------------------------"
64	-@echo "Using PETSc directory: ${PETSC_DIR}"
65	-@echo "Using PETSc arch: ${PETSC_ARCH}"
66	-@echo "-----------------------------------------"
67	-@grep "define PETSC_VERSION" ${PETSC_DIR}/include/petscversion.h | ${SED} "s/........//"
68	-@echo "-----------------------------------------"
69	-@echo "Using configure Options: ${CONFIGURE_OPTIONS}"
70	-@echo "Using configuration flags:"
71	-@grep "\#define " ${PETSCCONF_H}
72	-@echo "-----------------------------------------"
73	-@echo "Using C compile: ${PETSC_CCOMPILE}"
74	-@if [  "${MPICC_SHOW}" != "" ]; then \
75             printf  "mpicc -show: %b\n" "${MPICC_SHOW}";\
76          fi; \
77        printf  "C compiler version: %b\n" "${C_VERSION}"; \
78        if [ "${PETSC_CXXCOMPILE}" != "" ]; then \
79        echo "Using C++ compile: ${PETSC_CXXCOMPILE}";\
80        if [ "${MPICXX_SHOW}" != "" ]; then \
81               printf "mpicxx -show: %b\n" "${MPICXX_SHOW}"; \
82            fi;\
83            printf  "C++ compiler version: %b\n" "${Cxx_VERSION}"; \
84          fi
85	-@if [ "${FC}" != "" ]; then \
86	   echo "Using Fortran compile: ${PETSC_FCOMPILE}";\
87           if [ "${MPIFC_SHOW}" != "" ]; then \
88             printf "mpif90 -show: %b\n" "${MPIFC_SHOW}"; \
89           fi; \
90             printf  "Fortran compiler version: %b\n" "${FC_VERSION}"; \
91         fi
92	-@if [ "${CUDAC}" != "" ]; then \
93	   echo "Using CUDA compile: ${PETSC_CUCOMPILE}";\
94         fi
95	-@if [ "${CLANGUAGE}" = "CXX" ]; then \
96           echo "Using C++ compiler to compile PETSc";\
97        fi
98	-@echo "-----------------------------------------"
99	-@echo "Using C/C++ linker: ${PCC_LINKER}"
100	-@echo "Using C/C++ flags: ${PCC_LINKER_FLAGS}"
101	-@if [ "${FC}" != "" ]; then \
102	   echo "Using Fortran linker: ${FC_LINKER}";\
103	   echo "Using Fortran flags: ${FC_LINKER_FLAGS}";\
104         fi
105	-@echo "-----------------------------------------"
106	-@echo "Using system modules: ${LOADEDMODULES}"
107	-@if [ "${MPI_IS_MPIUNI}" = "1" ]; then \
108           echo Using mpi.h: mpiuni; \
109        else \
110           TESTDIR=`mktemp -q -d -t petscmpi-XXXXXXXX` && \
111           echo '#include <mpi.h>' > $${TESTDIR}/mpitest.c && \
112           BUF=`${CPP} ${PETSC_CPPFLAGS} ${PETSC_CC_INCLUDES} $${TESTDIR}/mpitest.c |grep 'mpi\.h' | ( head -1 ; cat > /dev/null )` && \
113           echo Using mpi.h: $${BUF}; ${RM} -rf $${TESTDIR}; \
114        fi
115	-@echo "-----------------------------------------"
116	-@echo "Using libraries: ${PETSC_LIB}"
117	-@echo "------------------------------------------"
118	-@echo "Using mpiexec: ${MPIEXEC}"
119	-@echo "------------------------------------------"
120	-@echo "Using MAKEFLAGS: -j$(MAKE_NP) -l$(MAKE_LOAD) $(MAKEFLAGS)"
121	-@echo "=========================================="
122
123#
124# Build MatLab binaries
125#
126matlabbin:
127	-@if [ "${MATLAB_MEX}" != "" -a "${MATLAB_SOCKET}" != "" -a "${PETSC_SCALAR}" = "real" -a "${PETSC_PRECISION}" = "double" ]; then \
128          echo "BEGINNING TO COMPILE MATLAB INTERFACE"; \
129            if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc" ] ; then ${MKDIR}  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc; fi; \
130            if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab" ] ; then ${MKDIR}  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab; fi; \
131            cd src/sys/classes/viewer/impls/socket/matlab && ${OMAKE} matlabcodes PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR}; \
132            echo "========================================="; \
133        fi
134#
135# Builds PETSc test examples for a given architecture
136#
137test_install: test
138check: test
139test:
140	-+@${OMAKE} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test_build 2>&1 | tee ./${PETSC_ARCH}/lib/petsc/conf/test.log
141testx:
142	-@${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testx_build 2>&1 | tee ./${PETSC_ARCH}/lib/petsc/conf/testx.log
143test_build:
144	-@echo "Running test examples to verify correct installation"
145	-@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}"
146	+@cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean
147	+@cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testex19
148	+@if [ "${HYPRE_LIB}" != "" ] && [ "${PETSC_WITH_BATCH}" = "" ] &&  [ "${PETSC_SCALAR}" = "real" ]; then \
149          cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex19_hypre; \
150         fi;
151	+@if [ "${MUMPS_LIB}" != "" ] && [ "${PETSC_WITH_BATCH}" = "" ]; then \
152          cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR}  DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex19_fieldsplit_mumps; \
153         fi;
154	+@if [ "${SUPERLU_DIST_LIB}" != "" ] && [ "${PETSC_WITH_BATCH}" = "" ]; then \
155          cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR}  DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex19_superlu_dist; \
156         fi;
157	+@if [ "${HDF5_LIB}" != "" ] && [ "${PETSC_WITH_BATCH}" = "" ]; then \
158          cd src/vec/vec/tests >/dev/null; \
159          ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean; \
160          ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} ex47.PETSc DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex47; \
161          ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean; \
162         fi;
163	+@if [ "${AMREX_LIB}" != "" ] && [ "${PETSC_WITH_BATCH}" = "" ]; then \
164           echo "Running testamres examples to verify correct installation";\
165           echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}";\
166           cd src/ksp/ksp/tutorials/amrex >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean;\
167           ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testamrex;\
168         fi;
169	+@if ( [ "${ML_LIB}" != "" ] ||  [ "${TRILINOS_LIB}" != "" ] ) && [ "${PETSC_WITH_BATCH}" = "" ]; then \
170          cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR}  DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex19_ml; \
171         fi;
172	+@if [ "${SUITESPARSE_LIB}" != "" ] && [ "${PETSC_WITH_BATCH}" = "" ]; then \
173          cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex19_suitesparse; \
174         fi;
175	+@cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} ex19.rm
176	+@if [ "${PETSC4PY}" = "yes" ]; then \
177          cd src/ksp/ksp/tutorials >/dev/null; \
178          ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean; \
179          ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testex100; \
180          ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean; \
181         fi;
182	+@egrep "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \
183         if test -s .ftn.log; then \
184          cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testex5f; \
185         fi; ${RM} .ftn.log;
186	+@cd src/snes/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean
187	-@echo "Completed test examples"
188testx_build:
189	-@echo "Running graphics test example to verify correct X11 installation"
190	-@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}"
191	@cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean
192	@cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testxex19
193	@cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean
194	-@echo "Completed graphics test example"
195test_usermakefile:
196	-@echo "Testing compile with user makefile"
197	-@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}"
198	@cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex19
199	@egrep "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \
200         if test -s .ftn.log; then \
201          cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex5f; \
202         fi; ${RM} .ftn.log;
203	@cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean
204	-@echo "Completed compile with user makefile"
205
206# Compare ABI/API of two versions of PETSc library with the old one defined by PETSC_{DIR,ARCH}_ABI_OLD
207abitest:
208	@if [ "${PETSC_DIR_ABI_OLD}" = "" ] || [ "${PETSC_ARCH_ABI_OLD}" = "" ]; \
209		then printf "You must set environment variables PETSC_DIR_ABI_OLD and PETSC_ARCH_ABI_OLD to run abitest\n"; \
210		exit 1; \
211	fi;
212	-@echo "Comparing ABI/API of the following two PETSc versions (you must have already configured and built them using GCC and with -g):"
213	-@echo "========================================================================================="
214	-@echo "    Old: PETSC_DIR_ABI_OLD  = ${PETSC_DIR_ABI_OLD}"
215	-@echo "         PETSC_ARCH_ABI_OLD = ${PETSC_ARCH_ABI_OLD}"
216	-@pushd ${PETSC_DIR_ABI_OLD} >> /dev/null ; echo "         Branch             = "`git rev-parse --abbrev-ref HEAD`
217	-@echo "    New: PETSC_DIR          = ${PETSC_DIR}"
218	-@echo "         PETSC_ARCH         = ${PETSC_ARCH}"
219	-@echo "         Branch             = "`git rev-parse --abbrev-ref HEAD`
220	-@echo "========================================================================================="
221	-@$(PYTHON)	${PETSC_DIR}/lib/petsc/bin/maint/abicheck.py -old_dir ${PETSC_DIR_ABI_OLD} -old_arch ${PETSC_ARCH_ABI_OLD} -new_dir ${PETSC_DIR} -new_arch ${PETSC_ARCH} -report_format html
222
223# Compare ABI/API of current PETSC_ARCH/PETSC_DIR with a previous branch
224abitestcomplete:
225	-@if [[ -f "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/configure.log" ]]; then \
226          OPTIONS=`grep -h -m 1 "Configure Options: " ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/configure.log  | sed "s!Configure Options: --configModules=PETSc.Configure --optionsModule=config.compilerOptions!!g"` ;\
227echo $${OPTIONS} ;\
228        fi ; \
229        if [[ "${PETSC_DIR_ABI_OLD}" != "" ]]; then \
230          PETSC_DIR_OLD=${PETSC_DIR_ABI_OLD}; \
231        else \
232          PETSC_DIR_OLD=${PETSC_DIR}/../petsc-abi; \
233        fi ; \
234        echo "=================================================================================================" ;\
235        echo "Doing ABI/API comparison between" ${branch} " and " `git rev-parse --abbrev-ref HEAD` "using " $${OPTIONS} ;\
236        echo "=================================================================================================" ;\
237        if [[ ! -d $${PETSC_DIR_OLD} ]]; then \
238          git clone ${PETSC_DIR} $${PETSC_DIR_OLD} ; \
239        else \
240          cd $${PETSC_DIR_OLD} ; \
241          git pull ; \
242        fi ; \
243        cd $${PETSC_DIR_OLD} ; \
244        git checkout ${branch} ; \
245        PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` ./configure $${OPTIONS} ; \
246        PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` make all test ; \
247        cd ${PETSC_DIR} ; \
248        ./configure $${OPTIONS}; \
249        make all test ; \
250        PETSC_DIR_ABI_OLD=$${PETSC_DIR_OLD} PETSC_ARCH_ABI_OLD=arch-branch-`git rev-parse ${branch}` make abitest
251
252# Deletes PETSc libraries
253deletelibs:
254	-${RM} -rf ${PETSC_LIB_DIR}/libpetsc*.*
255deletemods:
256	-${RM} -f ${PETSC_DIR}/${PETSC_ARCH}/include/petsc*.mod
257
258allclean:
259	-@${OMAKE} -f gmakefile clean
260
261clean:: allclean
262
263distclean: chk_petscdir
264	@if [ -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ]; then \
265	  echo "*** Preserving ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py in ${PETSC_DIR} ***"; \
266          mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/; fi
267	@echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***"
268	-${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/
269
270
271#
272reconfigure:
273	@unset MAKEFLAGS && ${PYTHON} ${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py
274#
275install:
276	@${PYTHON} ./config/install.py -destDir=${DESTDIR}
277	+${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} mpi4py-install petsc4py-install libmesh-install mfem-install slepc-install hpddm-install amrex-install
278
279mpistreams:
280	+@cd src/benchmarks/streams; ${OMAKE} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistreams
281
282mpistream:
283	+@cd src/benchmarks/streams; ${OMAKE} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistream
284
285openmpstreams:
286	+@cd src/benchmarks/streams; ${OMAKE} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstreams
287
288openmpstream:
289	+@cd src/benchmarks/streams; ${OMAKE} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstream
290
291# for legacy reasons
292stream: mpistream
293
294streams: mpistreams
295
296# ------------------------------------------------------------------
297#
298# All remaining actions are intended for PETSc developers only.
299# PETSc users should not generally need to use these commands.
300#
301#  See the users manual for how the tags files may be used from Emacs and Vi/Vim
302#
303alletags:
304	-@${PYTHON} lib/petsc/bin/maint/generateetags.py
305	-@find config -type f -name "*.py" |grep -v SCCS | xargs etags -o TAGS_PYTHON
306
307# obtain gtags from http://www.gnu.org/s/global/
308allgtags:
309	-@find ${PETSC_DIR}/include ${PETSC_DIR}/src -regex '\(.*makefile\|.*\.\(cc\|hh\|cpp\|C\|hpp\|c\|h\|cu\|m\)$$\)' | grep -v ftn-auto  | gtags -f -
310
311allfortranstubs:
312	-@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir
313	@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py ${BFORT}  ${VERBOSE}
314	-@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py -merge  ${VERBOSE}
315	-@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir
316deletefortranstubs:
317	-@find . -type d -name ftn-auto | xargs rm -rf
318
319# Builds all the documentation - should be done every night
320alldoc: allcite allpdf alldoc1 alldoc2 docsetdate
321
322# Build just citations
323allcite: chk_loc deletemanualpages
324	-${PYTHON} lib/petsc/bin/maint/countpetsccits.py
325	-${OMAKE} ACTION=manualpages_buildcite tree_basic LOC=${LOC}
326	-@sed -e s%man+../%man+manualpages/% ${LOC}/docs/manualpages/manualpages.cit > ${LOC}/docs/manualpages/htmlmap
327	-@cat ${PETSC_DIR}/src/docs/mpi.www.index >> ${LOC}/docs/manualpages/htmlmap
328
329# Build just PDF manuals + prerequisites
330allpdf: chk_loc allcite
331	-cd src/docs/tex/manual; ${OMAKE} manual.pdf LOC=${LOC}
332	-cd src/docs/tex/manual; ${OMAKE} developers.pdf LOC=${LOC}
333	-cd src/docs/tao_tex/manual; ${OMAKE} manual.pdf LOC=${LOC}
334
335# Build just manual pages + prerequisites
336allmanpages: chk_loc allcite
337	-${OMAKE} ACTION=manualpages tree_basic LOC=${LOC}
338
339# Build just manual examples + prerequisites
340allmanexamples: chk_loc allmanpages
341	-${OMAKE} ACTION=manexamples tree_basic LOC=${LOC}
342
343# Build everything that goes into 'doc' dir except html sources
344alldoc1: chk_loc chk_concepts_dir allcite allmanpages allmanexamples
345	-${OMAKE} manimplementations LOC=${LOC}
346	-${PYTHON} lib/petsc/bin/maint/wwwindex.py ${PETSC_DIR} ${LOC}
347	-${OMAKE} ACTION=getexlist tree_basic LOC=${LOC}
348	-${OMAKE} ACTION=exampleconcepts tree_basic LOC=${LOC}
349	-${PYTHON} lib/petsc/bin/maint/helpindex.py ${PETSC_DIR} ${LOC}
350
351# Builds .html versions of the source
352# html overwrites some stuff created by update-docs - hence this is done later.
353alldoc2: chk_loc
354	-${OMAKE} ACTION=html PETSC_DIR=${PETSC_DIR} alltree LOC=${LOC}
355	-${PYTHON} lib/petsc/bin/maint/update-docs.py ${PETSC_DIR} ${LOC}
356#
357# Makes links for all manual pages in $LOC/docs/manualpages/all
358allman:
359	@cd ${LOC}/docs/manualpages; rm -rf all ; mkdir all ; find *  -type d -wholename all -prune -o -name index.html -prune  -o -type f -name \*.html -exec ln -s  -f ../{} all \;
360
361DOCSETDATE_PRUNE_LIST=-o -type f -wholename share/petsc/saws/linearsolveroptions.html -prune -o -type f -wholename tutorials/HandsOnExercise.html -prune -o -type f -wholename tutorials/TAOHandsOnExercise.html -prune
362
363# modify all generated html files and add in version number, date, canonical URL info.
364docsetdate: chk_petscdir
365	@echo "Updating generated html files with petsc version, date, canonical URL info";\
366        version_release=`grep '^#define PETSC_VERSION_RELEASE ' include/petscversion.h |tr -s ' ' | cut -d ' ' -f 3`; \
367        version_major=`grep '^#define PETSC_VERSION_MAJOR ' include/petscversion.h |tr -s ' ' | cut -d ' ' -f 3`; \
368        version_minor=`grep '^#define PETSC_VERSION_MINOR ' include/petscversion.h |tr -s ' ' | cut -d ' ' -f 3`; \
369        version_subminor=`grep '^#define PETSC_VERSION_SUBMINOR ' include/petscversion.h |tr -s ' ' | cut -d ' ' -f 3`; \
370        if  [ $${version_release} = 0 ]; then \
371          petscversion=petsc-master; \
372          export petscversion; \
373        elif [ $${version_release} = 1 ]; then \
374          petscversion=petsc-$${version_major}.$${version_minor}.$${version_subminor}; \
375          export petscversion; \
376        else \
377          echo "Unknown PETSC_VERSION_RELEASE: $${version_release}"; \
378          exit; \
379        fi; \
380        datestr=`git log -1 --pretty=format:%ci | cut -d ' ' -f 1`; \
381        export datestr; \
382        gitver=`git describe --match "v*"`; \
383        export gitver; \
384        find * -type d -wholename src/docs/website \
385          -prune -o -type d -wholename src/benchmarks/results \
386          -prune -o -type d -wholename config/BuildSystem/docs/website \
387          -prune -o -type d -wholename include/web \
388          -prune -o -type d -wholename 'arch-*' \
389          -prune -o -type d -wholename lib/petsc/bin/maint \
390          -prune -o -type d -wholename externalpackages \
391          -prune ${DOCSETDATE_PRUNE_LIST} -o -type f -name \*.html \
392          -exec perl -pi -e 's^(<body.*>)^$$1\n   <div id=\"version\" align=right><b>$$ENV{petscversion} $$ENV{datestr}</b></div>\n   <div id="bugreport" align=right><a href="mailto:petsc-maint\@mcs.anl.gov?subject=Typo or Error in Documentation &body=Please describe the typo or error in the documentation: $$ENV{petscversion} $$ENV{gitver} {} "><small>Report Typos and Errors</small></a></div>^i' {} \; \
393          -exec perl -pi -e 's^(<head>)^$$1 <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/{}" />^i' {} \; ; \
394        echo "Done fixing version number, date, canonical URL info"
395
396alldocclean: deletemanualpages allcleanhtml
397
398# Deletes man pages (HTML version)
399deletemanualpages: chk_loc
400	-@if [ -d ${LOC} -a -d ${LOC}/docs/manualpages ]; then \
401          find ${LOC}/docs/manualpages -type f -name "*.html" -exec ${RM} {} \; ;\
402          ${RM} ${LOC}/docs/exampleconcepts ;\
403          ${RM} ${LOC}/docs/manualpages/manualpages.cit ;\
404          ${PYTHON} lib/petsc/bin/maint/update-docs.py ${PETSC_DIR} ${LOC} clean;\
405        fi
406
407allcleanhtml:
408	-${OMAKE} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} alltree
409
410chk_concepts_dir: chk_loc
411	@if [ ! -d "${LOC}/docs/manualpages/concepts" ]; then \
412	  echo Making directory ${LOC}/docs/manualpages/concepts for library; ${MKDIR} ${LOC}/docs/manualpages/concepts; fi
413
414###########################################################
415# targets to build distribution and update docs
416###########################################################
417
418# Creates ${HOME}/petsc.tar.gz [and petsc-lite.tar.gz]
419dist:
420	${PETSC_DIR}/lib/petsc/bin/maint/builddist ${PETSC_DIR} master
421
422# This target works only if you can do 'ssh petsc@login.mcs.anl.gov'
423# also copy the file over to ftp site.
424web-snapshot:
425	@if [ ! -f "${HOME}/petsc-master.tar.gz" ]; then \
426	    echo "~/petsc-master.tar.gz missing! cannot update petsc-master snapshot on mcs-web-site"; \
427	  else \
428            echo "updating petsc-master snapshot on mcs-web-site"; \
429	    tmpdir=`mktemp -d -t petsc-doc.XXXXXXXX`; \
430	    cd $${tmpdir}; tar -xzf ${HOME}/petsc-master.tar.gz; \
431	    /usr/bin/rsync  -e ssh -az --delete $${tmpdir}/petsc-master/ \
432              petsc@login.mcs.anl.gov:/mcs/web/research/projects/petsc/petsc-master ;\
433	    /bin/cp -f /home/petsc/petsc-master.tar.gz /mcs/ftp/pub/petsc/petsc-master.tar.gz;\
434	    ${RM} -rf $${tmpdir} ;\
435	  fi
436
437# build the tarfile - and then update petsc-master snapshot on mcs-web-site
438update-web-snapshot: dist web-snapshot
439
440# This target updates website main pages
441update-web:
442	@cd ${PETSC_DIR}/src/docs; make PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} bib2html; \
443	/usr/bin/rsync -az -C --exclude=documentation/index.html \
444          --exclude=documentation/installation.html --exclude=download/index.html \
445	  ${PETSC_DIR}/src/docs/website/ petsc@login.mcs.anl.gov:/mcs/web/research/projects/petsc
446	@cd ${PETSC_DIR}/docs; /usr/bin/rsync -az developers.pdf petsc@login.mcs.anl.gov:/mcs/web/research/projects/petsc/developers/
447	@cd ${PETSC_DIR}/src/docs/tex; /usr/bin/rsync -az petscapp.bib petsc.bib petsc@login.mcs.anl.gov:/mcs/web/research/projects/petsc/publications
448
449###########################################################
450#
451#  See script for details
452#
453gcov:
454	-@$(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py --run_gcov --petsc_arch ${PETSC_ARCH}
455
456mergegcov:
457	-@$(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py --merge_gcov --loc=${LOC} --petsc_arch ${PETSC_ARCH}
458
459
460########################
461#
462# Create the include dependency graph (requires graphviz to be available)
463#
464includegraph:
465	-@${PETSC_DIR}/src/contrib/style/include-graph.sh includegraph.pdf
466	-@echo Include dependency graph written to includegraph.pdf
467
468check_output:
469	-@${OMAKE} -f gmakefile.test check_output
470#
471# -------------------------------------------------------------------------------
472#
473# Some macros to check if the fortran interface is up-to-date.
474#
475countfortranfunctions:
476	-@cd ${PETSC_DIR}/src/fortran; egrep '^void' custom/*.c auto/*.c | \
477	cut -d'(' -f1 | tr -s  ' ' | cut -d' ' -f2 | uniq | egrep -v "(^$$|Petsc)" | \
478	sed "s/_$$//" | sort > /tmp/countfortranfunctions
479
480countcfunctions:
481	-@grep PETSC_EXTERN ${PETSC_DIR}/include/*.h  | grep "(" | tr -s ' ' | \
482	cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' |  \
483	tr 'A-Z' 'a-z' |  sort | uniq > /tmp/countcfunctions
484
485difffortranfunctions: countfortranfunctions countcfunctions
486	-@echo -------------- Functions missing in the fortran interface ---------------------
487	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2
488	-@echo ----------------- Functions missing in the C interface ------------------------
489	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2
490	-@${RM}  /tmp/countcfunctions /tmp/countfortranfunctions
491
492checkbadfortranstubs:
493	-@echo "========================================="
494	-@echo "Functions with MPI_Comm as an Argument"
495	-@echo "========================================="
496	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \
497	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
498	-@echo "========================================="
499	-@echo "Functions with a String as an Argument"
500	-@echo "========================================="
501	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \
502	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
503	-@echo "========================================="
504	-@echo "Functions with Pointers to PETSc Objects as Argument"
505	-@echo "========================================="
506	-@cd ${PETSC_DIR}/src/fortran/auto; \
507	_p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \
508	cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \
509	sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \
510	for OBJ in $$_p_OBJ; do \
511	grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \
512	cut -d'(' -f1 | cut -d' ' -f1,3; \
513	done
514
515checkpackagetests:
516	-@echo "Missing package tests"
517	-@cat config/examples/*.py > configexamples; pushd config/BuildSystem/config/packages/; packages=`ls *.py | sed "s/\\.py//g"`;popd; for i in $${packages}; do j=`echo $${i} | tr '[:upper:]' '[:lower:]'`; printf $${j} ; egrep "(with-$${j}|download-$${j})" configexamples | grep -v "=0" | wc -l ; done
518	-@echo "Missing download package tests"
519	-@cat config/examples/*.py > configexamples; pushd config/BuildSystem/config/packages/; packages=`grep -l "download " *.py  | sed "s/\\.py//g"`;popd; for i in $${packages}; do j=`echo $${i} | tr '[:upper:]' '[:lower:]'`; printf $${j} ; egrep "(download-$${j})" configexamples | grep -v "=0" | wc -l ; done
520
521.PHONY: info info_h all deletelibs allclean update \
522        alletags etags etags_complete etags_noexamples etags_makefiles etags_examples etags_fexamples alldoc allmanualpages \
523        allhtml allcleanhtml  countfortranfunctions \
524        start_configure configure_petsc configure_clean matlabbin install
525