xref: /petsc/makefile (revision 4bbf5ea87ee73436f0fee53b672039f91ba53c48)
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
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
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# all: builds the c, fortran, and f90 libraries
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	+@if [ "${MAKE_IS_GNUMAKE}" != "" ]; then \
33	   ${OMAKE_PRINTDIR} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} all-gnumake-local 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \
34	elif [ "${PETSC_BUILD_USING_CMAKE}" != "" ]; then \
35	   ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} all-cmake-local 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log \
36		| egrep -v '( --check-build-system |cmake -E | -o CMakeFiles/petsc[[:lower:]]*.dir/| -o lib/libpetsc|CMakeFiles/petsc[[:lower:]]*\.dir/(build|depend|requires)|-f CMakeFiles/Makefile2|Dependee .* is newer than depender |provides\.build. is up to date)'; \
37	 else \
38	   ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} all-legacy-local 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log \
39                | ${GREP} -v "has no symbols"; \
40	 fi
41	@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
42	+@if test -s ${PETSC_ARCH}/lib/petsc/conf/error.log; then \
43           printf ${PETSC_TEXT_HILIGHT}"**************************ERROR*************************************\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \
44           echo "  Error during compile, check ${PETSC_ARCH}/lib/petsc/conf/make.log" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \
45           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;\
46           printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\
47	 else \
48	  ${OMAKE} shared_install PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log ;\
49        fi #solaris make likes to print the whole command that gave error. So split this up into the smallest chunk below
50	@echo "Finishing make run at `date +'%a, %d %b %Y %H:%M:%S %z'`" >> ${PETSC_ARCH}/lib/petsc/conf/make.log
51	@if test -s ${PETSC_ARCH}/lib/petsc/conf/error.log; then exit 1; fi
52
53all-gnumake:
54	@if [ "${MAKE_IS_GNUMAKE}" != "" ]; then \
55          ${OMAKE_PRINTDIR}  PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} PETSC_BUILD_USING_CMAKE="" all;\
56        else printf ${PETSC_TEXT_HILIGHT}"Build not configured for GNUMAKE. Quiting"${PETSC_TEXT_NORMAL}"\n"; exit 1; fi
57
58all-cmake:
59	@if [ "${PETSC_BUILD_USING_CMAKE}" != "" ]; then \
60          ${OMAKE}  PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} MAKE_IS_GNUMAKE="" all;\
61        else printf ${PETSC_TEXT_HILIGHT}"Build not configured for CMAKE. Quiting"${PETSC_TEXT_NORMAL}"\n"; exit 1; fi
62
63all-legacy:
64	@${OMAKE}  PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} PETSC_BUILD_USING_CMAKE="" MAKE_IS_GNUMAKE="" all
65
66all-gnumake-local: info gnumake matlabbin mpi4py-build petsc4py-build libmesh-build slepc-build
67
68all-cmake-local: info cmakegen cmake matlabbin mpi4py-build petsc4py-build
69
70all-legacy-local: chklib_dir info deletelibs deletemods build matlabbin shared_nomesg mpi4py-build petsc4py-build
71
72#
73# Prints information about the system and version of PETSc being compiled
74#
75info:
76	-@echo "=========================================="
77	-@echo " "
78	-@echo "See documentation/faq.html and documentation/bugreporting.html"
79	-@echo "for help with installation problems.  Please send EVERYTHING"
80	-@echo "printed out below when reporting problems.  Please check the"
81	-@echo "mailing list archives and consider subscribing."
82	-@echo " "
83	-@echo "  http://www.mcs.anl.gov/petsc/miscellaneous/mailing-lists.html"
84	-@echo " "
85	-@echo "=========================================="
86	-@echo Starting make run on `hostname` at `date +'%a, %d %b %Y %H:%M:%S %z'`
87	-@echo Machine characteristics: `uname -a`
88	-@echo "-----------------------------------------"
89	-@echo "Using PETSc directory: ${PETSC_DIR}"
90	-@echo "Using PETSc arch: ${PETSC_ARCH}"
91	-@echo "-----------------------------------------"
92	-@grep "define PETSC_VERSION" ${PETSC_DIR}/include/petscversion.h | ${SED} "s/........//"
93	-@echo "-----------------------------------------"
94	-@echo "Using configure Options: ${CONFIGURE_OPTIONS}"
95	-@echo "Using configuration flags:"
96	-@grep "\#define " ${PETSCCONF_H}
97	-@echo "-----------------------------------------"
98	-@echo "Using C/C++ compile: ${PETSC_COMPILE}"
99	-@if [ "${PETSC_LANGUAGE}" = "CONLY" -a "${MPICC_SHOW}" != "" ]; then \
100             printf  "mpicc -show: %b\n" "${MPICC_SHOW}"; \
101	  elif [ "${PETSC_LANGUAGE}" = "CXXONLY" -a "${MPICXX_SHOW}" != "" ]; then \
102             printf "mpicxx -show: %b\n" "${MPICXX_SHOW}"; \
103          fi;
104	-@if [ "${FC}" != "" ]; then \
105	   echo "Using Fortran compile: ${PETSC_FCOMPILE}";\
106           if [ "${MPIFC_SHOW}" != "" ]; then \
107             printf "mpif90 -show: %b\n" "${MPIFC_SHOW}"; \
108           fi; \
109         fi
110	-@if [ "${CUDAC}" != "" ]; then \
111	   echo "Using CUDA compile: ${PETSC_CUCOMPILE}";\
112         fi
113	-@echo "-----------------------------------------"
114	-@echo "Using C/C++ linker: ${PCC_LINKER}"
115	-@echo "Using C/C++ flags: ${PCC_LINKER_FLAGS}"
116	-@if [ "${FC}" != "" ]; then \
117	   echo "Using Fortran linker: ${FC_LINKER}";\
118	   echo "Using Fortran flags: ${FC_LINKER_FLAGS}";\
119         fi
120	-@echo "-----------------------------------------"
121	-@echo "Using system modules: ${LOADEDMODULES}"
122	-@echo Using mpi.h: `echo '#include <mpi.h>' > ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/mpitest.c; ${CPP} ${PETSC_CCPPFLAGS} ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/mpitest.c |grep 'mpi\.h' |  ( head -1 ; cat > /dev/null )`
123	-@echo "-----------------------------------------"
124	-@echo "Using libraries: ${PETSC_LIB}"
125	-@echo "------------------------------------------"
126	-@echo "Using mpiexec: ${MPIEXEC}"
127	-@echo "------------------------------------------"
128	-@echo "Using MAKEFLAGS: -j$(MAKE_NP) $(MAKEFLAGS)"
129	-@echo "=========================================="
130
131#
132# Builds the PETSc libraries
133# This target also builds fortran77 and f90 interface
134# files and compiles .F files
135#
136build:
137	-@echo "BEGINNING TO COMPILE LIBRARIES IN ALL DIRECTORIES"
138	-@echo "========================================="
139	-@${OMAKE}  PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=libfast tree
140	-@${RANLIB} ${PETSC_LIB_DIR}/*.${AR_LIB_SUFFIX}  > tmpf 2>&1 ; ${GREP} -v "has no symbols" tmpf; ${RM} tmpf;
141	-@echo "Completed building libraries"
142	-@echo "========================================="
143#
144# Build MatLab binaries
145#
146matlabbin:
147	-@if [ "${MATLAB_MEX}" != "" -a "${PETSC_SCALAR}" = "real" -a "${PETSC_PRECISION}" = "double" ]; then \
148          echo "BEGINNING TO COMPILE MATLAB INTERFACE"; \
149            if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc" ] ; then ${MKDIR}  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc; fi; \
150            if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab" ] ; then ${MKDIR}  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab; fi; \
151            cd src/sys/classes/viewer/impls/socket/matlab && ${OMAKE} matlabcodes PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR}; \
152            echo "========================================="; \
153        fi
154#
155# Builds PETSc test examples for a given architecture
156#
157test_install: test
158check: test
159test:
160	-@${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
161	-@if [ "${PETSC_WITH_BATCH}" = "" ]; then \
162          printf "=========================================\n"; \
163          printf "Now to evaluate the computer systems you plan use - do:\n"; \
164          printf "make PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} streams\n"; \
165        fi
166testx:
167	-@${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testx_build 2>&1 | tee ./${PETSC_ARCH}/lib/petsc/conf/testx.log
168test_build:
169	-@echo "Running test examples to verify correct installation"
170	-@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}"
171	@cd src/snes/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean
172	@cd src/snes/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testex19
173	@if [ "${HYPRE_LIB}" != "" ] && [ "${PETSC_WITH_BATCH}" = "" ]; then \
174          cd src/snes/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex19_hypre; \
175         fi;
176	@if [ "${MUMPS_LIB}" != "" ] && [ "${PETSC_WITH_BATCH}" = "" ]; then \
177          cd src/snes/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR}  DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex19_fieldsplit_mumps; \
178         fi;
179	@if [ "${SUPERLU_DIST_LIB}" != "" ] && [ "${PETSC_WITH_BATCH}" = "" ]; then \
180          cd src/snes/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR}  DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex19_superlu_dist; \
181         fi;
182	@if ( [ "${ML_LIB}" != "" ] ||  [ "${TRILINOS_LIB}" != "" ] ) && [ "${PETSC_WITH_BATCH}" = "" ]; then \
183          cd src/snes/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR}  DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff runex19_ml; \
184         fi;
185	@cd src/snes/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} ex19.rm
186	@if [ "${PETSC4PY}" = "yes" ]; then \
187          cd src/ksp/ksp/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testex100; \
188         fi;
189	@egrep "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \
190         if test -s .ftn.log; then \
191          cd src/snes/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testex5f; \
192         fi; ${RM} .ftn.log;
193	@cd src/snes/examples/tutorials >/dev/null; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean
194	-@echo "Completed test examples"
195testx_build:
196	-@echo "Running graphics test example to verify correct X11 installation"
197	-@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}"
198	@cd src/snes/examples/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean
199	@cd src/snes/examples/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testxex19
200	@cd src/snes/examples/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} clean
201	-@echo "Completed graphics test example"
202
203testexamples: info
204	-@echo "BEGINNING TO COMPILE AND RUN TEST EXAMPLES"
205	-@echo "Due to different numerical round-off on certain"
206	-@echo "machines some of the numbers may not match exactly."
207	-@echo "========================================="
208	-@${OMAKE} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} ACTION=testexamples_C  tree
209	-@echo "Completed compiling and running test examples"
210	-@echo "========================================="
211testfortran: info
212	-@echo "BEGINNING TO COMPILE AND RUN FORTRAN TEST EXAMPLES"
213	-@echo "========================================="
214	-@echo "Due to different numerical round-off on certain"
215	-@echo "machines or the way Fortran formats numbers"
216	-@echo "some of the results may not match exactly."
217	-@echo "========================================="
218	-@if [ "${FC}" != "" ]; then \
219            ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=testexamples_Fortran tree; \
220            echo "Completed compiling and running Fortran test examples"; \
221          else \
222            echo "Error: No FORTRAN compiler available"; \
223          fi
224	-@echo "========================================="
225testexamples_uni: info
226	-@echo "BEGINNING TO COMPILE AND RUN TEST UNI-PROCESSOR EXAMPLES"
227	-@echo "Due to different numerical round-off on certain"
228	-@echo "machines some of the numbers may not match exactly."
229	-@echo "========================================="
230	-@${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=testexamples_C_X_MPIUni  tree
231	-@echo "Completed compiling and running uniprocessor test examples"
232	-@echo "========================================="
233testfortran_uni: info
234	-@echo "BEGINNING TO COMPILE AND RUN TEST UNI-PROCESSOR FORTRAN EXAMPLES"
235	-@echo "Due to different numerical round-off on certain"
236	-@echo "machines some of the numbers may not match exactly."
237	-@echo "========================================="
238	-@if [ "${FC}" != "" ]; then \
239            ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=testexamples_Fortran_MPIUni  tree; \
240            echo "Completed compiling and running uniprocessor fortran test examples"; \
241          else \
242            echo "Error: No FORTRAN compiler available"; \
243          fi
244	-@
245	-@echo "========================================="
246
247# Ranlib on the libraries
248ranlib:
249	${RANLIB} ${PETSC_LIB_DIR}/*.${AR_LIB_SUFFIX}
250
251# Deletes PETSc libraries
252deletelibs:
253	-${RM} -rf ${PETSC_LIB_DIR}/libpetsc*.*
254deletemods:
255	-${RM} -f ${PETSC_DIR}/${PETSC_ARCH}/include/petsc*.mod
256
257# Cleans up build
258allclean-legacy: deletelibs deletemods
259	-@${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=clean-legacy tree
260allclean-cmake:
261	-@cd ${PETSC_ARCH} && ${OMAKE} clean
262allclean-gnumake:
263	-@${OMAKE} -f gmakefile clean
264
265allclean:
266	@if [ "${MAKE_IS_GNUMAKE}" != "" ]; then \
267	   ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} allclean-gnumake; \
268	elif [ "${PETSC_BUILD_USING_CMAKE}" != "" ]; then \
269	   ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} allclean-cmake; \
270	else \
271	   ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} allclean-legacy; \
272	fi
273
274clean:: allclean
275
276distclean: chk_petscdir
277	@if [ -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ]; then \
278	  echo "*** Preserving ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py in ${PETSC_DIR} ***"; \
279          mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/; fi
280	@echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***"
281	-${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/
282
283
284#
285reconfigure:
286	@${PYTHON} ${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py
287#
288install:
289	@${PYTHON} ./config/install.py -destDir=${DESTDIR}
290	${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} mpi4py-install petsc4py-install libmesh-install slepc-install
291
292newall:
293	-@cd src/sys;  @${PYTHON} ${PETSC_DIR}/config/builder.py
294	-@cd src/vec;  @${PYTHON} ${PETSC_DIR}/config/builder.py
295	-@cd src/mat;  @${PYTHON} ${PETSC_DIR}/config/builder.py
296	-@cd src/dm;   @${PYTHON} ${PETSC_DIR}/config/builder.py
297	-@cd src/ksp;  @${PYTHON} ${PETSC_DIR}/config/builder.py
298	-@cd src/snes; @${PYTHON} ${PETSC_DIR}/config/builder.py
299	-@cd src/ts;   @${PYTHON} ${PETSC_DIR}/config/builder.py
300
301streams:
302	cd src/benchmarks/streams; ${OMAKE} PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} streams
303
304stream:
305	cd src/benchmarks/streams; ${OMAKE} PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} stream
306# ------------------------------------------------------------------
307#
308# All remaining actions are intended for PETSc developers only.
309# PETSc users should not generally need to use these commands.
310#
311#  See the users manual for how the tags files may be used from Emacs and Vi/Vim
312#
313alletags:
314	-@${PYTHON} lib/petsc/bin/maint/generateetags.py
315	-@find config -type f -name "*.py" |grep -v SCCS | xargs etags -o TAGS_PYTHON
316
317# obtain gtags from http://www.gnu.org/s/global/
318allgtags:
319	-@find ${PETSC_DIR}/include ${PETSC_DIR}/src ${PETSC_DIR}/bin -regex '\(.*makefile\|.*\.\(cc\|hh\|cpp\|C\|hpp\|c\|h\|cu\|m\)$$\)' | grep -v ftn-auto  | gtags -f -
320
321allfortranstubs:
322	-@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir
323	@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py ${BFORT}  ${VERBOSE}
324	-@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py -merge  ${VERBOSE}
325	-@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir
326deletefortranstubs:
327	-@find . -type d -name ftn-auto | xargs rm -rf
328cmakegen:
329	-@${PYTHON} config/cmakegen.py
330#
331# These are here for the target allci and allco, and etags
332#
333
334BMAKEFILES = conf/variables conf/rules conf/test
335SCRIPTS    = lib/petsc/bin/maint/builddist  lib/petsc/bin/maint/wwwman lib/petsc/bin/maint/xclude lib/petsc/bin/maint/bugReport.py lib/petsc/bin/maint/buildconfigtest lib/petsc/bin/maint/builddistlite \
336             lib/petsc/bin/maint/buildtest lib/petsc/bin/maint/checkBuilds.py lib/petsc/bin/maint/copylognightly lib/petsc/bin/maint/copylognightly.tao lib/petsc/bin/maint/countfiles lib/petsc/bin/maint/findbadfiles \
337             lib/petsc/bin/maint/fixinclude lib/petsc/bin/maint/getexlist lib/petsc/bin/maint/getpdflabels.py lib/petsc/bin/maint/helpindex.py lib/petsc/bin/maint/hosts.local lib/petsc/bin/maint/hosts.solaris  \
338             lib/petsc/bin/maint/lex.py  lib/petsc/bin/maint/mapnameslatex.py lib/petsc/bin/maint/startnightly lib/petsc/bin/maint/startnightly.tao lib/petsc/bin/maint/submitPatch.py \
339             lib/petsc/bin/maint/update-docs.py  lib/petsc/bin/maint/wwwindex.py lib/petsc/bin/maint/xcludebackup lib/petsc/bin/maint/xcludecblas lib/petsc/bin/maint/zap lib/petsc/bin/maint/zapall \
340             config/PETSc/Configure.py config/PETSc/Options.py \
341             config/PETSc/utilities/*.py
342
343
344# Builds all the documentation - should be done every night
345alldoc: allcite allpdf alldoc1 alldoc2 alldoc3 docsetdate
346
347# Build just citations
348allcite: chk_loc deletemanualpages
349	-${PYTHON} lib/petsc/bin/maint/countpetsccits.py
350	-${OMAKE} ACTION=manualpages_buildcite tree_basic LOC=${LOC}
351	-@sed -e s%man+../%man+manualpages/% ${LOC}/docs/manualpages/manualpages.cit > ${LOC}/docs/manualpages/htmlmap
352	-@cat ${PETSC_DIR}/src/docs/mpi.www.index >> ${LOC}/docs/manualpages/htmlmap
353
354# Build just PDF manuals + prerequisites
355allpdf: chk_loc allcite
356	-cd src/docs/tex/manual; ${OMAKE} manual.pdf LOC=${LOC}
357	-cd src/docs/tex/manual; ${OMAKE} developers.pdf LOC=${LOC}
358	-cd src/docs/tao_tex/manual; ${OMAKE} manual.pdf LOC=${LOC}
359
360# Build just manual pages + prerequisites
361allmanpages: chk_loc allcite
362	-${OMAKE} ACTION=manualpages tree_basic LOC=${LOC}
363
364# Build just manual examples + prerequisites
365allmanexamples: chk_loc allmanpages
366	-${OMAKE} ACTION=manexamples tree_basic LOC=${LOC}
367
368# Build everything that goes into 'doc' dir except html sources
369alldoc1: chk_loc chk_concepts_dir allcite allmanpages allmanexamples
370	-${OMAKE} manimplementations LOC=${LOC}
371	-${PYTHON} lib/petsc/bin/maint/wwwindex.py ${PETSC_DIR} ${LOC}
372	-${OMAKE} manconcepts LOC=${LOC}
373	-${OMAKE} ACTION=getexlist tree_basic LOC=${LOC}
374	-${OMAKE} ACTION=exampleconcepts tree_basic LOC=${LOC}
375	-${PYTHON} lib/petsc/bin/maint/helpindex.py ${PETSC_DIR} ${LOC}
376
377# Builds .html versions of the source
378# html overwrites some stuff created by update-docs - hence this is done later.
379alldoc2: chk_loc
380	-${OMAKE} ACTION=html PETSC_DIR=${PETSC_DIR} alltree LOC=${LOC}
381	-${PYTHON} lib/petsc/bin/maint/update-docs.py ${PETSC_DIR} ${LOC}
382#
383# Builds HTML versions of Matlab scripts
384alldoc3: chk_loc
385	if  [ "${MATLAB_COMMAND}" != "" ]; then\
386          export MATLABPATH=${MATLABPATH}:${PETSC_DIR}/share/petsc/matlab; \
387          cd ${PETSC_DIR}/share/petsc/matlab; ${MATLAB_COMMAND} -nodisplay -nodesktop -r "generatehtml;exit" ; \
388        fi
389
390#
391# Makes links for all manual pages in $LOC/docs/manualpages/all
392allman:
393	@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 \;
394
395DOCSETDATE_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
396
397# modify all generated html files and add in version number, date, canonical URL info.
398docsetdate: chk_petscdir
399	@echo "Updating generated html files with petsc version, date, canonical URL info";\
400        version_release=`grep '^#define PETSC_VERSION_RELEASE ' include/petscversion.h |tr -s ' ' | cut -d ' ' -f 3`; \
401        version_major=`grep '^#define PETSC_VERSION_MAJOR ' include/petscversion.h |tr -s ' ' | cut -d ' ' -f 3`; \
402        version_minor=`grep '^#define PETSC_VERSION_MINOR ' include/petscversion.h |tr -s ' ' | cut -d ' ' -f 3`; \
403        version_subminor=`grep '^#define PETSC_VERSION_SUBMINOR ' include/petscversion.h |tr -s ' ' | cut -d ' ' -f 3`; \
404        if  [ $${version_release} = 0 ]; then \
405          petscversion=petsc-master; \
406          export petscversion; \
407        elif [ $${version_release} = 1 ]; then \
408          petscversion=petsc-$${version_major}.$${version_minor}.$${version_subminor}; \
409          export petscversion; \
410        else \
411          echo "Unknown PETSC_VERSION_RELEASE: $${version_release}"; \
412          exit; \
413        fi; \
414        datestr=`git log -1 --pretty=format:%ci | cut -d ' ' -f 1`; \
415        export datestr; \
416        gitver=`git describe --match "v*"`; \
417        export gitver; \
418        find * -type d -wholename src/docs/website -prune -o -type d -wholename src/benchmarks/results -prune -o \
419          -type d -wholename config/BuildSystem/docs/website -prune -o -type d -wholename include/web -prune -o \
420          -type d -wholename 'arch-*' -prune -o -type d -wholename src/tops -prune -o -type d -wholename externalpackages -prune ${DOCSETDATE_PRUNE_LIST} -o \
421          -type f -name \*.html \
422          -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' {} \; \
423          -exec perl -pi -e 's^(<head>)^$$1 <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/{}" />^i' {} \; ; \
424        echo "Done fixing version number, date, canonical URL info"
425
426alldocclean: deletemanualpages allcleanhtml
427
428# Deletes man pages (HTML version)
429deletemanualpages: chk_loc
430	-@if [ -d ${LOC} -a -d ${LOC}/docs/manualpages ]; then \
431          find ${LOC}/docs/manualpages -type f -name "*.html" -exec ${RM} {} \; ;\
432          ${RM} ${LOC}/docs/exampleconcepts ;\
433          ${RM} ${LOC}/docs/manconcepts ;\
434          ${RM} ${LOC}/docs/manualpages/manualpages.cit ;\
435          ${PYTHON} lib/petsc/bin/maint/update-docs.py ${PETSC_DIR} ${LOC} clean;\
436        fi
437
438allcleanhtml:
439	-${OMAKE} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} alltree
440
441chk_concepts_dir: chk_loc
442	@if [ ! -d "${LOC}/docs/manualpages/concepts" ]; then \
443	  echo Making directory ${LOC}/docs/manualpages/concepts for library; ${MKDIR} ${LOC}/docs/manualpages/concepts; fi
444
445###########################################################
446# targets to build distribution and update docs
447###########################################################
448
449# Creates ${HOME}/petsc.tar.gz [and petsc-lite.tar.gz]
450dist:
451	${PETSC_DIR}/lib/petsc/bin/maint/builddist ${PETSC_DIR} master
452
453# This target works only if you can do 'ssh petsc@login.mcs.anl.gov'
454# also copy the file over to ftp site.
455web-snapshot:
456	@if [ ! -f "${HOME}/petsc-master.tar.gz" ]; then \
457	    echo "~/petsc-master.tar.gz missing! cannot update petsc-master snapshot on mcs-web-site"; \
458	  else \
459            echo "updating petsc-master snapshot on mcs-web-site"; \
460	    tmpdir=`mktemp -d -t petsc-doc.XXXXXXXX`; \
461	    cd $${tmpdir}; tar -xzf ${HOME}/petsc-master.tar.gz; \
462	    /usr/bin/rsync  -e ssh -az --delete $${tmpdir}/petsc-master/ \
463              petsc@login.mcs.anl.gov:/mcs/web/research/projects/petsc/petsc-master ;\
464	    /bin/cp -f /home/petsc/petsc-master.tar.gz /mcs/ftp/pub/petsc/petsc-master.tar.gz;\
465	    ${RM} -rf $${tmpdir} ;\
466	  fi
467
468# build the tarfile - and then update petsc-master snapshot on mcs-web-site
469update-web-snapshot: dist web-snapshot
470
471# This target updates website main pages
472update-web:
473	@cd ${PETSC_DIR}/src/docs; make PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} bib2html; \
474	/usr/bin/rsync -az -C --exclude=documentation/index.html \
475          --exclude=documentation/installation.html --exclude=download/index.html \
476	  ${PETSC_DIR}/src/docs/website/ petsc@login.mcs.anl.gov:/mcs/web/research/projects/petsc
477	@cd ${PETSC_DIR}/docs; /usr/bin/rsync -az developers.pdf petsc@login.mcs.anl.gov:/mcs/web/research/projects/petsc/developers/
478	@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
479
480#
481#  builds a single list of files for each PETSc library so they may all be built in parallel
482#  without a recursive set of make calls
483createfastbuild:
484	cd src/vec; ${RM} -f files; /bin/echo -n "SOURCEC = " > files; make tree ACTION=sourcelist BASE_DIR=${PETSC_DIR}/src/vec
485
486###########################################################
487#
488#  See script for details
489#
490gcov:
491	-@$(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py -run_gcov
492
493mergegcov:
494	-@$(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py -merge_gcov ${LOC} *.tar.gz
495
496########################
497#
498# Create the include dependency graph (requires graphviz to be available)
499#
500includegraph:
501	-@${PETSC_DIR}/src/contrib/style/include-graph.sh includegraph.pdf
502	-@echo Include dependency graph written to includegraph.pdf
503
504#
505# -------------------------------------------------------------------------------
506#
507# Some macros to check if the fortran interface is up-to-date.
508#
509countfortranfunctions:
510	-@cd ${PETSC_DIR}/src/fortran; egrep '^void' custom/*.c auto/*.c | \
511	cut -d'(' -f1 | tr -s  ' ' | cut -d' ' -f2 | uniq | egrep -v "(^$$|Petsc)" | \
512	sed "s/_$$//" | sort > /tmp/countfortranfunctions
513
514countcfunctions:
515	-@grep PETSC_EXTERN ${PETSC_DIR}/include/*.h  | grep "(" | tr -s ' ' | \
516	cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' |  \
517	tr 'A-Z' 'a-z' |  sort | uniq > /tmp/countcfunctions
518
519difffortranfunctions: countfortranfunctions countcfunctions
520	-@echo -------------- Functions missing in the fortran interface ---------------------
521	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2
522	-@echo ----------------- Functions missing in the C interface ------------------------
523	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2
524	-@${RM}  /tmp/countcfunctions /tmp/countfortranfunctions
525
526checkbadfortranstubs:
527	-@echo "========================================="
528	-@echo "Functions with MPI_Comm as an Argument"
529	-@echo "========================================="
530	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \
531	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
532	-@echo "========================================="
533	-@echo "Functions with a String as an Argument"
534	-@echo "========================================="
535	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \
536	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
537	-@echo "========================================="
538	-@echo "Functions with Pointers to PETSc Objects as Argument"
539	-@echo "========================================="
540	-@cd ${PETSC_DIR}/src/fortran/auto; \
541	_p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \
542	cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \
543	sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \
544	for OBJ in $$_p_OBJ; do \
545	grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \
546	cut -d'(' -f1 | cut -d' ' -f1,3; \
547	done
548
549checkpackagetests:
550	-@echo "Missing package tests"
551	-@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
552	-@echo "Missing download package tests"
553	-@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
554
555#
556# Automatically generates PETSc exercises in html from the tutorial examples.
557#
558# The introduction for each section is obtained from docs/manualpages-cite/header_${MANSEC} may be edited
559#  (used also in introductions to the manual pages)
560#
561# DO NOT EDIT the *.htm files generated since they will be automatically replaced.
562#
563# Eventually the line below will replace the two cd in the rule below, it is just this way now for speed
564#	-@${OMAKE} PETSC_DIR=${PETSC_DIR} pagemaker
565#
566exercises:
567	-@echo "========================================="
568	-@echo "Generating HTML tutorial exercises"
569	-@${RM} docs/pageform.txt
570	-@echo "title=\"PETSc Exercises\""                >  docs/pageform.txt
571	-@echo "access_title=Exercise Sections"              >>  docs/pageform.txt
572	-@echo "access_format=short"                        >> docs/pageform.txt
573	-@echo "startpage=../exercises/introduction.htm"  >> docs/pageform.txt
574	-@echo "NONE title=\"Introduction\" command=link src=../exercises/introduction.htm" >> docs/pageform.txt
575	-@echo "Generating HTML for individual directories"
576	-@echo "========================================="
577	-@${OMAKE} PETSC_DIR=${PETSC_DIR} ACTION=pagemaker tree
578	-@echo "Completed HTML for individual directories"
579	-@echo "NONE title=\"<HR>\" " >> docs/pageform.txt;
580	-@echo "NONE title=\"PETSc Documentation\" command=link src=../index.html target=replace" >> docs/pageform.txt
581	/home/MPI/class/mpiexmpl/maint/makepage.new -pageform=docs/pageform.txt -access_extra=/dev/null -outdir=docs/exercises
582	-@echo "========================================="
583
584.PHONY: info info_h all build testexamples testfortran testexamples_uni testfortran_uni ranlib deletelibs allclean update \
585        alletags etags etags_complete etags_noexamples etags_makefiles etags_examples etags_fexamples alldoc allmanualpages \
586        allhtml allcleanhtml  allci allco allrcslabel countfortranfunctions \
587        start_configure configure_petsc configure_clean matlabbin install
588
589petscao : petscmat petscao.f90.h
590petscdm : petscksp petscdm.f90.h
591petscdraw : petsc petscdraw.f90.h
592petscis : petsc petscis.f90.h
593petscksp : petscpc  petscksp.f90.h
594petsclog : petsc petsclog.f90.h
595petscmat : petscvec petscmat.f90.h
596petscmg : petscksp petscmg.f90.h
597petscpc : petscmat petscpc.f90.h
598petscsnes : petscksp petscsnes.f90.h
599petscsys : petsc petscsys.f90.h
600petscts : petscsnes petscts.f90.h
601petsc : petsc.f90.h
602petscvec : petscis petscvec.f90.h
603petscviewer : petsc petscviewer.f90.h
604petscmesh : petsc petscmesh.f90.h
605modules : petscao petscdm petscdraw petscis petscksp petsclog petscmat petscmg petscpc petscsnes petscsys petscts petsc petscvec petscviewer petscmesh
606