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