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