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