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