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, run after ./configure 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 ${PETSC_POST_BUILDS} 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 "Compiling 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} lib/petsc/bin/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: check_body ${PETSC_POST_CHECKS} 122 123check_install: check 124 125check_body: 126 -@echo "Running PETSc check examples to verify correct installation" 127 -@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}" 128 @if [ "${PETSC_WITH_BATCH}" != "" ]; then\ 129 echo "Running with batch filesystem, cannot run make check";\ 130 elif [ "${MPIEXEC}" = "/bin/false" ]; then\ 131 echo "*mpiexec not found*. cannot run make check";\ 132 else\ 133 ${RM} -f check_error;\ 134 ${RUN_TEST} OMP_NUM_THREADS=1 PETSC_OPTIONS="${EXTRA_OPTIONS} ${PETSC_TEST_OPTIONS}" PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" check_build 2>&1 | tee ./${PETSC_ARCH}/lib/petsc/conf/check.log;\ 135 if [ -f check_error ]; then\ 136 echo "Error while running make check";\ 137 ${RM} -f check_error;\ 138 exit 1;\ 139 fi;\ 140 ${RM} -f check_error;\ 141 fi; 142 143check_build: 144 +@cd src/snes/tutorials >/dev/null; ${RUN_TEST} clean-legacy 145 +@cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19 146 +@if [ ! "${MPI_IS_MPIUNI}" ]; then cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19_mpi; fi 147 +@if [ "`grep -E '^#define PETSC_HAVE_HYPRE 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_HYPRE 1" ] && [ "${PETSC_SCALAR}" = "real" ]; then\ 148 if [ "`grep -E '^#define PETSC_HAVE_CUDA 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_CUDA 1" ]; then HYPRE_TEST=runex19_hypre_cuda;\ 149 elif [ "`grep -E '^#define PETSC_HAVE_HIP 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_HIP 1" ]; then HYPRE_TEST=runex19_hypre_hip;\ 150 else HYPRE_TEST=runex19_hypre; fi;\ 151 cd src/snes/tutorials >/dev/null; ${RUN_TEST} $${HYPRE_TEST};\ 152 fi; 153 +@if [ "`grep -E '^#define PETSC_HAVE_CUDA 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_CUDA 1" ]; then\ 154 cd src/snes/tutorials >/dev/null; ${RUN_TEST} runex19_cuda;\ 155 fi; 156 +@if [ "`grep -E '^#define PETSC_HAVE_HIP 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_HIP 1" ]; then\ 157 cd src/snes/tutorials >/dev/null; ${RUN_TEST} runex19_hip;\ 158 fi; 159 +@if [ "${MPI_IS_MPIUNI}" = "" ]; then\ 160 cd src/snes/tutorials >/dev/null;\ 161 if [ "`grep -E '^#define PETSC_HAVE_KOKKOS_KERNELS 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_KOKKOS_KERNELS 1" ] && [ "${PETSC_SCALAR}" = "real" ] && [ "${PETSC_PRECISION}" = "double" ]; then\ 162 ${RUN_TEST} runex3k_kokkos;\ 163 fi;\ 164 if [ "`grep -E '^#define PETSC_HAVE_MUMPS 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_MUMPS 1" ]; then\ 165 ${RUN_TEST} runex19_fieldsplit_mumps;\ 166 fi;\ 167 if [ "`grep -E '^#define PETSC_HAVE_SUITESPARSE 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_SUITESPARSE 1" ]; then\ 168 ${RUN_TEST} runex19_suitesparse;\ 169 fi;\ 170 if [ "`grep -E '^#define PETSC_HAVE_SUPERLU_DIST 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_SUPERLU_DIST 1" ]; then\ 171 ${RUN_TEST} runex19_superlu_dist;\ 172 fi;\ 173 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\ 174 ${RUN_TEST} runex19_ml;\ 175 fi;\ 176 ${RUN_TEST} clean-legacy;\ 177 cd - > /dev/null;\ 178 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\ 179 echo "Running amrex test example to verify correct installation";\ 180 echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}";\ 181 cd src/ksp/ksp/tutorials/amrex >/dev/null;\ 182 ${RUN_TEST} clean-legacy;\ 183 ${RUN_TEST} testamrex;\ 184 ${RUN_TEST} clean-legacy;\ 185 cd - > /dev/null;\ 186 fi;\ 187 fi; 188 +@if [ "`grep -E '^#define PETSC_HAVE_HDF5 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_HDF5 1" ]; then\ 189 cd src/vec/vec/tests >/dev/null;\ 190 ${RUN_TEST} clean-legacy;\ 191 ${RUN_TEST} runex47;\ 192 ${RUN_TEST} clean-legacy;\ 193 fi; 194 +@if [ "${MPI4PY}" = "yes" ]; then\ 195 cd src/sys/tests >/dev/null;\ 196 ${RUN_TEST} clean-legacy;\ 197 ${RUN_TEST} testex55;\ 198 ${RUN_TEST} clean-legacy;\ 199 fi; 200 +@if [ "`grep -E '^#define PETSC_HAVE_PETSC4PY 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_PETSC4PY 1" ]; then\ 201 cd src/ksp/ksp/tutorials >/dev/null;\ 202 ${RUN_TEST} clean-legacy;\ 203 ${RUN_TEST} testex100;\ 204 ${RUN_TEST} clean-legacy;\ 205 fi; 206 +@if [ "`grep -E '^#define PETSC_USE_FORTRAN_BINDINGS 1' ${PETSCCONF_H}`" = "#define PETSC_USE_FORTRAN_BINDINGS 1" ]; then\ 207 cd src/snes/tutorials >/dev/null;\ 208 ${RUN_TEST} clean-legacy;\ 209 ${RUN_TEST} testex5f;\ 210 ${RUN_TEST} clean-legacy;\ 211 fi; 212 +@if [ "`grep -E '^#define PETSC_HAVE_MATLAB 1' ${PETSCCONF_H}`" = "#define PETSC_HAVE_MATLAB 1" ]; then\ 213 cd src/vec/vec/tutorials >/dev/null;\ 214 ${RUN_TEST} clean-legacy;\ 215 ${RUN_TEST} testex31;\ 216 ${RUN_TEST} clean-legacy;\ 217 fi; 218 -@echo "Completed PETSc check examples" 219 220# ********* Rules for make install ******************************************************************************************************************* 221 222install: 223 @${PYTHON} ./config/install.py -destDir=${DESTDIR} 224 +${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc 225 226# A smaller install with fewer extras 227install-lib: 228 @${PYTHON} ./config/install.py -destDir=${DESTDIR} -no-examples 229 +${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc 230 231install-builtafterpetsc: 232 @if [ "${PETSC_POST_INSTALLS}" != "" ]; then ${OMAKE_SELF} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=${PETSC_INSTALL} ${PETSC_POST_INSTALLS}; fi 233 @echo "*** Install of PETSc (and any other packages) complete ***" 234 235# Creates ${HOME}/petsc.tar.gz [and petsc-with-docs.tar.gz] 236dist: 237 ${PETSC_DIR}/lib/petsc/bin/maint/builddist ${PETSC_DIR} main 238 239# ******** Rules for running the full test suite ******************************************************************************************************** 240 241TESTMODE = testexamples 242ALLTESTS_CHECK_FAILURES = no 243ALLTESTS_MAKEFILE = ${PETSC_DIR}/gmakefile.test 244VALGRIND=0 245alltests: chk_in_petscdir ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 246 -@${RM} -rf ${PETSC_ARCH}/lib/petsc/conf/alltests.log alltests.log 247 +@if [ -f ${PETSC_DIR}/share/petsc/examples/gmakefile.test ] ; then\ 248 ALLTESTS_MAKEFILE=${PETSC_DIR}/share/petsc/examples/gmakefile.test ;\ 249 ALLTESTSLOG=alltests.log ;\ 250 else\ 251 ALLTESTS_MAKEFILE=${PETSC_DIR}/gmakefile.test;\ 252 ALLTESTSLOG=${PETSC_ARCH}/lib/petsc/conf/alltests.log ;\ 253 ln -s $${ALLTESTSLOG} alltests.log ;\ 254 fi;\ 255 ${OMAKE} allgtest ALLTESTS_MAKEFILE=$${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} MPIEXEC="${MPIEXEC}" DATAFILESPATH=${DATAFILESPATH} VALGRIND=${VALGRIND} 2>&1 | tee $${ALLTESTSLOG};\ 256 if [ x${ALLTESTS_CHECK_FAILURES} = xyes -a ${PETSC_PRECISION} != single ]; then\ 257 cat $${ALLTESTSLOG} | grep -E '(^not ok|not remade because of errors|^# No tests run)' | wc -l | grep '^[ ]*0$$' > /dev/null;\ 258 fi; 259 260allgtests-tap: allgtest-tap 261 +@${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} check-test-errors 262 263allgtest-tap: ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 264 +@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 265 266allgtest: ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 267 +@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).$$)' 268 269test: 270 +${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test 271cleantest: 272 +${OMAKE} -f ${ALLTESTS_MAKEFILE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} cleantest 273 274#********* Rules for cleaning *************************************************************************************************************************** 275 276deletelibs: 277 -${RM} -rf ${PETSC_LIB_DIR}/libpetsc*.* 278deletemods: 279 -${RM} -f ${PETSC_DIR}/${PETSC_ARCH}/include/petsc*.mod 280 281allclean: 282 -@${OMAKE} -f gmakefile clean 283 284clean:: allclean 285 286distclean: 287 @if [ -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ]; then\ 288 echo "*** Preserving ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py in ${PETSC_DIR} ***";\ 289 mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/;\ 290 echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***";\ 291 ${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/ ;\ 292 else\ 293 echo "*** Build files in PETSC_ARCH=${PETSC_ARCH} not found. Skipping delete! ***";\ 294 fi 295 296info: 297 +@${OMAKE} -f gmakefile gmakeinfo 298 299check_usermakefile: 300 -@echo "Testing compile with user makefile" 301 -@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}" 302 @cd src/snes/tutorials; ${RUN_TEST} clean-legacy 303 @cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex19 304 @grep -E "^#define PETSC_USE_FORTRAN_BINDINGS 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null;\ 305 if test -s .ftn.log; then\ 306 cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex5f;\ 307 fi; ${RM} .ftn.log; 308 @cd src/snes/tutorials; ${RUN_TEST} clean-legacy 309 -@echo "Completed compile with user makefile" 310 311#********* Rules for formatting Fortran source ********************************************************************************************** 312 313# pip install fprettify 314fprettify: 315 @git ls-files "*.[hF]90" | xargs fprettify --indent 2 --line-length 1000 --whitespace 2 --whitespace-type F --case 1 0 1 0 --enable-replacements --c-relations 316 317# git clone https://github.com/louoberto/fortify.git && cd fortify && export PATH=$PATH:$(pwd)/source 318fortify: 319 @files=`git ls-files "*.[hF]90"`; for i in $${files}; do fortify --tab_length 2 --lowercasing F $${i}; done 320 321#********* Rules for running clangformat ************************************************************************************************************ 322 323checkgitclean: 324 @if ! git diff --quiet; then\ 325 echo "The repository has uncommitted files, cannot run checkclangformat" ;\ 326 git status -s --untracked-files=no ;\ 327 false;\ 328 fi; 329 330# Check that all the C/C++ source code in the repository satisfies the .clang_format 331checkclangformat: checkclangformatversion checkgitclean clangformat 332 @if ! git diff --quiet; then\ 333 printf "The current commit has C/C++ source code formatting problems\n" ;\ 334 if [ -z "${CI_PIPELINE_ID}" ]; then\ 335 printf "Please run 'git diff' to check\n";\ 336 git diff --stat;\ 337 else\ 338 git diff --patch-with-stat > ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch;\ 339 git diff --patch-with-stat --color=always | head -1000;\ 340 if [ `wc -l < ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch` -gt 1000 ]; then\ 341 printf "The diff has been trimmed, check ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch (in CI artifacts) for all changes\n";\ 342 fi;\ 343 fi;\ 344 false;\ 345 fi; 346 347# Check that all the Fortran source code in the repository satisfies the fprettify format 348checkfprettifyformat: checkgitclean fprettify 349 @if ! git diff --quiet; then\ 350 printf "The current commit has Fortran source code formatting problems\n" ;\ 351 if [ -z "${CI_PIPELINE_ID}" ]; then\ 352 printf "Please run 'git diff' to check\n";\ 353 git diff --stat;\ 354 else\ 355 git diff --patch-with-stat > ${PETSC_ARCH}/lib/petsc/conf/checkfprettifyformat.patch;\ 356 git diff --patch-with-stat --color=always | head -1000;\ 357 if [ `wc -l < ${PETSC_ARCH}/lib/petsc/conf/checkfprettifyformat.patch` -gt 1000 ]; then\ 358 printf "The diff has been trimmed, check ${PETSC_ARCH}/lib/petsc/conf/checkfprettifyformat.patch (in CI artifacts) for all changes\n";\ 359 fi;\ 360 fi;\ 361 false;\ 362 fi; 363 364# Check and fix the style/formatting of sh scripts 365shellcheck: 366 @shellcheck --format=diff $$(git ls-files\*.sh) $$(file lib/petsc/bin/* lib/petsc/bin/maint/* | grep "/usr/bin/env sh" | cut -d: -f1) | patch -p1 367 368# Cannot use the following line since it encouters many problems we will likely not fix 369# shellcheck --format=tty $$(git ls-files\*.sh) $$(file lib/petsc/bin/* lib/petsc/bin/maint/* | grep "/usr/bin/env sh" | cut -d: -f1) 370checkshellcheck: shellcheck 371 @if ! git diff --quiet; then\ 372 printf "The current commit has shellcheck problems\n" ;\ 373 if [ -z "${CI_PIPELINE_ID}" ]; then\ 374 printf "Please run 'git diff' to check\n";\ 375 git diff --stat;\ 376 else\ 377 git diff --patch-with-stat > ${PETSC_ARCH}/lib/petsc/conf/checkshellcheck.patch;\ 378 git diff --patch-with-stat --color=always | head -1000;\ 379 if [ `wc -l < ${PETSC_ARCH}/lib/petsc/conf/checkshellcheck.patch` -gt 1000 ]; then\ 380 printf "The diff has been trimmed, check ${PETSC_ARCH}/lib/petsc/conf/checkshellcheck.patch (in CI artifacts) for all changes\n";\ 381 fi;\ 382 fi;\ 383 false;\ 384 fi; 385 386# Compare ABI/API of two versions of PETSc library with the old one defined by PETSC_{DIR,ARCH}_ABI_OLD 387abitest: 388 @if [ "${PETSC_DIR_ABI_OLD}" = "" ] || [ "${PETSC_ARCH_ABI_OLD}" = "" ];\ 389 then printf "You must set environment variables PETSC_DIR_ABI_OLD and PETSC_ARCH_ABI_OLD to run abitest\n";\ 390 exit 1;\ 391 fi; 392 -@echo "Comparing ABI/API of the following two PETSc versions (you must have already configured and built them using GCC and with -g):" 393 -@echo "=========================================================================================" 394 -@echo " Old: PETSC_DIR_ABI_OLD = ${PETSC_DIR_ABI_OLD}" 395 -@echo " PETSC_ARCH_ABI_OLD = ${PETSC_ARCH_ABI_OLD}" 396 -@pushd ${PETSC_DIR_ABI_OLD} >> /dev/null ; echo " Branch = "`git rev-parse --abbrev-ref HEAD` 397 -@echo " New: PETSC_DIR = ${PETSC_DIR}" 398 -@echo " PETSC_ARCH = ${PETSC_ARCH}" 399 -@echo " Branch = "`git rev-parse --abbrev-ref HEAD` 400 -@echo "=========================================================================================" 401 -@$(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 402 403# Run fortitude Fortran linter; pip install fortitude-lint; fortitude does not support using the preprocessor so it is of only limited utility 404fortitude: 405 -@fortitude check --line-length 1000 --ignore C003,C121,S241 --verbose --fix --preview 406 407# Compare ABI/API of current PETSC_ARCH/PETSC_DIR with a previous branch 408abitestcomplete: 409 -@if [[ -f "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/configure.log" ]]; then\ 410 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"` ;\ 411echo $${OPTIONS} ;\ 412 fi ;\ 413 if [[ "${PETSC_DIR_ABI_OLD}" != "" ]]; then\ 414 PETSC_DIR_OLD=${PETSC_DIR_ABI_OLD};\ 415 else\ 416 PETSC_DIR_OLD=${PETSC_DIR}/../petsc-abi;\ 417 fi ;\ 418 echo "=================================================================================================" ;\ 419 echo "Doing ABI/API comparison between" ${branch} " and " `git rev-parse --abbrev-ref HEAD` "using " $${OPTIONS} ;\ 420 echo "=================================================================================================" ;\ 421 if [[ ! -d $${PETSC_DIR_OLD} ]]; then\ 422 git clone ${PETSC_DIR} $${PETSC_DIR_OLD} ;\ 423 else\ 424 cd $${PETSC_DIR_OLD} ;\ 425 git pull ;\ 426 fi ;\ 427 cd $${PETSC_DIR_OLD} ;\ 428 git checkout ${branch} ;\ 429 PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` ./configure $${OPTIONS} ;\ 430 PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` make all test ;\ 431 cd ${PETSC_DIR} ;\ 432 ./configure $${OPTIONS};\ 433 make all test ;\ 434 PETSC_DIR_ABI_OLD=$${PETSC_DIR_OLD} PETSC_ARCH_ABI_OLD=arch-branch-`git rev-parse ${branch}` make abitest 435 436# ******** Rules for running Streams benchmark **************************************************************************************************** 437 438mpistreams: 439 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistreams 440 441mpistream: 442 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistream 443 444openmpstreams: 445 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstreams 446 447openmpstream: 448 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstream 449 450stream: mpistream 451 452streams: mpistreams 453 454# ******** Rules for generating tag files for Emacs/VIM ******************************************************************************************* 455 456alletags: etags 457 458etags: 459 -@${PYTHON} lib/petsc/bin/maint/generateetags.py && ${CP} TAGS ${PETSC_ARCH}/ 460 -@find config -type f -name "*.py" |grep -v SCCS | xargs etags -o TAGS_PYTHON 461 462# obtain gtags from https://www.gnu.org/software/global/ 463allgtags: 464 -@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 - 465 466# ********* Rules for building "classic" documentation; uses rules also in lib/petsc/conf/rules_doc.mk ************************************************** 467 468docs: 469 cd doc; ${OMAKE_SELF} docs 470 471chk_in_petscdir: 472 @if [ ! -f include/petscversion.h ]; then\ 473 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n" ;\ 474 echo " This target should be invoked in top level PETSc source dir!";\ 475 printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n"; false; fi 476 477chk_loc: 478 @if [ ${LOC}foo = foo ] ; then\ 479 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n";\ 480 echo " Please specify LOC variable for eg: make allmanpages LOC=/sandbox/petsc ";\ 481 printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n"; false; fi 482 @${MKDIR} ${LOC}/manualpages 483 484alldocclean: deletemanualpages allcleanhtml 485 486# Deletes man pages (.md version) 487deletemanualpages: chk_loc 488 -@if [ -d ${LOC} -a -d ${LOC}/manualpages ]; then\ 489 find ${LOC}/manualpages -type f -name "*.md" -exec ${RM} {}\; ;\ 490 ${RM} ${LOC}/manualpages/manualpages.cit ;\ 491 fi 492 493allcleanhtml: 494 -${OMAKE_SELF} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} tree 495 496# ********* Rules for checking code coverage ********************************************************************************************* 497 498gcov: 499 output_file_base_name=${PETSC_ARCH}-gcovr-report.json;\ 500 petsc_arch_dir=${PETSC_DIR}/${PETSC_ARCH};\ 501 tar_file=$${petsc_arch_dir}/$${output_file_base_name}.tar.bz2;\ 502 cd $${petsc_arch_dir} &&\ 503 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} &&\ 504 ${RM} -f $${tar_file} &&\ 505 tar --bzip2 -cf $${tar_file} -C $${petsc_arch_dir} ./$${output_file_base_name} &&\ 506 ${RM} $${petsc_arch_dir}/$${output_file_base_name} 507 508mergegcov: 509 $(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py --merge-branch `lib/petsc/bin/maint/check-merge-branch.sh` --html --xml ${PETSC_GCOV_OPTIONS} 510 511countcfunctions: 512 -@grep PETSC_EXTERN ${PETSC_DIR}/include/*.h | grep "(" | tr -s ' ' | cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' | tr 'A-Z' 'a-z' | sort | uniq > /tmp/countcfunctions 513 514checkpackagetests: 515 -@echo "Missing package tests" 516 -@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 517 -@echo "Missing download package tests" 518 -@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 519 520check_petsc4py_rst: 521 @${RM} -f petsc4py_rst.log 522 @echo "Checking src/binding/petsc4py/DESCRIPTION.rst" 523 @rst2html src/binding/petsc4py/DESCRIPTION.rst > /dev/null 2> petsc4py_rst.log 524 @if test -s petsc4py_rst.log; then cat petsc4py_rst.log; exit 1; fi 525 526# TODO: checkTestCoverage: that makes sure every tutorial test has at least one test listed in the file, perhaps handled by gmakegentest.py 527# TODO: check for PetscBeginFunctionUser in non-example source 528# TODO: check for __ at start of #define or symbol 529# TODO: checking for missing manual pages 530# TODO: check for incorrect %d 531# TODO: check for double blank lines 532# TODO: check for ill-formed manual pages 533# TODO: check for { on line after for 534# TODO: check for } then else on following line 535# TODO: check for } else { with SETERRQ on following line or if () { with SETERRQ on following line 536 537checkbadSpelling: 538 -@x=`python3 ../bin/extract.py | aspell list | sort -u` ; 539 540updatedatafiles: 541 -@if [ -d "${DATAFILESPATH}" ]; then\ 542 echo " ** Updating datafiles at ${DATAFILESPATH} **";\ 543 cd "${DATAFILESPATH}" && git pull -q; fi 544 545.PHONY: info info_h all deletelibs allclean update\ 546 alletags etags etags_complete etags_noexamples etags_makefiles etags_examples etags_fexamples alldoc allmanpages\ 547 allcleanhtml\ 548 start_configure configure_petsc configure_clean matlabbin install 549