xref: /petsc/makefile (revision f20f7ba3cb2804ff5410e1781a7b8ded5d5761a2)
1# $Id: makefile,v 1.254 1999/01/27 23:08:53 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	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS ACTION=etags_examplesc alltree
194	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS ACTION=etags_examplesf alltree
195	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS ACTION=etags_examplesh alltree
196	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS ACTION=etags_makefile alltree
197	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS etags_bmakefiles
198	-chmod g+w TAGS
199# Builds complete etags list; only for PETSc developers.
200etags_complete:
201	-${RM} ${PETSC_DIR}/TAGS_COMPLETE
202	-touch ${PETSC_DIR}/TAGS_COMPLETE
203	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_COMPLETE ACTION=etags_sourcec alltree
204	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_COMPLETE ACTION=etags_sourceh alltree
205	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_COMPLETE ACTION=etags_examplesc alltree
206	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_COMPLETE ACTION=etags_examplesf alltree
207	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_COMPLETE ACTION=etags_examplesh alltree
208	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_COMPLETE ACTION=etags_makefile alltree
209	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_COMPLETE etags_bmakefiles
210	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_COMPLETE ACTION=etags_docs alltree
211	-chmod g+w TAGS_COMPLETE
212# Builds the etags file that excludes the examples directories
213etags_noexamples:
214	-${RM} ${PETSC_DIR}/TAGS_NO_EXAMPLES
215	-touch ${PETSC_DIR}/TAGS_NO_EXAMPLES
216	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_NO_EXAMPLES ACTION=etags_sourcec alltree
217	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_NO_EXAMPLES ACTION=etags_sourceh alltree
218	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_NO_EXAMPLES ACTION=etags_makefile alltree
219	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_NO_EXAMPLES etags_bmakefiles
220	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_NO_EXAMPLES ACTION=etags_docs alltree
221	-chmod g+w TAGS_NO_EXAMPLES
222# Builds the etags file for makefiles
223etags_makefiles:
224	-${RM} ${PETSC_DIR}/TAGS_MAKEFILE
225	-touch ${PETSC_DIR}/TAGS_MAKEFILE
226	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_MAKEFILE ACTION=etags_makefile alltree
227	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_MAKEFILE etags_bmakefiles
228	-chmod g+w TAGS_MAKEFILE
229# Builds the etags file for examples
230etags_examples:
231	-${RM} ${PETSC_DIR}/TAGS_EXAMPLES
232	-touch ${PETSC_DIR}/TAGS_EXAMPLES
233	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_EXAMPLES ACTION=etags_examplesc alltree
234	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_EXAMPLES ACTION=etags_examplesh alltree
235	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_EXAMPLES ACTION=etags_examplesf alltree
236	-chmod g+w TAGS_EXAMPLES
237etags_fexamples:
238	-${RM} ${PETSC_DIR}/TAGS_FEXAMPLES
239	-touch ${PETSC_DIR}/TAGS_FEXAMPLES
240	-make PETSC_DIR=${PETSC_DIR} TAGSFILE=${PETSC_DIR}/TAGS_FEXAMPLES ACTION=etags_examplesf alltree
241	-chmod g+w TAGS_FEXAMPLES
242
243#
244# These are here for the target allci and allco, and etags
245#
246
247BMAKEFILES = bmake/common* bmake/*/base* bmake/*/petscconf.h
248DOCS	   = maint/addlinks maint/builddist maint/buildlinks maint/wwwman \
249	     maint/xclude maint/crontab bmake/common bmake/*/base* \
250	     maint/autoftp include/foldinclude/generateincludes \
251	     bin/petscviewinfo.text bin/petscoptsinfo.text \
252	     bmake/*/petscconf.h bmake/readme bmake/petscconf.defs
253
254# Deletes man pages (HTML version)
255deletemanualpages:
256	${RM} -f ${PETSC_DIR}/docs/manualpages/man*/* \
257                 ${PETSC_DIR}/docs/manualpages/man?.html \
258                 ${PETSC_DIR}/docs/manualpages/manualpages.cit
259
260# Deletes man pages (LaTeX version)
261deletelatexpages:
262	${RM} -f ${PETSC_DIR}/docs/tex/rsum/*sum*.tex
263
264# Builds all versions of the man pages
265allmanpages: allmanualpages alllatexpages
266allmanualpages: deletemanualpages
267	-${OMAKE} ACTION=manualpages_buildcite tree
268	-cd src/fortran/custom; ${OMAKE} manualpages_buildcite
269	-cd src/fortran/custom; ${OMAKE} manualpages
270	-${OMAKE} ACTION=manualpages tree
271	-maint/wwwindex.py ${PETSC_DIR}
272	-maint/examplesindex.tcl
273	-maint/htmlkeywords.tcl
274	-@chmod g+w docs/manualpages/man*/*
275
276alllatexpages: deletelatexpages
277	-${OMAKE} ACTION=latexpages tree
278	-cd src/fortran/custom; ${OMAKE} latexpages
279	-@chmod g+w docs/tex/rsum/*
280
281# Builds Fortran stub files
282allfortranstubs:
283	-@include/foldinclude/generateincludes
284	-@${RM} -f src/fortran/auto/*.c
285	-${OMAKE} ACTION=fortranstubs tree
286	-@cd src/fortran/auto; ${OMAKE} -f makefile fixfortran
287	chmod g+w src/fortran/auto/*.c
288
289allci:
290	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=ci  alltree
291
292allco:
293	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=co  alltree
294
295#
296#   The commands below are for generating ADIC versions of the code;
297# they are not currently used.
298#
299alladicignore:
300	-@${RM} ${PDIR}/adicignore
301	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adicignore  tree
302
303alladic:
304	-@echo "Beginning to compile ADIC source code in all directories"
305	-@echo "Using ADIC compiler: ${ADIC_CC} ${CCPPFLAGS}"
306	-@echo "========================================="
307	-@cd include ; \
308           ${ADIC_CC} -s -f 1 ${CCPPFLAGS} petsc.h
309	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adic  tree
310	-@cd src/inline ; \
311            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} adic
312	-@cd src/blaslapack ; \
313            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adic  tree
314
315alladiclib:
316	-@echo "Beginning to compile ADIC libraries in all directories"
317	-@echo "Using compiler: ${CC} ${COPTFLAGS}"
318	-@echo "-----------------------------------------"
319	-@echo "Using PETSc flags: ${PETSCFLAGS} ${PCONF}"
320	-@echo "-----------------------------------------"
321	-@echo "Using configuration flags:"
322	-@grep "define " bmake/${PETSC_ARCH}/petscconf.h
323	-@echo "-----------------------------------------"
324	-@echo "Using include paths: ${PETSC_INCLUDE}"
325	-@echo "-----------------------------------------"
326	-@echo "Using PETSc directory: ${PETSC_DIR}"
327	-@echo "Using PETSc arch: ${PETSC_ARCH}"
328	-@echo "========================================="
329	-@${RM} -f  ${PDIR}/*adic.a
330	-@${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adiclib  tree
331	-@cd src/blaslapack ; \
332            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} ACTION=adiclib  tree
333	-@cd src/adic/src ; \
334            ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} lib
335
336# -------------------------------------------------------------------------------
337#
338# Some macros to check if the fortran interface is up-to-date.
339#
340countfortranfunctions:
341	-@cd ${PETSC_DIR}/src/fortran; egrep '^void' custom/*.c auto/*.c | \
342	cut -d'(' -f1 | tr -s '' ' ' | cut -d' ' -f2 | uniq | egrep -v "(^$$|Petsc)" | \
343	sed "s/_$$//" | sort > /tmp/countfortranfunctions
344
345countcfunctions:
346	-@ grep extern ${PETSC_DIR}/include/*.h *.h | grep "(" | tr -s '' ' ' | \
347	cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '' '\012' |  \
348	tr 'A-Z' 'a-z' |  sort > /tmp/countcfunctions
349
350difffortranfunctions: countfortranfunctions countcfunctions
351	-@echo -------------- Functions missing in the fortran interface ---------------------
352	-@diff /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2
353	-@echo ----------------- Functions missing in the C interface ------------------------
354	-@diff /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2
355	-@${RM}  /tmp/countcfunctions /tmp/countfortranfunctions
356
357checkbadfortranstubs:
358	-@echo "========================================="
359	-@echo "Functions with MPI_Comm as an Argument"
360	-@echo "========================================="
361	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \
362	tr -s '' ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
363	-@echo "========================================="
364	-@echo "Functions with a String as an Argument"
365	-@echo "========================================="
366	-@cd ${PETSC_DIR}/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \
367	tr -s '' ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
368	-@echo "========================================="
369	-@echo "Functions with Pointers to PETSc Objects as Argument"
370	-@echo "========================================="
371	-@cd ${PETSC_DIR}/src/fortran/auto; \
372	_p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s '' ' ' | \
373	cut -d' ' -f 3 | tr -s '' '\012' | grep -v '{' | cut -d'*' -f1 | \
374	sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \
375	for OBJ in $$_p_OBJ; do \
376	grep "$$OBJ \*" *.c | tr -s '' ' ' | tr -s ':' ' ' | \
377	cut -d'(' -f1 | cut -d' ' -f1,3; \
378	done
379# Builds noise routines (not yet publically available)
380# Note:	 libfast cannot run on .F files on certain machines, so we
381# use lib and check for errors here.
382noise: info chkpetsc_dir
383	-@echo "Beginning to compile noise routines"
384	-@echo "========================================="
385	-@cd src/snes/interface/noise; \
386	  ${OMAKE} BOPT=${BOPT} PETSC_ARCH=${PETSC_ARCH} lib > trashz 2>&1; \
387	  grep -v clog trashz | grep -v "information sections" | \
388	  egrep -i '(Error|warning|Can)' >> /dev/null;\
389	  if [ "$$?" != 1 ]; then \
390	  cat trashz ; fi; ${RM} trashz
391	${RANLIB} ${PDIR}/libpetscsnes.a
392	-@chmod g+w  ${PDIR}/libpetscsnes.a
393	-@echo "Completed compiling noise routines"
394	-@echo "========================================="
395
396