xref: /petsc/makefile (revision 0515d99c3980657c344bbf276419f203e39e6d03)
1# $Id: makefile,v 1.353 2001/08/28 19:43:38 balay Exp $
2#
3# This is the makefile for installing PETSc. See the file
4# docs/website/documentation/installation.html for directions on installing PETSc.
5# See also bmake/common for additional commands.
6#
7ALL: all
8LOCDIR = .
9DIRS   = src include docs
10
11include ${PETSC_DIR}/bmake/common/base
12include ${PETSC_DIR}/bmake/common/test
13
14#
15# Basic targets to build PETSc libraries.
16# all: builds the c, fortran, and f90 libraries
17all:
18	@${OMAKE}  PETSC_ARCH=${PETSC_ARCH} BOPT=${BOPT} chkpetsc_dir
19	-@${MAKE} all_build 2>&1 | tee make_log_${PETSC_ARCH}_${BOPT}
20all_build: chk_petsc_dir info info_h chklib_dir deletelibs chk_fortranstubs blaslapack mpich build shared
21#
22# Prints information about the system and version of PETSc being compiled
23#
24info:
25	-@echo "=========================================="
26	-@echo " "
27	-@echo "See docs/troubleshooting.html and docs/bugreporting.html"
28	-@echo "for help with installation problems. Please send EVERYTHING"
29	-@echo "printed out below when reporting problems"
30	-@echo " "
31	-@echo "To subscribe to the PETSc users mailing list, send mail to "
32	-@echo "majordomo@mcs.anl.gov with the message: "
33	-@echo "subscribe petsc-announce"
34	-@echo " "
35	-@echo "=========================================="
36	-@echo On `date` on `hostname`
37	-@echo Machine characteristics: `uname -a`
38	-@echo "-----------------------------------------"
39	-@echo "Using C compiler: ${C_CC} ${COPTFLAGS} ${CCPPFLAGS}"
40	-@echo "C Compiler version: " `${C_CCV}`
41	-@if [ "${CXX}" != "" ]; then \
42	   echo "Using C++ compiler: ${CXX_CC} ${COPTFLAGS} ${CCPPFLAGS}";\
43	   echo "C++ Compiler version: " `${CXX_CCV}`;\
44	fi
45	-@if [ "${FC}" != "" ]; then \
46	   echo "Using Fortran compiler: ${C_FC} ${FOPTFLAGS} ${FCPPFLAGS}";\
47	   echo "Fortran Compiler version: " `${C_FCV}`;\
48         fi
49	-@echo "-----------------------------------------"
50	-@grep "define PETSC_VERSION" ${PETSC_DIR}/include/petscversion.h | ${SED} "s/........//"
51	-@echo "-----------------------------------------"
52	-@echo "Using PETSc flags: ${PETSCFLAGS} ${PCONF}"
53	-@echo "-----------------------------------------"
54	-@echo "Using configuration flags:"
55	-@grep "\#define " ${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h
56	-@echo "-----------------------------------------"
57	-@echo "Using include paths: ${PETSC_INCLUDE}"
58	-@echo "-----------------------------------------"
59	-@echo "Using PETSc directory: ${PETSC_DIR}"
60	-@echo "Using PETSc arch: ${PETSC_ARCH}"
61	-@echo "------------------------------------------"
62	-@echo "Using C linker: ${CLINKER}"
63	-@if [ "${FC}" != "" ]; then \
64	   echo "Using Fortran linker: ${FLINKER}";\
65         fi
66	-@echo "Using libraries: ${PETSC_LIB}"
67	-@echo "------------------------------------------"
68	-@echo "Using mpirun: ${MPIRUN}"
69	-@echo "=========================================="
70#
71#
72MINFO = ${PETSC_DIR}/bmake/${PETSC_ARCH}/petscmachineinfo.h
73info_h:
74	-@$(RM) -f MINFO ${MINFO}
75	-@echo  "static const char *petscmachineinfo = \"  " >> MINFO
76	-@echo  "Libraries compiled on `date` on `hostname` " >> MINFO
77	-@echo  Machine characteristics: `uname -a` "" >> MINFO
78	-@echo  "Using PETSc directory: ${PETSC_DIR}" >> MINFO
79	-@echo  "Using PETSc arch: ${PETSC_ARCH}" >> MINFO
80	-@echo  "-----------------------------------------\"; " >> MINFO
81	-@echo  "static const char *petsccompilerinfo = \"  " >> MINFO
82	-@echo  "Using C compiler: ${C_CC} ${COPTFLAGS} ${CCPPFLAGS} " >> MINFO
83	-@echo  "C Compiler version:"  >> MINFO ; ${C_CCV} >> MINFO 2>&1 ; true
84	-@echo  "C++ Compiler version:"  >> MINFO; ${CXX_CCV} >> MINFO 2>&1 ; true
85	-@echo  "Using Fortran compiler: ${C_FC} ${FOPTFLAGS} ${FCPPFLAGS}" >> MINFO
86	-@echo  "Fortran Compiler version:" >> MINFO ; ${C_FCV} >> MINFO 2>&1 ; true
87	-@echo  "-----------------------------------------\"; " >> MINFO
88	-@echo  "static const char *petsccompilerflagsinfo = \"  " >> MINFO
89	-@echo  "Using PETSc flags: ${PETSCFLAGS} ${PCONF}" >> MINFO
90	-@echo  "-----------------------------------------" >> MINFO
91	-@echo  "Using configuration flags:" >> MINFO
92	-@echo  "-----------------------------------------" >> MINFO
93	-@echo  "Using include paths: ${PETSC_INCLUDE}" >> MINFO
94	-@echo  "------------------------------------------\"; " >> MINFO
95	-@echo  "static const char *petsclinkerinfo = \"  " >> MINFO
96	-@echo  "Using C linker: ${CLINKER}" >> MINFO
97	-@echo  "Using Fortran linker: ${FLINKER}" >> MINFO
98	-@echo  "Using libraries: ${PETSC_LIB} \"; " >> MINFO
99	-@cat MINFO | ${SED} -e 's/\
100//g'  | ${SED} -e 's/\^M//g' | ${SED} -e 's/\\/\\\\/g' | ${SED} -e 's/$$/ \\n\\/' | sed -e 's/\;  \\n\\/\;/'> ${MINFO}
101	-@$(RM) MINFO
102
103#
104# Builds the PETSc libraries
105# This target also builds fortran77 and f90 interface
106# files and compiles .F files
107#
108build:
109	-@echo "BEGINNING TO COMPILE LIBRARIES IN ALL DIRECTORIES"
110	-@echo "========================================="
111	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=libfast tree
112	-@${RANLIB} ${PETSC_LIB_DIR}/*.${LIB_SUFFIX}
113	-@echo "Completed building libraries"
114	-@echo "========================================="
115#
116#  Compiles the blas and lapack source code if found
117blaslapack:
118	-@if [ -d f2cblaslapack/${PETSC_ARCH} -a ! -s f2cblaslapack/${PETSC_ARCH}/libf2cblas.a ] ; then cd f2cblaslapack;\
119        echo "=========================================";\
120        echo "Building C Blas/Lapack libraries";\
121        ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ;\
122        ${MV} libf2cblas.a libf2clapack.a ${PETSC_ARCH};\
123        ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} cleanblaslapack ;\
124        echo "Completed C building Blas/Lapack libraries";\
125        echo "========================================="; fi
126	-@if [ -d fblaslapack/${PETSC_ARCH} -a ! -s fblaslapack/${PETSC_ARCH}/libfblas.a ] ; then cd fblaslapack;\
127        echo "=========================================";\
128        echo "Building Fortran Blas/Lapack libraries";\
129        ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ;\
130        ${MV} libfblas.a libflapack.a ${PETSC_ARCH};\
131        ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} cleanblaslapck ;\
132        echo "Completed building Fortran Blas/Lapack libraries";\
133        echo "========================================="; fi
134#
135#  Compiles MPICH if found
136mpich:
137	-@releasename=`ls -d mpich* 2> /dev/null`;\
138        if [ -d $${releasename}/${PETSC_ARCH} -a ! -d $${releasename}/${PETSC_ARCH}/lib ] ; then cd $${releasename} ;\
139          echo "=========================================";\
140          echo "Compiling and installing " $${releasename};\
141          make; make install; \
142          echo "=========================================";\
143        fi;
144#
145# Builds PETSc test examples for a given BOPT and architecture
146#
147test: chkopts
148	-@echo "Running test examples to verify correct installation"
149	@cd src/snes/examples/tutorials; ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testex19
150	@if [ "${C_FC}" != "" ]; then cd src/snes/examples/tutorials; ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} testex5f; fi;
151	-@echo "Completed test examples"
152
153testexamples: info chkopts
154	-@echo "BEGINNING TO COMPILE AND RUN TEST EXAMPLES"
155	-@echo "Due to different numerical round-off on certain"
156	-@echo "machines some of the numbers may not match exactly."
157	-@echo "========================================="
158	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH}  PETSC_DIR=${PETSC_DIR} ACTION=testexamples_1  tree
159	-@echo "Completed compiling and running test examples"
160	-@echo "========================================="
161testfortran: info chkopts
162	-@echo "BEGINNING TO COMPILE AND RUN FORTRAN TEST EXAMPLES"
163	-@echo "========================================="
164	-@echo "Due to different numerical round-off on certain"
165	-@echo "machines or the way Fortran formats numbers"
166	-@echo "some of the results may not match exactly."
167	-@echo "========================================="
168	-@if [ "${C_FC}" != "" ]; then \
169            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=testexamples_3 tree; \
170            echo "Completed compiling and running Fortran test examples"; \
171          else \
172            echo "Error: No FORTRAN compiler available"; \
173          fi
174	-@echo "========================================="
175testexamples_uni: info chkopts
176	-@echo "BEGINNING TO COMPILE AND RUN TEST UNI-PROCESSOR EXAMPLES"
177	-@echo "Due to different numerical round-off on certain"
178	-@echo "machines some of the numbers may not match exactly."
179	-@echo "========================================="
180	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=testexamples_4  tree
181	-@echo "Completed compiling and running uniprocessor test examples"
182	-@echo "========================================="
183testfortran_uni: info chkopts
184	-@echo "BEGINNING TO COMPILE AND RUN TEST UNI-PROCESSOR FORTRAN EXAMPLES"
185	-@echo "Due to different numerical round-off on certain"
186	-@echo "machines some of the numbers may not match exactly."
187	-@echo "========================================="
188	-@if [ "${C_FC}" != "" ]; then \
189            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=testexamples_9  tree; \
190            echo "Completed compiling and running uniprocessor fortran test examples"; \
191          else \
192            echo "Error: No FORTRAN compiler available"; \
193          fi
194	-@
195	-@echo "========================================="
196
197# Ranlib on the libraries
198ranlib:
199	${RANLIB} ${PETSC_LIB_DIR}/*.${LIB_SUFFIX}
200
201# Deletes PETSc libraries
202deletelibs: chkopts_basic
203	-${RM} -f ${PETSC_LIB_DIR}/*
204
205# Cleans up build
206allclean: deletelibs
207	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} ACTION=clean tree
208
209
210#
211# Check if PETSC_DIR variable specified is valid
212#
213chk_petsc_dir:
214	@if [ ! -f ${PETSC_DIR}/include/petscversion.h ]; then \
215	  echo "Incorrect PETSC_DIR specified: ${PETSC_DIR}!"; \
216	  echo "You need to use / to separate directories, not \\!"; \
217	  echo "Aborting build"; \
218	  false; fi
219
220install:
221	-@if [ "${INSTALL_DIR}" == "${PETSC_DIR}" ]; then \
222	  echo "Install directory is current directory; nothing needs to be done";\
223        else \
224	  echo Installing PETSc at ${INSTALL_DIR};\
225          if [ ! -d `dirname ${INSTALL_DIR}` ]; then \
226	    mkdir `dirname ${INSTALL_DIR}` ; \
227          fi;\
228          if [ ! -d ${INSTALL_DIR} ]; then \
229	    mkdir ${INSTALL_DIR} ; \
230          fi;\
231          cp -fr include ${INSTALL_DIR};\
232          if [ ! -d ${INSTALL_DIR}/bmake ]; then \
233	    mkdir ${INSTALL_DIR}/bmake ; \
234          fi;\
235          cp -f bmake/adic* bmake/variables ${INSTALL_DIR}/bmake ; \
236          cp -fr bmake/common ${INSTALL_DIR}/bmake;\
237          cp -fr bmake/${PETSC_ARCH} ${INSTALL_DIR}/bmake;\
238          cp -fr bin ${INSTALL_DIR};\
239          if [ ! -d ${INSTALL_DIR}/lib ]; then \
240	    mkdir ${INSTALL_DIR}/lib ; \
241          fi;\
242          for i in lib/lib*; do \
243            bopt=`echo $${i} | ${SED} s=lib/lib==g`;\
244            if [ ! -d ${INSTALL_DIR}/$${i} ]; then \
245              mkdir ${INSTALL_DIR}/$${i};\
246            fi; \
247            if [ -d $${i}/${PETSC_ARCH} ]; then \
248              cp -fr $${i}/${PETSC_ARCH} ${INSTALL_DIR}/$${i};\
249              ${RANLIB}  ${INSTALL_DIR}/$${i}/*.a > /dev/null 2>&1 ;\
250              ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${INSTALL_DIR} BOPT=$${bopt} shared; \
251            fi;\
252          done;\
253          echo "sh/bash: PETSC_DIR="${INSTALL_DIR}"; export PETSC_DIR";\
254          echo "csh/tcsh: setenv PETSC_DIR "${INSTALL_DIR} ;\
255          echo "The do make test to verify correct install";\
256        fi;
257
258install_src:
259	-@if [ "${INSTALL_DIR}" == "${PETSC_DIR}" ]; then \
260	  echo "You did not set a directory to install to";\
261        else \
262	  echo Installing PETSc source at ${INSTALL_DIR};\
263          if [ ! -d `dirname ${INSTALL_DIR}` ]; then \
264	    mkdir `dirname ${INSTALL_DIR}` ; \
265          fi;\
266          if [ ! -d ${INSTALL_DIR} ]; then \
267	    mkdir ${INSTALL_DIR} ; \
268          fi;\
269          cp -fr src ${INSTALL_DIR};\
270        fi;
271
272install_docs:
273	-@if [ "${INSTALL_DIR}" == "${PETSC_DIR}" ]; then \
274	  echo "You did not set a directory to install to";\
275        else \
276	  echo Installing PETSc documentation at ${INSTALL_DIR};\
277          if [ ! -d `dirname ${INSTALL_DIR}` ]; then \
278	    mkdir `dirname ${INSTALL_DIR}` ; \
279          fi;\
280          if [ ! -d ${INSTALL_DIR} ]; then \
281	    mkdir ${INSTALL_DIR} ; \
282          fi;\
283          cp -fr docs ${INSTALL_DIR};\
284          ${RM} -fr docs/tex;\
285        fi;
286# ------------------------------------------------------------------
287#
288# All remaining actions are intended for PETSc developers only.
289# PETSc users should not generally need to use these commands.
290#
291
292# To access the tags in EMACS, type M-x visit-tags-table and specify
293# the file petsc/TAGS.
294# 1) To move to where a PETSc function is defined, enter M-. and the
295#     function name.
296# 2) To search for a string and move to the first occurrence,
297#     use M-x tags-search and the string.
298#     To locate later occurrences, use M-,
299# Builds all etags files
300alletags:
301	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSDIR=${PETSC_DIR} etags
302	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSDIR=${PETSC_DIR} etags_noexamples
303	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSDIR=${PETSC_DIR} etags_examples
304	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSDIR=${PETSC_DIR} etags_makefiles
305# Builds complete etags list
306etags:
307	-${RM} ${TAGSDIR}/TAGS
308	-touch ${TAGSDIR}/TAGS
309	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_sourcec alltree
310	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_sourcej alltree
311	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_sourceh alltree
312	-cd src/fortran; ${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_sourcef alltree
313	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_examplesc alltree
314	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_examplesf alltree
315	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_examplesch alltree
316	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_examplesfh alltree
317	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_makefile alltree
318	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS etags_bmakefiles
319	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_docs alltree
320	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_scripts alltree
321# Builds the etags file that excludes the examples directories
322etags_noexamples:
323	-${RM} ${TAGSDIR}/TAGS_NO_EXAMPLES
324	-touch ${TAGSDIR}/TAGS_NO_EXAMPLES
325	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_sourcec alltree
326	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_sourcej alltree
327	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_sourceh alltree
328	-cd src/fortran; ${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_sourcef alltree
329	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_makefile alltree
330	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES etags_bmakefiles
331	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_docs alltree
332# Builds the etags file for makefiles
333etags_makefiles:
334	-${RM} ${TAGSDIR}/TAGS_MAKEFILES
335	-touch ${TAGSDIR}/TAGS_MAKEFILES
336	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_MAKEFILES ACTION=etags_makefile alltree
337	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_MAKEFILES etags_bmakefiles
338# Builds the etags file for examples
339etags_examples:
340	-${RM} ${TAGSDIR}/TAGS_EXAMPLES
341	-touch ${TAGSDIR}/TAGS_EXAMPLES
342	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesc alltree
343	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesch alltree
344	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesf alltree
345	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesfh alltree
346etags_fexamples:
347	-${RM} ${TAGSDIR}/TAGS_FEXAMPLES
348	-touch ${TAGSDIR}/TAGS_FEXAMPLES
349	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_FEXAMPLES ACTION=etags_examplesf alltree
350	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesfh alltree
351#
352# These are here for the target allci and allco, and etags
353#
354
355BMAKEFILES = bmake/common/base bmake/common/test \
356	     bmake/common/bopt* bmake/*/rules bmake/*/variables bmake/*/packages \
357	     bmake/*/petscconf.h bmake/*/petscfix.h bmake/config/packages.in \
358	     bmake/config/petscfix.h.in  bmake/config/rules.in  \
359	     bmake/config/variables.in bmake/adic.init bmake/adicmf.init
360DOCS	   = bmake/readme bmake/petscconf.defs
361SCRIPTS    = maint/builddist  maint/wwwman maint/xclude maint/crontab python/PETSc/Configure.py python/PETSc/Options.py \
362             python/PETSc/packages/ADIC.py python/PETSc/packages/MPE.py python/PETSc/packages/Mathematica.py \
363             python/PETSc/packages/PLAPACK.py python/PETSc/packages/Triangle.py python/PETSc/packages/Matlab.py \
364             python/PETSc/packages/PVODE.py python/PETSc/packages/BlasLapack.py python/PETSc/packages/MPI.py \
365             python/PETSc/packages/BlockSolve.py python/PETSc/packages/NetCDF.py python/PETSc/packages/ParMetis.py \
366             python/PETSc/packages/update.py maint/confignightly/* config/*.py
367
368
369updatewebdocs:
370	-chmod -R ug+w /mcs/tmp/petsc-tmp
371	-chgrp -R petsc /mcs/tmp/petsc-tmp
372	-/bin/rm -rf /mcs/tmp/petscdocs
373	-/bin/cp -r /mcs/tmp/petsc-tmp/docs /mcs/tmp/petscdocs
374	-maint/update-docs.py /mcs/tmp/petscdocs
375	-find /mcs/tmp/petscdocs -type d -name "*" -exec chmod g+w {} \;
376	-/bin/cp -r /mcs/tmp/petscdocs/* ${PETSC_DIR}/docs
377	-/bin/rm -rf /mcs/tmp/petscdocs
378
379chk_loc:
380	@if [ ${LOC}foo = foo ] ; then \
381	  echo "*********************** ERROR ************************" ; \
382	  echo " Please specify LOC variable for eg: make allmanualpages LOC=/sandbox/petsc"; \
383	  echo "******************************************************";  false; fi
384
385# Builds all the documentation - should be done every night
386alldoc: alldoc1 alldoc2
387
388# Build everything that goes into 'doc' dir except html sources
389alldoc1: chk_loc deletemanualpages chk_concepts_dir
390	-${OMAKE} ACTION=manualpages_buildcite tree_basic LOC=${LOC}
391	cd docs/tex/manual; ${OMAKE} manual.pdf LOC=${LOC}
392	-${OMAKE} ACTION=manualpages tree_basic LOC=${LOC}
393	-maint/wwwindex.py ${PETSC_DIR} ${LOC}
394	-${OMAKE} ACTION=manexamples tree LOC=${LOC}
395	-${OMAKE} manconcepts LOC=${LOC}
396	-${OMAKE} ACTION=getexlist tree LOC=${LOC}
397	-${OMAKE} ACTION=exampleconcepts tree LOC=${LOC}
398	-maint/helpindex.py ${PETSC_DIR} ${LOC}
399
400# Builds .html versions of the source
401# html overwrites some stuff created by update-docs - hence this is done later.
402alldoc2: chk_loc
403	-${OMAKE} ACTION=html PETSC_DIR=${PETSC_DIR} alltree LOC=${LOC}
404	-maint/update-docs.py ${LOC}
405
406alldocclean: deletemanualpages allcleanhtml
407
408# Deletes man pages (HTML version)
409deletemanualpages: chk_loc
410	find ${LOC}/docs/manualpages -type f -name "*.html" -exec ${RM} {} \;
411	${RM} ${LOC}/docs/tex/exampleconcepts
412	${RM} ${LOC}/docs/tex/manconcepts
413	${RM} ${LOC}/docs/manualpages/manualpages.cit
414	-maint/update-docs.py ${LOC} clean
415
416allcleanhtml:
417	-${RM} include/adic/*.h.html include/esi/petsc/*.h.html
418	-${OMAKE} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} alltree
419
420chk_concepts_dir: chk_loc
421	@if [ ! -d "${LOC}/docs/manualpages/concepts" ]; then \
422	  echo Making directory ${LOC}/docs/manualpages/concepts for library; ${MKDIR} ${LOC}/docs/manualpages/concepts; fi
423#
424#  checks if should build Fortran stubs
425chk_fortranstubs:
426	-@if [ ! -f "${PETSC_DIR}/src/fortran/auto/makefile.src" -a "${C_FC}" != "" ]; then \
427          ${OMAKE} PETSC_DIR=${PETSC_DIR} allfortranstubs ;\
428        fi
429
430# Builds Fortran stub files
431allfortranstubs:
432	-@which ${BFORT} > /dev/null 2>&1;  \
433        if [ "$$?" != "0" ]; then \
434          echo "No bfort available, skipping building Fortran stubs";\
435        else \
436          ${RM} -f ${PETSC_DIR}/src/fortran/auto/*.c ;\
437	  touch ${PETSC_DIR}/src/fortran/auto/makefile.src ;\
438	  ${OMAKE} ACTION=fortranstubs tree_basic ;\
439	  cd ${PETSC_DIR}/src/fortran/auto; ${RM} makefile.src; echo SOURCEC = ` ls *.c | tr -s '\n' ' '` > makefile.src ;\
440	  cd ${PETSC_DIR}/src/fortran/auto; ${OMAKE} fixfortran ;\
441        fi
442
443allci:
444	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=ci  alltree
445
446allco:
447	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=co  alltree
448
449# usage make allrcslabel NEW_RCS_LABEL=v_2_0_28
450allrcslabel:
451	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} NEW_RCS_LABEL=${NEW_RCS_LABEL} ACTION=rcslabel  alltree
452#
453#   The commands below are for generating ADIC versions of the code;
454# they are not currently used.
455#
456alladicignore:
457	-@${RM} ${INSTALL_LIB_DIR}/adicignore
458	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adicignore  tree
459
460alladic:
461	-@echo "Beginning to compile ADIC source code in all directories"
462	-@echo "Using ADIC compiler: ${ADIC_CC} ${CCPPFLAGS}"
463	-@echo "========================================="
464	-@cd include ; \
465           ${ADIC_CC} -s -f 1 ${CCPPFLAGS} petsc.h
466	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adic  tree
467	-@cd src/inline ; \
468            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} adic
469	-@cd src/blaslapack ; \
470            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adic  tree
471
472alladiclib:
473	-@echo "Beginning to compile ADIC libraries in all directories"
474	-@echo "Using compiler: ${CC} ${COPTFLAGS}"
475	-@echo "-----------------------------------------"
476	-@echo "Using PETSc flags: ${PETSCFLAGS} ${PCONF}"
477	-@echo "-----------------------------------------"
478	-@echo "Using configuration flags:"
479	-@grep "define " bmake/${INLUDE_ARCH}/petscconf.h
480	-@echo "-----------------------------------------"
481	-@echo "Using include paths: ${PETSC_INCLUDE}"
482	-@echo "-----------------------------------------"
483	-@echo "Using PETSc directory: ${PETSC_DIR}"
484	-@echo "Using PETSc arch: ${PETSC_ARCH}"
485	-@echo "========================================="
486	-@${RM} -f  ${INSTALL_LIB_DIR}/*adic.${LIB_SUFFIX}
487	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adiclib  tree
488	-@cd src/blaslapack ; \
489            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adiclib  tree
490	-@cd src/adic/src ; \
491            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} lib
492
493# -------------------------------------------------------------------------------
494#
495# Some macros to check if the fortran interface is up-to-date.
496#
497countfortranfunctions:
498	-@cd ${PETSC_DIR}/src/fortran; egrep '^void' custom/*.c auto/*.c | \
499	cut -d'(' -f1 | tr -s  ' ' | cut -d' ' -f2 | uniq | egrep -v "(^$$|Petsc)" | \
500	sed "s/_$$//" | sort > /tmp/countfortranfunctions
501
502countcfunctions:
503	-@ grep extern ${PETSC_DIR}/include/*.h *.h | grep "(" | tr -s ' ' | \
504	cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' |  \
505	tr 'A-Z' 'a-z' |  sort > /tmp/countcfunctions
506
507difffortranfunctions: countfortranfunctions countcfunctions
508	-@echo -------------- Functions missing in the fortran interface ---------------------
509	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2
510	-@echo ----------------- Functions missing in the C interface ------------------------
511	-@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2
512	-@${RM}  /tmp/countcfunctions /tmp/countfortranfunctions
513
514checkbadfortranstubs:
515	-@echo "========================================="
516	-@echo "Functions with MPI_Comm as an Argument"
517	-@echo "========================================="
518	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \
519	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
520	-@echo "========================================="
521	-@echo "Functions with a String as an Argument"
522	-@echo "========================================="
523	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \
524	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
525	-@echo "========================================="
526	-@echo "Functions with Pointers to PETSc Objects as Argument"
527	-@echo "========================================="
528	-@cd ${PETSC_DIR}/src/fortran/auto; \
529	_p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \
530	cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \
531	sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \
532	for OBJ in $$_p_OBJ; do \
533	grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \
534	cut -d'(' -f1 | cut -d' ' -f1,3; \
535	done
536#
537# Automatically generates PETSc exercises in html from the tutorial examples.
538#
539# The introduction for each section is obtained from docs/manualpages/header_${MANSEC} is under RCS and may be edited
540#  (used also in introductions to the manual pages)
541# The overall introduction is in docs/exercises/introduction.html and is under RCS and may be edited
542# The list of exercises is from TUTORIALS in each directory's makefile
543#
544# DO NOT EDIT the pageform.txt or *.htm files generated since they will be automatically replaced.
545# The pagemaker rule is in the file bmake/common (at the bottom)
546#
547# Eventually the line below will replace the two cd in the rule below, it is just this way now for speed
548#	-@${OMAKE} PETSC_DIR=${PETSC_DIR} pagemaker
549#
550exercises:
551	-@echo "========================================="
552	-@echo "Generating HTML tutorial exercises"
553	-@${RM} docs/pageform.txt
554	-@echo "title=\"PETSc Exercises\""                >  docs/pageform.txt
555	-@echo "access_title=Exercise Sections"              >>  docs/pageform.txt
556	-@echo "access_format=short"                        >> docs/pageform.txt
557	-@echo "startpage=../exercises/introduction.htm"  >> docs/pageform.txt
558	-@echo "NONE title=\"Introduction\" command=link src=../exercises/introduction.htm" >> docs/pageform.txt
559	-@echo "Generating HTML for individual directories"
560	-@echo "========================================="
561	-@${OMAKE} PETSC_DIR=${PETSC_DIR} ACTION=pagemaker tree
562	-@echo "Completed HTML for individual directories"
563	-@echo "NONE title=\"<HR>\" " >> docs/pageform.txt;
564	-@echo "NONE title=\"PETSc Documentation\" command=link src=../index.html target=replace" >> docs/pageform.txt
565	/home/MPI/class/mpiexmpl/maint/makepage.new -pageform=docs/pageform.txt -access_extra=/dev/null -outdir=docs/exercises
566	-@echo "========================================="
567
568# Make a tarball of all the Python code
569#   This is currently used to release to the Teragrid
570petscPython.tgz:
571	@tar cvzf $@ --exclude SCCS --exclude BitKeeper --dereference python/
572	-@scp $@ tg-login2.uc.teragrid.org:./
573
574.PHONY: info info_h all all_build build testexamples testfortran testexamples_uni testfortran_uni ranlib deletelibs allclean update chk_petsc_dir \
575        alletags etags etags_complete etags_noexamples etags_makefiles etags_examples etags_fexamples updatewebdocs alldoc allmanualpages \
576        allhtml allcleanhtml allfortranstubs allci allco allrcslabel alladicignore alladic alladiclib countfortranfunctions \
577        start_configure configure_petsc configure_clean petscPython.tgz
578
579