1# 2# See https://petsc.org/release/install/ for instructions on installing PETSc 3# 4# This is the top level makefile for compiling PETSc. 5# * make help - useful messages on functionality 6# * make all - compile the PETSc libraries and utilities 7# * make check - runs a quick test that the libraries are built correctly and PETSc applications can run 8# 9# * make install - for use with ./configure is run with the --prefix=directory option 10# * make test - runs a comprehensive test suite (requires gnumake) 11# * make docs - build the entire PETSc website of documentation (locally) 12# * a variety of rules that print library properties useful for building applications (use make help) 13# * a variety of rules for PETSc developers 14# 15# gmakefile - manages the compiling PETSc in parallel 16# gmakefile.test - manages running the comprehensive test suite 17# 18# This makefile does not require GNUmake 19ALL: all 20DIRS = src include interfaces share/petsc/matlab 21 22# next line defines PETSC_DIR and PETSC_ARCH if they are not set 23include ././${PETSC_ARCH}/lib/petsc/conf/petscvariables 24include ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscrules 25include ${PETSC_DIR}/lib/petsc/conf/variables 26include ${PETSC_DIR}/lib/petsc/conf/rules.doc 27include ${PETSC_DIR}/lib/petsc/conf/rules.utils 28 29# This makefile contains a lot of PHONY targets with improperly specified prerequisites 30# where correct execution instead depends on the targets being processed in the correct 31# order. 32.NOTPARALLEL: 33 34OMAKE_SELF = $(OMAKE) -f makefile 35OMAKE_SELF_PRINTDIR = $(OMAKE_PRINTDIR) -f makefile 36 37#********* Rules for make all ********************************************************************************************************************************** 38 39all: 40 +@${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} chk_upgrade | tee ${PETSC_ARCH}/lib/petsc/conf/make.log 41 @ln -sf ${PETSC_ARCH}/lib/petsc/conf/make.log make.log 42 +@(${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 43 +@if [ "`cat ${PETSC_ARCH}/lib/petsc/conf/error.log 2> /dev/null`" != "0" ]; then \ 44 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; \ 45 if test -s ${PETSC_ARCH}/lib/petsc/conf/memoryerror.log; then \ 46 printf ${PETSC_TEXT_HILIGHT}"**************************ERROR*************************************\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \ 47 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; \ 48 printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\ 49 else \ 50 printf ${PETSC_TEXT_HILIGHT}"**************************ERROR*************************************\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \ 51 echo " Error during compile, check ${PETSC_ARCH}/lib/petsc/conf/make.log" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \ 52 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;\ 53 if [ "X${CONDA_ACTIVE}" != "X" ]; then \ 54 echo " Having Conda in your shell may have caused this problem, consider turning off Conda." 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\ 55 fi ; \ 56 printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\ 57 fi \ 58 else \ 59 ${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 ;\ 60 fi #solaris make likes to print the whole command that gave error. So split this up into the smallest chunk below 61 @echo "Finishing make run at `date +'%a, %d %b %Y %H:%M:%S %z'`" >> ${PETSC_ARCH}/lib/petsc/conf/make.log 62 @if [ "`cat ${PETSC_ARCH}/lib/petsc/conf/error.log 2> /dev/null`" != "0" ]; then exit 1; fi 63 64all-local: info libs matlabbin petsc4py-build libmesh-build mfem-build slepc-build hpddm-build amrex-build bamg-build 65 66${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files: 67 @touch -t 197102020000 ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files 68 69${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles: 70 @${MKDIR} -p ${PETSC_DIR}/${PETSC_ARCH}/tests && touch -t 197102020000 ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 71 72chk_upgrade: 73 -@PETSC_DIR=${PETSC_DIR} ${PYTHON} ${PETSC_DIR}/lib/petsc/bin/petscnagupgrade.py 74 75matlabbin: 76 -@if [ "${MATLAB_MEX}" != "" -a "${MATLAB_SOCKET}" != "" -a "${PETSC_SCALAR}" = "real" -a "${PETSC_PRECISION}" = "double" ]; then \ 77 echo "BEGINNING TO COMPILE MATLAB INTERFACE"; \ 78 if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc" ] ; then ${MKDIR} ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc; fi; \ 79 if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab" ] ; then ${MKDIR} ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab; fi; \ 80 cd src/sys/classes/viewer/impls/socket/mex-scripts && ${OMAKE_SELF} mex-scripts PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR}; \ 81 echo "========================================="; \ 82 fi 83 84allfortranstubs: 85 -@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir 86 @${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py ${BFORT} ${VERBOSE} 87 -@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py -merge ${VERBOSE} 88 -@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir 89 90deleteshared: 91 @for LIBNAME in ${SHLIBS}; \ 92 do \ 93 if [ -d ${INSTALL_LIB_DIR}/$${LIBNAME}.dylib.dSYM ]; then \ 94 echo ${RM} -rf ${INSTALL_LIB_DIR}/$${LIBNAME}.dylib.dSYM; \ 95 ${RM} -rf ${INSTALL_LIB_DIR}/$${LIBNAME}.dylib.dSYM; \ 96 fi; \ 97 echo ${RM} ${INSTALL_LIB_DIR}/$${LIBNAME}.${SL_LINKER_SUFFIX}; \ 98 ${RM} ${INSTALL_LIB_DIR}/$${LIBNAME}.${SL_LINKER_SUFFIX}; \ 99 done 100 @if [ -f ${INSTALL_LIB_DIR}/so_locations ]; then \ 101 echo ${RM} ${INSTALL_LIB_DIR}/so_locations; \ 102 ${RM} ${INSTALL_LIB_DIR}/so_locations; \ 103 fi 104 105deletefortranstubs: 106 -@find . -type d -name ftn-auto | xargs rm -rf 107 108reconfigure: allclean 109 @unset MAKEFLAGS && ${PYTHON} ${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py 110 111chkopts: 112 -@echo "Warning: chkopts target is deprecated and can be removed from user makefiles" 113 114gnumake: 115 +@echo "make gnumake is deprecated, use make libs" 116 +@make libs 117 118# ******** Rules for make check **************************************************************************************************************************** 119 120RUN_TEST = ${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff 121 122check_install: check 123check: 124 -@echo "Running check examples to verify correct installation" 125 -@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}" 126 @if [ "${PETSC_WITH_BATCH}" != "" ]; then \ 127 echo "Running with batch filesystem, cannot run make check"; \ 128 elif [ "${MPIEXEC}" = "/bin/false" ]; then \ 129 echo "*mpiexec not found*. cannot run make check"; \ 130 else \ 131 ${RM} -f check_error;\ 132 ${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; \ 133 if [ -f check_error ]; then \ 134 echo "Error while running make check"; \ 135 ${RM} -f check_error;\ 136 exit 1; \ 137 fi; \ 138 ${RM} -f check_error;\ 139 fi; 140 141check_build: 142 +@cd src/snes/tutorials >/dev/null; ${RUN_TEST} clean-legacy 143 +@cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19 144 +@if [ ! "${MPI_IS_MPIUNI}" ]; then cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19_mpi; fi 145 +@if [ "${HYPRE_LIB}" != "" ] && [ "${PETSC_SCALAR}" = "real" ]; then \ 146 if [ "${CUDA_LIB}" != "" ]; then HYPRE_TEST=runex19_hypre_cuda; \ 147 elif [ "${HIP_LIB}" != "" ]; then HYPRE_TEST=runex19_hypre_hip; \ 148 else HYPRE_TEST=runex19_hypre; fi; \ 149 cd src/snes/tutorials >/dev/null; ${RUN_TEST} $${HYPRE_TEST}; \ 150 fi; 151 +@if [ "${CUDA_LIB}" != "" ]; then \ 152 cd src/snes/tutorials >/dev/null; ${RUN_TEST} runex19_cuda; \ 153 fi; 154 +@if [ "${MPI_IS_MPIUNI}" = "" ]; then \ 155 cd src/snes/tutorials >/dev/null; \ 156 if [ "${KOKKOS_KERNELS_LIB}" != "" ] && [ "${PETSC_SCALAR}" = "real" ] && [ "${PETSC_PRECISION}" = "double" ]; then \ 157 ${RUN_TEST} runex3k_kokkos; \ 158 fi;\ 159 if [ "${MUMPS_LIB}" != "" ]; then \ 160 ${RUN_TEST} runex19_fieldsplit_mumps; \ 161 fi;\ 162 if [ "${SUITESPARSE_LIB}" != "" ]; then \ 163 ${RUN_TEST} runex19_suitesparse; \ 164 fi;\ 165 if [ "${SUPERLU_DIST_LIB}" != "" ]; then \ 166 ${RUN_TEST} runex19_superlu_dist; \ 167 fi;\ 168 if ( [ "${ML_LIB}" != "" ] || [ "${TRILINOS_LIB}" != "" ] ); then \ 169 ${RUN_TEST} runex19_ml; \ 170 fi; \ 171 ${RUN_TEST} clean-legacy; \ 172 cd - > /dev/null; \ 173 if ( [ "${AMREX_LIB}" != "" ] && [ "${CUDA_LIB}" = "" ] ); then \ 174 echo "Running amrex test example to verify correct installation";\ 175 echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}";\ 176 cd src/ksp/ksp/tutorials/amrex >/dev/null;\ 177 ${RUN_TEST} clean-legacy; \ 178 ${RUN_TEST} testamrex; \ 179 ${RUN_TEST} clean-legacy; \ 180 cd - > /dev/null; \ 181 fi;\ 182 fi; 183 +@if [ "${HDF5_LIB}" != "" ]; then \ 184 cd src/vec/vec/tests >/dev/null;\ 185 ${RUN_TEST} clean-legacy; \ 186 ${RUN_TEST} runex47; \ 187 ${RUN_TEST} clean-legacy; \ 188 fi; 189 +@if [ "${MPI4PY}" = "yes" ]; then \ 190 cd src/sys/tests >/dev/null; \ 191 ${RUN_TEST} clean-legacy; \ 192 ${RUN_TEST} testex55; \ 193 ${RUN_TEST} clean-legacy; \ 194 fi; 195 +@if [ "${PETSC4PY}" = "yes" ]; then \ 196 cd src/ksp/ksp/tutorials >/dev/null; \ 197 ${RUN_TEST} clean-legacy; \ 198 ${RUN_TEST} testex100; \ 199 ${RUN_TEST} clean-legacy; \ 200 fi; 201 +@grep -E "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \ 202 if test -s .ftn.log; then \ 203 cd src/snes/tutorials >/dev/null; \ 204 ${RUN_TEST} clean-legacy; \ 205 ${RUN_TEST} testex5f; \ 206 ${RUN_TEST} clean-legacy; \ 207 fi; ${RM} .ftn.log; 208 +@grep -E "^#define PETSC_HAVE_MATLAB 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \ 209 if test -s .ftn.log; then \ 210 cd src/vec/vec/tutorials >/dev/null; \ 211 ${RUN_TEST} clean-legacy; \ 212 ${RUN_TEST} testex31; \ 213 ${RUN_TEST} clean-legacy; \ 214 fi; ${RM} .ftn.log; 215 -@echo "Completed test examples" 216 217# ********* Rules for make install ******************************************************************************************************************* 218 219install: 220 @${PYTHON} ./config/install.py -destDir=${DESTDIR} 221 +${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc 222 223# A smaller install with fewer extras 224install-lib: 225 @${PYTHON} ./config/install.py -destDir=${DESTDIR} -no-examples 226 +${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc 227 228install-builtafterpetsc: 229 +${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 230 231# Creates ${HOME}/petsc.tar.gz [and petsc-with-docs.tar.gz] 232dist: 233 ${PETSC_DIR}/lib/petsc/bin/maint/builddist ${PETSC_DIR} main 234 235# ******** Rules for running the full test suite ******************************************************************************************************** 236 237TESTMODE = testexamples 238ALLTESTS_CHECK_FAILURES = no 239ALLTESTS_MAKEFILE = ${PETSC_DIR}/gmakefile.test 240VALGRIND=0 241alltests: chk_in_petscdir ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 242 -@${RM} -rf ${PETSC_ARCH}/lib/petsc/conf/alltests.log alltests.log 243 +@if [ -f ${PETSC_DIR}/share/petsc/examples/gmakefile.test ] ; then \ 244 ALLTESTS_MAKEFILE=${PETSC_DIR}/share/petsc/examples/gmakefile.test ; \ 245 ALLTESTSLOG=alltests.log ;\ 246 else \ 247 ALLTESTS_MAKEFILE=${PETSC_DIR}/gmakefile.test; \ 248 ALLTESTSLOG=${PETSC_ARCH}/lib/petsc/conf/alltests.log ;\ 249 ln -s $${ALLTESTSLOG} alltests.log ;\ 250 fi; \ 251 ${OMAKE} allgtest ALLTESTS_MAKEFILE=$${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} MPIEXEC="${MPIEXEC}" DATAFILESPATH=${DATAFILESPATH} VALGRIND=${VALGRIND} 2>&1 | tee $${ALLTESTSLOG};\ 252 if [ x${ALLTESTS_CHECK_FAILURES} = xyes -a ${PETSC_PRECISION} != single ]; then \ 253 cat $${ALLTESTSLOG} | grep -E '(^not ok|not remade because of errors|^# No tests run)' | wc -l | grep '^[ ]*0$$' > /dev/null; \ 254 fi; 255 256allgtests-tap: allgtest-tap 257 +@${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} check-test-errors 258 259allgtest-tap: ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 260 +@MAKEFLAGS="-j$(MAKE_TEST_NP) -l$(MAKE_LOAD) $(MAKEFLAGS)" ${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test OUTPUT=1 261 262allgtest: ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 263 +@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).$$)' 264 265test: 266 +${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test 267cleantest: 268 +${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} cleantest 269 270#********* Rules for cleaning *************************************************************************************************************************** 271 272deletelibs: 273 -${RM} -rf ${PETSC_LIB_DIR}/libpetsc*.* 274deletemods: 275 -${RM} -f ${PETSC_DIR}/${PETSC_ARCH}/include/petsc*.mod 276 277allclean: 278 -@${OMAKE} -f gmakefile clean 279 280clean:: allclean 281 282distclean: 283 @if [ -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ]; then \ 284 echo "*** Preserving ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py in ${PETSC_DIR} ***"; \ 285 mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/; fi 286 @echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***" 287 -${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/ 288 289info: 290 -@echo "==========================================" 291 -@echo " " 292 -@echo "See documentation/faq.html and documentation/bugreporting.html" 293 -@echo "for help with installation problems. Please send EVERYTHING" 294 -@echo "printed out below when reporting problems. Please check the" 295 -@echo "mailing list archives and consider subscribing." 296 -@echo " " 297 -@echo " https://petsc.org/release/community/mailing/" 298 -@echo " " 299 -@echo "==========================================" 300 -@echo Starting make run on `hostname` at `date +'%a, %d %b %Y %H:%M:%S %z'` 301 -@echo Machine characteristics: `uname -a` 302 -@echo "-----------------------------------------" 303 -@echo "Using PETSc directory: ${PETSC_DIR}" 304 -@echo "Using PETSc arch: ${PETSC_ARCH}" 305 -@echo "-----------------------------------------" 306 -@grep "define PETSC_VERSION" ${PETSC_DIR}/include/petscversion.h | ${SED} "s/........//" | head -n 7 307 -@echo "-----------------------------------------" 308 -@echo "Using configure Options: ${CONFIGURE_OPTIONS}" 309 -@echo "Using configuration flags:" 310 -@grep "\#define " ${PETSCCONF_H} | tail -n +2 311 -@echo "-----------------------------------------" 312 -@echo "Using C compile: ${PETSC_CCOMPILE_SINGLE}" 313 -@if [ "${MPICC_SHOW}" != "" ]; then \ 314 printf "mpicc -show: %b\n" "${MPICC_SHOW}";\ 315 fi; \ 316 printf "C compiler version: %b\n" "${C_VERSION}"; \ 317 if [ "${CXX}" != "" ]; then \ 318 echo "Using C++ compile: ${PETSC_CXXCOMPILE_SINGLE}";\ 319 if [ "${MPICXX_SHOW}" != "" ]; then \ 320 printf "mpicxx -show: %b\n" "${MPICXX_SHOW}"; \ 321 fi;\ 322 printf "C++ compiler version: %b\n" "${Cxx_VERSION}"; \ 323 fi 324 -@if [ "${FC}" != "" ]; then \ 325 echo "Using Fortran compile: ${PETSC_FCOMPILE_SINGLE}";\ 326 if [ "${MPIFC_SHOW}" != "" ]; then \ 327 printf "mpif90 -show: %b\n" "${MPIFC_SHOW}"; \ 328 fi; \ 329 printf "Fortran compiler version: %b\n" "${FC_VERSION}"; \ 330 fi 331 -@if [ "${CUDAC}" != "" ]; then \ 332 echo "Using CUDA compile: ${PETSC_CUCOMPILE_SINGLE}";\ 333 fi 334 -@if [ "${CLANGUAGE}" = "CXX" ]; then \ 335 echo "Using C++ compiler to compile PETSc";\ 336 fi 337 -@echo "-----------------------------------------" 338 -@echo "Using C/C++ linker: ${PCC_LINKER}" 339 -@echo "Using C/C++ flags: ${PCC_LINKER_FLAGS}" 340 -@if [ "${FC}" != "" ]; then \ 341 echo "Using Fortran linker: ${FC_LINKER}";\ 342 echo "Using Fortran flags: ${FC_LINKER_FLAGS}";\ 343 fi 344 -@echo "-----------------------------------------" 345 -@echo "Using system modules: ${LOADEDMODULES}" 346 -@if [ "${MPI_IS_MPIUNI}" = "1" ]; then \ 347 echo Using mpi.h: mpiuni; \ 348 else \ 349 TESTDIR=`mktemp -q -d -t petscmpi-XXXXXXXX` && \ 350 echo '#include <mpi.h>' > $${TESTDIR}/mpitest.c && \ 351 BUF=`${CPP} ${PETSC_CPPFLAGS} ${PETSC_CC_INCLUDES} $${TESTDIR}/mpitest.c |grep 'mpi\.h' | ( head -1 ; cat > /dev/null )` && \ 352 echo Using mpi.h: $${BUF}; ${RM} -rf $${TESTDIR}; \ 353 fi 354 -@echo "-----------------------------------------" 355 -@echo "Using libraries: ${PETSC_LIB}" 356 -@echo "------------------------------------------" 357 -@echo "Using mpiexec: ${MPIEXEC}" 358 -@echo "------------------------------------------" 359 -@echo "Using MAKE: ${MAKE}" 360 -@echo "Default MAKEFLAGS: MAKE_NP:${MAKE_NP} MAKE_LOAD:${MAKE_LOAD} MAKEFLAGS:${MAKEFLAGS}" 361 -@echo "==========================================" 362 363 364check_usermakefile: 365 -@echo "Testing compile with user makefile" 366 -@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}" 367 @cd src/snes/tutorials; ${RUN_TEST} clean-legacy 368 @cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex19 369 @grep -E "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \ 370 if test -s .ftn.log; then \ 371 cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex5f; \ 372 fi; ${RM} .ftn.log; 373 @cd src/snes/tutorials; ${RUN_TEST} clean-legacy 374 -@echo "Completed compile with user makefile" 375 376#********* Rules for running clangformat ************************************************************************************************************ 377 378checkgitclean: 379 @if ! git diff --quiet; then \ 380 echo "The repository has uncommitted files, cannot run checkclangformat" ;\ 381 git status -s --untracked-files=no ;\ 382 false;\ 383 fi; 384 385checkclangformatversion: 386 @version=`clang-format --version | cut -d" " -f3 | cut -d"." -f 1` ;\ 387 if [ "$$version" == "version" ]; then version=`clang-format --version | cut -d" " -f4 | cut -d"." -f 1`; fi;\ 388 if [ $$version != 16 ]; then echo "Require clang-format version 16! Currently used clang-format version is $$version" ;false ; fi 389 390# Check that all the source code in the repository satisfies the .clang_format 391checkclangformat: checkclangformatversion checkgitclean clangformat 392 @if ! git diff --quiet; then \ 393 printf "The current commit has source code formatting problems\n" ;\ 394 if [ -z "${CI_PIPELINE_ID}" ]; then \ 395 printf "Please run 'git diff' to check\n"; \ 396 git diff --stat; \ 397 else \ 398 git diff --patch-with-stat > ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch; \ 399 git diff --patch-with-stat --color=always | head -1000; \ 400 if [ `wc -l < ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch` -gt 1000 ]; then \ 401 printf "The diff has been trimmed, check ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch (in CI artifacts) for all changes\n"; \ 402 fi;\ 403 fi;\ 404 false;\ 405 fi; 406 407# Compare ABI/API of two versions of PETSc library with the old one defined by PETSC_{DIR,ARCH}_ABI_OLD 408abitest: 409 @if [ "${PETSC_DIR_ABI_OLD}" = "" ] || [ "${PETSC_ARCH_ABI_OLD}" = "" ]; \ 410 then printf "You must set environment variables PETSC_DIR_ABI_OLD and PETSC_ARCH_ABI_OLD to run abitest\n"; \ 411 exit 1; \ 412 fi; 413 -@echo "Comparing ABI/API of the following two PETSc versions (you must have already configured and built them using GCC and with -g):" 414 -@echo "=========================================================================================" 415 -@echo " Old: PETSC_DIR_ABI_OLD = ${PETSC_DIR_ABI_OLD}" 416 -@echo " PETSC_ARCH_ABI_OLD = ${PETSC_ARCH_ABI_OLD}" 417 -@pushd ${PETSC_DIR_ABI_OLD} >> /dev/null ; echo " Branch = "`git rev-parse --abbrev-ref HEAD` 418 -@echo " New: PETSC_DIR = ${PETSC_DIR}" 419 -@echo " PETSC_ARCH = ${PETSC_ARCH}" 420 -@echo " Branch = "`git rev-parse --abbrev-ref HEAD` 421 -@echo "=========================================================================================" 422 -@$(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 423 424# Compare ABI/API of current PETSC_ARCH/PETSC_DIR with a previous branch 425abitestcomplete: 426 -@if [[ -f "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/configure.log" ]]; then \ 427 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"` ;\ 428echo $${OPTIONS} ;\ 429 fi ; \ 430 if [[ "${PETSC_DIR_ABI_OLD}" != "" ]]; then \ 431 PETSC_DIR_OLD=${PETSC_DIR_ABI_OLD}; \ 432 else \ 433 PETSC_DIR_OLD=${PETSC_DIR}/../petsc-abi; \ 434 fi ; \ 435 echo "=================================================================================================" ;\ 436 echo "Doing ABI/API comparison between" ${branch} " and " `git rev-parse --abbrev-ref HEAD` "using " $${OPTIONS} ;\ 437 echo "=================================================================================================" ;\ 438 if [[ ! -d $${PETSC_DIR_OLD} ]]; then \ 439 git clone ${PETSC_DIR} $${PETSC_DIR_OLD} ; \ 440 else \ 441 cd $${PETSC_DIR_OLD} ; \ 442 git pull ; \ 443 fi ; \ 444 cd $${PETSC_DIR_OLD} ; \ 445 git checkout ${branch} ; \ 446 PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` ./configure $${OPTIONS} ; \ 447 PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` make all test ; \ 448 cd ${PETSC_DIR} ; \ 449 ./configure $${OPTIONS}; \ 450 make all test ; \ 451 PETSC_DIR_ABI_OLD=$${PETSC_DIR_OLD} PETSC_ARCH_ABI_OLD=arch-branch-`git rev-parse ${branch}` make abitest 452 453# ******** Rules for running Streams benchmark **************************************************************************************************** 454 455mpistreams: 456 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistreams 457 458mpistream: 459 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistream 460 461openmpstreams: 462 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstreams 463 464openmpstream: 465 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstream 466 467stream: mpistream 468 469streams: mpistreams 470 471# ******** Rules for generating tag files for Emacs/VIM ******************************************************************************************* 472 473alletags: 474 -@${PYTHON} lib/petsc/bin/maint/generateetags.py 475 -@find config -type f -name "*.py" |grep -v SCCS | xargs etags -o TAGS_PYTHON 476 477# obtain gtags from https://www.gnu.org/software/global/ 478allgtags: 479 -@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 - 480 481# ********* Rules for building "classic" documentation; uses rules also in lib/petsc/conf/rules.doc ************************************************** 482 483docs: 484 cd doc; ${OMAKE_SELF} sphinxhtml 485 486chk_in_petscdir: 487 @if [ ! -f include/petscversion.h ]; then \ 488 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n" ; \ 489 echo " This target should be invoked in top level PETSc source dir!"; \ 490 printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n" ; false; fi 491 492chk_loc: 493 @if [ ${LOC}foo = foo ] ; then \ 494 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n" ; \ 495 echo " Please specify LOC variable for eg: make allmanpages LOC=/sandbox/petsc "; \ 496 printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n" ; false; fi 497 @${MKDIR} ${LOC}/manualpages 498 499chk_c2html: 500 @if [ ${C2HTML}foo = foo ] ; then \ 501 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR ************************\n" ; \ 502 echo "Require c2html for html docs. Please reconfigure with --download-c2html=1"; \ 503 printf "******************************************************"${PETSC_TEXT_NORMAL}"\n" ;false; fi 504 505 506# the ACTION=manualpages cannot run in parallel because they all write to the same manualpages.cit file 507hloc=include/petsc/private 508allmanpages: chk_loc deletemanualpages 509 -echo " /* SUBMANSEC = PetscH */ " > ${hloc}/generated_khash.h 510 -sed -e 's?<T>?I?g' -e 's?<t>?i?g' -e 's?<KeyType>?PetscInt?g' ${hloc}/hashset.txt >> ${hloc}/generated_khash.h 511 -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 512 -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 513 -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 514 -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 515 -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 516 -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 517 -${RM} ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err 518 -${OMAKE_SELF} ACTION=manualpages tree_src LOC=${LOC} 519 -@sed -e s%man+../%man+manualpages/% ${LOC}/manualpages/manualpages.cit > ${LOC}/manualpages/htmlmap 520 -@cat ${PETSC_DIR}/doc/classic/mpi.www.index >> ${LOC}/manualpages/htmlmap 521 cat ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err 522 a=`cat ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err | wc -l`; test ! $$a -gt 0 523 524allmanexamples: chk_loc allmanpages 525 -${OMAKE_SELF} ACTION=manexamples tree LOC=${LOC} 526 527# 528# Goes through all manual pages adding links to implementations of the method 529# or class, at the end of the file. 530# 531# To find functions implementing methods, we use git grep to look for 532# well-formed PETSc functions 533# - with names containing a single underscore 534# - in files of appropriate types (.cu .c .cxx .h), 535# - in paths including "/impls/", 536# - excluding any line with a semicolon (to avoid matching prototypes), and 537# - excluding any line including "_Private", 538# storing potential matches in implsFuncAll.txt. 539# 540# For each man page we then grep in this file for the item's name followed by 541# a single underscore and process the resulting implsFunc.txt to generate HTML. 542# 543# To find class implementations, we populate implsClassAll.txt with candidates 544# - of the form "struct _p_itemName {", and 545# - not containing a semicolon 546# and then grep for particular values of itemName, generating implsClass.txt, 547# which is processed to generate HTML. 548# 549# Note: PETSC_DOC_OUT_ROOT_PLACEHOLDER must match the term used elsewhere in doc/ 550manimplementations: 551 -@git grep "struct\s\+_[pn]_[^\s]\+.*{" -- *.cpp *.cu *.c *.h *.cxx | grep -v -e ";" -e "/tests/" -e "/tutorials/" > implsClassAll.txt ; \ 552 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 ; \ 553 for i in ${LOC}/manualpages/*/*.md foo; do \ 554 if [ "$$i" != "foo" ] ; then \ 555 itemName=`basename $$i .md`;\ 556 grep "\s$${itemName}_" implsFuncAll.txt > implsFunc.txt ; \ 557 grep "_p_$${itemName}\b" implsClassAll.txt > implsClass.txt ; \ 558 if [ -s implsFunc.txt ] || [ -s implsClass.txt ] ; then \ 559 printf "\n## Implementations\n\n" >> $$i; \ 560 fi ; \ 561 if [ -s implsFunc.txt ] ; then \ 562 sed "s?\(.*\.[ch]x*u*\).*\($${itemName}.*\)(.*)?<A HREF=\"PETSC_DOC_OUT_ROOT_PLACEHOLDER/\1.html#\2\">\2 in \1</A><BR>?" implsFunc.txt >> $$i ; \ 563 fi ; \ 564 if [ -s implsClass.txt ] ; then \ 565 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 ; \ 566 fi ; \ 567 ${RM} implsFunc.txt implsClass.txt; \ 568 fi ; \ 569 done ; \ 570 ${RM} implsClassAll.txt implsFuncAll.txt 571 572# Build all classic docs except html sources 573alldoc_pre: chk_loc allmanpages allmanexamples 574 -${OMAKE_SELF} LOC=${LOC} manimplementations 575 -${PYTHON} lib/petsc/bin/maint/wwwindex.py ${PETSC_DIR} ${LOC} 576 577# Run after alldoc_pre to build html sources 578alldoc_post: chk_loc chk_c2html 579 -@if command -v parallel &> /dev/null; then \ 580 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' ; \ 581 else \ 582 ${OMAKE_SELF} HTMLMAP=${HTMLMAP} LOC=${LOC} PETSC_DIR=${PETSC_DIR} ACTION=html tree; \ 583 fi 584 585alldocclean: deletemanualpages allcleanhtml 586 587# Deletes man pages (.md version) 588deletemanualpages: chk_loc 589 -@if [ -d ${LOC} -a -d ${LOC}/manualpages ]; then \ 590 find ${LOC}/manualpages -type f -name "*.md" -exec ${RM} {} \; ;\ 591 ${RM} ${LOC}/manualpages/manualpages.cit ;\ 592 fi 593 594allcleanhtml: 595 -${OMAKE_SELF} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} tree 596 597# ********* Rules for checking code coverage ********************************************************************************************* 598 599gcov: 600 output_file_base_name=${PETSC_ARCH}-gcovr-report.json; \ 601 petsc_arch_dir=${PETSC_DIR}/${PETSC_ARCH}; \ 602 tar_file=$${petsc_arch_dir}/$${output_file_base_name}.tar.bz2; \ 603 cd $${petsc_arch_dir}/obj && \ 604 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} && \ 605 ${RM} -f $${tar_file} && \ 606 tar --bzip2 -cf $${tar_file} -C $${petsc_arch_dir} ./$${output_file_base_name} && \ 607 ${RM} $${petsc_arch_dir}/$${output_file_base_name} 608 609mergegcov: 610 $(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py --merge-branch `lib/petsc/bin/maint/check-merge-branch.sh` --html --xml ${PETSC_GCOV_OPTIONS} 611 612countfortranfunctions: 613 -@cd ${PETSC_DIR}/src/fortran; grep -E '^void' custom/*.c auto/*.c | \ 614 cut -d'(' -f1 | tr -s ' ' | cut -d' ' -f2 | uniq | grep -E -v "(^$$|Petsc)" | \ 615 sed "s/_$$//" | sort > /tmp/countfortranfunctions 616 617countcfunctions: 618 -@grep PETSC_EXTERN ${PETSC_DIR}/include/*.h | grep "(" | tr -s ' ' | \ 619 cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' | \ 620 tr 'A-Z' 'a-z' | sort | uniq > /tmp/countcfunctions 621 622difffortranfunctions: countfortranfunctions countcfunctions 623 -@echo -------------- Functions missing in the fortran interface --------------------- 624 -@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2 625 -@echo ----------------- Functions missing in the C interface ------------------------ 626 -@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2 627 -@${RM} /tmp/countcfunctions /tmp/countfortranfunctions 628 629checkbadfortranstubs: 630 -@echo "=========================================" 631 -@echo "Functions with MPI_Comm as an Argument" 632 -@echo "=========================================" 633 -@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \ 634 tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3 635 -@echo "=========================================" 636 -@echo "Functions with a String as an Argument" 637 -@echo "=========================================" 638 -@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \ 639 tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3 640 -@echo "=========================================" 641 -@echo "Functions with Pointers to PETSc Objects as Argument" 642 -@echo "=========================================" 643 -@cd ${PETSC_DIR}/src/fortran/auto; \ 644 _p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \ 645 cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \ 646 sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \ 647 for OBJ in $$_p_OBJ; do \ 648 grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \ 649 cut -d'(' -f1 | cut -d' ' -f1,3; \ 650 done 651 652checkpackagetests: 653 -@echo "Missing package tests" 654 -@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 655 -@echo "Missing download package tests" 656 -@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 657 658check_petsc4py_rst: 659 @${RM} -f petsc4py_rst.log 660 @echo "Checking src/binding/petsc4py/DESCRIPTION.rst" 661 @rst2html src/binding/petsc4py/DESCRIPTION.rst > /dev/null 2> petsc4py_rst.log 662 @if test -s petsc4py_rst.log; then cat petsc4py_rst.log; exit 1; fi 663 664# TODO: checkTestCoverage: that makes sure every tutorial test has at least one test listed in the file, perhaps handled by gmakegentest.py 665# TODO: check for PetscBeginFunctionUser in non-example source 666# TODO: check for __ at start of #define or symbol 667# TODO: checking for missing manual pages 668# TODO: check for incorrect %d 669# TODO: check for double blank lines 670# TODO: check for ill-formed manual pages 671# TODO: check for { on line after for 672# TODO: check for } then else on following line 673# TODO: check for } else { with SETERRQ on following line or if () { with SETERRQ on following line 674 675checkbadSpelling: 676 -@x=`python3 ../bin/extract.py | aspell list | sort -u` ; 677 678updatedatafiles: 679 -@if [ -d "${HOME}/datafiles" ]; then \ 680 echo " ** Updating datafiles at ${HOME}/datafiles **"; \ 681 cd "${HOME}/datafiles" && git pull -q; fi 682 683.PHONY: info info_h all deletelibs allclean update \ 684 alletags etags etags_complete etags_noexamples etags_makefiles etags_examples etags_fexamples alldoc allmanpages \ 685 allcleanhtml countfortranfunctions \ 686 start_configure configure_petsc configure_clean matlabbin install 687