#!/bin/csh # # @(#)install_gmt 3.206 03/16/00 # # Automatic installation of GMT version 3.3.4 # # Paul Wessel # 16-MAR-2000 #-------------------------------------------------------------------------------- # INITIALIZATION OF PARAMETERS #-------------------------------------------------------------------------------- set VERSION = 3.3.4 set DIR = pub/gmt if ($#argv > 1 || ($#argv > 0 && $1 == "-h")) then echo "install_gmt 3.206 - Automatic installation of GMT ${VERSION}" echo " " echo "install_gmt can be run interactively or in the background." echo "Background installs require a valid parameter file as argument." echo "The interactive session will write such a parameter file after" echo "installing successfully. Alternatively, compose a parameter" echo "file using the form on the GMT home page (www.soest.hawaii.edu/gmt)." echo " " echo "usage: install_gmt parameterfile [ >& logfile] (for background install)" echo "or install_gmt (for interactive install)" echo "or install_gmt -h (to display this message)" exit -1 endif #-------------------------------------------------------------------------------- # LISTING OF CURRENT FTP MIRROR SITES #-------------------------------------------------------------------------------- set N_FTP_SITES = 6 set FTP_SITE = (gmt.soest.hawaii.edu \ falcon.grdl.noaa.gov \ ftp.iag.usp.br \ ftp.geologi.uio.no \ ftp.eos.hokudai.ac.jp \ life.csu.edu.au) set WHERE = ("SOEST, U of Hawaii [GMT Home], Honolulu, Hawaii, USA" \ "NOAA, Lab for Satellite Altimetry, Silver Spring, Maryland, USA" \ "IAG-USP, Dept of Geophysics, U. of Sao Paulo, BRAZIL" \ "Inst for Geologi, U of Oslo, NORWAY" \ "ISV, Hokkaido U, Sapporo, JAPAN" \ "Charles Sturt U, Albury, AUSTRALIA") set IS_DNS = (1 1 0 0 1 0) #-------------------------------------------------------------------------------- set GMT = "GMT" set FILE = (${GMT}_progs ${GMT}_share ${GMT}_high ${GMT}_full ${GMT}_suppl ${GMT}_scripts ${GMT}_doc ${GMT}_web triangle) set FILE2 = (GMT${VERSION}_progs \ GMT${VERSION}_share \ GMT${VERSION}_high \ GMT${VERSION}_full \ GMT${VERSION}_suppl \ GMT${VERSION}_scripts \ GMT${VERSION}_doc \ GMT${VERSION}_web \ triangle) set BZIP2_SIZES = (0.51 3.7 8.6 28.8 0.31 3.0 4.0 1.4 0.09) set GZIP_SIZES = (0.62 4.0 10.7 47.1 0.37 4.2 5.0 1.5 0.11) unalias cd set topdir = `pwd` set os = `uname -s` #-------------------------------------------------------------------------------- # See if user has defined NETCDFHOME, if so use it as default path #-------------------------------------------------------------------------------- if ($?NETCDFHOME) then set netcdf_path = $NETCDFHOME else set netcdf_path = "" endif #-------------------------------------------------------------------------------- # See if user has defined EDITOR, if so use it as default path #-------------------------------------------------------------------------------- if ($?EDITOR) then set editor = $EDITOR else set editor = vi endif #-------------------------------------------------------------------------------- # GET SETTINGS FROM PARAMETER FILE OR INTERACTIVELY #-------------------------------------------------------------------------------- if ($#argv == 1) then #-------------------------------------------------------------------------------- # LOAD SETTINGS FROM FILE #-------------------------------------------------------------------------------- set interactive = 0 source $1 else #-------------------------------------------------------------------------------- # ASK FOR VALUES OF ALL SETTINGS #-------------------------------------------------------------------------------- set interactive = 1 set GMT_expand = "" endif #-------------------------------------------------------------------------------- # DETERMINE WHICH OF GZIP AND BZIP2 FILES TO USE #-------------------------------------------------------------------------------- if ($GMT_expand == "") then # Find if bzip2 or gzip are available bzip2 -h >&! $$ set answer = `wc -l $$` if ($answer[1] > 10) then # Use bzip2 set GMT_expand = bzip2 else # Try gzip gzip -h >&! $$ set answer = `wc -l $$` if ($answer[1] > 10) then # Use gzip set GMT_expand = gzip else echo "ERROR: Neither gzip or bzip2 installed - exits" exit -1 endif endif \rm -f $$ endif if ($GMT_expand == "bzip2") then # Use bzip2 set suffix = "bz2" set expand = "bzip2 -dc" set sizes = ($BZIP2_SIZES) echo "+++ Will expand *.bz2 files made with bzip2 +++" else if ($GMT_expand == "gzip") then set suffix = "gz" set expand = "gzip -dc" set sizes = ($GZIP_SIZES) echo "+++ Will expand *.gz files make with gzip +++" echo " [Consider installing bzip2 (http://sourceware.cygnus.com/bzip2/index.html)" echo " since bzip2 files are considerably smaller\!]" endif if ($interactive) then #-------------------------------------------------------------------------------- # MAKE UTILITY #-------------------------------------------------------------------------------- echo -n "==> Enter make utility to use [make]: " set GMT_make = $< #-------------------------------------------------------------------------------- # PRINT UTILITY #-------------------------------------------------------------------------------- echo -n "==> Enter print command to use [lpr]: " set GMT_print = ($<) #-------------------------------------------------------------------------------- # NETCDF SETUP #-------------------------------------------------------------------------------- echo -n "==> Have you installed netcdf version 3.4 or later? (y/n) [y]: " set answer = $< if ($answer == "n") then echo -n "==> Do you want me to ftp it for you? (y/n) [y]: " set answer = $< if ($answer == "n") then echo "Please install netcdf and then rerun install_gmt" exit endif set netcdf_ftp = y else if ($?NETCDFHOME) then set def = $NETCDFHOME else set def = /usr/local/netcdf-3.4 endif echo -n "==> Enter directory with netcdf lib and include [$def]: " set netcdf_path = $< if ($netcdf_path == "") then set netcdf_path = $def endif set netcdf_ftp = n endif #-------------------------------------------------------------------------------- # GMT FTP SECTION #-------------------------------------------------------------------------------- set GMT_get_this = (d d d d d d d d d) set GMT_triangle = d set GMT_ftpsite = 1 echo -n "==> Want to ftp and get any of the $GMT version archives? (y/n) [y]: " set GMT_ftp = $< if ($GMT_ftp == "y" || $GMT_ftp == "") then set GMT_get_this = (n n n n n n n n n) set GMT_ftp = y echo " " echo " We offer $N_FTP_SITES different ftp sites. Choose the one nearest" echo " you in order to minimize net traffic and transmission times." echo " The sites are:" echo " " while ($GMT_ftpsite <= $N_FTP_SITES) echo " ${GMT_ftpsite}. $WHERE[$GMT_ftpsite]" @ GMT_ftpsite++ end echo " " echo -n "==> Enter your choice [1]: " set answer = $< if ($answer == "") then @ GMT_ftpsite = 1 else @ GMT_ftpsite = $answer endif if ($GMT_ftpsite <= 0 || $GMT_ftpsite > $N_FTP_SITES) then @ GMT_ftpsite = 1 echo " Error in assigning site, use default site $WHERE[$GMT_ftpsite]" else echo " You selected the site in $WHERE[$GMT_ftpsite]" endif echo " " if ($IS_DNS[$GMT_ftpsite] == 1) then echo " " echo "This anonymous ftp server $FTP_SITE[$GMT_ftpsite] only accepts" echo "connections from computers on the Internet that are registered" echo "in the Domain Name System (DNS). If you encounter a problem" echo "connecting because your computer is not registered, please" echo "either use a different computer that is registered or see your" echo "computer systems administrator (or your site DNS coordinator)" echo "to register your computer." echo " " endif echo " The first two archives are required for a minimal GMT install" echo " " set blurb = ("Want the program source archive" \ "Want the support data (coastlines)" \ "Want optional high resolution coastline data" \ "Want optional full resolution coastline data" \ "Want optional GMT supplemental programs" \ "Want optional GMT example scripts and data" \ "Want optional GMT Documentation (PS and MAN)" \ "Want optional GMT Documentation (HTML)" ) foreach i (1 2 3 4 5 6 7 8) echo -n "==> $blurb[$i] [$sizes[$i] Mb]? (y/n) [y]: " set answer = $< if ($answer == "y" || $answer == "") then set GMT_get_this[$i] = y endif end echo " " echo "GMT can use two different algorithms for Delauney triangulation." echo " " echo " Shewchuck [1996]: Modern and very fast, copyrighted." echo " Watson [1982] : Older and slower, public domain." echo " " echo "Because of the copyright, GMT uses Watson's routine by default." echo " " echo -n "==> Want optional Shewchuck's triangulation routine [$sizes[9] Mb]? (y/n) [n]: " set answer = $< if ($answer == "y" || $answer == "") then set GMT_get_this[9] = y set GMT_triangle = y else set GMT_triangle = n endif endif set GMT_def = "$topdir/GMT${VERSION}" echo " " echo -n "==> Where should GMT data be stored [$GMT_def/share]? : " set GMT_share = $< if ($GMT_share == "") then set GMT_share = $GMT_def"/share" endif echo " " echo -n "==> Where should GMT executables be stored [$GMT_def/bin]? : " set GMT_bin = $< if ($GMT_bin == "") then set GMT_bin = $GMT_def"/bin" endif echo " " echo -n "==> Where should GMT linkable libraries be stored [$GMT_def/lib]? : " set GMT_lib = $< if ($GMT_lib == "") then set GMT_lib = $GMT_def"/lib" endif echo " " echo -n "==> Where should GMT include files be stored [$GMT_def/include]? : " set GMT_include = $< if ($GMT_include == "") then set GMT_include = $GMT_def"/include" endif echo " " echo "Unix man pages are usually stored in /usr/man/manX, where X is" echo "the relevant man section. This is usually l for local. Below," echo "you will be asked for X and the /usr/man part; the /manX will be" echo "appended automatically, so do not answer /usr/man/manl" echo " " echo -n "==> Where should GMT man pages be stored [$GMT_def/man]? : " set GMT_man = $< echo -n "==> Enter Man page section for GMT man pages (1-9,l) [l]: " set GMT_mansect = $< if ($GMT_mansect == "") then set GMT_mansect = "l" endif echo -n "==> Where should GMT www pages be stored [$GMT_def/www]? : " set GMT_web = $< echo " " echo 'At run-time, GMT uses the $GMTHOME environmental parameter to' echo "find $GMT_share. The name must not contain the trailing /share." echo "You may want to override the default if users will see a different" echo "mount point or a symbolic link instead of a local directory." echo " " echo -n "==> Enter default GMTHOME selection [$GMT_share:h]? : " set GMT_def = $< if ($GMT_def == "") then set GMT_def = $GMT_share:h endif echo " " echo "The answer to the following question will modify the GMT defaults." echo "(You can always change your mind by editing share/gmt.conf)" echo " " echo -n "==> Do you prefer SI or US default values for GMT (s/u) [s]: " set answer = $< if ($answer == "" || $answer == "s") then set GMT_si = y else set GMT_si = n endif echo " " echo "The answer to the following question will modify the GMT defaults." echo "(You can always change your mind later by using gmtset)" echo " " echo "PostScript (PS) files contain commands to set paper size, pick a" echo "specific paper tray, or ask for manual feed. Encapsulated PS" echo "files (EPS) are not intended for printers (but will print ok) and" echo "can be included in other documents. Both formats will preview" echo "on most previwers (out-of-date Sun pageview is an exception)." echo " " echo -n "==> Do you prefer PS or EPS as default PostScript output (p/e) [p]: " set answer = $< if ($answer == "" || $answer == "p") then set GMT_ps = y else set GMT_ps = n endif echo " " echo "Building the GMT libraries as shared instead of static will" echo "reduce executable sizes considerably. GMT supports shared" echo "libraries under Linux, SunOS, Solaris, IRIX, HPUX, and FreeBSD." echo "Under other systems you may have to manually configure macros" echo "and determine what specific options to use with ld." echo " " echo -n "==> Try to make and use shared libraries? (y/n) [n]: " set GMT_sharedlib = $< echo " " echo "If you have more than one C compiler you need to specify which," echo "otherwise the default cc should work fine." echo " " echo -n "==> Enter name of C compiler (include path if not in search path) [cc]: " set GMT_cc = $< if ($GMT_cc == "") then set GMT_cc = cc endif echo "GMT passes information about previous GMT commands onto later" echo "GMT commands via a hidden file (.gmtcommands). To avoid that" echo "this file is updated by more than one program at the same time" echo "(e.g., when connecting two or more GMT programs with pipes) we" echo "use POSIX advisory file locking on the file. Apparently, some" echo "versions of the Network File System (NFS) have not implemented" echo "file locking properly. We know this is the case with Linux" echo "pre-2.4 kernels when mounting NFS disks from a Unix server." echo "If this is your case you should turn file locking OFF." echo " " echo -n "==> Use POSIX Advisory File Locking in GMT (y/n) [y]: " set GMT_flock = $< if ($GMT_flock == "") then set GMT_flock = y endif echo -n "==> Want to test GMT by running the 20 examples? (y/n) [y]: " set GMT_run_examples = $< if ($GMT_run_examples == "") then set GMT_run_examples = y endif echo -n "==> Delete all tar files after install? (y/n) [n]: " set GMT_delete = $< if ($GMT_delete == "") then set GMT_delete = n endif endif if ($GMT_make == "") then set GMT_make = make endif if ($#GMT_print == 0) then set GMT_print = "lpr" endif #-------------------------------------------------------------------------------- # NETCDF SECTION #-------------------------------------------------------------------------------- if ($netcdf_ftp == "y") then cd $topdir # Set-up ftp command echo "user anonymous $USER@" >&! /tmp/$$ echo "cd pub/netcdf" >>& /tmp/$$ echo "binary" >>& /tmp/$$ echo "get netcdf.tar.Z" >>& /tmp/$$ echo "quit" >>& /tmp/$$ echo " " >>& /tmp/$$ # Get the file echo -n "Getting netcdf by anonymous ftp (be patient)..." ftp -dn unidata.ucar.edu < /tmp/$$ if ($status != 0) then echo "ftp failed - try again later" \rm -f /tmp/$$ exit -1 else echo "done" \rm -f /tmp/$$ endif zcat netcdf.tar.Z | tar xvf - set n_version = `cat netcdf*/src/VERSION` cd netcdf-${n_version}/src # Interix/OpenNT fix for bad lex which creates an #include statement for values.h which # which does not exist. We create an empty values.h file in the ncgen directory: if ($os == "Windows_NT" || $os == "Rhapsody") then touch ncgen/values.h endif if ($netcdf_path == "") then set netcdf_path = "$topdir/netcdf-${n_version}" endif if ($os == "Linux") then setenv DEFINES "-Df2cFortran" endif ./configure --prefix=$netcdf_path $GMT_make $GMT_make test $GMT_make install $GMT_make clean if ($os == "Windows_NT" || $os == "Rhapsody") then # Lord giveth, lord taketh away \rm -f ncgen/values.h endif cd ../.. if ($GMT_delete == "y") then \rm -f netcdf.tar.Z endif endif if ($netcdf_path == "") then # Not explicitly set, must assign it if ($?NETCDFHOME) then # Good, used an environmental variable for it set netcdf_path = $NETCDFHOME else if ($netcdf_ftp == "n") then # First see if it was already installed in $topdir (set netcdf_path = $topdir/netcdf-3.?) >& /dev/null if ($netcdf_path == "") then # No, give default place echo "install_gmt: No path for netcdf provided - default is /usr/local/netcdf" set netcdf_path = "/usr/local/netcdf" endif setenv NETCDFHOME $netcdf_path endif else setenv NETCDFHOME $netcdf_path endif #-------------------------------------------------------------------------------- # GMT FTP SECTION #-------------------------------------------------------------------------------- cd $topdir if ($GMT_ftp == "y") then set site = $GMT_ftpsite if ($site <= 0 || $site > $N_FTP_SITES) then @ site = 1 echo " Error in assigning site, use default site $WHERE[$site]" endif echo " " if ($IS_DNS[$site] == 1) then echo " " echo "This anonymous ftp server $FTP_SITE[$site] only accepts" echo "connections from computers on the Internet that are registered" echo "in the Domain Name System (DNS). If you encounter a problem" echo "connecting because your computer is not registered, please" echo "either use a different computer that is registered or see your" echo "computer systems administrator (or your site DNS coordinator)" echo "to register your computer." echo " " endif # Set-up ftp command echo "user anonymous $USER@" >&! /tmp/$$ echo "cd $DIR" >>& /tmp/$$ echo "binary" >>& /tmp/$$ foreach i (1 2 3 4 5 6 7 8 9) if ($GMT_get_this[$i] == "y") then # User has checked this one - first see if we already have it set get = 0 if (-e $FILE[$i].tar.$suffix) then set this = $FILE[$i].tar.$suffix else if (-e $FILE2[$i].tar.$suffix) then set this = $FILE2[$i].tar.$suffix else set get = 1 endif if ($interactive && $get == 0) then echo -n "==> $this already exists. Ftp it again? (y/n) [n]: " set answer = $< if ($answer == "y") then set get = 1 endif endif if ($get == 1) then echo "get $FILE[$i].tar.$suffix" >>& /tmp/$$ endif endif end echo "quit" >>& /tmp/$$ echo " " >>& /tmp/$$ # Get the files echo -n "Getting GMT by anonymous ftp from $WHERE[$site] (be patient)..." ftp -dn $FTP_SITE[$site] < /tmp/$$ if ($status != 0) then echo "fpt failed - try again later" \rm -f /tmp/$$ exit -1 else \rm -f /tmp/$$ echo "done" endif endif #-------------------------------------------------------------------------------- # First install source code and documentation #-------------------------------------------------------------------------------- foreach i (1 5 6 7 8 9) set ok = 1 if (-e $FILE[$i].tar.$suffix) then set this = $FILE[$i].tar.$suffix else if (-e $FILE2[$i].tar.$suffix) then set this = $FILE2[$i].tar.$suffix else set ok = 0 endif if ($ok == 1) then # File exists if ($interactive) then echo -n "==> Untar files from archive $this ? (y/n) [y]: " set answer = $< if ($answer == "") then set answer = "y" endif else if ($GMT_get_this[$i] != "n") then set answer = "y" else set answer = "n" endif if ($answer == "y") then $expand $this | tar xvf - endif endif end #-------------------------------------------------------------------------------- # Now do coastline archives #-------------------------------------------------------------------------------- if ($interactive) then set GMT_coast = (. . .) echo " " echo "Normally, all coastline files are installed in GMT${VERSION}/share." echo "However, you can also place some of them in separate directories." echo "These dirs must exist or you must have write permission to make them." echo "If alternate directories are specified then a coastline.conf file will" echo "be kept in $topdir/GMT${VERSION}/share to contain the names of these directories." echo "NOTE: Do not append the final subdirectory /share as that is done automatically\!" echo " " endif set dir = ${topdir}/GMT${VERSION} \rm -f /tmp/$$ set j = 0 foreach i (2 3 4) set ok = 1 @ j++ if (-e $FILE[$i].tar.$suffix) then set this = $FILE[$i].tar.$suffix else if (-e $FILE2[$i].tar.$suffix) then set this = $FILE2[$i].tar.$suffix else set ok = 0 endif if ($ok == 1 && $GMT_get_this[$i] != "n") then # File is present if ($interactive) then echo -n "==> Extract contents from file $this ? (y/n) [y]: " set answer = $< if ($answer == "y" || $answer == "") then echo -n "==> Place $this in GMT${VERSION}/share? (y/n) [y]: " set answer2 = $< if ($answer2 == "y" || $answer2 == "") then set GMT_coast[$j] = ${topdir}/GMT${VERSION} else echo -n "==> Enter alternative full directory path for $this (GMT will append /share): " set GMT_coast[$j] = $< echo $GMT_coast[$j] >> /tmp/$$ endif else set GMT_get_this[$i] = n endif else if ($GMT_coast[$j] == ".") then set GMT_coast[$j] = ${topdir}/GMT${VERSION} else echo $GMT_coast[$j] >> /tmp/$$ endif endif if ($GMT_get_this[$i] != "n") then if (! -d $GMT_coast[$j]) then mkdir -p $GMT_coast[$j] else set status = 0 endif if ($status != 0) then echo "Could not make the directory $GMT_coast[$j] - $this not untarred" else cd $GMT_coast[$j] $expand $topdir/$this | tar xvf - cd $topdir endif endif endif end if (-e /tmp/$$) then # Install coastline.conf file echo "# GMT Coastline Path Configuration File" >! $topdir/GMT${VERSION}/share/coastline.conf echo "" >> $topdir/GMT${VERSION}/share/coastline.conf sort -u /tmp/$$ >> $topdir/GMT${VERSION}/share/coastline.conf \rm -f /tmp/$$ echo "$topdir/GMT${VERSION}/share/coastline.conf initialized" else # Not needed set GMT_coast = (. . .) endif echo " " echo -n "Set write privileges on all files in GMT${VERSION} ..." cd GMT${VERSION} chmod -R +w . cd .. echo "Done" echo " " #-------------------------------------------------------------------------------- # GMT INSTALLATION PREPARATIONS #-------------------------------------------------------------------------------- cd $topdir cd GMT${VERSION} set here = `pwd` if ($interactive) then if ($GMT_triangle == "d") then if (-e src/README.TRIANGLE) then set GMT_triangle = y endif endif set edit = (0 0 0 0 1 0 0 0 0 0 0 1) set blurb = ("dbase: Extracting data from NGDC DEM and other grids" \ "cps: Encoding and decoding of Complete PostScript files for archiving" \ "imgsrc: Extracting grids from global altimeter files (Sandwell/Smith)" \ "meca: Plotting special symbols in seismology and geodesy" \ "mex: Matlab interface for reading/writing GMT grdfiles (REQUIRES MATLAB)" \ "mgg: Programs for making, managing, and plotting MGD77 & .gmt data" \ "misc: Make posters on laserwriters and create bit-patterns" \ "segyprogs: Plot SEGY seismic data files" \ "spotter: Plate tectonic backtracking and hotspotting" \ "x2sys: New (Generic) Track intersection (crossover) tools" \ "x_system: Old (MGG-specific) Track intersection (crossover) tools" \ "xgrid: An X11-based graphical editor for netCDF-based .grd files") set GMT_suppl = (n n n n n n n n n n n n) if (-d src/cps) then echo -n "==> Install any of the supplemental programs? (y/n/a(ll)) [a]: " set answer = $< if ($answer == "a" || $answer == "") then set GMT_suppl = (y y y y y y y y y y y y) else if ($answer == "y" || $answer == "") then set i = 0 foreach pkg (dbase cps imgsrc meca mex mgg misc segyprogs spotter x2sys x_system xgrid) @ i++ if (-d src/$pkg) then echo " " echo $blurb[$i] echo " " echo -n "==> Install the $pkg programs? (y/n) [y]: " set answer = $< if ($answer == "y" || $answer == "") then set GMT_suppl[$i] = y endif endif end endif endif set GMT_print_doc = n set GMT_print_tutorial = n set GMT_paper = "A4" if (-d www/gmt/doc/ps) then echo -n "==> Want to print any of the GMT Documentation? (y/n) [n]: " set answer = $< if ($answer == "y") then echo -n "==> Print GMT Technical Reference and Cookbook (20.5 Mb, 141 pages)? (y/n) [y]: " set GMT_print_doc = $< if ($GMT_print_doc == "") then set GMT_print_doc = y endif echo -n "==> Print GMT Tutorial and Short Course (1.3 Mb, 33 pages)? (y/n) [y]: " set GMT_print_tutorial = $< if ($GMT_print_tutorial == "") then set GMT_print_tutorial = y endif echo -n "==> Documents use A4 format. Reformat them to US Letter? (y/n) [n]: " set Letter = $< if ($Letter == "y") then set GMT_paper = "Letter" endif endif endif endif # If we got here via a parameter file that had blank answers # we need to provide the default values here if ($GMT_def == "" && $GMT_share == "") then set GMT_def = $here else if ($GMT_def == "") then set GMT_def = $GMT_share:h endif if ($GMT_share == "") then set GMT_share = $here"/share" endif # Are we allowed to write in $GMT_share? if (-w $GMT_share:h) then set write_share = 1 else set write_share = 0 endif if ($GMT_bin == "") then set GMT_bin = $here"/bin" endif if ($GMT_lib == "") then set GMT_lib = $here"/lib" endif if ($GMT_include == "") then set GMT_include = $here"/include" endif # Are we allowed to write in $GMT_bin? if (-w $GMT_bin:h) then set write_bin = 1 else set write_bin = 0 endif if ($GMT_man == "") then set GMT_man = "$here/man" endif # Are we allowed to write in $GMT_man? set head = $GMT_man:h if (-w $head:h) then set write_man = 1 else set write_man = 0 endif if ($GMT_web == "") then set GMT_web = "$here/www" endif # Are we allowed to write in $GMT_web? if (-w $GMT_web:h) then set write_web = 1 else set write_web = 0 endif #-------------------------------------------------------------------------------- # CONFIGURE PREPARATION #-------------------------------------------------------------------------------- if ($GMT_share == "") then set sharedir = else set sharedir =(--datadir=$GMT_share) endif if ($GMT_man == "") then set mandir = else set mandir =(--mandir=$GMT_man) endif if ($GMT_web == "") then set webdir = else set webdir =(--enable-www=$GMT_web) endif if ($GMT_si == "y") then set enable_us = else set enable_us =(--enable-US) endif if ($GMT_ps == "y") then set enable_eps = else set enable_eps =(--enable-eps) endif if ($GMT_flock == "y") then set disable_flock = else set disable_flock =(--disable-flock) endif if ($GMT_triangle == "y") then set enable_triangle =(--enable-triangle) else set enable_triangle = endif if ($GMT_sharedlib == "y") then set enable_shared = (--enable-shared) else set enable_shared = endif #-------------------------------------------------------------------------------- # GMT installation commences here #-------------------------------------------------------------------------------- echo " " echo "---> Begin GMT $VERSION installation <---" echo " " echo "---> Run configure to create makegmt.macros and gmt_notposix.h" # Clean out old cached values \rm -f config.{cache,log,status} # Set environmental variables if desired if ($GMT_cc != "") then setenv CC $GMT_cc endif if ($os == "Windows_NT" || $os == "Rhapsody") then # Since otherwise config.guess will fail and abort set HFIX = (--host=unknown) else set HFIX = endif ./configure $HFIX --prefix=$GMT_def --bindir=$GMT_bin --libdir=$GMT_lib --includedir=$GMT_include $enable_us \ $enable_eps $disable_flock $enable_shared $enable_triangle $mandir --enable-mansect=$GMT_mansect $webdir $sharedir if (-f .gmtconfigure) then cat .gmtconfigure if ($interactive) then echo -n "==> Do you want to edit makegmt.macros manually? (y/n) [n]: " set answer = $< if ($answer == "y") then $(EDITOR) src/makegmt.macros endif endif endif # Unset environmental variables if ($GMT_cc != "") then unsetenv CC endif # OK, descend into src directory cd src # Make a copy of gmt_notposix.h \mv -f gmt_notposix.h gmt_notposix.h.copy echo " " echo '---> Clean out old executables, *.o, *.a, and gmt_nan.h' make spotless # Restore gmt_notposix.h that we just wiped \mv -f gmt_notposix.h.copy gmt_notposix.h echo "---> Create gmt_nan.h" $GMT_make init echo "---> Make all" $GMT_make all if ($status > 0) then echo " " echo "Problems during make all - exit and examine manually" echo "Run this script again later" exit -1 endif if ($write_bin == 1) then echo "---> Make install" $GMT_make install if ($status > 0) then echo " " echo "Problems during make install - exit and examine manually" echo "Run this script again later" exit -1 endif else echo "You do not have write permission to make $GMT_bin" endif cd .. #-------------------------------------------------------------------------------- # RUN EXAMPLES #-------------------------------------------------------------------------------- # Run examples with /src as binary path and /share as GMTHOME in case the user did # not have permission to place files in GMT_share and GMT_bin if ( -d examples) then if ($GMT_run_examples == "y") then $GMT_make run-examples endif endif #-------------------------------------------------------------------------------- # INSTALL SUPPLEMENTAL PROGRAMS #-------------------------------------------------------------------------------- set edit = (0 0 0 0 1 0 0 0 0 0 0 1) if ( -d src/cps) then cd src setenv GMTHOME $GMT_share:h set i = 0 foreach pkg (dbase cps imgsrc meca mex mgg misc segyprogs spotter x2sys x_system xgrid) @ i++ if (-d $pkg) then if ($GMT_suppl[$i] == "y") then echo "Installing the $pkg package." if ($edit[$i] == 1) then if ($interactive) then echo "You may need to edit the makefile to change a few parameters." echo -n "==> Hit return to continue: " set answer = $< cd $pkg $editor makefile cd .. endif endif cd $pkg $GMT_make spotless all if ($write_bin == 1) then $GMT_make install if ($status > 0) then echo "Problems during install - check manually later" else echo "$pkg successfully installed" $GMT_make clean >& /dev/null endif else echo "You do not have write permission to install binaries in $GMT_bin" endif cd .. endif endif end cd .. endif #-------------------------------------------------------------------------------- # INSTALL LIB DIRECTORY #-------------------------------------------------------------------------------- if ($write_share == 1) then $GMT_make install-data endif #-------------------------------------------------------------------------------- # INSTALL MAN PAGES #-------------------------------------------------------------------------------- if ($write_man == 1) then if (-d man/manl) then $GMT_make install-man echo "All users must include $GMT_man in their MANPATH" else echo "GMT Man pages not installed" unset GMT_man endif else echo "You do not have write permission to make $GMT_man" endif #-------------------------------------------------------------------------------- # INSTALL WWW PAGES #-------------------------------------------------------------------------------- if ($write_web == 1) then if (-d www) then $GMT_make install-www echo "All users should add $GMT_web/gmt/gmt_services.html to their browser bookmarks" endif else echo "You do not have write permission to create $GMT_web" endif #-------------------------------------------------------------------------------- # PRINT DOCUMENTATION #-------------------------------------------------------------------------------- if (-d www/gmt/doc/ps) then if (GMT_print_doc == "y" || $GMT_print_tutorial == "y") then cd www/gmt/doc/ps if (-e GMT_Docs.ps.$suffix) then $GMT_expand -d GMT_Docs.ps.$suffix echo "Uncompressed PostScript Cookbook Documentation" endif if (-e GMT_Tutorial.ps.$suffix) then $GMT_expand -d GMT_Tutorial.ps.$suffix echo "Uncompressed PostScript Tutorial Documentation" endif if ($GMT_paper == "Letter") then sh papersize.sh Letter endif if ($GMT_print_doc == "y") then $GMT_print GMT_Docs.ps echo "GMT Documentation spooled to printer" endif if ($GMT_print_tutorial == "y") then $GMT_print GMT_Tutorial.ps echo "GMT Tutorial spooled to printer" endif cd .. endif endif cd $here/src if ($write_bin == 1) then $GMT_make clean if ($status > 0) then echo " " echo "Problems during make clean - exit and examine manually" echo "Run this script again later" exit -1 endif else echo "Manually do the final installs as another user (root?)" echo "Go to the main GMT directory and say:" echo "make install install-suppl clean" endif if ($write_share == 0) then echo "Manually do the coastline install as another user (root?)" echo "Go to the main GMT directory and say:" echo "make install-data" endif if ($write_man == 0) then echo "Manually do the man page install as another user (root?)" echo "Go to the main GMT directory and say:" echo "make install-man" endif if ($write_web == 0) then echo "Manually do the www page install as another user (root?)" echo "Go to the main GMT directory and say:" echo "make install-www" endif if ($GMT_delete == "y") then \rm -f GMT*.tar.$suffix triangle.tar.$suffix endif echo "GMT installation complete. Remember to set these:" echo " " echo "-----------------------------------------------------------------------" echo "setenv GMTHOME $GMT_share:h" echo "set path = ($GMT_bin" '$path)' if ($?GMT_man) then echo -n "Add $GMT_man to MANPATH" echo ":" endif if ($?GMT_web) then echo "Add $GMT_web/gmt/gmt_services.html as browser bookmark" endif echo "-----------------------------------------------------------------------" #-------------------------------------------------------------------------------- # SAVE SESSION SETTINGS TO INSTALL.PAR #-------------------------------------------------------------------------------- cat << EOF >! /tmp/$$ # This file contains parameters needed by the install script # for GMT Version 3.3.3 or later. Give this parameter file # as the argument to the install_gmt script and the whole # installation process can be placed in the background. # Default answers will be selected where none is given. # You can edit the values, but do not remove definitions! # # This script was created by install_gmt on # EOF echo -n "# " >> /tmp/$$ date >> /tmp/$$ cat << EOF >> /tmp/$$ # #--------------------------------------------- # SYSTEM UTILITIES #--------------------------------------------- set GMT_expand = $GMT_expand set GMT_print = "$GMT_print" set GMT_make = $GMT_make #--------------------------------------------- # NETCDF SECTION #--------------------------------------------- set netcdf_ftp = $netcdf_ftp set netcdf_path = $netcdf_path #--------------------------------------------- # GMT FTP SECTION #--------------------------------------------- set GMT_ftp = $GMT_ftp set GMT_ftpsite = $GMT_ftpsite # GMT_get_this order is (progs share high full # suppl scripts doc web triangle) set GMT_get_this = ($GMT_get_this) #--------------------------------------------- # GMT SUPPLEMENTS SELECT SECTION #--------------------------------------------- # GMT_suppl order is (dbase cps imgsrc meca mex # mgg misc segyprogs spotter x2sys x_system xgrid) set GMT_suppl = ($GMT_suppl) #--------------------------------------------- # GMT ENVIRONMENT SECTION #--------------------------------------------- set GMT_si = $GMT_si set GMT_ps = $GMT_ps set GMT_def = $GMT_def set GMT_share = $GMT_share set GMT_bin = $GMT_bin set GMT_lib = $GMT_lib set GMT_include = $GMT_include set GMT_man = $GMT_man set GMT_web = $GMT_web set GMT_coast = ($GMT_coast) set GMT_mansect = $GMT_mansect #--------------------------------------------- # COMPILING & LINKING SECTION #--------------------------------------------- set GMT_sharedlib = $GMT_sharedlib set GMT_cc = $GMT_cc set GMT_triangle = $GMT_triangle set GMT_flock = $GMT_flock #--------------------------------------------- # TEST & PRINT SECTION #--------------------------------------------- set GMT_run_examples = $GMT_run_examples set GMT_print_doc = $GMT_print_doc set GMT_print_tutorial = $GMT_print_tutorial set GMT_paper = $GMT_paper set GMT_delete = $GMT_delete EOF sed -e s/\"/\'/g /tmp/$$ >! $topdir/install.par \rm -f /tmp/$$ echo "install_gmt: Session parameters written to file install.par"