xref: /petsc/makefile (revision d76296fb008fad0778941da6aa631b87f579d18a)
1# $Id: makefile,v 1.281 1999/04/06 19:19:15 bsmith Exp bsmith $
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_time
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/*/petscconf.h bmake/win32/makefile.dos
238DOCS	   = bmake/readme bmake/petscconf.defs
239SCRIPTS    = maint/addlinks maint/builddist maint/buildlinks maint/wwwman \
240	     maint/xclude maint/crontab  \
241	     maint/autoftp include/foldinclude/generateincludes
242
243# Builds all the documentation - should be done every night
244alldoc: allmanpages
245	cd docs/tex/manual; ${OMAKE} manual.dvi manual.ps manual.html splitmanual.html
246
247# Deletes man pages (HTML version)
248deletemanualpages:
249	${RM} -f ${PETSC_DIR}/docs/manualpages/*/*.html \
250                 ${PETSC_DIR}/docs/manualpages/manualpages.cit
251
252# Deletes man pages (LaTeX version)
253deletelatexpages:
254	${RM} -f ${PETSC_DIR}/docs/tex/rsum/*sum*.tex
255
256# Builds all versions of the man pages
257allmanpages: allmanualpages alllatexpages
258allmanualpages: deletemanualpages
259	-${OMAKE} ACTION=manualpages_buildcite tree
260	-${OMAKE} ACTION=manualpages tree
261	-maint/wwwindex.py ${PETSC_DIR}
262	-maint/examplesindex.tcl
263	-maint/htmlkeywords.tcl
264	-@chmod g+w docs/manualpages/*/*.html
265
266alllatexpages: deletelatexpages
267	-${OMAKE} ACTION=latexpages tree
268	-@chmod g+w docs/tex/rsum/*
269
270# Builds Fortran stub files
271allfortranstubs:
272	-@include/foldinclude/generateincludes
273	-@${RM} -f src/fortran/auto/*.c
274	-${OMAKE} ACTION=fortranstubs tree
275	-@cd src/fortran/auto; ${OMAKE} -f makefile fixfortran
276	chmod g+w src/fortran/auto/*.c
277
278allci:
279	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=ci  alltree
280
281allco:
282	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=co  alltree
283
284#
285#   The commands below are for generating ADIC versions of the code;
286# they are not currently used.
287#
288alladicignore:
289	-@${RM} ${PDIR}/adicignore
290	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adicignore  tree
291
292alladic:
293	-@echo "Beginning to compile ADIC source code in all directories"
294	-@echo "Using ADIC compiler: ${ADIC_CC} ${CCPPFLAGS}"
295	-@echo "========================================="
296	-@cd include ; \
297           ${ADIC_CC} -s -f 1 ${CCPPFLAGS} petsc.h
298	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adic  tree
299	-@cd src/inline ; \
300            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} adic
301	-@cd src/blaslapack ; \
302            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adic  tree
303
304alladiclib:
305	-@echo "Beginning to compile ADIC libraries in all directories"
306	-@echo "Using compiler: ${CC} ${COPTFLAGS}"
307	-@echo "-----------------------------------------"
308	-@echo "Using PETSc flags: ${PETSCFLAGS} ${PCONF}"
309	-@echo "-----------------------------------------"
310	-@echo "Using configuration flags:"
311	-@grep "define " bmake/${PETSC_ARCH}/petscconf.h
312	-@echo "-----------------------------------------"
313	-@echo "Using include paths: ${PETSC_INCLUDE}"
314	-@echo "-----------------------------------------"
315	-@echo "Using PETSc directory: ${PETSC_DIR}"
316	-@echo "Using PETSc arch: ${PETSC_ARCH}"
317	-@echo "========================================="
318	-@${RM} -f  ${PDIR}/*adic.a
319	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adiclib  tree
320	-@cd src/blaslapack ; \
321            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adiclib  tree
322	-@cd src/adic/src ; \
323            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} lib
324
325# -------------------------------------------------------------------------------
326#
327# Some macros to check if the fortran interface is up-to-date.
328#
329countfortranfunctions:
330	-@cd ${PETSC_DIR}/src/fortran; egrep '^void' custom/*.c auto/*.c | \
331	cut -d'(' -f1 | tr -s  ' ' | cut -d' ' -f2 | uniq | egrep -v "(^$$|Petsc)" | \
332	sed "s/_$$//" | sort > /tmp/countfortranfunctions
333
334countcfunctions:
335	-@ grep extern ${PETSC_DIR}/include/*.h *.h | grep "(" | tr -s ' ' | \
336	cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' |  \
337	tr 'A-Z' 'a-z' |  sort > /tmp/countcfunctions
338
339difffortranfunctions: countfortranfunctions countcfunctions
340	-@echo -------------- Functions missing in the fortran interface ---------------------
341	-@diff /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2
342	-@echo ----------------- Functions missing in the C interface ------------------------
343	-@diff /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2
344	-@${RM}  /tmp/countcfunctions /tmp/countfortranfunctions
345
346checkbadfortranstubs:
347	-@echo "========================================="
348	-@echo "Functions with MPI_Comm as an Argument"
349	-@echo "========================================="
350	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \
351	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
352	-@echo "========================================="
353	-@echo "Functions with a String as an Argument"
354	-@echo "========================================="
355	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \
356	tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
357	-@echo "========================================="
358	-@echo "Functions with Pointers to PETSc Objects as Argument"
359	-@echo "========================================="
360	-@cd ${PETSC_DIR}/src/fortran/auto; \
361	_p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \
362	cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \
363	sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \
364	for OBJ in $$_p_OBJ; do \
365	grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \
366	cut -d'(' -f1 | cut -d' ' -f1,3; \
367	done
368# Builds noise routines (not yet publically available)
369# Note:	 libfast cannot run on .F files on certain machines, so we
370# use lib and check for errors here.
371noise: info chkpetsc_dir
372	-@echo "Beginning to compile noise routines"
373	-@echo "========================================="
374	-@cd src/snes/interface/noise; \
375	  ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} lib > trashz 2>&1; \
376	  grep -v clog trashz | grep -v "information sections" | \
377	  egrep -i '(Error|warning|Can)' >> /dev/null;\
378	  if [ "$$?" != 1 ]; then \
379	  cat trashz ; fi; ${RM} trashz
380	${RANLIB} ${PDIR}/libpetscsnes.a
381	-@chmod g+w  ${PDIR}/libpetscsnes.a
382	-@echo "Completed compiling noise routines"
383	-@echo "========================================="
384
385