xref: /petsc/makefile (revision 837231ba0dd6f27a681e729565b34e12ca14c2d6)
1# $Id: makefile,v 1.198 1997/10/20 02:26:18 curfman Exp bsmith $
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#
7
8CFLAGS	 =
9SOURCEC	 =
10SOURCEF	 =
11DOCS	 = docs/Changes.html docs/Machines.html Readme.html maint/addlinks \
12	   maint/builddist docs/FAQ.html docs/Installation.html docs/BugReporting.html\
13           docs/Troubleshooting.html docs/Changes.html docs/CodeManagement.html \
14	   maint/buildlinks maint/wwwman maint/xclude maint/crontab\
15	   bmake/common bmake/*/base* maint/autoftp docs/www/sec/* \
16           include/finclude/generateincludes bin/petscviewinfo.text \
17           bin/petscoptsinfo.text
18OBJSC	 =
19OBJSF	 =
20LIBBASE	 = libpetscvec
21DIRS	 = src include docs
22
23include $(PETSC_DIR)/bmake/$(PETSC_ARCH)/base
24
25#
26#  Prints information about the system and PETSc being compiled
27#
28info:
29	-@echo "=========================================="
30	-@echo On `date` on `hostname`
31	-@echo Machine characteristics: `uname -a`
32	-@echo "-----------------------------------------"
33	-@echo "Using C compiler: $(CC) $(COPTFLAGS)"
34	-@if [ "$(CCV)" != "unknown" ] ; then \
35	  echo "Compiler version:" ; \
36          $(CCV) ; fi
37	-@echo "Using Fortran compiler: $(FC) $(FFLAGS) $(FOPTFLAGS)"
38	-@echo "-----------------------------------------"
39	-@grep PETSC_VERSION_NUMBER include/petsc.h | sed "s/........//"
40	-@echo "-----------------------------------------"
41	-@echo "Using PETSc flags: $(PETSCFLAGS) $(PCONF)"
42	-@echo "-----------------------------------------"
43	-@echo "Using configuration flags: $(CONF)"
44	-@echo "-----------------------------------------"
45	-@echo "Using include paths: $(PETSC_INCLUDE)"
46	-@echo "-----------------------------------------"
47	-@echo "Using PETSc directory: $(PETSC_DIR)"
48	-@echo "Using PETSc arch: $(PETSC_ARCH)"
49	-@echo "------------------------------------------"
50	-@echo "Using C linker: $(CLINKER)"
51	-@echo "Using libraries: $(PETSC_LIB)"
52	-@echo "Using Fortran linker: $(FLINKER)"
53	-@echo "Using Fortran libraries: $(PETSC_FORTRAN_LIB)"
54	-@echo "=========================================="
55
56# Builds PETSc libraries for a given BOPT and architecture
57all: info chkpetsc_dir deletelibs build_kernels
58	-@echo "BEGINNING TO COMPILE LIBRARIES IN ALL DIRECTORIES"
59	-@echo "========================================="
60	-@$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) \
61	   ACTION=libfast  tree
62	-@cd $(PETSC_DIR)/src/sys/src ; \
63	$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) rs6000_time
64	$(RANLIB) $(PDIR)/*.a
65	-@chmod g+w  $(PDIR)/*.a
66	-@echo "Completed building libraries"
67	-@echo "========================================="
68
69# Builds PETSc test examples for a given BOPT and architecture
70testexamples: info chkopts
71	-@echo "BEGINNING TO COMPILE AND RUN TEST EXAMPLES"
72	-@echo "Due to different numerical round-off on certain"
73	-@echo "machines some of the numbers may not match exactly."
74	-@echo "========================================="
75	-@$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) \
76	   ACTION=testexamples_1  tree
77	-@echo "Completed compiling and running test examples"
78	-@echo "========================================="
79
80# Builds PETSc test examples for a given BOPT and architecture
81testexamples_uni: info chkopts
82	-@echo "BEGINNING TO COMPILE AND RUN TEST UNI-PROCESSOR EXAMPLES"
83	-@echo "Due to different numerical round-off on certain"
84	-@echo "machines some of the numbers may not match exactly."
85	-@echo "========================================="
86	-@$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) \
87	   ACTION=testexamples_4  tree
88	-@echo "Completed compiling and running uniprocessor test examples"
89	-@echo "========================================="
90
91#
92# Builds PETSc Fortran interface libary
93# Note:	 libfast cannot run on .F files on certain machines, so we
94# use lib and check for errors here.
95fortran: info chkpetsc_dir
96	-@echo "BEGINNING TO COMPILE FORTRAN INTERFACE LIBRARY"
97	-@echo "========================================="
98	-$(RM) -f $(PDIR)/libpetscfortran.*
99	-@cd src/fortran/custom; \
100	  $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) lib > trashz 2>&1; \
101	  grep -v clog trashz | grep -v "information sections" | \
102	  egrep -i '(Error|warning|Can)' >> /dev/null;\
103	  if [ "$$?" != 1 ]; then \
104	  cat trashz ; fi; $(RM) trashz
105	-@cd src/fortran/auto; \
106	  $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) libfast
107	$(RANLIB) $(PDIR)/libpetscfortran.a
108	-@chmod g+w  $(PDIR)/*.a
109	-@echo "Completed compiling Fortran interface library"
110	-@echo "========================================="
111
112#
113# Builds PETSc Fortran kernels; some numerical kernels have
114# a Fortran version that may give better performance on certain
115# machines. These always provide better performance for complex numbers.
116fortrankernels: info chkpetsc_dir
117	-$(RM) -f $(PDIR)/libpetsckernels.*
118	-@echo "BEGINNING TO COMPILE FORTRAN KERNELS LIBRARY"
119	-@echo "========================================="
120	-@cd src/fortran/kernels; \
121	  $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) lib
122	-@chmod g+w  $(PDIR)/*.a
123	-@echo "Completed compiling Fortran kernels library"
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	-@echo "On some machines you may get messages of the form"
135	-@echo "PetscScalarAddressToFortran:C and Fortran arrays are"
136	-@echo "not commonly aligned or are too far apart to be indexed"
137	-@echo "by an integer. Locations: C xxxc Fortran xxxf"
138	-@echo "Locations/sizeof(Scalar): C yyc Fortran yyf"
139	-@echo "This indicates that you may not be able to use the"
140	-@echo "PETSc routines VecGetArray() and MatGetArray() from Fortran"
141	-@echo "========================================="
142	-@$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) \
143	   ACTION=testexamples_3  tree
144	-@echo "Completed compiling and running Fortran test examples"
145	-@echo "========================================="
146#
147# Builds PETSc Fortran90 interface libary
148# Note:	 libfast cannot run on .F files on certain machines, so we
149# use lib and check for errors here.
150# Note: F90 interface currently only supported in NAG F90 compiler
151fortran90: info chkpetsc_dir fortran
152	-@echo "BEGINNING TO COMPILE FORTRAN90 INTERFACE LIBRARY"
153	-@echo "========================================="
154	-@cd src/fortran/f90; \
155	  $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) lib > trashz 2>&1; \
156	  grep -v clog trashz | grep -v "information sections" | \
157	  egrep -i '(Error|warning|Can)' >> /dev/null;\
158	  if [ "$$?" != 1 ]; then \
159	  cat trashz ; fi; $(RM) trashz
160	$(RANLIB) $(PDIR)/libpetscfortran.a
161	-@chmod g+w  $(PDIR)/*.a
162	-@echo "Completed compiling Fortran90 interface library"
163	-@echo "========================================="
164
165# Builds noise routines (not yet publically available)
166# Note:	 libfast cannot run on .F files on certain machines, so we
167# use lib and check for errors here.
168noise: info chkpetsc_dir
169	-@echo "Beginning to compile noise routines"
170	-@echo "========================================="
171	-@cd src/snes/interface/noise; \
172	  $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) lib > trashz 2>&1; \
173	  grep -v clog trashz | grep -v "information sections" | \
174	  egrep -i '(Error|warning|Can)' >> /dev/null;\
175	  if [ "$$?" != 1 ]; then \
176	  cat trashz ; fi; $(RM) trashz
177	$(RANLIB) $(PDIR)/libpetscsnes.a
178	-@chmod g+w  $(PDIR)/libpetscsnes.a
179	-@echo "Completed compiling noise routines"
180	-@echo "========================================="
181
182petscblas: info chkpetsc_dir
183	-$(RM) -f $(PDIR)/libpetscblas.*
184	-@echo "BEGINNING TO COMPILE C VERSION OF BLAS AND LAPACK"
185	-@echo "========================================="
186	-@cd src/adic/blas; \
187	  $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) libfast
188	-@cd src/adic/lapack; \
189	  $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) ACTION=libfast tree
190	$(RANLIB) $(PDIR)/libpetscblas.a
191	-@chmod g+w  $(PDIR)/*.a
192	-@echo "Completed compiling C version of BLAS and LAPACK"
193	-@echo "========================================="
194
195# If fortrankernels are used, build them.
196build_kernels:
197	-@if [ "$(KERNEL_LIB)" != ""  ] ; then \
198	$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) fortrankernels; fi
199
200# Ranlib on the libraries
201ranlib:
202	$(RANLIB) $(PDIR)/*.a
203
204# Deletes PETSc libraries
205deletelibs: chkopts_basic
206	-$(RM) -f $(PDIR)/*
207
208# Deletes man pages (HTML version)
209deletewwwpages:
210	$(RM) -f $(PETSC_DIR)/docs/www/man*/* $(PETSC_DIR)/docs/www/www.cit \
211	         $(PETSC_DIR)/docs/www/man*.html
212
213# Deletes man pages (LaTeX version)
214deletelatexpages:
215	$(RM) -f $(PETSC_DIR)/docs/tex/rsum/*sum*.tex
216
217# To access the tags in emacs, type M-x visit-tags-table and specify
218# the file petsc/TAGS.	Then, to move to where a PETSc function is
219# defined, enter M-. and the function name.  To search for a string
220# and move to the first occurrence, use M-x tags-search and the string.
221# To locate later occurrences, use M-,
222
223TAGS_INCLUDE_FILES  = include/*.h include/pinclude/*.h include/FINCLUDE/*.h
224TAGS_BMAKE_FILES    = bmake/common bmake/*/base*
225TAGS_EXAMPLE_FILES  = src/*/examples/*/*.[c,h,F,f] src/*/examples/*/*/*.[c,h,F,f] \
226                      src/benchmarks/*.c src/contrib/*/examples/*/*.[c,h,F,f]
227TAGS_DOC_FILES      = docs/tex/manual/routin.tex docs/tex/manual/manual.tex \
228                      docs/tex/manual/manual_tex.tex docs/tex/manual/intro.tex \
229                      docs/tex/manual/part1.tex docs/tex/manual/part2.tex
230TAGS_SRC_FILES      = src/*/*.[c,h] src/*/interface/*.[c,h] src/*/src/*.[c,h] \
231                      src/*/utils/*.[c,h] \
232                      src/*/impls/*.[c,h] src/*/impls/*/*.[c,h] src/*/impls/*/*/*.[c,h] \
233                      src/gvec/impls/*/*/*/*/*.[c,h] src/contrib/*/*.[c,h] \
234                      src/contrib/*/src/*.[c,h] src/fortran/custom/*.[c,h,F]
235TAGS_MAKEFILE_FILES = include/makefile include/*/makefile \
236                      makefile \
237                      src/makefile src/*/makefile src/*/src/makefile \
238                      src/*/interface/makefile \
239                      src/*/utils/makefile \
240                      src/*/impls/makefile src/*/impls/*/makefile src/*/impls/*/*/makefile \
241                      src/*/examples/makefile src/*/examples/*/makefile src/*/examples/*/*/makefile \
242                      src/gvec/impls/*/*/*/*/makefile src/gvec/impls/*/*/*/makefile \
243                      src/fortran/*/makefile \
244                      src/contrib/*/makefile src/contrib/*/src/makefile \
245                      src/contrib/*/examples/makefile src/contrib/*/examples/*/makefile \
246                      docs/makefile
247
248# Builds all etags files
249alletags:
250	-make etags_complete
251	-make etags
252	-make etags_noexamples
253	-make etags_makefiles
254
255# Builds the basic etags file.	This should be employed by most users.
256etags:
257	$(RM) TAGS
258	etags -f TAGS $(TAGS_INCLUDE_FILES)
259	etags -a -f TAGS $(TAGS_SRC_FILES)
260	etags -a -f TAGS $(TAGS_EXAMPLE_FILES)
261	etags -a -f TAGS $(TAGS_MAKEFILE_FILES)
262	etags -a -f TAGS $(TAGS_BMAKE_FILES)
263	chmod g+w TAGS
264
265# Builds complete etags list; only for PETSc developers.
266etags_complete:
267	$(RM) TAGS_COMPLETE
268	etags -f TAGS_COMPLETE $(TAGS_SRC_FILES)
269	etags -a -f TAGS_COMPLETE $(TAGS_INCLUDE_FILES)
270	etags -a -f TAGS_COMPLETE $(TAGS_EXAMPLE_FILES)
271	etags -a -f TAGS_COMPLETE $(TAGS_MAKEFILE_FILES)
272	etags -a -f TAGS_COMPLETE $(TAGS_BMAKE_FILES)
273	etags -a -f TAGS_COMPLETE $(TAGS_DOC_FILES)
274	chmod g+w TAGS_COMPLETE
275
276# Builds the etags file that excludes the examples directories
277etags_noexamples:
278	$(RM) TAGS_NO_EXAMPLES
279	etags -f TAGS_NO_EXAMPLES $(TAGS_SRC_FILES)
280	etags -a -f TAGS_NO_EXAMPLES $(TAGS_INCLUDE_FILES)
281	etags -a -f TAGS_NO_EXAMPLES $(TAGS_MAKEFILE_FILES)
282	etags -a -f TAGS_NO_EXAMPLES $(TAGS_BMAKE_FILES)
283	etags -a -f TAGS_NO_EXAMPLES $(TAGS_DOC_FILES)
284	chmod g+w TAGS_NO_EXAMPLES
285
286# Builds the etags file for makefiles
287etags_makefiles:
288	$(RM) TAGS_MAKEFILES
289	etags -f TAGS_MAKEFILES $(TAGS_MAKEFILE_FILES)
290	etags -a -f TAGS_MAKEFILES $(TAGS_BMAKE_FILES)
291	chmod g+w TAGS_MAKEFILES
292
293# Builds the etags file for examples
294etags_examples:
295	$(RM) TAGS_EXAMPLES
296	etags -f TAGS_EXAMPLES $(TAGS_EXAMPLE_FILES)
297	chmod g+w TAGS_EXAMPLES
298
299#
300# ctags builds the tags file required for VI.
301# To use the tags file do the following:
302# 1. within vi invole the command - :set tags=/home/bsmith/petsc/tags
303#    or add  the command to your ~/.exrc file - set tags=/home/bsmith/petsc/tags
304# 2. now to go to a tag do - :tag TAGNAME for eg - :tag MatCreate
305#
306ctags:
307	$(RM) tags
308	ctags -w -f tags $(TAGS_INCLUDE_FILES)
309	ctags -w -a -f tags $(TAGS_SRC_FILES)
310	ctags -w -a -f tags $(TAGS_EXAMPLE_FILES)
311	ctags -w -a -f tags $(TAGS_MAKEFILE_FILES)
312	ctags -w -a -f tags $(TAGS_BMAKE_FILES)
313	chmod g+w tags
314
315# ------------------------------------------------------------------
316#
317# All remaining actions are intended for PETSc developers only.
318# PETSc users should not generally need to use these commands.
319#
320
321# Builds all versions of the man pages
322allmanpages: allwwwpages alllatexpages
323allwwwpages: deletewwwpages
324	-make ACTION=wwwpages_buildcite tree
325	-cd src/fortran/custom; make wwwpages_buildcite
326	-cd src/fortran/custom; make wwwpages
327	-make ACTION=wwwpages tree
328	-maint/wwwman
329	-maint/examplesindex.tcl -www
330	-maint/htmlkeywords.tcl
331	-@chmod g+w docs/www/man*/*
332
333#This is similar to allwwwpages except -www -> -wwwhome
334#The wwwmanpages built this way can pe placed at PETSc Home Page
335allwwwhomepages: deletewwwpages
336	-make ACTION=wwwpages_buildcite tree
337	-cd src/fortran/custom; make wwwpages_buildcite
338	-cd src/fortran/custom; make wwwpages
339	-make ACTION=wwwpages tree
340	-maint/wwwman
341	-maint/examplesindex.tcl -wwwhome
342	-maint/htmlkeywords.tcl -wwwhome
343	-@chmod g+w docs/www/man*/*
344
345alllatexpages: deletelatexpages
346	-make ACTION=latexpages tree
347	-cd src/fortran/custom; make latexpages
348	-@chmod g+w docs/tex/rsum/*
349
350# Builds Fortran stub files
351allfortranstubs:
352	-@include/finclude/generateincludes
353	-@$(RM) -f src/fortran/auto/*.c
354	-make ACTION=fortranstubs tree
355	chmod g+w src/fortran/auto/*.c
356
357allci:
358	-@cd src/fortran/custom ; $(OMAKE) BOPT=$(BOPT) ci
359	-@$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) ACTION=ci  tree
360
361allco:
362	-@cd src/fortran/custom ; $(OMAKE) BOPT=$(BOPT) co
363	-@$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) ACTION=co  tree
364
365#
366#   The commands below are for generating ADIC versions of the code;
367# they are not currently used.
368#
369CFLAGS   =  $(CPPFLAGS) $(CONF)
370alladicignore:
371	-@$(RM) $(PDIR)/adicignore
372	-@$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) ACTION=adicignore  tree
373
374alladic:
375	-@echo "Beginning to compile ADIC source code in all directories"
376	-@echo "Using ADIC compiler: $(ADIC_CC) $(CFLAGS)"
377	-@echo "========================================="
378	-@cd include ; \
379           $(ADIC_CC) -s -f 1 $(CFLAGS) petsc.h
380	-@$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) ACTION=adic  tree
381	-@cd src/inline ; \
382            $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) adic
383	-@cd src/adic/blas ; \
384            $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) adic
385	-@cd src/adic/lapack ; \
386            $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) ACTION=adic  tree
387
388alladiclib:
389	-@echo "Beginning to compile ADIC libraries in all directories"
390	-@echo "Using compiler: $(CC) $(COPTFLAGS)"
391	-@echo "-----------------------------------------"
392	-@echo "Using PETSc flags: $(PETSCFLAGS) $(PCONF)"
393	-@echo "-----------------------------------------"
394	-@echo "Using configuration flags: $(CONF)"
395	-@echo "-----------------------------------------"
396	-@echo "Using include paths: $(PETSC_INCLUDE)"
397	-@echo "-----------------------------------------"
398	-@echo "Using PETSc directory: $(PETSC_DIR)"
399	-@echo "Using PETSc arch: $(PETSC_ARCH)"
400	-@echo "========================================="
401	-@$(RM) -f  $(PDIR)/*adic.a
402	-@$(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) ACTION=adiclib  tree
403	-@cd src/adic/blas ; \
404            $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) adiclib
405	-@cd src/adic/lapack ; \
406            $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) ACTION=adiclib  tree
407	-@cd src/adic/src ; \
408            $(OMAKE) BOPT=$(BOPT) PETSC_ARCH=$(PETSC_ARCH) lib
409
410# -------------------------------------------------------------------------------
411#
412# Some macros to check if the fortran interface is up-to-date.
413#
414countfortranfunctions:
415	-@cd $(PETSC_DIR)/src/fortran; egrep '^void' custom/*.c auto/*.c | \
416	cut -d'(' -f1 | tr -s '' ' ' | cut -d' ' -f2 | uniq | egrep -v "(^$$|Petsc)" | \
417	sed "s/_$$//" | sort > /tmp/countfortranfunctions
418
419countcfunctions:
420	-@ grep extern $(PETSC_DIR)/include/*.h *.h | grep "(" | tr -s '' ' ' | \
421	cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '' '\012' |  \
422	tr 'A-Z' 'a-z' |  sort > /tmp/countcfunctions
423
424difffortranfunctions: countfortranfunctions countcfunctions
425	-@echo -------------- Functions missing in the fortran interface ---------------------
426	-@diff /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2
427	-@echo ----------------- Functions missing in the C interface ------------------------
428	-@diff /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2
429	-@$(RM)  /tmp/countcfunctions /tmp/countfortranfunctions
430
431checkbadfortranstubs:
432	-@echo "========================================="
433	-@echo "Functions with MPI_Comm as an Argument"
434	-@echo "========================================="
435	-@cd $(PETSC_DIR)/src/fortran/auto; grep '^void' *.c | grep 'MPI_Comm' | \
436	tr -s '' ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
437	-@echo "========================================="
438	-@echo "Functions with a String as an Argument"
439	-@echo "========================================="
440	-@cd $(PETSC_DIR)/src/fortran/auto; grep '^void' *.c | grep 'char \*' | \
441	tr -s '' ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3
442	-@echo "========================================="
443	-@echo "Functions with Pointers to PETSc Objects as Argument"
444	-@echo "========================================="
445	-@cd $(PETSC_DIR)/src/fortran/auto; \
446	_p_OBJ=`grep _p_ $(PETSC_DIR)/include/*.h | tr -s '' ' ' | \
447	cut -d' ' -f 3 | tr -s '' '\012' | grep -v '{' | cut -d'*' -f1 | \
448	sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \
449	for OBJ in $$_p_OBJ; do \
450	grep "$$OBJ \*" *.c | tr -s '' ' ' | tr -s ':' ' ' | \
451	cut -d'(' -f1 | cut -d' ' -f1,3; \
452	done
453