xref: /petsc/makefile (revision 549d3d68a6ae470532d58d544870024f02ff2d7c)
1# $Id: makefile,v 1.286 1999/04/18 07:10:49 balay Exp balay $
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
8
9DIRS	   = src include docs
10
11include ${PETSC_DIR}/bmake/${PETSC_ARCH}/base
12
13#
14# Basic targets to build PETSc libraries.
15# all     : builds the c, fortran, and f90 libraries
16all       : info chkpetsc_dir deletelibs build_c build_fortran shared
17#
18# Prints information about the system and version of PETSc being compiled
19#
20info:
21	-@echo "=========================================="
22	-@echo "See docs/troubleshooting.html and docs/bugreporting.html"
23	-@echo "for help with installation problems. Please send EVERYTHING"
24	-@echo "printed out below when reporting problems"
25	-@echo "=========================================="
26	-@echo On `date` on `hostname`
27	-@echo Machine characteristics: `uname -a`
28	-@echo "-----------------------------------------"
29	-@echo "Using C compiler: ${CC} ${COPTFLAGS} ${CCPPFLAGS}"
30	-@if [ -n "${CCV}" -a "${CCV}" != "unknown" ] ; then \
31	  echo "Compiler version:" `${CCV}` ; fi
32	-@echo "Using Fortran compiler: ${FC} ${FOPTFLAGS} ${FCPPFLAGS}"
33	-@echo "-----------------------------------------"
34	-@grep PETSC_VERSION_NUMBER include/petsc.h | sed "s/........//"
35	-@echo "-----------------------------------------"
36	-@echo "Using PETSc flags: ${PETSCFLAGS} ${PCONF}"
37	-@echo "-----------------------------------------"
38	-@echo "Using configuration flags:"
39	-@grep "define " bmake/${PETSC_ARCH}/petscconf.h
40	-@echo "-----------------------------------------"
41	-@echo "Using include paths: ${PETSC_INCLUDE}"
42	-@echo "-----------------------------------------"
43	-@echo "Using PETSc directory: ${PETSC_DIR}"
44	-@echo "Using PETSc arch: ${PETSC_ARCH}"
45	-@echo "------------------------------------------"
46	-@echo "Using C linker: ${CLINKER}"
47	-@echo "Using Fortran linker: ${FLINKER}"
48	-@echo "Using libraries: ${PETSC_LIB}"
49	-@echo "=========================================="
50
51#
52# Builds the PETSc libraries
53# This target also builds fortran77 and f90 interface
54# files. (except compiling *.F files)
55#
56build_c:
57	-@echo "BEGINNING TO COMPILE LIBRARIES IN ALL DIRECTORIES"
58	-@echo "========================================="
59	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=libfast  tree
60	-@cd ${PETSC_DIR}/src/sys/src/time ; \
61	${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} rs6000_asmtime
62	${RANLIB} ${PDIR}/*.a
63	-@chmod g+w  ${PDIR}/*.a
64	-@echo "Completed building libraries"
65	-@echo "========================================="
66
67#
68# Builds PETSc Fortran source
69# Note:	 libfast cannot run on .F files on certain machines, so we
70# use libf to compile the fortran source files.
71#
72build_fortran:
73	-@echo "BEGINNING TO COMPILE FORTRAN SOURCE"
74	-@echo "========================================="
75	-@cd src/fortran/custom; \
76	  ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} libf clean
77	-@cd src/fortran/kernels; \
78	  ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} libf clean
79	${RANLIB} ${PDIR}/libpetscfortran.a
80	${RANLIB} ${PDIR}/libpetsc.a
81	-@chmod g+w  ${PDIR}/*.a
82	-@echo "Completed compiling Fortran source"
83	-@echo "========================================="
84
85petscblas: info chkpetsc_dir
86	-${RM} -f ${PDIR}/libpetscblas.*
87	-@echo "BEGINNING TO COMPILE C VERSION OF BLAS AND LAPACK"
88	-@echo "========================================="
89	-@cd src/blaslapack; \
90	  ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=libfast tree
91	${RANLIB} ${PDIR}/libpetscblas.a
92	-@chmod g+w  ${PDIR}/*.a
93	-@echo "Completed compiling C version of BLAS and LAPACK"
94	-@echo "========================================="
95
96
97# Builds PETSc test examples for a given BOPT and architecture
98testexamples: info chkopts
99	-@echo "BEGINNING TO COMPILE AND RUN TEST EXAMPLES"
100	-@echo "Due to different numerical round-off on certain"
101	-@echo "machines some of the numbers may not match exactly."
102	-@echo "========================================="
103	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} \
104	   ACTION=testexamples_1  tree
105	-@echo "Completed compiling and running test examples"
106	-@echo "========================================="
107
108# Builds PETSc test examples for a given BOPT and architecture
109testfortran: info chkopts
110	-@echo "BEGINNING TO COMPILE AND RUN FORTRAN TEST EXAMPLES"
111	-@echo "========================================="
112	-@echo "Due to different numerical round-off on certain"
113	-@echo "machines or the way Fortran formats numbers"
114	-@echo "some of the results may not match exactly."
115	-@echo "========================================="
116	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} \
117	   ACTION=testexamples_3  tree
118	-@echo "Completed compiling and running Fortran test examples"
119	-@echo "========================================="
120
121# Builds PETSc test examples for a given BOPT and architecture
122testexamples_uni: info chkopts
123	-@echo "BEGINNING TO COMPILE AND RUN TEST UNI-PROCESSOR EXAMPLES"
124	-@echo "Due to different numerical round-off on certain"
125	-@echo "machines some of the numbers may not match exactly."
126	-@echo "========================================="
127	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} \
128	   ACTION=testexamples_4  tree
129	-@echo "Completed compiling and running uniprocessor test examples"
130	-@echo "========================================="
131testfortran_uni: info chkopts
132	-@echo "BEGINNING TO COMPILE AND RUN TEST UNI-PROCESSOR FORTRAN EXAMPLES"
133	-@echo "Due to different numerical round-off on certain"
134	-@echo "machines some of the numbers may not match exactly."
135	-@echo "========================================="
136	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} \
137	   ACTION=testexamples_9  tree
138	-@echo "Completed compiling and running uniprocessor fortran test examples"
139	-@echo "========================================="
140
141# Ranlib on the libraries
142ranlib:
143	${RANLIB} ${PDIR}/*.a
144
145# Deletes PETSc libraries
146deletelibs: chkopts_basic
147	-${RM} -f ${PDIR}/*
148
149
150# ------------------------------------------------------------------
151#
152# All remaining actions are intended for PETSc developers only.
153# PETSc users should not generally need to use these commands.
154#
155
156# To access the tags in EMACS, type M-x visit-tags-table and specify
157# the file petsc/TAGS.
158# 1) To move to where a PETSc function is defined, enter M-. and the
159#     function name.
160# 2) To search for a string and move to the first occurrence,
161#     use M-x tags-search and the string.
162#     To locate later occurrences, use M-,
163# Builds all etags files
164alletags:
165	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSDIR=${PETSC_DIR} etags
166	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSDIR=${PETSC_DIR} etags_complete
167	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSDIR=${PETSC_DIR} etags_noexamples
168	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSDIR=${PETSC_DIR} etags_examples
169	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSDIR=${PETSC_DIR} etags_makefiles
170# Builds the basic etags file.	This should be employed by most users.
171etags:
172	-${RM} ${TAGSDIR}/TAGS
173	-touch ${TAGSDIR}/TAGS
174	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_sourcec alltree
175	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_sourceh alltree
176	-cd src/fortran; ${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_sourcef alltree
177	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_examplesc alltree
178	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_examplesf alltree
179	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_examplesch alltree
180	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_examplesfh alltree
181	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS ACTION=etags_makefile alltree
182	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS etags_bmakefiles
183	-chmod g+w TAGS
184# Builds complete etags list; only for PETSc developers.
185etags_complete:
186	-${RM} ${TAGSDIR}/TAGS_COMPLETE
187	-touch ${TAGSDIR}/TAGS_COMPLETE
188	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_sourcec alltree
189	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_sourceh alltree
190	-cd src/fortran; ${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_sourcef alltree
191	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_examplesc alltree
192	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_examplesf alltree
193	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_examplesch alltree
194	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_examplesfh alltree
195	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_makefile alltree
196	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE etags_bmakefiles
197	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_docs alltree
198	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_COMPLETE ACTION=etags_scripts alltree
199	-chmod g+w TAGS_COMPLETE
200# Builds the etags file that excludes the examples directories
201etags_noexamples:
202	-${RM} ${TAGSDIR}/TAGS_NO_EXAMPLES
203	-touch ${TAGSDIR}/TAGS_NO_EXAMPLES
204	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_sourcec alltree
205	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_sourceh alltree
206	-cd src/fortran; ${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_sourcef alltree
207	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_makefile alltree
208	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES etags_bmakefiles
209	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_NO_EXAMPLES ACTION=etags_docs alltree
210	-chmod g+w TAGS_NO_EXAMPLES
211# Builds the etags file for makefiles
212etags_makefiles:
213	-${RM} ${TAGSDIR}/TAGS_MAKEFILES
214	-touch ${TAGSDIR}/TAGS_MAKEFILES
215	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_MAKEFILES ACTION=etags_makefile alltree
216	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_MAKEFILES etags_bmakefiles
217	-chmod g+w TAGS_MAKEFILES
218# Builds the etags file for examples
219etags_examples:
220	-${RM} ${TAGSDIR}/TAGS_EXAMPLES
221	-touch ${TAGSDIR}/TAGS_EXAMPLES
222	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesc alltree
223	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesch alltree
224	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesf alltree
225	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesfh alltree
226	-chmod g+w TAGS_EXAMPLES
227etags_fexamples:
228	-${RM} ${TAGSDIR}/TAGS_FEXAMPLES
229	-touch ${TAGSDIR}/TAGS_FEXAMPLES
230	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_FEXAMPLES ACTION=etags_examplesf alltree
231	-${OMAKE} PETSC_DIR=${PETSC_DIR} TAGSFILE=${TAGSDIR}/TAGS_EXAMPLES ACTION=etags_examplesfh alltree
232	-chmod g+w TAGS_FEXAMPLES
233#
234# These are here for the target allci and allco, and etags
235#
236
237BMAKEFILES = bmake/common* bmake/*/base bmake/*/base_variables bmake/base.site \
238	     bmake/*/petscconf.h bmake/win32/makefile.dos bin/config/base*.in
239DOCS	   = bmake/readme bmake/petscconf.defs
240SCRIPTS    = maint/addlinks maint/builddist maint/buildlinks maint/wwwman \
241	     maint/xclude maint/crontab  \
242	     maint/autoftp include/foldinclude/generateincludes
243
244# Builds all the documentation - should be done every night
245alldoc: allmanpages
246	cd docs/tex/manual; ${OMAKE} manual.dvi manual.ps manual.html splitmanual.html
247
248# Deletes man pages (HTML version)
249deletemanualpages:
250	${RM} -f ${PETSC_DIR}/docs/manualpages/*/*.html \
251                 ${PETSC_DIR}/docs/manualpages/manualpages.cit
252
253# Deletes man pages (LaTeX version)
254deletelatexpages:
255	${RM} -f ${PETSC_DIR}/docs/tex/rsum/*sum*.tex
256
257# Builds all versions of the man pages
258allmanpages: allmanualpages alllatexpages
259allmanualpages: deletemanualpages
260	-${OMAKE} ACTION=manualpages_buildcite tree
261	-${OMAKE} ACTION=manualpages tree
262	-maint/wwwindex.py ${PETSC_DIR}
263	-maint/examplesindex.tcl
264	-maint/htmlkeywords.tcl
265	-@chmod g+w docs/manualpages/*/*.html
266
267alllatexpages: deletelatexpages
268	-${OMAKE} ACTION=latexpages tree
269	-@chmod g+w docs/tex/rsum/*
270
271# Builds Fortran stub files
272allfortranstubs:
273	-@include/foldinclude/generateincludes
274	-@${RM} -f src/fortran/auto/*.c
275	-${OMAKE} ACTION=fortranstubs tree
276	-@cd src/fortran/auto; ${OMAKE} -f makefile fixfortran
277	chmod g+w src/fortran/auto/*.c
278
279allci:
280	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=ci  alltree
281
282allco:
283	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=co  alltree
284
285#
286#   The commands below are for generating ADIC versions of the code;
287# they are not currently used.
288#
289alladicignore:
290	-@${RM} ${PDIR}/adicignore
291	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adicignore  tree
292
293alladic:
294	-@echo "Beginning to compile ADIC source code in all directories"
295	-@echo "Using ADIC compiler: ${ADIC_CC} ${CCPPFLAGS}"
296	-@echo "========================================="
297	-@cd include ; \
298           ${ADIC_CC} -s -f 1 ${CCPPFLAGS} petsc.h
299	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adic  tree
300	-@cd src/inline ; \
301            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} adic
302	-@cd src/blaslapack ; \
303            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adic  tree
304
305alladiclib:
306	-@echo "Beginning to compile ADIC libraries in all directories"
307	-@echo "Using compiler: ${CC} ${COPTFLAGS}"
308	-@echo "-----------------------------------------"
309	-@echo "Using PETSc flags: ${PETSCFLAGS} ${PCONF}"
310	-@echo "-----------------------------------------"
311	-@echo "Using configuration flags:"
312	-@grep "define " bmake/${PETSC_ARCH}/petscconf.h
313	-@echo "-----------------------------------------"
314	-@echo "Using include paths: ${PETSC_INCLUDE}"
315	-@echo "-----------------------------------------"
316	-@echo "Using PETSc directory: ${PETSC_DIR}"
317	-@echo "Using PETSc arch: ${PETSC_ARCH}"
318	-@echo "========================================="
319	-@${RM} -f  ${PDIR}/*adic.a
320	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adiclib  tree
321	-@cd src/blaslapack ; \
322            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adiclib  tree
323	-@cd src/adic/src ; \
324            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} lib
325
326# -------------------------------------------------------------------------------
327#
328# Some macros to check if the fortran interface is up-to-date.
329#
330countfortranfunctions:
331	-@cd ${PETSC_DIR}/src/fortran; egrep '^void' custom/*.c auto/*.c | \
332	cut -d'(' -f1 | tr -s  ' ' | cut -d' ' -f2 | uniq | egrep -v "(^$$|Petsc)" | \
333	sed "s/_$$//" | sort > /tmp/countfortranfunctions
334
335countcfunctions:
336	-@ grep extern ${PETSC_DIR}/include/*.h *.h | grep "(" | tr -s ' ' | \
337	cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' |  \
338	tr 'A-Z' 'a-z' |  sort > /tmp/countcfunctions
339
340difffortranfunctions: countfortranfunctions countcfunctions
341	-@echo -------------- Functions missing in the fortran interface ---------------------
342	-@diff /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2
343	-@echo ----------------- Functions missing in the C interface ------------------------
344	-@diff /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2
345	-@${RM}  /tmp/countcfunctions /tmp/countfortranfunctions
346
347checkbadfortranstubs:
348	-@echo "========================================="
349	-@echo "Functions with MPI_Comm as an Argument"
350	-@echo "========================================="
351	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \
352	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
353	-@echo "========================================="
354	-@echo "Functions with a String as an Argument"
355	-@echo "========================================="
356	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \
357	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
358	-@echo "========================================="
359	-@echo "Functions with Pointers to PETSc Objects as Argument"
360	-@echo "========================================="
361	-@cd ${PETSC_DIR}/src/fortran/auto; \
362	_p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \
363	cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \
364	sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \
365	for OBJ in $$_p_OBJ; do \
366	grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \
367	cut -d'(' -f1 | cut -d' ' -f1,3; \
368	done
369# Builds noise routines (not yet publically available)
370# Note:	 libfast cannot run on .F files on certain machines, so we
371# use lib and check for errors here.
372noise: info chkpetsc_dir
373	-@echo "Beginning to compile noise routines"
374	-@echo "========================================="
375	-@cd src/snes/interface/noise; \
376	  ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} lib > trashz 2>&1; \
377	  grep -v clog trashz | grep -v "information sections" | \
378	  egrep -i '(Error|warning|Can)' >> /dev/null;\
379	  if [ "$$?" != 1 ]; then \
380	  cat trashz ; fi; ${RM} trashz
381	${RANLIB} ${PDIR}/libpetscsnes.a
382	-@chmod g+w  ${PDIR}/libpetscsnes.a
383	-@echo "Completed compiling noise routines"
384	-@echo "========================================="
385
386