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