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