xref: /petsc/makefile (revision 1f2f3863f0914e5570741ebee92873cc854bcf2b)
1753a1a87SJed Brown#
24c512586SBarry Smith# See https://petsc.org/release/install/ for instructions on installing PETSc
3753a1a87SJed Brown#
44c512586SBarry Smith# This is the top level makefile for compiling PETSc.
54c512586SBarry Smith#   * make help - useful messages on functionality
64c512586SBarry Smith#   * make all  - compile the PETSc libraries and utilities
74c512586SBarry Smith#   * make check - runs a quick test that the libraries are built correctly and PETSc applications can run
84c512586SBarry Smith#
94c512586SBarry Smith#   * make install - for use with ./configure is run with the --prefix=directory option
104c512586SBarry Smith#   * make test - runs a comprehensive test suite (requires gnumake)
114c512586SBarry Smith#   * make docs - build the entire PETSc website of documentation (locally)
124c512586SBarry Smith#   * a variety of rules that print library properties useful for building applications (use make help)
134c512586SBarry Smith#   * a variety of rules for PETSc developers
144c512586SBarry Smith#
154c512586SBarry Smith# gmakefile - manages the compiling PETSc in parallel
164c512586SBarry Smith# gmakefile.test - manages running the comprehensive test suite
174c512586SBarry Smith#
184c512586SBarry Smith# This makefile does not require GNUmake
19753a1a87SJed BrownALL: all
209e423941SBarry SmithDIRS = src include interfaces share/petsc/matlab
21753a1a87SJed Brown
22753a1a87SJed Brown# next line defines PETSC_DIR and PETSC_ARCH if they are not set
23af0996ceSBarry Smithinclude ././${PETSC_ARCH}/lib/petsc/conf/petscvariables
24ed5129f1SBarry Smithinclude ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscrules
25af0996ceSBarry Smithinclude ${PETSC_DIR}/lib/petsc/conf/variables
269e423941SBarry Smithinclude ${PETSC_DIR}/lib/petsc/conf/rules.doc
275c0471eeSBarry Smithinclude ${PETSC_DIR}/lib/petsc/conf/rules.utils
28753a1a87SJed Brown
29fa2665b1SJed Brown# This makefile contains a lot of PHONY targets with improperly specified prerequisites
30fa2665b1SJed Brown# where correct execution instead depends on the targets being processed in the correct
314c512586SBarry Smith# order.
32fa2665b1SJed Brown.NOTPARALLEL:
33fa2665b1SJed Brown
340e03b746SBarry SmithOMAKE_SELF = $(OMAKE) -f makefile
350e03b746SBarry SmithOMAKE_SELF_PRINTDIR = $(OMAKE_PRINTDIR) -f makefile
360e03b746SBarry Smith
374c512586SBarry Smith#********* Rules for make all **********************************************************************************************************************************
384c512586SBarry Smith
39dd8585cdSJed Brownall:
4008147ea0SBarry Smith	+@${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} chk_upgrade | tee ${PETSC_ARCH}/lib/petsc/conf/make.log
41af0996ceSBarry Smith	@ln -sf ${PETSC_ARCH}/lib/petsc/conf/make.log make.log
420093410fSSatish Balay	+@(${OMAKE_SELF_PRINTDIR} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} all-local; echo "$$?" > ${PETSC_ARCH}/lib/petsc/conf/error.log) 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log
432b38c152SPierre Jolivet	+@if [ "`cat ${PETSC_ARCH}/lib/petsc/conf/error.log 2> /dev/null`" != "0" ]; then \
44f53b81b6SPierre Jolivet           grep -E '(out of memory allocating.*after a total of|gfortran: fatal error: Killed signal terminated program f951|f95: fatal error: Killed signal terminated program f951)' ${PETSC_ARCH}/lib/petsc/conf/make.log | tee ${PETSC_ARCH}/lib/petsc/conf/memoryerror.log > /dev/null; \
450093410fSSatish Balay           if test -s ${PETSC_ARCH}/lib/petsc/conf/memoryerror.log; then \
4671488455SBarry Smith             printf ${PETSC_TEXT_HILIGHT}"**************************ERROR*************************************\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \
4771488455SBarry Smith             echo "  Error during compile, you need to increase the memory allocated to the VM and rerun " 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \
4871488455SBarry Smith             printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\
490093410fSSatish Balay           else \
50af0996ceSBarry Smith             printf ${PETSC_TEXT_HILIGHT}"**************************ERROR*************************************\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \
51af0996ceSBarry Smith             echo "  Error during compile, check ${PETSC_ARCH}/lib/petsc/conf/make.log" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \
52af0996ceSBarry Smith             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;\
53af0996ceSBarry Smith             printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\
540093410fSSatish Balay           fi \
55753a1a87SJed Brown	 else \
560e03b746SBarry Smith	  ${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 ;\
57753a1a87SJed Brown        fi #solaris make likes to print the whole command that gave error. So split this up into the smallest chunk below
584dcdf380SSatish Balay	@echo "Finishing make run at `date +'%a, %d %b %Y %H:%M:%S %z'`" >> ${PETSC_ARCH}/lib/petsc/conf/make.log
592b38c152SPierre Jolivet	@if [ "`cat ${PETSC_ARCH}/lib/petsc/conf/error.log 2> /dev/null`" != "0" ]; then exit 1; fi
60753a1a87SJed Brown
61504e95faSBarry Smithall-local: info libs matlabbin petsc4py-build libmesh-build mfem-build slepc-build hpddm-build amrex-build bamg-build
62fa2665b1SJed Brown
639e423941SBarry Smith${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files:
649e423941SBarry Smith	@touch -t 197102020000 ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files
659e423941SBarry Smith
669e423941SBarry Smith${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles:
679e423941SBarry Smith	@${MKDIR} -p ${PETSC_DIR}/${PETSC_ARCH}/tests && touch -t 197102020000 ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles
689e423941SBarry Smith
694c512586SBarry Smithchk_upgrade:
704c512586SBarry Smith	-@PETSC_DIR=${PETSC_DIR} ${PYTHON} ${PETSC_DIR}/lib/petsc/bin/petscnagupgrade.py
71753a1a87SJed Brown
72d2b3add8SSatish Balaymatlabbin:
734242cbabSBarry Smith	-@if [ "${MATLAB_MEX}" != "" -a "${MATLAB_SOCKET}" != "" -a "${PETSC_SCALAR}" = "real" -a "${PETSC_PRECISION}" = "double" ]; then \
74d2b3add8SSatish Balay          echo "BEGINNING TO COMPILE MATLAB INTERFACE"; \
75d2b3add8SSatish Balay            if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc" ] ; then ${MKDIR}  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc; fi; \
76d2b3add8SSatish Balay            if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab" ] ; then ${MKDIR}  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab; fi; \
77b75c6efcSBarry Smith            cd src/sys/classes/viewer/impls/socket/mex-scripts && ${OMAKE_SELF} mex-scripts PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR}; \
78d2b3add8SSatish Balay            echo "========================================="; \
79d2b3add8SSatish Balay        fi
804c512586SBarry Smith
814c512586SBarry Smithallfortranstubs:
824c512586SBarry Smith	-@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir
834c512586SBarry Smith	@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py ${BFORT}  ${VERBOSE}
844c512586SBarry Smith	-@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py -merge  ${VERBOSE}
854c512586SBarry Smith	-@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir
864c512586SBarry Smith
874c512586SBarry Smithdeleteshared:
884c512586SBarry Smith	@for LIBNAME in ${SHLIBS}; \
894c512586SBarry Smith	do \
904c512586SBarry Smith	   if [ -d ${INSTALL_LIB_DIR}/$${LIBNAME}.dylib.dSYM ]; then \
914c512586SBarry Smith             echo ${RM} -rf ${INSTALL_LIB_DIR}/$${LIBNAME}.dylib.dSYM; \
924c512586SBarry Smith	     ${RM} -rf ${INSTALL_LIB_DIR}/$${LIBNAME}.dylib.dSYM; \
934c512586SBarry Smith	   fi; \
944c512586SBarry Smith           echo ${RM} ${INSTALL_LIB_DIR}/$${LIBNAME}.${SL_LINKER_SUFFIX}; \
954c512586SBarry Smith           ${RM} ${INSTALL_LIB_DIR}/$${LIBNAME}.${SL_LINKER_SUFFIX}; \
964c512586SBarry Smith	done
974c512586SBarry Smith	@if [ -f ${INSTALL_LIB_DIR}/so_locations ]; then \
984c512586SBarry Smith          echo ${RM} ${INSTALL_LIB_DIR}/so_locations; \
994c512586SBarry Smith          ${RM} ${INSTALL_LIB_DIR}/so_locations; \
1004c512586SBarry Smith	fi
1014c512586SBarry Smith
1024c512586SBarry Smithdeletefortranstubs:
1034c512586SBarry Smith	-@find . -type d -name ftn-auto | xargs rm -rf
1044c512586SBarry Smith
1054c512586SBarry Smithreconfigure: allclean
1064c512586SBarry Smith	@unset MAKEFLAGS && ${PYTHON} ${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py
1074c512586SBarry Smith
1084c512586SBarry Smithchkopts:
1094c512586SBarry Smith	-@echo "Warning: chkopts target is deprecated and can be removed from user makefiles"
1104c512586SBarry Smith
1114c512586SBarry Smithgnumake:
1124c512586SBarry Smith	+@echo "make gnumake is deprecated, use make libs"
1134c512586SBarry Smith	+@make libs
1144c512586SBarry Smith
1154c512586SBarry Smith# ********  Rules for make check ****************************************************************************************************************************
1164c512586SBarry Smith
11727cb8d94SBarry SmithRUN_TEST = ${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff
11827cb8d94SBarry Smith
1190e03b746SBarry Smithcheck_install: check
1200e03b746SBarry Smithcheck:
1210e03b746SBarry Smith	-@echo "Running check examples to verify correct installation"
122753a1a87SJed Brown	-@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}"
12327cb8d94SBarry Smith	@if [ "${PETSC_WITH_BATCH}" != "" ]; then \
12427cb8d94SBarry Smith           echo "Running with batch filesystem, cannot run make check"; \
12527cb8d94SBarry Smith        elif [ "${MPIEXEC}" = "/bin/false" ]; then \
12627cb8d94SBarry Smith           echo "*mpiexec not found*. cannot run make check"; \
12727cb8d94SBarry Smith        else \
12827cb8d94SBarry Smith          ${RM} -f check_error;\
12927cb8d94SBarry Smith          ${RUN_TEST} PETSC_OPTIONS="${PETSC_OPTIONS} ${PETSC_TEST_OPTIONS}" PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" check_build 2>&1 | tee ./${PETSC_ARCH}/lib/petsc/conf/check.log; \
13027cb8d94SBarry Smith          if [ -f check_error ]; then \
13127cb8d94SBarry Smith            echo "Error while running make check"; \
13227cb8d94SBarry Smith            ${RM} -f check_error;\
13327cb8d94SBarry Smith            exit 1; \
13427cb8d94SBarry Smith          fi; \
13527cb8d94SBarry Smith          ${RM} -f check_error;\
13627cb8d94SBarry Smith        fi;
13727cb8d94SBarry Smith
13827cb8d94SBarry Smithcheck_build:
13927cb8d94SBarry Smith	+@cd src/snes/tutorials >/dev/null; ${RUN_TEST} clean-legacy
14027cb8d94SBarry Smith	+@cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19
14127cb8d94SBarry Smith	+@if [ ! "${MPI_IS_MPIUNI}" ]; then cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19_mpi; fi
14227cb8d94SBarry Smith	+@if [ "${HYPRE_LIB}" != "" ] && [ "${PETSC_SCALAR}" = "real" ]; then \
143de5e753aSSatish Balay          if [ "${CUDA_LIB}" != "" ]; then HYPRE_TEST=runex19_hypre_cuda; \
144de5e753aSSatish Balay          elif [ "${HIP_LIB}" != "" ]; then HYPRE_TEST=runex19_hypre_hip; \
14527cb8d94SBarry Smith          else HYPRE_TEST=runex19_hypre; fi; \
14627cb8d94SBarry Smith          cd src/snes/tutorials >/dev/null; ${RUN_TEST} $${HYPRE_TEST}; \
14727cb8d94SBarry Smith        fi;
14827cb8d94SBarry Smith	+@if [ "${CUDA_LIB}" != "" ]; then \
14927cb8d94SBarry Smith          cd src/snes/tutorials >/dev/null; ${RUN_TEST} runex19_cuda; \
15027cb8d94SBarry Smith        fi;
15127cb8d94SBarry Smith	+@if [ "${MPI_IS_MPIUNI}" = "" ]; then \
15227cb8d94SBarry Smith          cd src/snes/tutorials >/dev/null; \
15327cb8d94SBarry Smith          if [ "${KOKKOS_KERNELS_LIB}" != "" ]  &&  [ "${PETSC_SCALAR}" = "real" ] && [ "${PETSC_PRECISION}" = "double" ]; then \
15427cb8d94SBarry Smith            ${RUN_TEST} runex3k_kokkos; \
155de5e753aSSatish Balay          fi;\
15627cb8d94SBarry Smith          if [ "${MUMPS_LIB}" != "" ]; then \
15727cb8d94SBarry Smith             ${RUN_TEST} runex19_fieldsplit_mumps; \
15827cb8d94SBarry Smith          fi;\
15927cb8d94SBarry Smith          if [ "${SUITESPARSE_LIB}" != "" ]; then \
16027cb8d94SBarry Smith             ${RUN_TEST} runex19_suitesparse; \
16127cb8d94SBarry Smith          fi;\
16227cb8d94SBarry Smith          if [ "${SUPERLU_DIST_LIB}" != "" ]; then \
16327cb8d94SBarry Smith            ${RUN_TEST} runex19_superlu_dist; \
16427cb8d94SBarry Smith          fi;\
16527cb8d94SBarry Smith          if ( [ "${ML_LIB}" != "" ] ||  [ "${TRILINOS_LIB}" != "" ] ); then \
16627cb8d94SBarry Smith            ${RUN_TEST} runex19_ml; \
16727cb8d94SBarry Smith          fi; \
16827cb8d94SBarry Smith	  ${RUN_TEST} clean-legacy; \
16927cb8d94SBarry Smith          cd - > /dev/null; \
170e91fee76SPierre Jolivet          if ( [ "${AMREX_LIB}" != "" ] && [ "${CUDA_LIB}" = "" ] ); then \
171bd579fedSSatish Balay            echo "Running amrex test example to verify correct installation";\
172bd579fedSSatish Balay            echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}";\
173bd579fedSSatish Balay            cd src/ksp/ksp/tutorials/amrex >/dev/null;\
17427cb8d94SBarry Smith            ${RUN_TEST} clean-legacy; \
17527cb8d94SBarry Smith            ${RUN_TEST} testamrex; \
17627cb8d94SBarry Smith            ${RUN_TEST} clean-legacy; \
17727cb8d94SBarry Smith            cd - > /dev/null; \
17827cb8d94SBarry Smith          fi;\
17927cb8d94SBarry Smith        fi;
18027cb8d94SBarry Smith	+@if [ "${HDF5_LIB}" != "" ]; then \
18127cb8d94SBarry Smith          cd src/vec/vec/tests >/dev/null;\
18227cb8d94SBarry Smith          ${RUN_TEST} clean-legacy; \
18327cb8d94SBarry Smith          ${RUN_TEST} runex47; \
18427cb8d94SBarry Smith          ${RUN_TEST} clean-legacy; \
185bd579fedSSatish Balay         fi;
186b6efb0a5SBarry Smith	+@if [ "${MPI4PY}" = "yes" ]; then \
187b6efb0a5SBarry Smith           cd src/sys/tests >/dev/null; \
18827cb8d94SBarry Smith           ${RUN_TEST} clean-legacy; \
18927cb8d94SBarry Smith           ${RUN_TEST} testex55; \
19027cb8d94SBarry Smith           ${RUN_TEST} clean-legacy; \
191b6efb0a5SBarry Smith         fi;
19245ee4180SJed Brown	+@if [ "${PETSC4PY}" = "yes" ]; then \
193c4762a1bSJed Brown           cd src/ksp/ksp/tutorials >/dev/null; \
19427cb8d94SBarry Smith           ${RUN_TEST} clean-legacy; \
19527cb8d94SBarry Smith           ${RUN_TEST} testex100; \
19627cb8d94SBarry Smith           ${RUN_TEST} clean-legacy; \
1975061939cSBarry Smith         fi;
198f53b81b6SPierre Jolivet	+@grep -E "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \
199cb297985SSatish Balay         if test -s .ftn.log; then \
200bd579fedSSatish Balay           cd src/snes/tutorials >/dev/null; \
20127cb8d94SBarry Smith           ${RUN_TEST} clean-legacy; \
20227cb8d94SBarry Smith           ${RUN_TEST} testex5f; \
20327cb8d94SBarry Smith           ${RUN_TEST} clean-legacy; \
204cb297985SSatish Balay         fi; ${RM} .ftn.log;
205f53b81b6SPierre Jolivet	+@grep -E "^#define PETSC_HAVE_MATLAB 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \
20669cdbcb9SBarry Smith         if test -s .ftn.log; then \
207bd579fedSSatish Balay           cd src/vec/vec/tutorials >/dev/null; \
20827cb8d94SBarry Smith           ${RUN_TEST} clean-legacy; \
20927cb8d94SBarry Smith           ${RUN_TEST} testex31; \
21027cb8d94SBarry Smith           ${RUN_TEST} clean-legacy; \
21169cdbcb9SBarry Smith          fi; ${RM} .ftn.log;
212753a1a87SJed Brown	-@echo "Completed test examples"
21327cb8d94SBarry Smith
2144c512586SBarry Smith# ********* Rules for make install *******************************************************************************************************************
2154c512586SBarry Smith
2164c512586SBarry Smithinstall:
2174c512586SBarry Smith	@${PYTHON} ./config/install.py -destDir=${DESTDIR}
2184c512586SBarry Smith	+${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc
2194c512586SBarry Smith
2204c512586SBarry Smith# A smaller install with fewer extras
2214c512586SBarry Smithinstall-lib:
2224c512586SBarry Smith	@${PYTHON} ./config/install.py -destDir=${DESTDIR} -no-examples
2234c512586SBarry Smith	+${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc
2244c512586SBarry Smith
2254c512586SBarry Smithinstall-builtafterpetsc:
2264c512586SBarry Smith	+${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=${PETSC_INSTALL} petsc4py-install libmesh-install mfem-install slepc-install hpddm-install amrex-install bamg-install
2274c512586SBarry Smith
2284c512586SBarry Smith# Creates ${HOME}/petsc.tar.gz [and petsc-with-docs.tar.gz]
2294c512586SBarry Smithdist:
2304c512586SBarry Smith	${PETSC_DIR}/lib/petsc/bin/maint/builddist ${PETSC_DIR} main
2314c512586SBarry Smith
232088deb40SBarry Smith# ******** Rules for running the full test suite ********************************************************************************************************
233088deb40SBarry Smith
234088deb40SBarry SmithTESTMODE = testexamples
235088deb40SBarry SmithALLTESTS_CHECK_FAILURES = no
236088deb40SBarry SmithALLTESTS_MAKEFILE = ${PETSC_DIR}/gmakefile.test
237088deb40SBarry SmithVALGRIND=0
238088deb40SBarry Smithalltests: chk_in_petscdir ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles
239088deb40SBarry Smith	-@${RM} -rf ${PETSC_ARCH}/lib/petsc/conf/alltests.log alltests.log
240088deb40SBarry Smith	+@if [ -f ${PETSC_DIR}/share/petsc/examples/gmakefile.test ] ; then \
241088deb40SBarry Smith            ALLTESTS_MAKEFILE=${PETSC_DIR}/share/petsc/examples/gmakefile.test ; \
242088deb40SBarry Smith            ALLTESTSLOG=alltests.log ;\
243088deb40SBarry Smith          else \
244088deb40SBarry Smith            ALLTESTS_MAKEFILE=${PETSC_DIR}/gmakefile.test; \
245088deb40SBarry Smith            ALLTESTSLOG=${PETSC_ARCH}/lib/petsc/conf/alltests.log ;\
246088deb40SBarry Smith            ln -s $${ALLTESTSLOG} alltests.log ;\
247088deb40SBarry Smith          fi; \
248088deb40SBarry Smith          ${OMAKE} allgtest ALLTESTS_MAKEFILE=$${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} MPIEXEC="${MPIEXEC}" DATAFILESPATH=${DATAFILESPATH} VALGRIND=${VALGRIND} 2>&1 | tee $${ALLTESTSLOG};\
249088deb40SBarry Smith          if [ x${ALLTESTS_CHECK_FAILURES} = xyes -a ${PETSC_PRECISION} != single ]; then \
250088deb40SBarry Smith            cat $${ALLTESTSLOG} | grep -E '(^not ok|not remade because of errors|^# No tests run)' | wc -l | grep '^[ ]*0$$' > /dev/null; \
251088deb40SBarry Smith          fi;
252088deb40SBarry Smith
253088deb40SBarry Smithallgtests-tap: allgtest-tap
254088deb40SBarry Smith	+@${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} check-test-errors
255088deb40SBarry Smith
256088deb40SBarry Smithallgtest-tap: ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles
257088deb40SBarry Smith	+@MAKEFLAGS="-j$(MAKE_TEST_NP) -l$(MAKE_LOAD) $(MAKEFLAGS)" ${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test OUTPUT=1
258088deb40SBarry Smith
259088deb40SBarry Smithallgtest: ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles
260088deb40SBarry Smith	+@MAKEFLAGS="-j$(MAKE_TEST_NP) -l$(MAKE_LOAD) $(MAKEFLAGS)" ${OMAKE} -k -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test V=0 2>&1 | grep -E -v '^(ok [^#]*(# SKIP|# TODO|$$)|[A-Za-z][A-Za-z0-9_]*\.(c|F|cxx|F90).$$)'
261088deb40SBarry Smith
262088deb40SBarry Smithtest:
263088deb40SBarry Smith	+${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test
264088deb40SBarry Smithcleantest:
265088deb40SBarry Smith	+${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} cleantest
266088deb40SBarry Smith
2674c512586SBarry Smith#********* Rules for cleaning ***************************************************************************************************************************
2684c512586SBarry Smith
2694c512586SBarry Smithdeletelibs:
2704c512586SBarry Smith	-${RM} -rf ${PETSC_LIB_DIR}/libpetsc*.*
2714c512586SBarry Smithdeletemods:
2724c512586SBarry Smith	-${RM} -f ${PETSC_DIR}/${PETSC_ARCH}/include/petsc*.mod
2734c512586SBarry Smith
2744c512586SBarry Smithallclean:
2754c512586SBarry Smith	-@${OMAKE} -f gmakefile clean
2764c512586SBarry Smith
2774c512586SBarry Smithclean:: allclean
2784c512586SBarry Smith
27908147ea0SBarry Smithdistclean:
2804c512586SBarry Smith	@if [ -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ]; then \
2814c512586SBarry Smith	  echo "*** Preserving ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py in ${PETSC_DIR} ***"; \
2824c512586SBarry Smith          mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/; fi
2834c512586SBarry Smith	@echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***"
2844c512586SBarry Smith	-${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/
2854c512586SBarry Smith
2864c512586SBarry Smithinfo:
2874c512586SBarry Smith	-@echo "=========================================="
2884c512586SBarry Smith	-@echo " "
2894c512586SBarry Smith	-@echo "See documentation/faq.html and documentation/bugreporting.html"
2904c512586SBarry Smith	-@echo "for help with installation problems.  Please send EVERYTHING"
2914c512586SBarry Smith	-@echo "printed out below when reporting problems.  Please check the"
2924c512586SBarry Smith	-@echo "mailing list archives and consider subscribing."
2934c512586SBarry Smith	-@echo " "
2944c512586SBarry Smith	-@echo "  https://petsc.org/release/community/mailing/"
2954c512586SBarry Smith	-@echo " "
2964c512586SBarry Smith	-@echo "=========================================="
2974c512586SBarry Smith	-@echo Starting make run on `hostname` at `date +'%a, %d %b %Y %H:%M:%S %z'`
2984c512586SBarry Smith	-@echo Machine characteristics: `uname -a`
2994c512586SBarry Smith	-@echo "-----------------------------------------"
3004c512586SBarry Smith	-@echo "Using PETSc directory: ${PETSC_DIR}"
3014c512586SBarry Smith	-@echo "Using PETSc arch: ${PETSC_ARCH}"
3024c512586SBarry Smith	-@echo "-----------------------------------------"
3034c512586SBarry Smith	-@grep "define PETSC_VERSION" ${PETSC_DIR}/include/petscversion.h | ${SED} "s/........//" | head -n 7
3044c512586SBarry Smith	-@echo "-----------------------------------------"
3054c512586SBarry Smith	-@echo "Using configure Options: ${CONFIGURE_OPTIONS}"
3064c512586SBarry Smith	-@echo "Using configuration flags:"
3074c512586SBarry Smith	-@grep "\#define " ${PETSCCONF_H} | tail -n +2
3084c512586SBarry Smith	-@echo "-----------------------------------------"
3094c512586SBarry Smith	-@echo "Using C compile: ${PETSC_CCOMPILE_SINGLE}"
3104c512586SBarry Smith	-@if [  "${MPICC_SHOW}" != "" ]; then \
3114c512586SBarry Smith             printf  "mpicc -show: %b\n" "${MPICC_SHOW}";\
3124c512586SBarry Smith          fi; \
3134c512586SBarry Smith        printf  "C compiler version: %b\n" "${C_VERSION}"; \
3144c512586SBarry Smith        if [ "${CXX}" != "" ]; then \
3154c512586SBarry Smith        echo "Using C++ compile: ${PETSC_CXXCOMPILE_SINGLE}";\
3164c512586SBarry Smith        if [ "${MPICXX_SHOW}" != "" ]; then \
3174c512586SBarry Smith               printf "mpicxx -show: %b\n" "${MPICXX_SHOW}"; \
3184c512586SBarry Smith            fi;\
3194c512586SBarry Smith            printf  "C++ compiler version: %b\n" "${Cxx_VERSION}"; \
3204c512586SBarry Smith          fi
3214c512586SBarry Smith	-@if [ "${FC}" != "" ]; then \
3224c512586SBarry Smith	   echo "Using Fortran compile: ${PETSC_FCOMPILE_SINGLE}";\
3234c512586SBarry Smith           if [ "${MPIFC_SHOW}" != "" ]; then \
3244c512586SBarry Smith             printf "mpif90 -show: %b\n" "${MPIFC_SHOW}"; \
3254c512586SBarry Smith           fi; \
3264c512586SBarry Smith             printf  "Fortran compiler version: %b\n" "${FC_VERSION}"; \
3274c512586SBarry Smith         fi
3284c512586SBarry Smith	-@if [ "${CUDAC}" != "" ]; then \
3294c512586SBarry Smith	   echo "Using CUDA compile: ${PETSC_CUCOMPILE_SINGLE}";\
3304c512586SBarry Smith         fi
3314c512586SBarry Smith	-@if [ "${CLANGUAGE}" = "CXX" ]; then \
3324c512586SBarry Smith           echo "Using C++ compiler to compile PETSc";\
3334c512586SBarry Smith        fi
3344c512586SBarry Smith	-@echo "-----------------------------------------"
3354c512586SBarry Smith	-@echo "Using C/C++ linker: ${PCC_LINKER}"
3364c512586SBarry Smith	-@echo "Using C/C++ flags: ${PCC_LINKER_FLAGS}"
3374c512586SBarry Smith	-@if [ "${FC}" != "" ]; then \
3384c512586SBarry Smith	   echo "Using Fortran linker: ${FC_LINKER}";\
3394c512586SBarry Smith	   echo "Using Fortran flags: ${FC_LINKER_FLAGS}";\
3404c512586SBarry Smith         fi
3414c512586SBarry Smith	-@echo "-----------------------------------------"
3424c512586SBarry Smith	-@echo "Using system modules: ${LOADEDMODULES}"
3434c512586SBarry Smith	-@if [ "${MPI_IS_MPIUNI}" = "1" ]; then \
3444c512586SBarry Smith           echo Using mpi.h: mpiuni; \
3454c512586SBarry Smith        else \
3464c512586SBarry Smith           TESTDIR=`mktemp -q -d -t petscmpi-XXXXXXXX` && \
3474c512586SBarry Smith           echo '#include <mpi.h>' > $${TESTDIR}/mpitest.c && \
3484c512586SBarry Smith           BUF=`${CPP} ${PETSC_CPPFLAGS} ${PETSC_CC_INCLUDES} $${TESTDIR}/mpitest.c |grep 'mpi\.h' | ( head -1 ; cat > /dev/null )` && \
3494c512586SBarry Smith           echo Using mpi.h: $${BUF}; ${RM} -rf $${TESTDIR}; \
3504c512586SBarry Smith        fi
3514c512586SBarry Smith	-@echo "-----------------------------------------"
3524c512586SBarry Smith	-@echo "Using libraries: ${PETSC_LIB}"
3534c512586SBarry Smith	-@echo "------------------------------------------"
3544c512586SBarry Smith	-@echo "Using mpiexec: ${MPIEXEC}"
3554c512586SBarry Smith	-@echo "------------------------------------------"
3564c512586SBarry Smith	-@echo "Using MAKE: ${MAKE}"
3574c512586SBarry Smith	-@echo "Default MAKEFLAGS: MAKE_NP:${MAKE_NP} MAKE_LOAD:${MAKE_LOAD} MAKEFLAGS:${MAKEFLAGS}"
3584c512586SBarry Smith	-@echo "=========================================="
3594c512586SBarry Smith
3604c512586SBarry Smith
3610e03b746SBarry Smithcheck_usermakefile:
362b752486dSSatish Balay	-@echo "Testing compile with user makefile"
363b752486dSSatish Balay	-@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}"
36427cb8d94SBarry Smith	@cd src/snes/tutorials; ${RUN_TEST} clean-legacy
365c4762a1bSJed Brown	@cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex19
366f53b81b6SPierre Jolivet	@grep -E "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \
367b752486dSSatish Balay         if test -s .ftn.log; then \
368c4762a1bSJed Brown          cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex5f; \
369b752486dSSatish Balay         fi; ${RM} .ftn.log;
37027cb8d94SBarry Smith	@cd src/snes/tutorials; ${RUN_TEST} clean-legacy
371b752486dSSatish Balay	-@echo "Completed compile with user makefile"
372753a1a87SJed Brown
3734c512586SBarry Smith#********* Rules for running clangformat ************************************************************************************************************
3744c512586SBarry Smith
375c45dcc3fSBarry Smithcheckgitclean:
3769a632cc8SPierre Jolivet	@if ! git diff --quiet; then \
377d5b43468SJose E. Roman           echo "The repository has uncommitted files, cannot run checkclangformat" ;\
378c45dcc3fSBarry Smith           git status -s --untracked-files=no ;\
379c45dcc3fSBarry Smith           false;\
380c45dcc3fSBarry Smith        fi;
381c45dcc3fSBarry Smith
382c45dcc3fSBarry Smithcheckclangformatversion:
383c45dcc3fSBarry Smith	@version=`clang-format --version | cut -d" " -f3 | cut -d"." -f 1` ;\
384c45dcc3fSBarry Smith         if [ "$$version" == "version" ]; then version=`clang-format --version | cut -d" " -f4 | cut -d"." -f 1`; fi;\
3856c5826a2SPierre Jolivet         if [ $$version != 16 ]; then echo "Require clang-format version 16! Currently used clang-format version is $$version" ;false ; fi
386c45dcc3fSBarry Smith
387c45dcc3fSBarry Smith# Check that all the source code in the repository satisfies the .clang_format
388c45dcc3fSBarry Smithcheckclangformat: checkclangformatversion checkgitclean clangformat
3899a632cc8SPierre Jolivet	@if ! git diff --quiet; then \
3909a632cc8SPierre Jolivet          printf "The current commit has source code formatting problems\n" ;\
3919a632cc8SPierre Jolivet          if [ -z "${CI_PIPELINE_ID}"  ]; then \
3929a632cc8SPierre Jolivet            printf "Please run 'git diff' to check\n"; \
3939a632cc8SPierre Jolivet            git diff --stat; \
3949a632cc8SPierre Jolivet          else \
3959a632cc8SPierre Jolivet            git diff --patch-with-stat >  ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch; \
3969a632cc8SPierre Jolivet            git diff --patch-with-stat --color=always | head -1000; \
3979a632cc8SPierre Jolivet            if [ `wc -l < ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch` -gt 1000 ]; then \
3989a632cc8SPierre Jolivet              printf "The diff has been trimmed, check ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch (in CI artifacts) for all changes\n"; \
3999a632cc8SPierre Jolivet            fi;\
4009a632cc8SPierre Jolivet          fi;\
401c45dcc3fSBarry Smith          false;\
402c45dcc3fSBarry Smith        fi;
403c45dcc3fSBarry Smith
4043d33ad60SJunchao Zhang# Compare ABI/API of two versions of PETSc library with the old one defined by PETSC_{DIR,ARCH}_ABI_OLD
4053d33ad60SJunchao Zhangabitest:
406cab5ea25SPierre Jolivet	@if [ "${PETSC_DIR_ABI_OLD}" = "" ] || [ "${PETSC_ARCH_ABI_OLD}" = "" ]; \
4073d33ad60SJunchao Zhang		then printf "You must set environment variables PETSC_DIR_ABI_OLD and PETSC_ARCH_ABI_OLD to run abitest\n"; \
4083d33ad60SJunchao Zhang		exit 1; \
4093d33ad60SJunchao Zhang	fi;
4103d33ad60SJunchao Zhang	-@echo "Comparing ABI/API of the following two PETSc versions (you must have already configured and built them using GCC and with -g):"
4113d33ad60SJunchao Zhang	-@echo "========================================================================================="
4123d33ad60SJunchao Zhang	-@echo "    Old: PETSC_DIR_ABI_OLD  = ${PETSC_DIR_ABI_OLD}"
4133d33ad60SJunchao Zhang	-@echo "         PETSC_ARCH_ABI_OLD = ${PETSC_ARCH_ABI_OLD}"
4147b444a09SBarry Smith	-@pushd ${PETSC_DIR_ABI_OLD} >> /dev/null ; echo "         Branch             = "`git rev-parse --abbrev-ref HEAD`
4153d33ad60SJunchao Zhang	-@echo "    New: PETSC_DIR          = ${PETSC_DIR}"
4163d33ad60SJunchao Zhang	-@echo "         PETSC_ARCH         = ${PETSC_ARCH}"
4177b444a09SBarry Smith	-@echo "         Branch             = "`git rev-parse --abbrev-ref HEAD`
4183d33ad60SJunchao Zhang	-@echo "========================================================================================="
419454c5dfcSJunchao Zhang	-@$(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
4203d33ad60SJunchao Zhang
4217b444a09SBarry Smith# Compare ABI/API of current PETSC_ARCH/PETSC_DIR with a previous branch
4227b444a09SBarry Smithabitestcomplete:
4237b444a09SBarry Smith	-@if [[ -f "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/configure.log" ]]; then \
4247b444a09SBarry Smith          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"` ;\
4257b444a09SBarry Smithecho $${OPTIONS} ;\
4267b444a09SBarry Smith        fi ; \
4277b444a09SBarry Smith        if [[ "${PETSC_DIR_ABI_OLD}" != "" ]]; then \
4287b444a09SBarry Smith          PETSC_DIR_OLD=${PETSC_DIR_ABI_OLD}; \
4297b444a09SBarry Smith        else \
4307b444a09SBarry Smith          PETSC_DIR_OLD=${PETSC_DIR}/../petsc-abi; \
4317b444a09SBarry Smith        fi ; \
4327b444a09SBarry Smith        echo "=================================================================================================" ;\
4337b444a09SBarry Smith        echo "Doing ABI/API comparison between" ${branch} " and " `git rev-parse --abbrev-ref HEAD` "using " $${OPTIONS} ;\
4347b444a09SBarry Smith        echo "=================================================================================================" ;\
4357b444a09SBarry Smith        if [[ ! -d $${PETSC_DIR_OLD} ]]; then \
4367b444a09SBarry Smith          git clone ${PETSC_DIR} $${PETSC_DIR_OLD} ; \
4377b444a09SBarry Smith        else \
4387b444a09SBarry Smith          cd $${PETSC_DIR_OLD} ; \
4397b444a09SBarry Smith          git pull ; \
4407b444a09SBarry Smith        fi ; \
4417b444a09SBarry Smith        cd $${PETSC_DIR_OLD} ; \
4427b444a09SBarry Smith        git checkout ${branch} ; \
4437b444a09SBarry Smith        PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` ./configure $${OPTIONS} ; \
4447b444a09SBarry Smith        PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` make all test ; \
4457b444a09SBarry Smith        cd ${PETSC_DIR} ; \
4467b444a09SBarry Smith        ./configure $${OPTIONS}; \
4477b444a09SBarry Smith        make all test ; \
4487b444a09SBarry Smith        PETSC_DIR_ABI_OLD=$${PETSC_DIR_OLD} PETSC_ARCH_ABI_OLD=arch-branch-`git rev-parse ${branch}` make abitest
4497b444a09SBarry Smith
4504c512586SBarry Smith# ******** Rules for running Streams benchmark ****************************************************************************************************
451753a1a87SJed Brown
4524198fb66SBarry Smithmpistreams:
4530e03b746SBarry Smith	+@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistreams
4545fabf859SBarry Smith
4554198fb66SBarry Smithmpistream:
4560e03b746SBarry Smith	+@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistream
4574198fb66SBarry Smith
4584198fb66SBarry Smithopenmpstreams:
4590e03b746SBarry Smith	+@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstreams
4604198fb66SBarry Smith
4614198fb66SBarry Smithopenmpstream:
4620e03b746SBarry Smith	+@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstream
4634198fb66SBarry Smith
4644198fb66SBarry Smithstream: mpistream
4654198fb66SBarry Smith
4664198fb66SBarry Smithstreams: mpistreams
467fc5166cbSSatish Balay
4684c512586SBarry Smith# ********  Rules for generating tag files for Emacs/VIM *******************************************************************************************
4694c512586SBarry Smith
470753a1a87SJed Brownalletags:
471c3a89c15SBarry Smith	-@${PYTHON} lib/petsc/bin/maint/generateetags.py
472753a1a87SJed Brown	-@find config -type f -name "*.py" |grep -v SCCS | xargs etags -o TAGS_PYTHON
473753a1a87SJed Brown
47437763f56SJed Brown# obtain gtags from https://www.gnu.org/software/global/
475762ef373SBarry Smithallgtags:
47637763f56SJed Brown	-@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 -
477762ef373SBarry Smith
478ed5129f1SBarry Smith# ********* Rules for building "classic" documentation; uses rules also in lib/petsc/conf/rules.doc **************************************************
479753a1a87SJed Brown
4804c512586SBarry Smithdocs:
4814c512586SBarry Smith	cd doc; ${OMAKE_SELF} sphinxhtml
4829e423941SBarry Smith
4839e423941SBarry Smithchk_in_petscdir:
4849e423941SBarry Smith	@if [ ! -f include/petscversion.h ]; then \
4859e423941SBarry Smith	  printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n" ; \
4869e423941SBarry Smith	  echo " This target should be invoked in top level PETSc source dir!"; \
4879e423941SBarry Smith	  printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n" ;  false; fi
4889e423941SBarry Smith
4899e423941SBarry Smithchk_loc:
4909e423941SBarry Smith	@if [ ${LOC}foo = foo ] ; then \
4919e423941SBarry Smith	  printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n" ; \
4929e423941SBarry Smith	  echo " Please specify LOC variable for eg: make allmanpages LOC=/sandbox/petsc "; \
4939e423941SBarry Smith	  printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n" ;  false; fi
4949e423941SBarry Smith	@${MKDIR} ${LOC}/manualpages
4959e423941SBarry Smith
4969e423941SBarry Smithchk_c2html:
4979e423941SBarry Smith	@if [ ${C2HTML}foo = foo ] ; then \
4989e423941SBarry Smith          printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR ************************\n" ; \
4999e423941SBarry Smith          echo "Require c2html for html docs. Please reconfigure with --download-c2html=1"; \
5009e423941SBarry Smith          printf "******************************************************"${PETSC_TEXT_NORMAL}"\n" ;false; fi
5019e423941SBarry Smith
5029e423941SBarry Smith
5039e423941SBarry Smith# the ACTION=manualpages cannot run in parallel because they all write to the same manualpages.cit file
5046121d795SBarry Smithhloc=include/petsc/private
505589e537fSPatrick Sananallmanpages: chk_loc deletemanualpages
5062ba9d5beSBarry Smith	-echo " /* SUBMANSEC = PetscH */ " > ${hloc}/generated_khash.h
5072ba9d5beSBarry Smith	-sed -e 's?<T>?I?g' -e 's?<t>?i?g' -e 's?<KeyType>?PetscInt?g' ${hloc}/hashset.txt >> ${hloc}/generated_khash.h
5082ba9d5beSBarry Smith	-sed -e 's?<T>?IJ?g' -e 's?<t>?ij?g' -e 's?<KeyType>?struct {PetscInt i, j;}?g' ${hloc}/hashset.txt >> ${hloc}/generated_khash.h
5092ba9d5beSBarry Smith	-sed -e 's?<T>?I?g' -e 's?<t>?i?g' -e 's?<KeyType>?PetscInt?g'  -e 's?<ValType>?PetscInt?g' ${hloc}/hashmap.txt >> ${hloc}/generated_khash.h
5102ba9d5beSBarry Smith	-sed -e 's?<T>?IJ?g' -e 's?<t>?ij?g' -e 's?<KeyType>?struct {PetscInt i, j;}?g' -e 's?<ValType>?PetscInt?g' ${hloc}/hashmap.txt >> ${hloc}/generated_khash.h
511faa16638SBarry Smith	-sed -e 's?<T>?IJ?g' -e 's?<t>?ij?g' -e 's?<KeyType>?struct {PetscInt i, j;}?g' -e 's?<ValType>?PetscScalar?g' ${hloc}/hashmap.txt >> ${hloc}/generated_khash.h
5122ba9d5beSBarry Smith	-sed -e 's?<T>?IV?g' -e 's?<t>?iv?g' -e 's?<KeyType>?PetscInt?g'  -e 's?<ValType>?PetscScalar?g' ${hloc}/hashmap.txt >> ${hloc}/generated_khash.h
5132ba9d5beSBarry Smith	-sed -e 's?<T>?Obj?g' -e 's?<t>?obj?g' -e 's?<KeyType>?PetscInt64?g'  -e 's?<ValType>?PetscObject?g' ${hloc}/hashmap.txt >> ${hloc}/generated_khash.h
51471c41f4fSBarry Smith	-${RM} ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err
515ac09b921SBarry Smith	-${OMAKE_SELF} ACTION=manualpages tree_src LOC=${LOC}
51673fdd05bSBarry Smith	-@sed -e s%man+../%man+manualpages/% ${LOC}/manualpages/manualpages.cit > ${LOC}/manualpages/htmlmap
51773fdd05bSBarry Smith	-@cat ${PETSC_DIR}/doc/classic/mpi.www.index >> ${LOC}/manualpages/htmlmap
51849762cbcSSatish Balay	cat ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err
519d7b6776fSBarry Smith	a=`cat ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err | wc -l`; test ! $$a -gt 0
520f4da3331SVáclav Hapla
521f4da3331SVáclav Haplaallmanexamples: chk_loc allmanpages
5229e423941SBarry Smith	-${OMAKE_SELF} ACTION=manexamples tree LOC=${LOC}
5239e423941SBarry Smith
5249e423941SBarry Smith#
5259e423941SBarry Smith#    Goes through all manual pages adding links to implementations of the method
5269e423941SBarry Smith# or class, at the end of the file.
5279e423941SBarry Smith#
5289e423941SBarry Smith# To find functions implementing methods, we use git grep to look for
5299e423941SBarry Smith# well-formed PETSc functions
5309e423941SBarry Smith# - with names containing a single underscore
5319e423941SBarry Smith# - in files of appropriate types (.cu .c .cxx .h),
5329e423941SBarry Smith# - in paths including "/impls/",
5339e423941SBarry Smith# - excluding any line with a semicolon (to avoid matching prototypes), and
5349e423941SBarry Smith# - excluding any line including "_Private",
5359e423941SBarry Smith# storing potential matches in implsFuncAll.txt.
5369e423941SBarry Smith#
5379e423941SBarry Smith# For each man page we then grep in this file for the item's name followed by
5389e423941SBarry Smith# a single underscore and process the resulting implsFunc.txt to generate HTML.
5399e423941SBarry Smith#
5409e423941SBarry Smith# To find class implementations, we populate implsClassAll.txt with candidates
5419e423941SBarry Smith# - of the form "struct _p_itemName {",  and
5429e423941SBarry Smith# - not containing a semicolon
5439e423941SBarry Smith# and then grep for particular values of itemName, generating implsClass.txt,
5449e423941SBarry Smith# which is processed to generate HTML.
5459e423941SBarry Smith#
5469e423941SBarry Smith# Note: PETSC_DOC_OUT_ROOT_PLACEHOLDER must match the term used elsewhere in doc/
5479e423941SBarry Smithmanimplementations:
5489e423941SBarry Smith	-@git grep "struct\s\+_[pn]_[^\s]\+.*{" -- *.cpp *.cu *.c *.h *.cxx | grep -v -e ";" -e "/tests/" -e "/tutorials/" > implsClassAll.txt ; \
5499e423941SBarry Smith  git grep -n "^\(static \)\?\(PETSC_EXTERN \)\?\(PETSC_INTERN \)\?\(extern \)\?PetscErrorCode \+[^_ ]\+_[^_ ]\+(" -- '*/impls/*.c' '*/impls/*.cpp' '*/impls/*.cu' '*/impls/*.cxx' '*/impls/*.h' | grep -v -e ";" -e "_[Pp]rivate" > implsFuncAll.txt ; \
5509e423941SBarry Smith  for i in ${LOC}/manualpages/*/*.md foo; do \
5519e423941SBarry Smith       if [ "$$i" != "foo" ] ; then \
5529e423941SBarry Smith          itemName=`basename $$i .md`;\
5539e423941SBarry Smith          grep "\s$${itemName}_" implsFuncAll.txt > implsFunc.txt ; \
5549e423941SBarry Smith          grep "_p_$${itemName}\b" implsClassAll.txt > implsClass.txt ; \
5559e423941SBarry Smith          if [ -s implsFunc.txt ] || [ -s implsClass.txt ] ; then \
5569e423941SBarry Smith            printf "\n## Implementations\n\n" >> $$i; \
5579e423941SBarry Smith          fi ; \
5589e423941SBarry Smith          if [ -s implsFunc.txt ] ; then \
5599e423941SBarry Smith            sed "s?\(.*\.[ch]x*u*\).*\($${itemName}.*\)(.*)?<A HREF=\"PETSC_DOC_OUT_ROOT_PLACEHOLDER/\1.html#\2\">\2 in \1</A><BR>?" implsFunc.txt >> $$i ; \
5609e423941SBarry Smith          fi ; \
5619e423941SBarry Smith          if [ -s implsClass.txt ] ; then \
562*1f2f3863SBarry Smith            sed "s?\(.*\.[ch]x*u*\):.*struct.*\(_p_$${itemName}\).*{?<A HREF=\"PETSC_DOC_OUT_ROOT_PLACEHOLDER/\1.html#\2\">\2 in \1</A><BR>?" implsClass.txt >> $$i ; \
5639e423941SBarry Smith          fi ; \
5649e423941SBarry Smith          ${RM} implsFunc.txt implsClass.txt; \
5659e423941SBarry Smith       fi ; \
5669e423941SBarry Smith  done ; \
5679e423941SBarry Smith  ${RM} implsClassAll.txt implsFuncAll.txt
568f4da3331SVáclav Hapla
5697b770568SPatrick Sanan# Build all classic docs except html sources
5709e423941SBarry Smithalldoc_pre: chk_loc allmanpages allmanexamples
5719e423941SBarry Smith	-${OMAKE_SELF} LOC=${LOC} manimplementations
572c3a89c15SBarry Smith	-${PYTHON} lib/petsc/bin/maint/wwwindex.py ${PETSC_DIR} ${LOC}
573753a1a87SJed Brown
57403953011SBarry Smith# Run after alldoc_pre to build html sources
57503953011SBarry Smithalldoc_post: chk_loc  chk_c2html
57603953011SBarry Smith	-@if command -v parallel &> /dev/null; then \
5779cd31cfbSBarry Smith           ls include/makefile src/*/makefile | xargs dirname | parallel -j ${MAKE_TEST_NP} --load ${MAKE_LOAD} 'cd {}; ${OMAKE_SELF} HTMLMAP=${HTMLMAP} LOC=${LOC} PETSC_DIR=${PETSC_DIR} ACTION=html tree' ; \
57803953011SBarry Smith         else \
5799cd31cfbSBarry Smith           ${OMAKE_SELF} HTMLMAP=${HTMLMAP} LOC=${LOC} PETSC_DIR=${PETSC_DIR} ACTION=html tree; \
58003953011SBarry Smith        fi
581753a1a87SJed Brown
58272ece014SPatrick Sananalldocclean: deletemanualpages allcleanhtml
583753a1a87SJed Brown
584589e537fSPatrick Sanan# Deletes man pages (.md version)
585753a1a87SJed Browndeletemanualpages: chk_loc
58673fdd05bSBarry Smith	-@if [ -d ${LOC} -a -d ${LOC}/manualpages ]; then \
58773fdd05bSBarry Smith          find ${LOC}/manualpages -type f -name "*.md" -exec ${RM} {} \; ;\
58873fdd05bSBarry Smith          ${RM} ${LOC}/manualpages/manualpages.cit ;\
589753a1a87SJed Brown        fi
590753a1a87SJed Brown
591753a1a87SJed Brownallcleanhtml:
5929e423941SBarry Smith	-${OMAKE_SELF} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} tree
593753a1a87SJed Brown
5944c512586SBarry Smith# ********* Rules for checking code coverage *********************************************************************************************
595753a1a87SJed Brown
596753a1a87SJed Browngcov:
59741baa1e4SJacob Faibussowitsch	output_file_base_name=${PETSC_ARCH}-gcovr-report.json; \
59820c90202SJacob Faibussowitsch	petsc_arch_dir=${PETSC_DIR}/${PETSC_ARCH}; \
599ccfcae5eSJacob Faibussowitsch        tar_file=$${petsc_arch_dir}/$${output_file_base_name}.tar.bz2; \
600ccfcae5eSJacob Faibussowitsch	cd $${petsc_arch_dir}/obj && \
601ccfcae5eSJacob Faibussowitsch	gcovr --json --output $${petsc_arch_dir}/$${output_file_base_name} --exclude '.*/ftn-auto/.*' --exclude-lines-by-pattern '^\s*SETERR.*' --exclude-throw-branches --exclude-unreachable-branches -j 4 --gcov-executable "${PETSC_COVERAGE_EXEC}" --root ${PETSC_DIR} . ${PETSC_GCOV_OPTIONS} && \
602ccfcae5eSJacob Faibussowitsch	${RM} -f $${tar_file} && \
603ccfcae5eSJacob Faibussowitsch	tar --bzip2 -cf $${tar_file} -C $${petsc_arch_dir} ./$${output_file_base_name} && \
604ccfcae5eSJacob Faibussowitsch	${RM} $${petsc_arch_dir}/$${output_file_base_name}
605753a1a87SJed Brown
606753a1a87SJed Brownmergegcov:
6077ce81a4bSJacob Faibussowitsch	$(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py --merge-branch `lib/petsc/bin/maint/check-merge-branch.sh` --html --xml ${PETSC_GCOV_OPTIONS}
608b0e5478fSScott Kruger
609753a1a87SJed Browncountfortranfunctions:
610f53b81b6SPierre Jolivet	-@cd ${PETSC_DIR}/src/fortran; grep -E '^void' custom/*.c auto/*.c | \
611f53b81b6SPierre Jolivet	cut -d'(' -f1 | tr -s  ' ' | cut -d' ' -f2 | uniq | grep -E -v "(^$$|Petsc)" | \
612753a1a87SJed Brown	sed "s/_$$//" | sort > /tmp/countfortranfunctions
613753a1a87SJed Brown
614753a1a87SJed Browncountcfunctions:
615068711b4SBarry Smith	-@grep PETSC_EXTERN ${PETSC_DIR}/include/*.h  | grep "(" | tr -s ' ' | \
616753a1a87SJed Brown	cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' |  \
617068711b4SBarry Smith	tr 'A-Z' 'a-z' |  sort | uniq > /tmp/countcfunctions
618753a1a87SJed Brown
619753a1a87SJed Browndifffortranfunctions: countfortranfunctions countcfunctions
620753a1a87SJed Brown	-@echo -------------- Functions missing in the fortran interface ---------------------
621753a1a87SJed Brown	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2
622753a1a87SJed Brown	-@echo ----------------- Functions missing in the C interface ------------------------
623753a1a87SJed Brown	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2
624753a1a87SJed Brown	-@${RM}  /tmp/countcfunctions /tmp/countfortranfunctions
625753a1a87SJed Brown
626753a1a87SJed Browncheckbadfortranstubs:
627753a1a87SJed Brown	-@echo "========================================="
628753a1a87SJed Brown	-@echo "Functions with MPI_Comm as an Argument"
629753a1a87SJed Brown	-@echo "========================================="
630753a1a87SJed Brown	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \
631753a1a87SJed Brown	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
632753a1a87SJed Brown	-@echo "========================================="
633753a1a87SJed Brown	-@echo "Functions with a String as an Argument"
634753a1a87SJed Brown	-@echo "========================================="
635753a1a87SJed Brown	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \
636753a1a87SJed Brown	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
637753a1a87SJed Brown	-@echo "========================================="
638753a1a87SJed Brown	-@echo "Functions with Pointers to PETSc Objects as Argument"
639753a1a87SJed Brown	-@echo "========================================="
640753a1a87SJed Brown	-@cd ${PETSC_DIR}/src/fortran/auto; \
641753a1a87SJed Brown	_p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \
642753a1a87SJed Brown	cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \
643753a1a87SJed Brown	sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \
644753a1a87SJed Brown	for OBJ in $$_p_OBJ; do \
645753a1a87SJed Brown	grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \
646753a1a87SJed Brown	cut -d'(' -f1 | cut -d' ' -f1,3; \
647753a1a87SJed Brown	done
648a3269974SBarry Smith
649a3269974SBarry Smithcheckpackagetests:
650a3269974SBarry Smith	-@echo "Missing package tests"
651f53b81b6SPierre Jolivet	-@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} ; grep -E "(with-$${j}|download-$${j})" configexamples | grep -v "=0" | wc -l ; done
652a3269974SBarry Smith	-@echo "Missing download package tests"
653f53b81b6SPierre Jolivet	-@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} ; grep -E "(download-$${j})" configexamples | grep -v "=0" | wc -l ; done
654a3269974SBarry Smith
6554c512586SBarry Smithcheck_petsc4py_rst:
6564c512586SBarry Smith	@${RM} -f petsc4py_rst.log
6574c512586SBarry Smith	@echo "Checking src/binding/petsc4py/DESCRIPTION.rst"
6584c512586SBarry Smith	@rst2html src/binding/petsc4py/DESCRIPTION.rst > /dev/null 2> petsc4py_rst.log
6594c512586SBarry Smith	@if test -s petsc4py_rst.log; then cat petsc4py_rst.log; exit 1; fi
6604c512586SBarry Smith
6614c512586SBarry Smith# TODO: checkTestCoverage: that makes sure every tutorial test has at least one test listed in the file, perhaps handled by gmakegentest.py
6624c512586SBarry Smith# TODO: check for PetscBeginFunctionUser in non-example source
6634c512586SBarry Smith# TODO: check for __ at start of #define or symbol
6644c512586SBarry Smith# TODO: checking for missing manual pages
6654c512586SBarry Smith# TODO: check for incorrect %d
6664c512586SBarry Smith# TODO: check for double blank lines
6674c512586SBarry Smith# TODO: check for ill-formed manual pages
6684c512586SBarry Smith# TODO: check for { on line after for
6694c512586SBarry Smith# TODO: check for } then else on following line
6704c512586SBarry Smith# TODO: check for } else { with SETERRQ on following line or if () { with SETERRQ on following line
6714c512586SBarry Smith
6724c512586SBarry SmithcheckbadSpelling:
6734c512586SBarry Smith	-@x=`python3 ../bin/extract.py | aspell list | sort -u` ;
6744c512586SBarry Smith
6754c512586SBarry Smithupdatedatafiles:
6764c512586SBarry Smith	-@if [ -d "${HOME}/datafiles" ]; then \
6774c512586SBarry Smith            echo " ** Updating datafiles at ${HOME}/datafiles **"; \
6784c512586SBarry Smith            cd "${HOME}/datafiles" && git pull -q; fi
6794c512586SBarry Smith
680dc0529c6SBarry Smith.PHONY: info info_h all deletelibs allclean update \
681425fd74bSBarry Smith        alletags etags etags_complete etags_noexamples etags_makefiles etags_examples etags_fexamples alldoc allmanpages \
682425fd74bSBarry Smith        allcleanhtml  countfortranfunctions \
683416ff897SSatish Balay        start_configure configure_petsc configure_clean matlabbin install
684