xref: /petsc/makefile (revision d5b43468fb8780a8feea140ccd6fa3e6a50411cc)
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
7LOCDIR	 = ./
8DIRS	 = src include tutorials interfaces share/petsc/matlab
9
10# next line defines PETSC_DIR and PETSC_ARCH if they are not set
11include ././${PETSC_ARCH}/lib/petsc/conf/petscvariables
12include ${PETSC_DIR}/lib/petsc/conf/variables
13include ${PETSC_DIR}/lib/petsc/conf/rules
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#
53# Prints information about the system and version of PETSc being compiled
54#
55info:
56	-@echo "=========================================="
57	-@echo " "
58	-@echo "See documentation/faq.html and documentation/bugreporting.html"
59	-@echo "for help with installation problems.  Please send EVERYTHING"
60	-@echo "printed out below when reporting problems.  Please check the"
61	-@echo "mailing list archives and consider subscribing."
62	-@echo " "
63	-@echo "  https://petsc.org/release/community/mailing/"
64	-@echo " "
65	-@echo "=========================================="
66	-@echo Starting make run on `hostname` at `date +'%a, %d %b %Y %H:%M:%S %z'`
67	-@echo Machine characteristics: `uname -a`
68	-@echo "-----------------------------------------"
69	-@echo "Using PETSc directory: ${PETSC_DIR}"
70	-@echo "Using PETSc arch: ${PETSC_ARCH}"
71	-@echo "-----------------------------------------"
72	-@grep "define PETSC_VERSION" ${PETSC_DIR}/include/petscversion.h | ${SED} "s/........//"
73	-@echo "-----------------------------------------"
74	-@echo "Using configure Options: ${CONFIGURE_OPTIONS}"
75	-@echo "Using configuration flags:"
76	-@grep "\#define " ${PETSCCONF_H}
77	-@echo "-----------------------------------------"
78	-@echo "Using C compile: ${PETSC_CCOMPILE_SINGLE}"
79	-@if [  "${MPICC_SHOW}" != "" ]; then \
80             printf  "mpicc -show: %b\n" "${MPICC_SHOW}";\
81          fi; \
82        printf  "C compiler version: %b\n" "${C_VERSION}"; \
83        if [ "${CXX}" != "" ]; then \
84        echo "Using C++ compile: ${PETSC_CXXCOMPILE_SINGLE}";\
85        if [ "${MPICXX_SHOW}" != "" ]; then \
86               printf "mpicxx -show: %b\n" "${MPICXX_SHOW}"; \
87            fi;\
88            printf  "C++ compiler version: %b\n" "${Cxx_VERSION}"; \
89          fi
90	-@if [ "${FC}" != "" ]; then \
91	   echo "Using Fortran compile: ${PETSC_FCOMPILE_SINGLE}";\
92           if [ "${MPIFC_SHOW}" != "" ]; then \
93             printf "mpif90 -show: %b\n" "${MPIFC_SHOW}"; \
94           fi; \
95             printf  "Fortran compiler version: %b\n" "${FC_VERSION}"; \
96         fi
97	-@if [ "${CUDAC}" != "" ]; then \
98	   echo "Using CUDA compile: ${PETSC_CUCOMPILE_SINGLE}";\
99         fi
100	-@if [ "${CLANGUAGE}" = "CXX" ]; then \
101           echo "Using C++ compiler to compile PETSc";\
102        fi
103	-@echo "-----------------------------------------"
104	-@echo "Using C/C++ linker: ${PCC_LINKER}"
105	-@echo "Using C/C++ flags: ${PCC_LINKER_FLAGS}"
106	-@if [ "${FC}" != "" ]; then \
107	   echo "Using Fortran linker: ${FC_LINKER}";\
108	   echo "Using Fortran flags: ${FC_LINKER_FLAGS}";\
109         fi
110	-@echo "-----------------------------------------"
111	-@echo "Using system modules: ${LOADEDMODULES}"
112	-@if [ "${MPI_IS_MPIUNI}" = "1" ]; then \
113           echo Using mpi.h: mpiuni; \
114        else \
115           TESTDIR=`mktemp -q -d -t petscmpi-XXXXXXXX` && \
116           echo '#include <mpi.h>' > $${TESTDIR}/mpitest.c && \
117           BUF=`${CPP} ${PETSC_CPPFLAGS} ${PETSC_CC_INCLUDES} $${TESTDIR}/mpitest.c |grep 'mpi\.h' | ( head -1 ; cat > /dev/null )` && \
118           echo Using mpi.h: $${BUF}; ${RM} -rf $${TESTDIR}; \
119        fi
120	-@echo "-----------------------------------------"
121	-@echo "Using libraries: ${PETSC_LIB}"
122	-@echo "------------------------------------------"
123	-@echo "Using mpiexec: ${MPIEXEC}"
124	-@echo "------------------------------------------"
125	-@echo "Using MAKE: $(MAKE)"
126	-@echo "Using MAKEFLAGS: -j$(MAKE_NP) -l$(MAKE_LOAD) $(MAKEFLAGS)"
127	-@echo "=========================================="
128
129#
130# Build MatLab binaries
131#
132matlabbin:
133	-@if [ "${MATLAB_MEX}" != "" -a "${MATLAB_SOCKET}" != "" -a "${PETSC_SCALAR}" = "real" -a "${PETSC_PRECISION}" = "double" ]; then \
134          echo "BEGINNING TO COMPILE MATLAB INTERFACE"; \
135            if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc" ] ; then ${MKDIR}  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc; fi; \
136            if [ ! -d "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab" ] ; then ${MKDIR}  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/matlab; fi; \
137            cd src/sys/classes/viewer/impls/socket/matlab && ${OMAKE_SELF} matlabcodes PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR}; \
138            echo "========================================="; \
139        fi
140#
141# Builds PETSc check examples for a given architecture
142#
143RUN_TEST = ${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} DIFF=${PETSC_DIR}/lib/petsc/bin/petscdiff
144
145check_install: check
146check:
147	-@echo "Running check examples to verify correct installation"
148	-@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}"
149	@if [ "${PETSC_WITH_BATCH}" != "" ]; then \
150           echo "Running with batch filesystem, cannot run make check"; \
151        elif [ "${MPIEXEC}" = "/bin/false" ]; then \
152           echo "*mpiexec not found*. cannot run make check"; \
153        else \
154          ${RM} -f check_error;\
155          ${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; \
156          if [ -f check_error ]; then \
157            echo "Error while running make check"; \
158            ${RM} -f check_error;\
159            exit 1; \
160          fi; \
161          ${RM} -f check_error;\
162        fi;
163
164check_build:
165	+@cd src/snes/tutorials >/dev/null; ${RUN_TEST} clean-legacy
166	+@cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19
167	+@if [ ! "${MPI_IS_MPIUNI}" ]; then cd src/snes/tutorials >/dev/null; ${RUN_TEST} testex19_mpi; fi
168	+@if [ "${HYPRE_LIB}" != "" ] && [ "${PETSC_SCALAR}" = "real" ]; then \
169          if [ "${CUDA_LIB}" != "" ]; then HYPRE_TEST=runex19_hypre_cuda; \
170          elif [ "${HIP_LIB}" != "" ]; then HYPRE_TEST=runex19_hypre_hip; \
171          else HYPRE_TEST=runex19_hypre; fi; \
172          cd src/snes/tutorials >/dev/null; ${RUN_TEST} $${HYPRE_TEST}; \
173        fi;
174	+@if [ "${CUDA_LIB}" != "" ]; then \
175          cd src/snes/tutorials >/dev/null; ${RUN_TEST} runex19_cuda; \
176        fi;
177	+@if [ "${MPI_IS_MPIUNI}" = "" ]; then \
178          cd src/snes/tutorials >/dev/null; \
179          if [ "${KOKKOS_KERNELS_LIB}" != "" ]  &&  [ "${PETSC_SCALAR}" = "real" ] && [ "${PETSC_PRECISION}" = "double" ]; then \
180            ${RUN_TEST} runex3k_kokkos; \
181          fi;\
182          if [ "${MUMPS_LIB}" != "" ]; then \
183             ${RUN_TEST} runex19_fieldsplit_mumps; \
184          fi;\
185          if [ "${SUITESPARSE_LIB}" != "" ]; then \
186             ${RUN_TEST} runex19_suitesparse; \
187          fi;\
188          if [ "${SUPERLU_DIST_LIB}" != "" ]; then \
189            ${RUN_TEST} runex19_superlu_dist; \
190          fi;\
191          if ( [ "${ML_LIB}" != "" ] ||  [ "${TRILINOS_LIB}" != "" ] ); then \
192            ${RUN_TEST} runex19_ml; \
193          fi; \
194	  ${RUN_TEST} clean-legacy; \
195          cd - > /dev/null; \
196          if [ "${AMREX_LIB}" != "" ]; then \
197            echo "Running amrex test example to verify correct installation";\
198            echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}";\
199            cd src/ksp/ksp/tutorials/amrex >/dev/null;\
200            ${RUN_TEST} clean-legacy; \
201            ${RUN_TEST} testamrex; \
202            ${RUN_TEST} clean-legacy; \
203            cd - > /dev/null; \
204          fi;\
205        fi;
206	+@if [ "${HDF5_LIB}" != "" ]; then \
207          cd src/vec/vec/tests >/dev/null;\
208          ${RUN_TEST} clean-legacy; \
209          ${RUN_TEST} runex47; \
210          ${RUN_TEST} clean-legacy; \
211         fi;
212	+@if [ "${MPI4PY}" = "yes" ]; then \
213           cd src/sys/tests >/dev/null; \
214           ${RUN_TEST} clean-legacy; \
215           ${RUN_TEST} testex55; \
216           ${RUN_TEST} clean-legacy; \
217         fi;
218	+@if [ "${PETSC4PY}" = "yes" ]; then \
219           cd src/ksp/ksp/tutorials >/dev/null; \
220           ${RUN_TEST} clean-legacy; \
221           ${RUN_TEST} testex100; \
222           ${RUN_TEST} clean-legacy; \
223         fi;
224	+@grep -E "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \
225         if test -s .ftn.log; then \
226           cd src/snes/tutorials >/dev/null; \
227           ${RUN_TEST} clean-legacy; \
228           ${RUN_TEST} testex5f; \
229           ${RUN_TEST} clean-legacy; \
230         fi; ${RM} .ftn.log;
231	+@grep -E "^#define PETSC_HAVE_MATLAB 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \
232         if test -s .ftn.log; then \
233           cd src/vec/vec/tutorials >/dev/null; \
234           ${RUN_TEST} clean-legacy; \
235           ${RUN_TEST} testex31; \
236           ${RUN_TEST} clean-legacy; \
237          fi; ${RM} .ftn.log;
238	-@echo "Completed test examples"
239
240check_usermakefile:
241	-@echo "Testing compile with user makefile"
242	-@echo "Using PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}"
243	@cd src/snes/tutorials; ${RUN_TEST} clean-legacy
244	@cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex19
245	@grep -E "^#define PETSC_HAVE_FORTRAN 1" ${PETSCCONF_H} | tee .ftn.log > /dev/null; \
246         if test -s .ftn.log; then \
247          cd src/snes/tutorials; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} -f ${PETSC_DIR}/share/petsc/Makefile.user ex5f; \
248         fi; ${RM} .ftn.log;
249	@cd src/snes/tutorials; ${RUN_TEST} clean-legacy
250	-@echo "Completed compile with user makefile"
251
252checkgitclean:
253	@if ! git diff --quiet; then \
254           echo "The repository has uncommitted files, cannot run checkclangformat" ;\
255           git status -s --untracked-files=no ;\
256           false;\
257        fi;
258
259checkclangformatversion:
260	@version=`clang-format --version | cut -d" " -f3 | cut -d"." -f 1` ;\
261         if [ "$$version" == "version" ]; then version=`clang-format --version | cut -d" " -f4 | cut -d"." -f 1`; fi;\
262         if [ $$version != 15 ]; then echo "Require clang-format version 15! Currently used clang-format version is $$version" ;false ; fi
263
264# Check that all the source code in the repository satisfies the .clang_format
265checkclangformat: checkclangformatversion checkgitclean clangformat
266	@if ! git diff --quiet; then \
267          printf "The current commit has source code formatting problems\n" ;\
268          if [ -z "${CI_PIPELINE_ID}"  ]; then \
269            printf "Please run 'git diff' to check\n"; \
270            git diff --stat; \
271          else \
272            git diff --patch-with-stat >  ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch; \
273            git diff --patch-with-stat --color=always | head -1000; \
274            if [ `wc -l < ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch` -gt 1000 ]; then \
275              printf "The diff has been trimmed, check ${PETSC_ARCH}/lib/petsc/conf/checkclangformat.patch (in CI artifacts) for all changes\n"; \
276            fi;\
277          fi;\
278          false;\
279        fi;
280
281# Compare ABI/API of two versions of PETSc library with the old one defined by PETSC_{DIR,ARCH}_ABI_OLD
282abitest:
283	@if [ "${PETSC_DIR_ABI_OLD}" = "" ] || [ "${PETSC_ARCH_ABI_OLD}" = "" ]; \
284		then printf "You must set environment variables PETSC_DIR_ABI_OLD and PETSC_ARCH_ABI_OLD to run abitest\n"; \
285		exit 1; \
286	fi;
287	-@echo "Comparing ABI/API of the following two PETSc versions (you must have already configured and built them using GCC and with -g):"
288	-@echo "========================================================================================="
289	-@echo "    Old: PETSC_DIR_ABI_OLD  = ${PETSC_DIR_ABI_OLD}"
290	-@echo "         PETSC_ARCH_ABI_OLD = ${PETSC_ARCH_ABI_OLD}"
291	-@pushd ${PETSC_DIR_ABI_OLD} >> /dev/null ; echo "         Branch             = "`git rev-parse --abbrev-ref HEAD`
292	-@echo "    New: PETSC_DIR          = ${PETSC_DIR}"
293	-@echo "         PETSC_ARCH         = ${PETSC_ARCH}"
294	-@echo "         Branch             = "`git rev-parse --abbrev-ref HEAD`
295	-@echo "========================================================================================="
296	-@$(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
297
298# Compare ABI/API of current PETSC_ARCH/PETSC_DIR with a previous branch
299abitestcomplete:
300	-@if [[ -f "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/configure.log" ]]; then \
301          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"` ;\
302echo $${OPTIONS} ;\
303        fi ; \
304        if [[ "${PETSC_DIR_ABI_OLD}" != "" ]]; then \
305          PETSC_DIR_OLD=${PETSC_DIR_ABI_OLD}; \
306        else \
307          PETSC_DIR_OLD=${PETSC_DIR}/../petsc-abi; \
308        fi ; \
309        echo "=================================================================================================" ;\
310        echo "Doing ABI/API comparison between" ${branch} " and " `git rev-parse --abbrev-ref HEAD` "using " $${OPTIONS} ;\
311        echo "=================================================================================================" ;\
312        if [[ ! -d $${PETSC_DIR_OLD} ]]; then \
313          git clone ${PETSC_DIR} $${PETSC_DIR_OLD} ; \
314        else \
315          cd $${PETSC_DIR_OLD} ; \
316          git pull ; \
317        fi ; \
318        cd $${PETSC_DIR_OLD} ; \
319        git checkout ${branch} ; \
320        PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` ./configure $${OPTIONS} ; \
321        PETSC_DIR=`pwd` PETSC_ARCH=arch-branch-`git rev-parse ${branch}` make all test ; \
322        cd ${PETSC_DIR} ; \
323        ./configure $${OPTIONS}; \
324        make all test ; \
325        PETSC_DIR_ABI_OLD=$${PETSC_DIR_OLD} PETSC_ARCH_ABI_OLD=arch-branch-`git rev-parse ${branch}` make abitest
326
327# Deletes PETSc libraries
328deletelibs:
329	-${RM} -rf ${PETSC_LIB_DIR}/libpetsc*.*
330deletemods:
331	-${RM} -f ${PETSC_DIR}/${PETSC_ARCH}/include/petsc*.mod
332
333allclean:
334	-@${OMAKE} -f gmakefile clean
335
336clean:: allclean
337
338distclean: chk_petscdir
339	@if [ -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ]; then \
340	  echo "*** Preserving ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py in ${PETSC_DIR} ***"; \
341          mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/; fi
342	@echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***"
343	-${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/
344
345
346#
347reconfigure: allclean
348	@unset MAKEFLAGS && ${PYTHON} ${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py
349#
350install:
351	@${PYTHON} ./config/install.py -destDir=${DESTDIR}
352	+${OMAKE_SELF} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} petsc4py-install libmesh-install mfem-install slepc-install hpddm-install amrex-install bamg-install
353
354mpistreams:
355	+@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistreams
356
357mpistream:
358	+@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} mpistream
359
360openmpstreams:
361	+@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstreams
362
363openmpstream:
364	+@cd src/benchmarks/streams; ${OMAKE_SELF} PATH="${PETSC_DIR}/${PETSC_ARCH}/lib:${PATH}" PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} openmpstream
365
366# for legacy reasons
367stream: mpistream
368
369streams: mpistreams
370
371# ------------------------------------------------------------------
372#
373# All remaining actions are intended for PETSc developers only.
374# PETSc users should not generally need to use these commands.
375#
376#  See the users manual for how the tags files may be used from Emacs and Vi/Vim
377#
378alletags:
379	-@${PYTHON} lib/petsc/bin/maint/generateetags.py
380	-@find config -type f -name "*.py" |grep -v SCCS | xargs etags -o TAGS_PYTHON
381
382# obtain gtags from https://www.gnu.org/software/global/
383allgtags:
384	-@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 -
385
386allfortranstubs:
387	-@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir
388	@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py ${BFORT}  ${VERBOSE}
389	-@${PYTHON} lib/petsc/bin/maint/generatefortranstubs.py -merge  ${VERBOSE}
390	-@${RM} -rf ${PETSC_ARCH}/include/petsc/finclude/ftn-auto/*-tmpdir
391deletefortranstubs:
392	-@find . -type d -name ftn-auto | xargs rm -rf
393
394# Build just manual pages + prerequisites
395# Also builds citations
396hloc=include/petsc/private
397allmanpages: chk_loc deletemanualpages
398	-sed -e 's?<T>?I?g' -e 's?<t>?i?g' -e 's?<Type>?PetscInt?g' ${hloc}/hashset.txt > ${hloc}/generated_hashset.txt
399	-sed -e 's?<T>?IJ?g' -e 's?<t>?ij?g' -e 's?<Type>?struct {PetscInt i,j;}?g' ${hloc}/hashset.txt >> ${hloc}/generated_hashset.txt
400	-${RM} ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err
401	-${OMAKE_SELF} ACTION=manualpages tree_src LOC=${LOC}
402	-@sed -e s%man+../%man+manualpages/% ${LOC}/docs/manualpages/manualpages.cit > ${LOC}/docs/manualpages/htmlmap
403	-@cat ${PETSC_DIR}/doc/classic/mpi.www.index >> ${LOC}/docs/manualpages/htmlmap
404	cat ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err
405	a=`cat ${PETSC_DIR}/${PETSC_ARCH}/manualpages.err | wc -l`; test ! $$a -gt 0
406
407# Build just manual examples + prerequisites
408allmanexamples: chk_loc allmanpages
409	-${OMAKE_SELF} ACTION=manexamples tree_basic LOC=${LOC}
410
411# Build all classic docs except html sources
412alldoc1: chk_loc allmanpages allmanexamples
413	-${OMAKE_SELF} manimplementations LOC=${LOC}
414	-${PYTHON} lib/petsc/bin/maint/wwwindex.py ${PETSC_DIR} ${LOC}
415
416# Builds .html versions of the source
417# html overwrites some stuff - hence this is done later.
418alldoc2: chk_loc allmanpages
419	-${OMAKE_SELF} ACTION=html PETSC_DIR=${PETSC_DIR} alltree LOC=${LOC}
420
421# A version which presumes allmanpages has already been run
422alldoc_post: chk_loc
423	-${OMAKE_SELF} ACTION=html PETSC_DIR=${PETSC_DIR} alltree LOC=${LOC}
424
425alldocclean: deletemanualpages allcleanhtml
426
427# Deletes man pages (.md version)
428deletemanualpages: chk_loc
429	-@if [ -d ${LOC} -a -d ${LOC}/docs/manualpages ]; then \
430          find ${LOC}/docs/manualpages -type f -name "*.md" -exec ${RM} {} \; ;\
431          ${RM} ${LOC}/docs/manualpages/manualpages.cit ;\
432        fi
433
434allcleanhtml:
435	-${OMAKE_SELF} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} alltree
436
437# Builds simple html versions of the source without links into the $PETSC_ARCH/obj directory, used by make mergegcov
438srchtml:
439	-${OMAKE_SELF} ACTION=simplehtml PETSC_DIR=${PETSC_DIR} alltree_src
440
441###########################################################
442# targets to build distribution and update docs
443###########################################################
444
445# Creates ${HOME}/petsc.tar.gz [and petsc-with-docs.tar.gz]
446dist:
447	${PETSC_DIR}/lib/petsc/bin/maint/builddist ${PETSC_DIR} main
448
449###########################################################
450#
451#  See script for details
452#
453gcov:
454	@$(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py --run_gcov --petsc_arch ${PETSC_ARCH}
455
456mergegcov:
457	@$(PYTHON) ${PETSC_DIR}/lib/petsc/bin/maint/gcov.py --merge_gcov  --petsc_arch ${PETSC_ARCH} --merge_branch `lib/petsc/bin/maint/check-merge-branch.sh`
458
459#
460# -------------------------------------------------------------------------------
461#
462# Some macros to check if the fortran interface is up-to-date.
463#
464countfortranfunctions:
465	-@cd ${PETSC_DIR}/src/fortran; grep -E '^void' custom/*.c auto/*.c | \
466	cut -d'(' -f1 | tr -s  ' ' | cut -d' ' -f2 | uniq | grep -E -v "(^$$|Petsc)" | \
467	sed "s/_$$//" | sort > /tmp/countfortranfunctions
468
469countcfunctions:
470	-@grep PETSC_EXTERN ${PETSC_DIR}/include/*.h  | grep "(" | tr -s ' ' | \
471	cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' |  \
472	tr 'A-Z' 'a-z' |  sort | uniq > /tmp/countcfunctions
473
474difffortranfunctions: countfortranfunctions countcfunctions
475	-@echo -------------- Functions missing in the fortran interface ---------------------
476	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2
477	-@echo ----------------- Functions missing in the C interface ------------------------
478	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2
479	-@${RM}  /tmp/countcfunctions /tmp/countfortranfunctions
480
481checkbadfortranstubs:
482	-@echo "========================================="
483	-@echo "Functions with MPI_Comm as an Argument"
484	-@echo "========================================="
485	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \
486	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
487	-@echo "========================================="
488	-@echo "Functions with a String as an Argument"
489	-@echo "========================================="
490	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \
491	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
492	-@echo "========================================="
493	-@echo "Functions with Pointers to PETSc Objects as Argument"
494	-@echo "========================================="
495	-@cd ${PETSC_DIR}/src/fortran/auto; \
496	_p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \
497	cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \
498	sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \
499	for OBJ in $$_p_OBJ; do \
500	grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \
501	cut -d'(' -f1 | cut -d' ' -f1,3; \
502	done
503
504checkpackagetests:
505	-@echo "Missing package tests"
506	-@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
507	-@echo "Missing download package tests"
508	-@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
509
510.PHONY: info info_h all deletelibs allclean update \
511        alletags etags etags_complete etags_noexamples etags_makefiles etags_examples etags_fexamples alldoc allmanpages \
512        allcleanhtml  countfortranfunctions \
513        start_configure configure_petsc configure_clean matlabbin install
514