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