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