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