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 24#include ${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/test.common 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_petscdir 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 printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/petsc/conf/make.log;\ 54 fi \ 55 else \ 56 ${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 ;\ 57 fi #solaris make likes to print the whole command that gave error. So split this up into the smallest chunk below 58 @echo "Finishing make run at `date +'%a, %d %b %Y %H:%M:%S %z'`" >> ${PETSC_ARCH}/lib/petsc/conf/make.log 59 @if [ "`cat ${PETSC_ARCH}/lib/petsc/conf/error.log 2> /dev/null`" != "0" ]; then exit 1; fi 60 61all-local: info libs matlabbin petsc4py-build libmesh-build mfem-build slepc-build hpddm-build amrex-build bamg-build 62 63${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files: 64 @touch -t 197102020000 ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files 65 66${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles: 67 @${MKDIR} -p ${PETSC_DIR}/${PETSC_ARCH}/tests && touch -t 197102020000 ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 68 69libs: ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles 70 +@r=`echo "${MAKEFLAGS}" | grep ' -j'`; \ 71 if [ "$$?" = 0 ]; then make_j=""; else make_j="-j${MAKE_NP}"; fi; \ 72 r=`echo "${MAKEFLAGS}" | grep ' -l'`; \ 73 if [ "$$?" = 0 ]; then make_l=""; else make_l="-l${MAKE_LOAD}"; fi; \ 74 cmd="${OMAKE_PRINTDIR} -f gmakefile $${make_j} $${make_l} ${MAKE_PAR_OUT_FLG} V=${V} libs"; \ 75 cd ${PETSC_DIR} && echo $${cmd} && exec $${cmd} 76 77chk_upgrade: 78 -@PETSC_DIR=${PETSC_DIR} ${PYTHON} ${PETSC_DIR}/lib/petsc/bin/petscnagupgrade.py 79 80chklib_dir: 81 @if [ ! -d "${INSTALL_LIB_DIR}" ]; then \ 82 echo Making directory ${INSTALL_LIB_DIR} for library; ${MKDIR} ${INSTALL_LIB_DIR} ; fi 83 84matlabbin: 85 -@if [ "${MATLAB_MEX}" != "" -a "${MATLAB_SOCKET}" != "" -a "${PETSC_SCALAR}" = "real" -a "${PETSC_PRECISION}" = "double" ]; then \ 86 echo "BEGINNING TO COMPILE MATLAB INTERFACE"; \ 87 if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc" ] ; then ${MKDIR} ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc; fi; \ 88 if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab" ] ; then ${MKDIR} ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab; fi; \ 89 cd src/sys/classes/viewer/impls/socket/mex-scripts && ${OMAKE_SELF} mex-scripts PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR}; \ 90 echo "========================================="; \ 91 fi 92 93allfortranstubs: 94 -@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir 95 @${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py ${BFORT} ${VERBOSE} 96 -@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py -merge ${VERBOSE} 97 -@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir 98 99deleteshared: 100 @for LIBNAME in ${SHLIBS}; \ 101 do \ 102 if [ -d ${INSTALL_LIB_DIR}/$${LIBNAME}.dylib.dSYM ]; then \ 103 echo ${RM} -rf ${INSTALL_LIB_DIR}/$${LIBNAME}.dylib.dSYM; \ 104 ${RM} -rf ${INSTALL_LIB_DIR}/$${LIBNAME}.dylib.dSYM; \ 105 fi; \ 106 echo ${RM} ${INSTALL_LIB_DIR}/$${LIBNAME}.${SL_LINKER_SUFFIX}; \ 107 ${RM} ${INSTALL_LIB_DIR}/$${LIBNAME}.${SL_LINKER_SUFFIX}; \ 108 done 109 @if [ -f ${INSTALL_LIB_DIR}/so_locations ]; then \ 110 echo ${RM} ${INSTALL_LIB_DIR}/so_locations; \ 111 ${RM} ${INSTALL_LIB_DIR}/so_locations; \ 112 fi 113 114deletefortranstubs: 115 -@find . -type d -name ftn-auto | xargs rm -rf 116 117reconfigure: allclean 118 @unset MAKEFLAGS && ${PYTHON} ${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py 119 120chkopts: 121 -@echo "Warning: chkopts target is deprecated and can be removed from user makefiles" 122 123gnumake: 124 +@echo "make gnumake is deprecated, use make libs" 125 +@make libs 126 127# ******** Rules for make check **************************************************************************************************************************** 128 129RUN_TEST = ${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff 130 131check_install: check 132check: 133 -@echo "Running check examples to verify correct installation" 134 -@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}" 135 @if [ "${PETSC_WITH_BATCH}" != "" ]; then \ 136 echo "Running with batch filesystem, cannot run make check"; \ 137 elif [ "${MPIEXEC}" = "/bin/false" ]; then \ 138 echo "*mpiexec not found*. cannot run make check"; \ 139 else \ 140 ${RM} -f check_error;\ 141 ${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; \ 142 if [ -f check_error ]; then \ 143 echo "Error while running make check"; \ 144 ${RM} -f check_error;\ 145 exit 1; \ 146 fi; \ 147 ${RM} -f check_error;\ 148 fi; 149 150check_build: 151 +@cd src/snes/tutorials >/dev/null; ${RUN_TEST} clean-legacy 152 +@cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19 153 +@if [ ! "${MPI_IS_MPIUNI}" ]; then cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19_mpi; fi 154 +@if [ "${HYPRE_LIB}" != "" ] && [ "${PETSC_SCALAR}" = "real" ]; then \ 155 if [ "${CUDA_LIB}" != "" ]; then HYPRE_TEST=runex19_hypre_cuda; \ 156 elif [ "${HIP_LIB}" != "" ]; then HYPRE_TEST=runex19_hypre_hip; \ 157 else HYPRE_TEST=runex19_hypre; fi; \ 158 cd src/snes/tutorials >/dev/null; ${RUN_TEST} $${HYPRE_TEST}; \ 159 fi; 160 +@if [ "${CUDA_LIB}" != "" ]; then \ 161 cd src/snes/tutorials >/dev/null; ${RUN_TEST} runex19_cuda; \ 162 fi; 163 +@if [ "${MPI_IS_MPIUNI}" = "" ]; then \ 164 cd src/snes/tutorials >/dev/null; \ 165 if [ "${KOKKOS_KERNELS_LIB}" != "" ] && [ "${PETSC_SCALAR}" = "real" ] && [ "${PETSC_PRECISION}" = "double" ]; then \ 166 ${RUN_TEST} runex3k_kokkos; \ 167 fi;\ 168 if [ "${MUMPS_LIB}" != "" ]; then \ 169 ${RUN_TEST} runex19_fieldsplit_mumps; \ 170 fi;\ 171 if [ "${SUITESPARSE_LIB}" != "" ]; then \ 172 ${RUN_TEST} runex19_suitesparse; \ 173 fi;\ 174 if [ "${SUPERLU_DIST_LIB}" != "" ]; then \ 175 ${RUN_TEST} runex19_superlu_dist; \ 176 fi;\ 177 if ( [ "${ML_LIB}" != "" ] || [ "${TRILINOS_LIB}" != "" ] ); then \ 178 ${RUN_TEST} runex19_ml; \ 179 fi; \ 180 ${RUN_TEST} clean-legacy; \ 181 cd - > /dev/null; \ 182 if ( [ "${AMREX_LIB}" != "" ] && [ "${CUDA_LIB}" = "" ] ); then \ 183 echo "Running amrex test example to verify correct installation";\ 184 echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}";\ 185 cd src/ksp/ksp/tutorials/amrex >/dev/null;\ 186 ${RUN_TEST} clean-legacy; \ 187 ${RUN_TEST} testamrex; \ 188 ${RUN_TEST} clean-legacy; \ 189 cd - > /dev/null; \ 190 fi;\ 191 fi; 192 +@if [ "${HDF5_LIB}" != "" ]; then \ 193 cd src/vec/vec/tests >/dev/null;\ 194 ${RUN_TEST} clean-legacy; \ 195 ${RUN_TEST} runex47; \ 196 ${RUN_TEST} clean-legacy; \ 197 fi; 198 +@if [ "${MPI4PY}" = "yes" ]; then \ 199 cd src/sys/tests >/dev/null; \ 200 ${RUN_TEST} clean-legacy; \ 201 ${RUN_TEST} testex55; \ 202 ${RUN_TEST} clean-legacy; \ 203 fi; 204 +@if [ "${PETSC4PY}" = "yes" ]; then \ 205 cd src/ksp/ksp/tutorials >/dev/null; \ 206 ${RUN_TEST} clean-legacy; \ 207 ${RUN_TEST} testex100; \ 208 ${RUN_TEST} clean-legacy; \ 209 fi; 210 +@grep -E "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \ 211 if test -s .ftn.log; then \ 212 cd src/snes/tutorials >/dev/null; \ 213 ${RUN_TEST} clean-legacy; \ 214 ${RUN_TEST} testex5f; \ 215 ${RUN_TEST} clean-legacy; \ 216 fi; ${RM} .ftn.log; 217 +@grep -E "^#define PETSC_HAVE_MATLAB 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \ 218 if test -s .ftn.log; then \ 219 cd src/vec/vec/tutorials >/dev/null; \ 220 ${RUN_TEST} clean-legacy; \ 221 ${RUN_TEST} testex31; \ 222 ${RUN_TEST} clean-legacy; \ 223 fi; ${RM} .ftn.log; 224 -@echo "Completed test examples" 225 226# ********* Rules for make install ******************************************************************************************************************* 227 228install: 229 @${PYTHON} ./config/install.py -destDir=${DESTDIR} 230 +${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc 231 232# A smaller install with fewer extras 233install-lib: 234 @${PYTHON} ./config/install.py -destDir=${DESTDIR} -no-examples 235 +${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} PETSC_INSTALL=$@ install-builtafterpetsc 236 237install-builtafterpetsc: 238 +${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 239 240# Creates ${HOME}/petsc.tar.gz [and petsc-with-docs.tar.gz] 241dist: 242 ${PETSC_DIR}/lib/petsc/bin/maint/builddist ${PETSC_DIR} main 243 244#********* Rules for cleaning *************************************************************************************************************************** 245 246deletelibs: 247 -${RM} -rf ${PETSC_LIB_DIR}/libpetsc*.* 248deletemods: 249 -${RM} -f ${PETSC_DIR}/${PETSC_ARCH}/include/petsc*.mod 250 251allclean: 252 -@${OMAKE} -f gmakefile clean 253 254clean:: allclean 255 256distclean: chk_petscdir 257 @if [ -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ]; then \ 258 echo "*** Preserving ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py in ${PETSC_DIR} ***"; \ 259 mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/; fi 260 @echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***" 261 -${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/ 262 263#********* Rules for printing library properties useful for building applications *********************************************************** 264 265getmpilinklibs: 266 -@echo ${MPI_LIB} 267 268getmpiincludedirs: 269 -@echo ${MPI_INCLUDE} 270 271getmpiexec: 272 -@echo ${MPIEXEC} 273 274getccompiler: 275 -@echo ${CC} 276 277getfortrancompiler: 278 -@echo ${FC} 279 280getcxxcompiler: 281 -@echo ${CXX} 282 283getlinklibs: 284 -@echo ${C_SH_LIB_PATH} ${PETSC_TS_LIB} 285 286getincludedirs: 287 -@echo ${PETSC_CC_INCLUDES} 288 289getcflags: 290 -@echo ${CC_FLAGS} 291 292getcxxflags: 293 -@echo ${CXX_FLAGS} 294 295getfortranflags: 296 -@echo ${FC_FLAGS} 297 298getblaslapacklibs: 299 -@echo ${BLASLAPACK_LIB} 300 301getautoconfargs: 302 -@echo CC='"${CC}"' CXX='"${CXX}"' FC='"${FC}"' CFLAGS='"${CC_FLAGS}"' CXXFLAGS='"${CXX_FLAGS}"' FCFLAGS='"${FC_FLAGS}"' LIBS='"${C_SH_LIB_PATH} ${PETSC_TS_LIB}"' 303 304info: 305 -@echo "==========================================" 306 -@echo " " 307 -@echo "See documentation/faq.html and documentation/bugreporting.html" 308 -@echo "for help with installation problems. Please send EVERYTHING" 309 -@echo "printed out below when reporting problems. Please check the" 310 -@echo "mailing list archives and consider subscribing." 311 -@echo " " 312 -@echo " https://petsc.org/release/community/mailing/" 313 -@echo " " 314 -@echo "==========================================" 315 -@echo Starting make run on `hostname` at `date +'%a, %d %b %Y %H:%M:%S %z'` 316 -@echo Machine characteristics: `uname -a` 317 -@echo "-----------------------------------------" 318 -@echo "Using PETSc directory: ${PETSC_DIR}" 319 -@echo "Using PETSc arch: ${PETSC_ARCH}" 320 -@echo "-----------------------------------------" 321 -@grep "define PETSC_VERSION" ${PETSC_DIR}/include/petscversion.h | ${SED} "s/........//" | head -n 7 322 -@echo "-----------------------------------------" 323 -@echo "Using configure Options: ${CONFIGURE_OPTIONS}" 324 -@echo "Using configuration flags:" 325 -@grep "\#define " ${PETSCCONF_H} | tail -n +2 326 -@echo "-----------------------------------------" 327 -@echo "Using C compile: ${PETSC_CCOMPILE_SINGLE}" 328 -@if [ "${MPICC_SHOW}" != "" ]; then \ 329 printf "mpicc -show: %b\n" "${MPICC_SHOW}";\ 330 fi; \ 331 printf "C compiler version: %b\n" "${C_VERSION}"; \ 332 if [ "${CXX}" != "" ]; then \ 333 echo "Using C++ compile: ${PETSC_CXXCOMPILE_SINGLE}";\ 334 if [ "${MPICXX_SHOW}" != "" ]; then \ 335 printf "mpicxx -show: %b\n" "${MPICXX_SHOW}"; \ 336 fi;\ 337 printf "C++ compiler version: %b\n" "${Cxx_VERSION}"; \ 338 fi 339 -@if [ "${FC}" != "" ]; then \ 340 echo "Using Fortran compile: ${PETSC_FCOMPILE_SINGLE}";\ 341 if [ "${MPIFC_SHOW}" != "" ]; then \ 342 printf "mpif90 -show: %b\n" "${MPIFC_SHOW}"; \ 343 fi; \ 344 printf "Fortran compiler version: %b\n" "${FC_VERSION}"; \ 345 fi 346 -@if [ "${CUDAC}" != "" ]; then \ 347 echo "Using CUDA compile: ${PETSC_CUCOMPILE_SINGLE}";\ 348 fi 349 -@if [ "${CLANGUAGE}" = "CXX" ]; then \ 350 echo "Using C++ compiler to compile PETSc";\ 351 fi 352 -@echo "-----------------------------------------" 353 -@echo "Using C/C++ linker: ${PCC_LINKER}" 354 -@echo "Using C/C++ flags: ${PCC_LINKER_FLAGS}" 355 -@if [ "${FC}" != "" ]; then \ 356 echo "Using Fortran linker: ${FC_LINKER}";\ 357 echo "Using Fortran flags: ${FC_LINKER_FLAGS}";\ 358 fi 359 -@echo "-----------------------------------------" 360 -@echo "Using system modules: ${LOADEDMODULES}" 361 -@if [ "${MPI_IS_MPIUNI}" = "1" ]; then \ 362 echo Using mpi.h: mpiuni; \ 363 else \ 364 TESTDIR=`mktemp -q -d -t petscmpi-XXXXXXXX` && \ 365 echo '#include <mpi.h>' > $${TESTDIR}/mpitest.c && \ 366 BUF=`${CPP} ${PETSC_CPPFLAGS} ${PETSC_CC_INCLUDES} $${TESTDIR}/mpitest.c |grep 'mpi\.h' | ( head -1 ; cat > /dev/null )` && \ 367 echo Using mpi.h: $${BUF}; ${RM} -rf $${TESTDIR}; \ 368 fi 369 -@echo "-----------------------------------------" 370 -@echo "Using libraries: ${PETSC_LIB}" 371 -@echo "------------------------------------------" 372 -@echo "Using mpiexec: ${MPIEXEC}" 373 -@echo "------------------------------------------" 374 -@echo "Using MAKE: ${MAKE}" 375 -@echo "Default MAKEFLAGS: MAKE_NP:${MAKE_NP} MAKE_LOAD:${MAKE_LOAD} MAKEFLAGS:${MAKEFLAGS}" 376 -@echo "==========================================" 377 378 379check_usermakefile: 380 -@echo "Testing compile with user makefile" 381 -@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}" 382 @cd src/snes/tutorials; ${RUN_TEST} clean-legacy 383 @cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex19 384 @grep -E "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \ 385 if test -s .ftn.log; then \ 386 cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex5f; \ 387 fi; ${RM} .ftn.log; 388 @cd src/snes/tutorials; ${RUN_TEST} clean-legacy 389 -@echo "Completed compile with user makefile" 390 391#********* Rules for running clangformat ************************************************************************************************************ 392 393checkgitclean: 394 @if ! git diff --quiet; then \ 395 echo "The repository has uncommitted files, cannot run checkclangformat" ;\ 396 git status -s --untracked-files=no ;\ 397 false;\ 398 fi; 399 400checkclangformatversion: 401 @version=`clang-format --version | cut -d" " -f3 | cut -d"." -f 1` ;\ 402 if [ "$$version" == "version" ]; then version=`clang-format --version | cut -d" " -f4 | cut -d"." -f 1`; fi;\ 403 if [ $$version != 16 ]; then echo "Require clang-format version 16! Currently used clang-format version is $$version" ;false ; fi 404 405# Check that all the source code in the repository satisfies the .clang_format 406checkclangformat: checkclangformatversion checkgitclean clangformat 407 @if ! git diff --quiet; then \ 408 printf "The current commit has source code formatting problems\n" ;\ 409 if [ -z "${CI_PIPELINE_ID}" ]; then \ 410 printf "Please run 'git diff' to check\n"; \ 411 git diff --stat; \ 412 else \ 413 git diff --patch-with-stat > ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch; \ 414 git diff --patch-with-stat --color=always | head -1000; \ 415 if [ `wc -l < ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch` -gt 1000 ]; then \ 416 printf "The diff has been trimmed, check ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch (in CI artifacts) for all changes\n"; \ 417 fi;\ 418 fi;\ 419 false;\ 420 fi; 421 422# Compare ABI/API of two versions of PETSc library with the old one defined by PETSC_{DIR,ARCH}_ABI_OLD 423abitest: 424 @if [ "${PETSC_DIR_ABI_OLD}" = "" ] || [ "${PETSC_ARCH_ABI_OLD}" = "" ]; \ 425 then printf "You must set environment variables PETSC_DIR_ABI_OLD and PETSC_ARCH_ABI_OLD to run abitest\n"; \ 426 exit 1; \ 427 fi; 428 -@echo "Comparing ABI/API of the following two PETSc versions (you must have already configured and built them using GCC and with -g):" 429 -@echo "=========================================================================================" 430 -@echo " Old: PETSC_DIR_ABI_OLD = ${PETSC_DIR_ABI_OLD}" 431 -@echo " PETSC_ARCH_ABI_OLD = ${PETSC_ARCH_ABI_OLD}" 432 -@pushd ${PETSC_DIR_ABI_OLD} >> /dev/null ; echo " Branch = "`git rev-parse --abbrev-ref HEAD` 433 -@echo " New: PETSC_DIR = ${PETSC_DIR}" 434 -@echo " PETSC_ARCH = ${PETSC_ARCH}" 435 -@echo " Branch = "`git rev-parse --abbrev-ref HEAD` 436 -@echo "=========================================================================================" 437 -@$(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 438 439# Compare ABI/API of current PETSC_ARCH/PETSC_DIR with a previous branch 440abitestcomplete: 441 -@if [[ -f "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/configure.log" ]]; then \ 442 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"` ;\ 443echo $${OPTIONS} ;\ 444 fi ; \ 445 if [[ "${PETSC_DIR_ABI_OLD}" != "" ]]; then \ 446 PETSC_DIR_OLD=${PETSC_DIR_ABI_OLD}; \ 447 else \ 448 PETSC_DIR_OLD=${PETSC_DIR}/../petsc-abi; \ 449 fi ; \ 450 echo "=================================================================================================" ;\ 451 echo "Doing ABI/API comparison between" ${branch} " and " `git rev-parse --abbrev-ref HEAD` "using " $${OPTIONS} ;\ 452 echo "=================================================================================================" ;\ 453 if [[ ! -d $${PETSC_DIR_OLD} ]]; then \ 454 git clone ${PETSC_DIR} $${PETSC_DIR_OLD} ; \ 455 else \ 456 cd $${PETSC_DIR_OLD} ; \ 457 git pull ; \ 458 fi ; \ 459 cd $${PETSC_DIR_OLD} ; \ 460 git checkout ${branch} ; \ 461 PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` ./configure $${OPTIONS} ; \ 462 PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` make all test ; \ 463 cd ${PETSC_DIR} ; \ 464 ./configure $${OPTIONS}; \ 465 make all test ; \ 466 PETSC_DIR_ABI_OLD=$${PETSC_DIR_OLD} PETSC_ARCH_ABI_OLD=arch-branch-`git rev-parse ${branch}` make abitest 467 468# ******** Rules for running Streams benchmark **************************************************************************************************** 469 470mpistreams: 471 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistreams 472 473mpistream: 474 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistream 475 476openmpstreams: 477 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstreams 478 479openmpstream: 480 +@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstream 481 482stream: mpistream 483 484streams: mpistreams 485 486# ******** Rules for generating tag files for Emacs/VIM ******************************************************************************************* 487 488alletags: 489 -@${PYTHON} lib/petsc/bin/maint/generateetags.py 490 -@find config -type f -name "*.py" |grep -v SCCS | xargs etags -o TAGS_PYTHON 491 492# obtain gtags from https://www.gnu.org/software/global/ 493allgtags: 494 -@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 - 495 496# ********* Rules for building "classic" documentation; uses rules also in lib/petsc/conf/petscrules.doc ************************************************** 497 498docs: 499 cd doc; ${OMAKE_SELF} sphinxhtml 500 501chk_petscdir: 502 @mypwd=`pwd`; cd ${PETSC_DIR} 2>&1 > /dev/null; true_PETSC_DIR=`pwd`; cd $${mypwd} 2>&1 >/dev/null; \ 503 newpwd=`echo $${mypwd} | sed "s+$${true_PETSC_DIR}+DUMMY+g"`;\ 504 haspetsc=`echo $${mypwd} | sed "s+petsc-+DUMMY+g"`;\ 505 if [ $${mypwd} = $${newpwd} -a $${haspetsc} != $${mypwd} ]; then \ 506 printf ${PETSC_TEXT_HILIGHT}"*********************W-a-r-n-i-n-g*************************\n" ; \ 507 echo "Your PETSC_DIR may not match the directory you are in";\ 508 echo "PETSC_DIR " $${true_PETSC_DIR} "Current directory" $${mypwd};\ 509 echo "Ignore this if you are running make check ";\ 510 printf "******************************************************"${PETSC_TEXT_NORMAL}"\n" ; \ 511 fi 512 513chk_in_petscdir: 514 @if [ ! -f include/petscversion.h ]; then \ 515 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n" ; \ 516 echo " This target should be invoked in top level PETSc source dir!"; \ 517 printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n" ; false; fi 518 519chk_loc: 520 @if [ ${LOC}foo = foo ] ; then \ 521 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR **********************************************\n" ; \ 522 echo " Please specify LOC variable for eg: make allmanpages LOC=/sandbox/petsc "; \ 523 printf "****************************************************************************"${PETSC_TEXT_NORMAL}"\n" ; false; fi 524 @${MKDIR} ${LOC}/manualpages 525 526chk_c2html: 527 @if [ ${C2HTML}foo = foo ] ; then \ 528 printf ${PETSC_TEXT_HILIGHT}"*********************** ERROR ************************\n" ; \ 529 echo "Require c2html for html docs. Please reconfigure with --download-c2html=1"; \ 530 printf "******************************************************"${PETSC_TEXT_NORMAL}"\n" ;false; fi 531 532 533# the ACTION=manualpages cannot run in parallel because they all write to the same manualpages.cit file 534hloc=include/petsc/private 535allmanpages: chk_loc deletemanualpages 536 -echo " /* SUBMANSEC = PetscH */ " > ${hloc}/generated_khash.h 537 -sed -e 's?<T>?I?g' -e 's?<t>?i?g' -e 's?<KeyType>?PetscInt?g' ${hloc}/hashset.txt >> ${hloc}/generated_khash.h 538 -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 539 -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 540 -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 541 -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 542 -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 543 -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 544 -${RM} ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err 545 -${OMAKE_SELF} ACTION=manualpages tree_src LOC=${LOC} 546 -@sed -e s%man+../%man+manualpages/% ${LOC}/manualpages/manualpages.cit > ${LOC}/manualpages/htmlmap 547 -@cat ${PETSC_DIR}/doc/classic/mpi.www.index >> ${LOC}/manualpages/htmlmap 548 cat ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err 549 a=`cat ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err | wc -l`; test ! $$a -gt 0 550 551allmanexamples: chk_loc allmanpages 552 -${OMAKE_SELF} ACTION=manexamples tree LOC=${LOC} 553 554# 555# Goes through all manual pages adding links to implementations of the method 556# or class, at the end of the file. 557# 558# To find functions implementing methods, we use git grep to look for 559# well-formed PETSc functions 560# - with names containing a single underscore 561# - in files of appropriate types (.cu .c .cxx .h), 562# - in paths including "/impls/", 563# - excluding any line with a semicolon (to avoid matching prototypes), and 564# - excluding any line including "_Private", 565# storing potential matches in implsFuncAll.txt. 566# 567# For each man page we then grep in this file for the item's name followed by 568# a single underscore and process the resulting implsFunc.txt to generate HTML. 569# 570# To find class implementations, we populate implsClassAll.txt with candidates 571# - of the form "struct _p_itemName {", and 572# - not containing a semicolon 573# and then grep for particular values of itemName, generating implsClass.txt, 574# which is processed to generate HTML. 575# 576# Note: PETSC_DOC_OUT_ROOT_PLACEHOLDER must match the term used elsewhere in doc/ 577manimplementations: 578 -@git grep "struct\s\+_[pn]_[^\s]\+.*{" -- *.cpp *.cu *.c *.h *.cxx | grep -v -e ";" -e "/tests/" -e "/tutorials/" > implsClassAll.txt ; \ 579 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 ; \ 580 for i in ${LOC}/manualpages/*/*.md foo; do \ 581 if [ "$$i" != "foo" ] ; then \ 582 itemName=`basename $$i .md`;\ 583 grep "\s$${itemName}_" implsFuncAll.txt > implsFunc.txt ; \ 584 grep "_p_$${itemName}\b" implsClassAll.txt > implsClass.txt ; \ 585 if [ -s implsFunc.txt ] || [ -s implsClass.txt ] ; then \ 586 printf "\n## Implementations\n\n" >> $$i; \ 587 fi ; \ 588 if [ -s implsFunc.txt ] ; then \ 589 sed "s?\(.*\.[ch]x*u*\).*\($${itemName}.*\)(.*)?<A HREF=\"PETSC_DOC_OUT_ROOT_PLACEHOLDER/\1.html#\2\">\2 in \1</A><BR>?" implsFunc.txt >> $$i ; \ 590 fi ; \ 591 if [ -s implsClass.txt ] ; then \ 592 sed "s?\(.*\.[ch]x*u*\):.*\(_p_$${itemName}\)\b.*{?<A HREF=\"PETSC_DOC_OUT_ROOT_PLACEHOLDER/\1.html#\2\">\2 in \1</A><BR>?" implsClass.txt >> $$i ; \ 593 fi ; \ 594 ${RM} implsFunc.txt implsClass.txt; \ 595 fi ; \ 596 done ; \ 597 ${RM} implsClassAll.txt implsFuncAll.txt 598 599# Build all classic docs except html sources 600alldoc_pre: chk_loc allmanpages allmanexamples 601 -${OMAKE_SELF} LOC=${LOC} manimplementations 602 -${PYTHON} lib/petsc/bin/maint/wwwindex.py ${PETSC_DIR} ${LOC} 603 604# Run after alldoc_pre to build html sources 605alldoc_post: chk_loc chk_c2html 606 -@if command -v parallel &> /dev/null; then \ 607 ls include/makefile src/*/makefile | xargs dirname | parallel -j ${MAKE_TEST_NP} --load ${MAKE_LOAD} 'cd {}; ${OMAKE_SELF} LOC=${LOC} PETSC_DIR=${PETSC_DIR} ACTION=html tree' ; \ 608 else \ 609 ${OMAKE_SELF} ACTION=html PETSC_DIR=${PETSC_DIR} tree LOC=${LOC}; \ 610 fi 611 612alldocclean: deletemanualpages allcleanhtml 613 614# Deletes man pages (.md version) 615deletemanualpages: chk_loc 616 -@if [ -d ${LOC} -a -d ${LOC}/manualpages ]; then \ 617 find ${LOC}/manualpages -type f -name "*.md" -exec ${RM} {} \; ;\ 618 ${RM} ${LOC}/manualpages/manualpages.cit ;\ 619 fi 620 621allcleanhtml: 622 -${OMAKE_SELF} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} tree 623 624# ********* Rules for checking code coverage ********************************************************************************************* 625 626gcov: 627 output_file_base_name=${PETSC_ARCH}-gcovr-report.json; \ 628 petsc_arch_dir=${PETSC_DIR}/${PETSC_ARCH}; \ 629 tar_file=$${petsc_arch_dir}/$${output_file_base_name}.tar.bz2; \ 630 cd $${petsc_arch_dir}/obj && \ 631 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} && \ 632 ${RM} -f $${tar_file} && \ 633 tar --bzip2 -cf $${tar_file} -C $${petsc_arch_dir} ./$${output_file_base_name} && \ 634 ${RM} $${petsc_arch_dir}/$${output_file_base_name} 635 636mergegcov: 637 $(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py --merge-branch `lib/petsc/bin/maint/check-merge-branch.sh` --html --xml ${PETSC_GCOV_OPTIONS} 638 639#********* Rules for make clangformat and checking violation of coding standards ************************************************************** 640 641# Format all the source code in the given directory and down according to the file .clang_format 642clangformat: 643 -@git --no-pager ls-files -z ${GITCFSRC} | xargs -0 -P $(MAKE_NP) -L 10 clang-format -i 644 645GITSRC = '*.[chF]' '*.F90' '*.hpp' '*.cpp' '*.cxx' '*.cu' ${GITSRCEXCL} 646GITSRCEXCL = \ 647':!*khash/*' \ 648':!*valgrind/*' \ 649':!*yaml/*' \ 650':!*perfstubs/*' 651GITCFSRC = '*.[ch]' '*.hpp' '*.cpp' '*.cxx' '*.cu' ${GITSRCEXCL} ${GITCFSRCEXCL} 652GITCFSRCEXCL = \ 653':!*petscversion.h' \ 654':!*mpif.h' \ 655':!*mpiunifdef.h' \ 656':!*finclude/*' \ 657':!systems/*' \ 658':!*benchmarks/*' \ 659':!*binding/*' \ 660':!*-custom/*' \ 661':!*f90-mod/*' 662 663checkbadSource: 664 @git --no-pager grep -n -P 'self\.gitcommit' -- config/BuildSystem/config/packages | grep 'origin/' ; if [[ "$$?" == "0" ]]; then echo "Error: Do not use a branch name in a configure package file"; false; fi 665 -@${RM} -f checkbadSource.out 666 -@echo "------Double blank lines in file -----------------------------------" > checkbadSource.out 667 -@git --no-pager grep -n -P '^$$' -- ${GITSRC} > doublelinecheck.out 668 -@${PYTHON} ${PETSC_DIR}/lib/petsc/bin/maint/doublelinecheck.py doublelinecheck.out >> checkbadSource.out 669 -@${RM} -f doublelinecheck.out 670 -@echo "------Tabs in file -------------------------------------------------" >> checkbadSource.out 671 -@git --no-pager grep -n -P '\t' -- ${GITSRC} >> checkbadSource.out;true 672 -@echo "------White space at end of line -----------------------------------" >> checkbadSource.out 673 -@git --no-pager grep -n -P ' $$' -- ${GITSRC} >> checkbadSource.out;true 674 -@echo "------Two ;; -------------------------------------------------------" >> checkbadSource.out 675 -@git --no-pager grep -n -P -e ';;' -- ${GITSRC} | grep -v ' for (' >> checkbadSource.out;true 676 -@echo "------PetscCall for an MPI error code ------------------------------" >> checkbadSource.out 677 -@git --no-pager grep -n -P -e '= MPI[U]*_\w*\(.*PetscCall' -- ${GITSRC} | grep -v MPIU_File >> checkbadSource.out;true 678 -@echo "------Missing if (ierr) return ierr; -------------------------------" >> checkbadSource.out 679 -@git --no-pager grep -n -P -e 'ierr = PetscInitialize\(' -- '*.[ch]' '*.cpp' '*.cxx' '*.cu' | grep -v 'if (ierr) return ierr;' | grep -E "(test|tutorial)" >> checkbadSource.out;true 680 -@echo "------DOS file (with DOS newlines) ---------------------------------" >> checkbadSource.out 681 -@git --no-pager grep -n -P '\r' -- ${GITSRC} >> checkbadSource.out;true 682 -@echo "------{ before SETERRQ ---------------------------------------------" >> checkbadSource.out 683 -@git --no-pager grep -n -P '{SETERRQ' -- ${GITSRC} >> checkbadSource.out;true 684 -@echo "------PetscCall following SETERRQ ----------------------------------" >> checkbadSource.out 685 -@git --no-pager grep -n -P 'SETERRQ' -- ${GITSRC} | grep ";PetscCall" >> checkbadSource.out;true 686 -@echo "------SETERRQ() without defined error code -------------------------" >> checkbadSource.out 687 -@git --no-pager grep -n -P 'SETERRQ\((?!\))' -- ${GITSRC} | grep -v PETSC_ERR | grep " if " | grep -v "__VA_ARGS__" | grep -v flow.c >> checkbadSource.out;true 688 -@echo "------SETERRQ() with trailing newline ------------------------------" >> checkbadSource.out 689 -@git --no-pager grep -n -P "SETERRQ[1-9]?.*\\\n\"" -- ${GITSRC} >> checkbadSource.out;true 690 -@echo "------Define keyword used in test definition -----------------------" >> checkbadSource.out 691 -@git --no-pager grep -n -P -e 'requires:.*define\(' -- ${GITSRC} >> checkbadSource.out;true 692 -@echo "------No new line at end of file -----------------------------------" >> checkbadSource.out 693 -@git --no-pager grep -n -P '[^\n]\z' -- ${GITSRC} >> checkbadSource.out;true 694 -@echo "------Using if (condition) SETERRQ(...) instead of PetscCheck() ----" >> checkbadSource.out 695 -@git --no-pager grep -n -P ' if +(.*) *SETERRQ' -- ${GITSRC} | grep -v 'PetscUnlikelyDebug' | grep -v 'petscerror.h' >> checkbadSource.out;true 696 -@echo "------Using if (PetscUnlikelyDebug(condition)) SETERRQ(...) instead of PetscAssert()" >> checkbadSource.out 697 -@git --no-pager grep -n -P -E ' if +\(PetscUnlikelyDebug.*\) *SETERRQ' -- ${GITSRC} | grep -v petscerror.h >> checkbadSource.out;true 698 -@echo "------Using PetscFunctionReturn(ierr) ------------------------------" >> checkbadSource.out 699 -@git --no-pager grep -n -P 'PetscFunctionReturn(ierr)' -- ${GITSRC} >> checkbadSource.out;true 700 -@echo "------Defining a returning macro without PetscMacroReturns() -------" >> checkbadSource.out 701 -@git --no-pager grep -n -P 'define .*\w+;\s+do' -- ${GITSRC} | grep -E -v '(PetscMacroReturns|PetscDrawCollectiveBegin|MatPreallocateBegin|PetscOptionsBegin|PetscObjectOptionsBegin|PetscOptionsHeadEnd)' >> checkbadSource.out;true 702 -@echo "------Defining an error checking macro using CHKERR style ----------" >> checkbadSource.out 703 -@git --no-pager grep -n -P 'define\s+CHKERR\w*\(.*\)\s*do\s+{' -- ${GITSRC} >> checkbadSource.out;true 704 @a=`cat checkbadSource.out | wc -l`; l=`expr $$a - 18` ;\ 705 if [ $$l -gt 0 ] ; then \ 706 echo $$l " files with errors detected in source code formatting" ;\ 707 cat checkbadSource.out ;\ 708 else \ 709 ${RM} -f checkbadSource.out;\ 710 fi;\ 711 test ! $$l -gt 0 712 -@git --no-pager grep -P -n "[\x00-\x08\x0E-\x1F\x80-\xFF]" -- ${GITSRC} > badSourceChar.out;true 713 -@w=`cat badSourceChar.out | wc -l`;\ 714 if [ $$w -gt 0 ] ; then \ 715 echo "Source files with non-ASCII characters ----------------" ;\ 716 cat badSourceChar.out ;\ 717 else \ 718 ${RM} -f badSourceChar.out;\ 719 fi 720 @test ! -s badSourceChar.out 721 722checkbadFileChange: 723 @git diff --stat --exit-code `lib/petsc/bin/maint/check-merge-branch.sh`..HEAD -- src/sys/yaml/src src/sys/yaml/include src/sys/yaml/License include/petsc/private/valgrind include/petsc/private/kash 724 725vermin: 726 @vermin -vvv -t=3.4- ${VERMIN_OPTIONS} ${PETSC_DIR}/config 727 728lint: 729 ${PYTHON} ${PETSC_DIR}/lib/petsc/bin/maint/petsclinter --verbose=${V} --apply-patches=${REPLACE} $(LINTER_OPTIONS) 730 731help-lint: 732 @${PYTHON} ${PETSC_DIR}/lib/petsc/bin/maint/petsclinter --help 733 -@echo "Basic usage:" 734 -@echo " make lint <options>" 735 -@echo " make test-lint <options> <test only options>" 736 -@echo 737 -@echo "Options:" 738 -@echo " V=[1,0] Enable or disable verbose output" 739 -@echo " LINTER_OPTIONS=\"--opt1 --opt2 ...\" See above for available options" 740 -@echo 741 -@echo "Test Only Options:" 742 -@echo " REPLACE=[1,0] Enable or disable replacing test output" 743 -@echo 744 745test-lint: 746 ${PYTHON} ${PETSC_DIR}/lib/petsc/bin/maint/petsclinter ${PETSC_DIR}/src/sys/tests/linter --test -j0 --werror --replace=${REPLACE} --verbose=${V} $(LINTER_OPTIONS) 747 748countfortranfunctions: 749 -@cd ${PETSC_DIR}/src/fortran; grep -E '^void' custom/*.c auto/*.c | \ 750 cut -d'(' -f1 | tr -s ' ' | cut -d' ' -f2 | uniq | grep -E -v "(^$$|Petsc)" | \ 751 sed "s/_$$//" | sort > /tmp/countfortranfunctions 752 753countcfunctions: 754 -@grep PETSC_EXTERN ${PETSC_DIR}/include/*.h | grep "(" | tr -s ' ' | \ 755 cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' | \ 756 tr 'A-Z' 'a-z' | sort | uniq > /tmp/countcfunctions 757 758difffortranfunctions: countfortranfunctions countcfunctions 759 -@echo -------------- Functions missing in the fortran interface --------------------- 760 -@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2 761 -@echo ----------------- Functions missing in the C interface ------------------------ 762 -@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2 763 -@${RM} /tmp/countcfunctions /tmp/countfortranfunctions 764 765checkbadfortranstubs: 766 -@echo "=========================================" 767 -@echo "Functions with MPI_Comm as an Argument" 768 -@echo "=========================================" 769 -@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \ 770 tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3 771 -@echo "=========================================" 772 -@echo "Functions with a String as an Argument" 773 -@echo "=========================================" 774 -@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \ 775 tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3 776 -@echo "=========================================" 777 -@echo "Functions with Pointers to PETSc Objects as Argument" 778 -@echo "=========================================" 779 -@cd ${PETSC_DIR}/src/fortran/auto; \ 780 _p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \ 781 cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \ 782 sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \ 783 for OBJ in $$_p_OBJ; do \ 784 grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \ 785 cut -d'(' -f1 | cut -d' ' -f1,3; \ 786 done 787 788checkpackagetests: 789 -@echo "Missing package tests" 790 -@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 791 -@echo "Missing download package tests" 792 -@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 793 794check_petsc4py_rst: 795 @${RM} -f petsc4py_rst.log 796 @echo "Checking src/binding/petsc4py/DESCRIPTION.rst" 797 @rst2html src/binding/petsc4py/DESCRIPTION.rst > /dev/null 2> petsc4py_rst.log 798 @if test -s petsc4py_rst.log; then cat petsc4py_rst.log; exit 1; fi 799 800# TODO: checkTestCoverage: that makes sure every tutorial test has at least one test listed in the file, perhaps handled by gmakegentest.py 801# TODO: check for PetscBeginFunctionUser in non-example source 802# TODO: check for __ at start of #define or symbol 803# TODO: checking for missing manual pages 804# TODO: check for incorrect %d 805# TODO: check for double blank lines 806# TODO: check for ill-formed manual pages 807# TODO: check for { on line after for 808# TODO: check for } then else on following line 809# TODO: check for } else { with SETERRQ on following line or if () { with SETERRQ on following line 810 811# Lists all the URLs in the PETSc repository that are unaccessible, nonexistent, or permanently moved (301) 812# REPLACE=1 locations marked as permanently moved (301) are replaced in the repository 813# This code is fragile; always check the changes after a use of REPLACE=1 before committing the changes 814# 815# Notes: 816# The first tr in the line is split lines for the cases where multiple URLs are in the same line 817# The first sed handles the case (http[s]*://xxx) 818# The list is sorted by length so that if REPLACE is used the longer apply before the shorter 819# The code recursively follows the permanently moved (301) redirections until it reaches the final URL 820# For DropBox we need to check the validity of the new URL but do not want to return to user the internal "raw" URL 821checkbadURLS: 822 -@x=`git grep "http[s]*://" -- '*.[chF]' '*.html' '*.cpp' '*.cxx' '*.cu' '*.F90' '*.py' '*.tex' | grep -E -v "(config/packages|HandsOnExercises)" | tr '[[:blank:]]' '\n' | grep 'http[s]*://' | sed 's!.*(\(http[s]*://[-a-zA-Z0-9_./()?=&+%~]*\))!\1!g' | sed 's!.*\(http[s]*://[-a-zA-Z0-9_./()?=&+%~]*\).*!\1!g' | sed 's/\.$$//g' | sort | uniq| awk '{ print length, $$0 }' | sort -r -n -s | cut -d" " -f2` ; \ 823 for i in $$x; do \ 824 url=$$i; \ 825 msg=''; \ 826 while [[ "$${msg}D" == "D" ]] ; do \ 827 y1=`curl --connect-timeout 5 --head --silent $${url} | head -n 1`; \ 828 y2=`echo $${y1} | grep ' 4[0-9]* '`; \ 829 y3=`echo $${y1} | grep ' 301 '`; \ 830 if [[ "$${y1}D" == "D" ]] ; then \ 831 msg="Unable to reach site" ; \ 832 elif [[ "$${y2}D" != "D" ]] ; then \ 833 msg=$${y1} ; \ 834 elif [[ "$${y3}D" != "D" ]] ; then \ 835 l=`curl --connect-timeout 5 --head --silent $${url} | grep ocation | sed 's/.*ocation:[[:blank:]]\(.*\)/\1/g' | tr -d '\r'` ; \ 836 w=`echo $$l | grep 'http'` ; \ 837 if [[ "$${w}D" != "D" ]] ; then \ 838 url=$$l ; \ 839 else \ 840 ws=`echo $${url} | sed 's!\(http[s]*://[-a-zA-Z0-9_.]*\)/.*!\1!g'` ; \ 841 dp=`echo $${ws}$${l} | grep "dropbox.com/s/raw"` ; \ 842 if [[ "$${dp}D" != "D" ]] ; then \ 843 b=`curl --connect-timeout 5 --head --silent $${ws}$$l | head -n 1` ; \ 844 c=`echo $${b} | grep -E "( 2[0-9]* | 302 )"` ; \ 845 if [[ "$${c}D" == "D" ]] ; then \ 846 msg=`echo "dropbox file doesn't exist" $${c}` ; \ 847 else \ 848 break ; \ 849 fi; \ 850 else \ 851 url="$${ws}$$l" ; \ 852 fi; \ 853 fi; \ 854 else \ 855 break; \ 856 fi; \ 857 done;\ 858 if [[ "$${msg}D" == "D" && "$${url}" != "$$i" ]] ; then \ 859 echo "URL" $$i "has moved to valid final location:" $${url} ; \ 860 if [[ "$${REPLACE}D" != "D" ]] ; then \ 861 git psed $$i $$l ;\ 862 fi; \ 863 elif [[ "$${msg}D" != "D" && "$${url}" != "$$i" ]] ; then \ 864 echo "ERROR: URL" $$i "has moved to invalid final location:" $${url} $${msg} ; \ 865 elif [[ "$${msg}D" != "D" ]] ; then \ 866 echo "ERROR: URL" $$i "invalid:" $${msg} ; \ 867 fi; \ 868 done 869 870checkbadSpelling: 871 -@x=`python3 ../bin/extract.py | aspell list | sort -u` ; 872 873updatedatafiles: 874 -@if [ -d "${HOME}/datafiles" ]; then \ 875 echo " ** Updating datafiles at ${HOME}/datafiles **"; \ 876 cd "${HOME}/datafiles" && git pull -q; fi 877 878.PHONY: info info_h all deletelibs allclean update \ 879 alletags etags etags_complete etags_noexamples etags_makefiles etags_examples etags_fexamples alldoc allmanpages \ 880 allcleanhtml countfortranfunctions \ 881 start_configure configure_petsc configure_clean matlabbin install 882