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