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 20 21# next line defines PETSC_DIR and PETSC_ARCH if they are not set 22include ././${PETSC_ARCH}/lib/petsc/conf/petscvariables 23include ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscrules 24include ${PETSC_DIR}/lib/petsc/conf/rules_doc.mk 25include ${PETSC_DIR}/lib/petsc/conf/rules_util.mk 26 27# This makefile contains a lot of PHONY targets with improperly specified prerequisites 28# where correct execution instead depends on the targets being processed in the correct 29# order. 30.NOTPARALLEL: 31 32OMAKE_SELF = $(OMAKE) -f makefile 33OMAKE_SELF_PRINTDIR = $(OMAKE_PRINTDIR) -f makefile 34PETSCCONF_H = ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h 35 36#********* Rules for make all ********************************************************************************************************************************** 37 38all: 39 +@${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} chk_upgrade | tee ${PETSC_ARCH}/lib/petsc/conf/make.log 40 @ln -sf ${PETSC_ARCH}/lib/petsc/conf/make.log make.log 41 +@(${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 42 +@if [ "`cat ${PETSC_ARCH}/lib/petsc/conf/error.log 2> /dev/null`" != "0" ]; then \ 43 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; \ 44 if test -s ${PETSC_ARCH}/lib/petsc/conf/memoryerror.log; then \ 45 printf ${PETSC_TEXT_HILIGHT}"**************************ERROR*************************************\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \ 46 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; \ 47 printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\ 48 else \ 49 printf ${PETSC_TEXT_HILIGHT}"**************************ERROR*************************************\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \ 50 echo " Error during compile, check ${PETSC_ARCH}/lib/petsc/conf/make.log" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log; \ 51 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;\ 52 if [ "X${CONDA_ACTIVE}" != "X" ]; then \ 53 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;\ 54 fi ; \ 55 printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\ 56 fi \ 57 else \ 58 ${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 ;\ 59 fi #solaris make likes to print the whole command that gave error. So split this up into the smallest chunk below 60 @echo "Finishing make run at `date +'%a, %d %b %Y %H:%M:%S %z'`" >> ${PETSC_ARCH}/lib/petsc/conf/make.log 61 @if [ "`cat ${PETSC_ARCH}/lib/petsc/conf/error.log 2> /dev/null`" != "0" ]; then exit 1; fi 62 63all-local: info libs matlabbin petsc4py-build libmesh-build mfem-build slepc-build hpddm-build amrex-build bamg-build dolfinx-build 64 65${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files: 66 @touch -t 197102020000 ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files 67 68${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles: 69 @${MKDIR} -p ${PETSC_DIR}/${PETSC_ARCH}/tests && touch -t 197102020000 ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 70 71chk_upgrade: 72 -@PETSC_DIR=${PETSC_DIR} ${PYTHON} ${PETSC_DIR}/lib/petsc/bin/petscnagupgrade.py 73 74matlabbin: 75 -@if [ "${MATLAB_MEX}" != "" -a "${MATLAB_SOCKET}" != "" -a "${PETSC_SCALAR}" = "real" -a "${PETSC_PRECISION}" = "double" ]; then \ 76 echo "BEGINNING TO COMPILE MATLAB INTERFACE"; \ 77 if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc" ] ; then ${MKDIR} ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc; fi; \ 78 if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab" ] ; then ${MKDIR} ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab; fi; \ 79 cd src/sys/classes/viewer/impls/socket/mex-scripts && ${OMAKE_SELF} mex-scripts PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR}; \ 80 echo "========================================="; \ 81 fi 82 83fortranbindings: deletefortranbindings 84 @${PYTHON} config/utils/generatefortranbindings.py --petsc-dir=${PETSC_DIR} --petsc-arch=${PETSC_ARCH} 85 86deleteshared: 87 @for LIBNAME in ${SHLIBS}; \ 88 do \ 89 if [ -d ${INSTALL_LIB_DIR}/$${LIBNAME}$${LIB_NAME_SUFFIX}.dylib.dSYM ]; then \ 90 echo ${RM} -rf ${INSTALL_LIB_DIR}/$${LIBNAME}$${LIB_NAME_SUFFIX}.dylib.dSYM; \ 91 ${RM} -rf ${INSTALL_LIB_DIR}/$${LIBNAME}$${LIB_NAME_SUFFIX}.dylib.dSYM; \ 92 fi; \ 93 echo ${RM} ${INSTALL_LIB_DIR}/$${LIBNAME}$${LIB_NAME_SUFFIX}.${SL_LINKER_SUFFIX}; \ 94 ${RM} ${INSTALL_LIB_DIR}/$${LIBNAME}$${LIB_NAME_SUFFIX}.${SL_LINKER_SUFFIX}; \ 95 done 96 @if [ -f ${INSTALL_LIB_DIR}/so_locations ]; then \ 97 echo ${RM} ${INSTALL_LIB_DIR}/so_locations; \ 98 ${RM} ${INSTALL_LIB_DIR}/so_locations; \ 99 fi 100 101deletefortranbindings: 102 -@find src -type d -name ftn-auto* | xargs rm -rf 103 -@if [ -n "${PETSC_ARCH}" ] && [ -d ${PETSC_ARCH} ] && [ -d ${PETSC_ARCH}/src ]; then \ 104 find ${PETSC_ARCH}/src -type d -name ftn-auto* | xargs rm -rf ;\ 105 fi 106 107reconfigure: allclean 108 @unset MAKEFLAGS && ${PYTHON} ${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py 109 110chkopts: 111 -@echo "Warning: chkopts target is deprecated and can be removed from user makefiles" 112 113gnumake: 114 +@echo "make gnumake is deprecated, use make libs" 115 +@make libs 116 117# ******** Rules for make check **************************************************************************************************************************** 118 119RUN_TEST = ${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff 120 121check_install: check 122check: 123 -@echo "Running PETSc check examples to verify correct installation" 124 -@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}" 125 @if [ "${PETSC_WITH_BATCH}" != "" ]; then \ 126 echo "Running with batch filesystem, cannot run make check"; \ 127 elif [ "${MPIEXEC}" = "/bin/false" ]; then \ 128 echo "*mpiexec not found*. cannot run make check"; \ 129 else \ 130 ${RM} -f check_error;\ 131 ${RUN_TEST} OMP_NUM_THREADS=1 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; \ 132 if [ -f check_error ]; then \ 133 echo "Error while running make check"; \ 134 ${RM} -f check_error;\ 135 exit 1; \ 136 fi; \ 137 ${RM} -f check_error;\ 138 fi; 139 140check_build: 141 +@cd src/snes/tutorials >/dev/null; ${RUN_TEST} clean-legacy 142 +@cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19 143 +@if [ ! "${MPI_IS_MPIUNI}" ]; then cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19_mpi; fi 144 +@if [ "`grep -E '^#define PETSC_HAVE_HYPRE 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_HYPRE 1" ] && [ "${PETSC_SCALAR}" = "real" ]; then \ 145 if [ "`grep -E '^#define PETSC_HAVE_CUDA 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_CUDA 1" ]; then HYPRE_TEST=runex19_hypre_cuda; \ 146 elif [ "`grep -E '^#define PETSC_HAVE_HIP 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_HIP 1" ]; then HYPRE_TEST=runex19_hypre_hip; \ 147 else HYPRE_TEST=runex19_hypre; fi; \ 148 cd src/snes/tutorials >/dev/null; ${RUN_TEST} $${HYPRE_TEST}; \ 149 fi; 150 +@if [ "`grep -E '^#define PETSC_HAVE_CUDA 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_CUDA 1" ]; then \ 151 cd src/snes/tutorials >/dev/null; ${RUN_TEST} runex19_cuda; \ 152 fi; 153 +@if [ "`grep -E '^#define PETSC_HAVE_HIP 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_HIP 1" ]; then \ 154 cd src/snes/tutorials >/dev/null; ${RUN_TEST} runex19_hip; \ 155 fi; 156 +@if [ "${MPI_IS_MPIUNI}" = "" ]; then \ 157 cd src/snes/tutorials >/dev/null; \ 158 if [ "`grep -E '^#define PETSC_HAVE_KOKKOS_KERNELS 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_KOKKOS_KERNELS 1" ] && [ "${PETSC_SCALAR}" = "real" ] && [ "${PETSC_PRECISION}" = "double" ]; then \ 159 ${RUN_TEST} runex3k_kokkos; \ 160 fi;\ 161 if [ "`grep -E '^#define PETSC_HAVE_MUMPS 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_MUMPS 1" ]; then \ 162 ${RUN_TEST} runex19_fieldsplit_mumps; \ 163 fi;\ 164 if [ "`grep -E '^#define PETSC_HAVE_SUITESPARSE 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_SUITESPARSE 1" ]; then \ 165 ${RUN_TEST} runex19_suitesparse; \ 166 fi;\ 167 if [ "`grep -E '^#define PETSC_HAVE_SUPERLU_DIST 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_SUPERLU_DIST 1" ]; then \ 168 ${RUN_TEST} runex19_superlu_dist; \ 169 fi;\ 170 if [ "`grep -E '^#define PETSC_HAVE_ML 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_ML 1" ] || [ "`grep -E '^#define PETSC_HAVE_TRILINOS 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_TRILINOS 1" ]; then \ 171 ${RUN_TEST} runex19_ml; \ 172 fi; \ 173 ${RUN_TEST} clean-legacy; \ 174 cd - > /dev/null; \ 175 if [ "`grep -E '^#define PETSC_HAVE_AMREX 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_AMREX 1" ] && [ "`grep -E '^#define PETSC_HAVE_CUDA 1' ${PETSCCONF_H}`" != "#define PETSC_HAVE_CUDA 1" ]; then \ 176 echo "Running amrex test example to verify correct installation";\ 177 echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}";\ 178 cd src/ksp/ksp/tutorials/amrex >/dev/null;\ 179 ${RUN_TEST} clean-legacy; \ 180 ${RUN_TEST} testamrex; \ 181 ${RUN_TEST} clean-legacy; \ 182 cd - > /dev/null; \ 183 fi;\ 184 fi; 185 +@if [ "`grep -E '^#define PETSC_HAVE_HDF5 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_HDF5 1" ]; then \ 186 cd src/vec/vec/tests >/dev/null;\ 187 ${RUN_TEST} clean-legacy; \ 188 ${RUN_TEST} runex47; \ 189 ${RUN_TEST} clean-legacy; \ 190 fi; 191 +@if [ "${MPI4PY}" = "yes" ]; then \ 192 cd src/sys/tests >/dev/null; \ 193 ${RUN_TEST} clean-legacy; \ 194 ${RUN_TEST} testex55; \ 195 ${RUN_TEST} clean-legacy; \ 196 fi; 197 +@if [ "${PETSC4PY}" = "yes" ]; then \ 198 cd src/ksp/ksp/tutorials >/dev/null; \ 199 ${RUN_TEST} clean-legacy; \ 200 ${RUN_TEST} testex100; \ 201 ${RUN_TEST} clean-legacy; \ 202 fi; 203 +@if [ "`grep -E '^#define PETSC_USE_FORTRAN_BINDINGS 1' ${PETSCCONF_H}`" = "#define PETSC_USE_FORTRAN_BINDINGS 1" ]; then \ 204 cd src/snes/tutorials >/dev/null; \ 205 ${RUN_TEST} clean-legacy; \ 206 ${RUN_TEST} testex5f; \ 207 ${RUN_TEST} clean-legacy; \ 208 fi; 209 +@if [ "`grep -E '^#define PETSC_HAVE_MATLAB 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_MATLAB 1" ]; then \ 210 ${RUN_TEST} clean-legacy; \ 211 ${RUN_TEST} testex31; \ 212 ${RUN_TEST} clean-legacy; \ 213 fi; 214 +@if [ "${SLEPC}" = "yes" ]; then \ 215 ${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} slepc-check; \ 216 fi; 217 +@if [ "${MFEM}" = "yes" ]; then \ 218 ${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} mfem-check; \ 219 fi; 220 -@echo "Completed PETSc check examples" 221 222# ********* Rules for make install ******************************************************************************************************************* 223 224install: 225 @${PYTHON} ./config/install.py -destDir=${DESTDIR} 226 +${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc 227 228# A smaller install with fewer extras 229install-lib: 230 @${PYTHON} ./config/install.py -destDir=${DESTDIR} -no-examples 231 +${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc 232 233install-builtafterpetsc: 234 +${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 dolfinx-install 235 236# Creates ${HOME}/petsc.tar.gz [and petsc-with-docs.tar.gz] 237dist: 238 ${PETSC_DIR}/lib/petsc/bin/maint/builddist ${PETSC_DIR} main 239 240# ******** Rules for running the full test suite ******************************************************************************************************** 241 242TESTMODE = testexamples 243ALLTESTS_CHECK_FAILURES = no 244ALLTESTS_MAKEFILE = ${PETSC_DIR}/gmakefile.test 245VALGRIND=0 246alltests: chk_in_petscdir ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 247 -@${RM} -rf ${PETSC_ARCH}/lib/petsc/conf/alltests.log alltests.log 248 +@if [ -f ${PETSC_DIR}/share/petsc/examples/gmakefile.test ] ; then \ 249 ALLTESTS_MAKEFILE=${PETSC_DIR}/share/petsc/examples/gmakefile.test ; \ 250 ALLTESTSLOG=alltests.log ;\ 251 else \ 252 ALLTESTS_MAKEFILE=${PETSC_DIR}/gmakefile.test; \ 253 ALLTESTSLOG=${PETSC_ARCH}/lib/petsc/conf/alltests.log ;\ 254 ln -s $${ALLTESTSLOG} alltests.log ;\ 255 fi; \ 256 ${OMAKE} allgtest ALLTESTS_MAKEFILE=$${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} MPIEXEC="${MPIEXEC}" DATAFILESPATH=${DATAFILESPATH} VALGRIND=${VALGRIND} 2>&1 | tee $${ALLTESTSLOG};\ 257 if [ x${ALLTESTS_CHECK_FAILURES} = xyes -a ${PETSC_PRECISION} != single ]; then \ 258 cat $${ALLTESTSLOG} | grep -E '(^not ok|not remade because of errors|^# No tests run)' | wc -l | grep '^[ ]*0$$' > /dev/null; \ 259 fi; 260 261allgtests-tap: allgtest-tap 262 +@${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} check-test-errors 263 264allgtest-tap: ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 265 +@MAKEFLAGS="-j$(MAKE_TEST_NP) -l$(MAKE_LOAD) $(MAKEFLAGS)" ${OMAKE} ${MAKE_SHUFFLE_FLG} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test OUTPUT=1 266 267allgtest: ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 268 +@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).$$)' 269 270test: 271 +${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test 272cleantest: 273 +${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} cleantest 274 275#********* Rules for cleaning *************************************************************************************************************************** 276 277deletelibs: 278 -${RM} -rf ${PETSC_LIB_DIR}/libpetsc*.* 279deletemods: 280 -${RM} -f ${PETSC_DIR}/${PETSC_ARCH}/include/petsc*.mod 281 282allclean: 283 -@${OMAKE} -f gmakefile clean 284 285clean:: allclean 286 287distclean: 288 @if [ -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ]; then \ 289 echo "*** Preserving ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py in ${PETSC_DIR} ***"; \ 290 mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/; \ 291 echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***"; \ 292 ${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/ ; \ 293 else \ 294 echo "*** Build files in PETSC_ARCH=${PETSC_ARCH} not found. Skipping delete! ***"; \ 295 fi 296 297info: 298 +@${OMAKE} -f gmakefile gmakeinfo 299 300check_usermakefile: 301 -@echo "Testing compile with user makefile" 302 -@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}" 303 @cd src/snes/tutorials; ${RUN_TEST} clean-legacy 304 @cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex19 305 @grep -E "^#define PETSC_USE_FORTRAN_BINDINGS 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \ 306 if test -s .ftn.log; then \ 307 cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex5f; \ 308 fi; ${RM} .ftn.log; 309 @cd src/snes/tutorials; ${RUN_TEST} clean-legacy 310 -@echo "Completed compile with user makefile" 311 312#********* Rules for running clangformat ************************************************************************************************************ 313 314checkgitclean: 315 @if ! git diff --quiet; then \ 316 echo "The repository has uncommitted files, cannot run checkclangformat" ;\ 317 git status -s --untracked-files=no ;\ 318 false;\ 319 fi; 320 321# Check that all the source code in the repository satisfies the .clang_format 322checkclangformat: checkclangformatversion checkgitclean clangformat 323 @if ! git diff --quiet; then \ 324 printf "The current commit has source code formatting problems\n" ;\ 325 if [ -z "${CI_PIPELINE_ID}" ]; then \ 326 printf "Please run 'git diff' to check\n"; \ 327 git diff --stat; \ 328 else \ 329 git diff --patch-with-stat > ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch; \ 330 git diff --patch-with-stat --color=always | head -1000; \ 331 if [ `wc -l < ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch` -gt 1000 ]; then \ 332 printf "The diff has been trimmed, check ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch (in CI artifacts) for all changes\n"; \ 333 fi;\ 334 fi;\ 335 false;\ 336 fi; 337 338# Compare ABI/API of two versions of PETSc library with the old one defined by PETSC_{DIR,ARCH}_ABI_OLD 339abitest: 340 @if [ "${PETSC_DIR_ABI_OLD}" = "" ] || [ "${PETSC_ARCH_ABI_OLD}" = "" ]; \ 341 then printf "You must set environment variables PETSC_DIR_ABI_OLD and PETSC_ARCH_ABI_OLD to run abitest\n"; \ 342 exit 1; \ 343 fi; 344 -@echo "Comparing ABI/API of the following two PETSc versions (you must have already configured and built them using GCC and with -g):" 345 -@echo "=========================================================================================" 346 -@echo " Old: PETSC_DIR_ABI_OLD = ${PETSC_DIR_ABI_OLD}" 347 -@echo " PETSC_ARCH_ABI_OLD = ${PETSC_ARCH_ABI_OLD}" 348 -@pushd ${PETSC_DIR_ABI_OLD} >> /dev/null ; echo " Branch = "`git rev-parse --abbrev-ref HEAD` 349 -@echo " New: PETSC_DIR = ${PETSC_DIR}" 350 -@echo " PETSC_ARCH = ${PETSC_ARCH}" 351 -@echo " Branch = "`git rev-parse --abbrev-ref HEAD` 352 -@echo "=========================================================================================" 353 -@$(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 354 355# Compare ABI/API of current PETSC_ARCH/PETSC_DIR with a previous branch 356abitestcomplete: 357 -@if [[ -f "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/configure.log" ]]; then \ 358 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"` ;\ 359echo $${OPTIONS} ;\ 360 fi ; \ 361 if [[ "${PETSC_DIR_ABI_OLD}" != "" ]]; then \ 362 PETSC_DIR_OLD=${PETSC_DIR_ABI_OLD}; \ 363 else \ 364 PETSC_DIR_OLD=${PETSC_DIR}/../petsc-abi; \ 365 fi ; \ 366 echo "=================================================================================================" ;\ 367 echo "Doing ABI/API comparison between" ${branch} " and " `git rev-parse --abbrev-ref HEAD` "using " $${OPTIONS} ;\ 368 echo "=================================================================================================" ;\ 369 if [[ ! -d $${PETSC_DIR_OLD} ]]; then \ 370 git clone ${PETSC_DIR} $${PETSC_DIR_OLD} ; \ 371 else \ 372 cd $${PETSC_DIR_OLD} ; \ 373 git pull ; \ 374 fi ; \ 375 cd $${PETSC_DIR_OLD} ; \ 376 git checkout ${branch} ; \ 377 PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` ./configure $${OPTIONS} ; \ 378 PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` make all test ; \ 379 cd ${PETSC_DIR} ; \ 380 ./configure $${OPTIONS}; \ 381 make all test ; \ 382 PETSC_DIR_ABI_OLD=$${PETSC_DIR_OLD} PETSC_ARCH_ABI_OLD=arch-branch-`git rev-parse ${branch}` make abitest 383 384# ******** Rules for running Streams benchmark **************************************************************************************************** 385 386mpistreams: 387 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistreams 388 389mpistream: 390 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistream 391 392openmpstreams: 393 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstreams 394 395openmpstream: 396 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstream 397 398stream: mpistream 399 400streams: mpistreams 401 402# ******** Rules for generating tag files for Emacs/VIM ******************************************************************************************* 403 404alletags: 405 -@${PYTHON} lib/petsc/bin/maint/generateetags.py && cp TAGS ${PETSC_ARCH}/ 406 -@find config -type f -name "*.py" |grep -v SCCS | xargs etags -o TAGS_PYTHON 407 408# obtain gtags from https://www.gnu.org/software/global/ 409allgtags: 410 -@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 - 411 412# ********* Rules for building "classic" documentation; uses rules also in lib/petsc/conf/rules_doc.mk ************************************************** 413 414docs: 415 cd doc; ${OMAKE_SELF} docs 416 417chk_in_petscdir: 418 @if [ ! -f include/petscversion.h ]; then \ 419 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n" ; \ 420 echo " This target should be invoked in top level PETSc source dir!"; \ 421 printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n" ; false; fi 422 423chk_loc: 424 @if [ ${LOC}foo = foo ] ; then \ 425 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n" ; \ 426 echo " Please specify LOC variable for eg: make allmanpages LOC=/sandbox/petsc "; \ 427 printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n" ; false; fi 428 @${MKDIR} ${LOC}/manualpages 429 430alldocclean: deletemanualpages allcleanhtml 431 432# Deletes man pages (.md version) 433deletemanualpages: chk_loc 434 -@if [ -d ${LOC} -a -d ${LOC}/manualpages ]; then \ 435 find ${LOC}/manualpages -type f -name "*.md" -exec ${RM} {} \; ;\ 436 ${RM} ${LOC}/manualpages/manualpages.cit ;\ 437 fi 438 439allcleanhtml: 440 -${OMAKE_SELF} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} tree 441 442# ********* Rules for checking code coverage ********************************************************************************************* 443 444gcov: 445 output_file_base_name=${PETSC_ARCH}-gcovr-report.json; \ 446 petsc_arch_dir=${PETSC_DIR}/${PETSC_ARCH}; \ 447 tar_file=$${petsc_arch_dir}/$${output_file_base_name}.tar.bz2; \ 448 cd $${petsc_arch_dir} && \ 449 gcovr --json --output $${petsc_arch_dir}/$${output_file_base_name} --exclude '.*/ftn-auto/.*' --exclude '.*/petscsys.h' --exclude-lines-by-pattern '^\s*SETERR.*' --exclude-throw-branches --exclude-unreachable-branches --gcov-ignore-parse-errors -j 8 --gcov-executable "${PETSC_COVERAGE_EXEC}" --root ${PETSC_DIR} ./obj ./tests ${PETSC_GCOV_OPTIONS} && \ 450 ${RM} -f $${tar_file} && \ 451 tar --bzip2 -cf $${tar_file} -C $${petsc_arch_dir} ./$${output_file_base_name} && \ 452 ${RM} $${petsc_arch_dir}/$${output_file_base_name} 453 454mergegcov: 455 $(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py --merge-branch `lib/petsc/bin/maint/check-merge-branch.sh` --html --xml ${PETSC_GCOV_OPTIONS} 456 457countcfunctions: 458 -@grep PETSC_EXTERN ${PETSC_DIR}/include/*.h | grep "(" | tr -s ' ' | \ 459 cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' | \ 460 tr 'A-Z' 'a-z' | sort | uniq > /tmp/countcfunctions 461 462checkpackagetests: 463 -@echo "Missing package tests" 464 -@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 465 -@echo "Missing download package tests" 466 -@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 467 468check_petsc4py_rst: 469 @${RM} -f petsc4py_rst.log 470 @echo "Checking src/binding/petsc4py/DESCRIPTION.rst" 471 @rst2html src/binding/petsc4py/DESCRIPTION.rst > /dev/null 2> petsc4py_rst.log 472 @if test -s petsc4py_rst.log; then cat petsc4py_rst.log; exit 1; fi 473 474# TODO: checkTestCoverage: that makes sure every tutorial test has at least one test listed in the file, perhaps handled by gmakegentest.py 475# TODO: check for PetscBeginFunctionUser in non-example source 476# TODO: check for __ at start of #define or symbol 477# TODO: checking for missing manual pages 478# TODO: check for incorrect %d 479# TODO: check for double blank lines 480# TODO: check for ill-formed manual pages 481# TODO: check for { on line after for 482# TODO: check for } then else on following line 483# TODO: check for } else { with SETERRQ on following line or if () { with SETERRQ on following line 484 485checkbadSpelling: 486 -@x=`python3 ../bin/extract.py | aspell list | sort -u` ; 487 488updatedatafiles: 489 -@if [ -d "${HOME}/datafiles" ]; then \ 490 echo " ** Updating datafiles at ${HOME}/datafiles **"; \ 491 cd "${HOME}/datafiles" && git pull -q; fi 492 493.PHONY: info info_h all deletelibs allclean update \ 494 alletags etags etags_complete etags_noexamples etags_makefiles etags_examples etags_fexamples alldoc allmanpages \ 495 allcleanhtml \ 496 start_configure configure_petsc configure_clean matlabbin install 497