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