#!/bin/bash # # For use on sun/linux/cygwin/mingw/OS X/Windows platforms. # # This script handles installation of ESP-r executables, # databases, training and reference materials. # # This script is a work in progress, and is undergoing # continual improvement. It has been tested on the following # platform/compiler/graphics library configurations: # # ===================================================================================== # OS Distribution / Host User rev Compiler x11 GTK noX XML # ===================================================================================== # Linux Gentoo / NRCan:c.monster aferguso 578 gcc3.4.6 P P P P # gcc4.1.1 P P P P # gcc32 P P P P # Mandrake 10.0 jhand 578 gcc3.4 P P - P # ----------------------------------------------------------------------------- # Fedora Core 5 A.Horsford 489 gcc32 P - - - # 480 gcc4.1.0 X - - - # ----------------------------------------------------------------------------- # Linspire (2.6.14) (a) C.Jones 480 gcc3.3.5 X X - - # ------------------------------------------------------------------------------------- # CYGWIN NT5.1 aferguso 578 gcc3.4.4 P P P - # ------------------------------------------------------------------------------------- # MINGW NT5.1 aferguso 578 gcc3.4.2 - P P - # ------------------------------------------------------------------------------------- # Solaris SunOS 4 / NRCan:nrn7 aferguso 578 sunCC X (b) - P - # Solaris SunOS 5.10 jhand 578 sunCC P - - - # Solaris SunOS 5.10 jhand 578 gcc3.4 P P - - # ------------------------------------------------------------------------------------- # Mac OSX 10.4 jhand 578 gcc3.3 P P - - # ===================================================================================== # Notes: # P : pass - all ESP-r binaries compiled successfully, ancillary files installed # X : fail - one or more of the ESP-r binaries failed to compile # - : not applicable / not tested # (a): Linspire seems to be an extrodinarly non-standard linux system. # (b): nrn7 appears to have non-standard X11 header files. # #===================================================================== clim_convert() # converts climate dbs from iwec.a to binary formats #===================================================================== # Arg_1 = target file # Arg_2 = source file { # short=`echo $1 | sed 's/^.*\///g'` # city=$short # country=$short # country=`echo $short | sed 's/_.*$//g;'` # city=`echo $short | sed 's/_iwec//g;'` # city=`echo $city | sed 's/.iwec//g;'` # city=`echo $city | sed 's/_cwec//g;'` # city=`echo $city | sed 's/.cwec//g;'` # city=`echo $city | sed 's/^.*_//g;'` # printf "\r - Creating binary climate databases [$city ($country)]..." # sed-less version TargetName=`echo $2 | sed 's/\.a$//g'` printf "\r " printf "\r - Creating binary climate databases [${TargetName}]..." rm -f $1 $CLM -mode text -file $1 -act asci2bin silent $2 >/dev/null 2>/dev/null } #===================================================================== # Main script #===================================================================== echo " " echo " ESP-r installation script." echo " " echo " Please consult the README file before commencing " echo " installation. This script will rebuild the ESP-r" echo " modules on your system. You can abort this process" echo " at any time by pressing c." # Set default settings. mode="interactive" # Interactive/silent installation # (silent mode isn't yet supported) SRCdir=`pwd` # Source Directory DESTdir=/usr/esru # Target Directory xml_support=prompt # support for XML output debugging="no" # include debugging symbols EXE="" # executable file extension (i.e. .exe on cygwin and Windows) FFLAGS="-I../include " # initial fortran compiler flags CFLAGS="-I../include " # initial C compiler flags LD_FLAGS=" " # inisial link-loader flags platform="auto-detect" # default platform install_dbs="yes" # Install dbs files install_training="yes" # training files install_exes="prompt" # executables delete_temp_files="yes" # Delete temporary files. preserve_espr_dir="yes" # save existing ESP-r directory by default gnu_version="gcc3" # flag indicating which version of gcc is in use make_msg_file=".make_msg" # Dump make messages? compiler_version="none" # append string to compilers? xLibs="X11" # Default x-library enableFPE="no" # FPE-exception handling? extendedDebug="no" # Enable agressive debugging / warnings /FPE? use_intel="no" # Use intel compilers? skip_ish_calcs="no" # Skip update of exemplar shading files? #----------------------------------------------------------- # List of targets understood by bps #----------------------------------------------------------- # Buildable targets: programs="aco b2e bps dbm dfs c2e clm e2r ecnv eco grd ish mfs mld mrt pdb prj res run vew" # (bld plt, pro net and vww are not currently built) # Add leading and trailing spaces for regexp matching programs=" ${programs} " # default targets: empty for now targets=" " #----------------------------------------------------------- # Detect architecture. #----------------------------------------------------------- architecture=`uname -s` # machine type #----------------------------------------------------------- # Is Stat available? assume stat will be in /bin or /usr/bin, # since which might also not be available. #----------------------------------------------------------- if [ -x /usr/bin/stat ]; then stat_avail="yes" elif [ -x /bin/stat ]; then stat_avail="yes" else stat_avail="no" fi # Command line options. help=0 input="no" if [ $# -ne 0 ]; then for i do if [ "${input}" = "yes" ]; then input="no" else case "$i" in -h | --help) help=1; shift;; --debug) debugging=yes; shift;; -d) shift; DESTdir=$1; input="yes"; shift;; --force) preserve_espr_dir="no"; shift;; --no_training) install_training="no"; shift;; --no_dbs) install_dbs="no"; shift;; --no_exes) install_exes="no"; shift;; --extra-debug) debugging="yes"; extendedDebugging="yes"; shift;; --silent) mode="silent"; shift;; --xml) xml_support=yes; shift;; --gcc32) gnu_version="gcc32"; shift;; --gcc4) gnu_version="gcc4"; shift;; --intel) use_intel="yes"; shift;; --X11) xLibs="X11"; shift;; --GTK) xLibs="GTK"; shift;; --noX) xLibs="noX"; shift;; --fpe) enableFPE="yes"; shift;; --compiler_version) shift; input="yes"; compiler_version=$1; shift;; -v | --verbose) make_msg_file=""; shift;; --skip_ish_calcs) skip_ish_calcs="yes"; shift;; clean) targets="${targets} clean" shift;; *) # check if target is "buildable", match="no" position=`expr match " $programs " ".* ${i} .*"` if [ "${position}" != 0 ]; then targets="${targets} ${i}" shift else # Trap unsupported arguements. echo " " echo " Error: arguement $i is not supported. " echo " Run ./Install --help for more information." echo " " exit fi ;; esac fi done fi # If Targets is empty, build all programs by default. if [ "${targets}" = " " ]; then targets="${programs}" else # Add a trailing space for regexp search targets="${targets} " fi #----------------------------------------------------------- # Header. #----------------------------------------------------------- if [ $help -eq 1 ]; then echo " " echo " USAGE: Install [OPTIONS] [NAME]" echo " " echo " This installation script can be used to install" echo " ESP-r on your system. To install ESP-r using the " echo " standard defaults and interactive dialogues, run " echo " the script without any arguements, eg:" echo " " echo " $ ./Install " echo " " echo " You can also specify alternate configurations " echo " using the script's options. For instance, to " echo " install ESP-r in your home directory, use the" echo " command:" echo " " echo " $ ./Install -d ~/esru" echo " " echo " It is also possible to build esp-r executables " echo " individually, by specifying the name(s) of the " echo " desired program(s), eg:" echo " " echo " $ ./Install bps " echo " " echo " or to install a module in a specific location" echo " " echo " $ ./Install -d ~/esru bps " echo " " echo " The installation script also supports silent " echo " (non-interactive) usage, using the '--silent' " echo " command line argument. Any of the command-line " echo " arguments specified below can be used in " echo " combination with the '--silent' option." echo " " echo " ARGUMENTS: " echo " " echo " to install one or more named modules (e.g." echo " Install clm for the module clm)" echo " " echo " --compiler_version : Append to the default" echo " compiler binaries. For instance, to invoke the compiler" echo " binaries gcc-3.4.6, g++-3.4.6, and g77-3.4.6, specify " echo " '--compiler_version -3.4.6'." echo " compilation on Apple PPC machines should typically use" echo " '--compiler_version -3.3'." echo " " echo " -d , --destination : Install " echo " ESP-r in /esp-r directory. The " echo " default path is ${DESTdir}." echo " " echo " --debug: Include debugging symbols in executable" echo " the default is no debugging symbols. Note that" echo " if you include debugging then you should answer" echo " no when asked if you want to install the executables." echo " " echo " --extra-debug: Enable extended debugging options" echo " " echo " --force: Overwrite a corrupted installation. " echo " " echo " --fpe: Enable compiler-specific floating-point-exception" echo " handling procedures, if available." echo " " echo " --gcc32: Use 3.2 version of GCC provided by the" echo " compat-gcc-32, compat-gcc-32-c++, compat-gcc-32-g77" echo " and compat-libf2c-32 packages." echo " " echo " --gcc4: Use the GCC4 compilers (gcc, g++ and gFortran)." echo " NOTE: compilation of ESP-r with GCC4+ is not currently" echo " supported, and may introduce uncertianty into results." echo " GCC4-builds of ESP-r should be used for testing purposes" echo " only." echo " " echo " -h, --help: Display this help message." echo " " echo " --intel: Use the intel compiler suite (icc,ifort,icpc)." echo " " echo " --no_dbs: Skip installation of database files." echo " " echo " --no_exes: Do not copy executable files into the" echo " installation directory." echo " " echo " --no_training: Skip installation of training models." echo " " echo " --skip_ish_calcs: Skip recalculation of shading files " echo " associated with training and validation exemplars." echo " This option significantly shortens the time required" echo " to install training and validation files, but shading" echo " files must be updated manually." echo " " echo " --silent: Invoke the silent (non-interactive) installation" echo " mode. Default options will be selected, unless " echo " alternatives are specified in command-line parameters." echo " " echo " --X11, --GTK, --noX:" echo " Build ESP-r using the specified graphics library (that", echo " is; X11, GTK or noX for a console-only application)." echo " " echo " --xml: Compile bps with support for direct export of results" echo " in xml and csv formats. Requires the GNU libxml2 and" echo " libstdc++ libraries." echo " " echo " -v, --verbose: Print compilation messages to screen." echo " " echo " Notes:" echo " " echo " 1. While ESP-r compiles with the GCC 4 / gFortran compilers, the " echo " results obtained with ESP-r binaries built with GCC4 exhibit " echo " unexplained differences from the GCC3 versions. Until the " echo " GCC4 results have been verified, use GCC3-built versions of " echo " ESP-r for scientific research or consulting work." echo " " echo " 2. There are two versions of ESP-r - the standard full distribution" echo " based on the X11 graphic libraries and a beta version which uses the" echo " GTK graphic libraries (but which lacks a few facilities)." echo " " exit fi # check that xml support is available if [ "$xml_support" = "yes" ] || [ "$xml_support" = "prompt" ]; then # check for libxml2 headers on system if [ ! -d /usr/include/libxml2 ] && [ ! -d /usr/local/include/libxml2 ]; then # Libraries not found. Disable XML support xml_support="no" xml_libs_found="no" # If runnning silently, warn user. if [ "$mode" = "silent" ]; then echo " " echo " Warning: Library libxml2 could not be found" echo " in /usr/include or /usr/local/include " echo " " echo " XML support disabled." fi else # Add XML include files to include paths xml_libs_found="yes" LIBXML2_INCLUDE="-I/usr/include/libxml2 -I/usr/local/include/libxml2" # xml support may optionally include support for xslt & exslt. Check # that libraries are available # # This code has only been tested with GNU ld. # ld_output=`ld -o /dev/null -lxslt 2>&1 | sed "s/^ld: cannot find .*$//g"` case $ld_output in "") xsl_libs_available="no";; *) xsl_libs_available="yes";; esac fi fi #-------------------------------------------------------------------- # Error trap command-line options #-------------------------------------------------------------------- #check that platform can be successfully detected. if [ "$platform" = "auto-detect" ]; then # auto-dectectable architectures - add more as additional platforms # become available. if [ "$architecture" != "Linux" ] && [ "$architecture" != "CYGWIN_NT-5.1" ] && [ "$architecture" != "CYGWIN_NT-5.0" ] && [ "$architecture" != "CYGWIN_NT-5.2" ] && [ "$architecture" != "MINGW32_NT-5.1" ] && [ "$architecture" != "MINGW32_NT-5.0" ] && [ "$architecture" != "MINGW32_NT-5.2" ] && [ "$architecture" != "Darwin" ] && [ "$architecture" != "SunOS" ]; then platform="prompt"; # Auto-detection of platform is not supported # If in silent mode, inform user and quit. if [ "$mode" = "silent" ]; then echo " " echo " ERROR: could not interpret machine architecture (${architecture})" echo " Specify using the --platform switch, or run script in interactive" echo " mode." echo " " exit fi fi fi #---------------------------------------------------------------------- # Prompt user for basic options if script is running interactively # # - We could add more options here, and perhaps provide novice/expert # modes... #---------------------------------------------------------------------- if [ "$mode" = "interactive" ]; then echo " " echo " Please answer the following questions. Default answers" echo " are in []. To accept the default, press return. " # Check if platform auto-dectection is enabled, and confirm with user if [ "${platform}" = "auto-detect" ]; then YN=none; echo " " echo " Your computer identifies itself as ${architecture}. " echo " Is this information correct (y/n)? [y]" while [ "$YN" != "y" ] && [ "$YN" != "n" ] && [ "$YN" != "" ] do if [ "$YN" != "none" ]; then echo "" echo "Please answer yes or no (y/n) [y]." fi read YN done if [ "$YN" = "n" ]; then # user must be prompted for platform platform="prompt" fi fi #Platform auto-detection disabled, or user wants to overide if [ "${platform}" = "prompt" ]; then A=none; while [ $A != "1" ] && [ $A != "2" ] && [ $A != "3" ] && [ $A != "4" ] && [ $A != "5" ] && [ $A != "6" ] do if [ $A != "none" ]; then echo "" echo " Please choose a type from the list (1-5)." echo "" fi echo " Computer type: " echo " (1) Sun / solaris" echo " (2) Linux" echo " (3) Cygwin (Late-Beta testing)" echo " (4) MinGW (native Windows)" echo " (5) MacOS X (10.2 or later)" read A # Use the 'known_host' keyword to permit compilation # on frequently used, nonstandard hosts. if [ "$A" = "known_host" ]; then echo " Host: " echo " (1) nrn7 (SunOS)" read A case $A in 1) custom_host="nrn7" A=1 mode="silent";; *) echo "Error: Unknown host" exit;; esac fi done case "$A" in 1) platform=sun;; 2) platform=linux;; 3) platform=cygwin;; 4) platform=mingw;; 5) platform=mac;; esac fi fi #----------------------------------------------------------- # If auto-detection is active, interpret architecture #----------------------------------------------------------- if [ "$platform" = "auto-detect" ]; then # Add more architectures here as they become available. # Note: $architecture has been error-trapped above. case $architecture in Linux) platform="linux";; CYGWIN_NT-5.2 | CYGWIN_NT-5.1 | CYGWIN_NT-5.0 ) platform="cygwin";; MINGW32_NT-5.2 | MINGW32_NT-5.1 | MINGW32_NT-5.0 ) platform="mingw";; Darwin) platform="mac";; SunOS) platform="sun";; esac fi #----------------------------------------------------------- # Architcture is now known. If architecture is sun, prompt # for compiler. On macs, users should use --compiler_version -3.3 # directive. Otherwise, use GNU set. #----------------------------------------------------------- if [ "$mode" = "interactive" ]; then if [ "$platform" = "sun" ] || [ "$platform" = "linux" ]; then compiler="prompt" fi fi if [ "$compiler" != "prompt" ]; then if [ "$use_intel" = "yes" ]; then compiler="intel" else compiler="GNU" fi fi if [ "$compiler" = "prompt" ] && [ "$mode" = "interactive" ]; then A=none; echo "" echo " ESP-r can be built with the Sun Fortran 90, GNU or " echo " intel compilers." while [ $A != "1" ] && [ $A != "2" ] && [ $A != "3" ] do if [ $A != "none" ]; then echo "" echo " Please choose a compiler from the list [2]." echo "" fi echo " Compiler: " echo " (1) Sun fortran 90 (cc and f90)" echo " (2) GNU fortran (gcc 3.X and g77)" echo " (3) Intel fortran (icc, icpc and ifort)" read A if [ "$A" = "" ]; then A="2" fi done case "$A" in 1) compiler=sunF90;; 2) compiler=GNU;; 3) compiler=intel;; esac else echo " " echo " The $compiler compiler set will be used." fi #----------------------------------------------------------- # Prompt user for inclusion of H3Kreports (XML output) # on supported platforms (presently linux/cygwin/mingw!) #----------------------------------------------------------- if [ "$mode" = "interactive" ]; then if [ "$platform" = "linux" ] || [ "$platform" = "cygwin" ] || [ "$platform" = "mingw" ] || [ "$platform" = "mac" ] || [ "$platform" = "sun" ] ; then # XML available on platform if [ "${xml_libs_found}" = "no" ]; then #LIBXML2 libraries not available. echo " " echo " The libxml2 library does not appear to be installed" echo " on this system. The library could not be found in" echo " /usr/include or /usr/local/include. Support for " echo " experimental XML output will be disabled, but the " echo " rest of the ESP-r installation will proceed normally. " else # Libraries were found. Prompt user for inclusion. B="none" while [ "$B" != "y" ] && [ "$B" != "n" ] && [ "$B" != "Y" ] && [ "$B" != "N" ] do if [ "$B" != "none" ]; then echo "" echo "Please answer yes or no (y/n)." fi echo " " echo " Install with experimental XML output support? This may " case "${xml_support}" in yes) echo " significantly increase simulation run-time. (y/n) [y]";; *) echo " significantly increase simulation run-time. (y/n) [n]";; esac read B if [ "$B" = "" ]; then case "${xml_support}" in yes) B="y";; *) B="n";; esac fi done if [ "$B" = "y" ]; then # Enable xml xml_support="yes" echo " XML output enabled for bps" else # Disable XML xml_support="no" echo " XML output excluded from bps" fi fi else # XML not available on platform. echo " " echo " Experimental XML output support. is presently not " echo " available on ${platform}. XML support disabled." xml_support="no" fi else # Silent mode: Disable XML by default if [ "$xml_support" = "prompt" ]; then xml_support="no" fi fi #---------------------------------------------------------------------- # Prompt for graphics libraries #---------------------------------------------------------------------- if [ "$mode" = "interactive" ]; then # Which modes are actually available, given our platform/compiler # combination? GTK_prompt="1" X11_prompt="2" noX_prompt="3" default="$X11_prompt" if [ "$compiler" = "sunF90" ]; then # Is GTK really incompatable with f90 on sun? GTK_prompt="-" fi if [ "$platform" = "mingw" ]; then # MinGW by definition excludes X11. X11_prompt="-" default="$noX_prompt" fi A=none; while [ "$A" != "$GTK_prompt" ] && [ "$A" != "$X11_prompt" ] && [ "$A" != "$noX_prompt" ] do if [ "$A" != "none" ]; then echo "" echo " Please choose a graphics library from the list." echo "" fi echo " Graphics library: [$default] " if [ "$GTK_prompt" != "-" ]; then echo " (1) GTK graphics library"; fi if [ "$X11_prompt" != "-" ]; then echo " (2) X11 graphics library"; fi if [ "$noX_prompt" != "-" ]; then echo " (3) no graphics library (text-only application)"; fi read A if [ "$A" = "-" ]; then A=none; fi if [ "$A" = "" ]; then A="$default" fi done case "$A" in "$GTK_prompt") xLibs=GTK;; "$X11_prompt") xLibs=X11;; "$noX_prompt") xLibs=noX;; esac else # Assume X11 is available on all systems, except mingw # Xll is defaulted to if [ "$platform" = "mingw" ]; then xLibs=noX echo " " echo " A text-only application will be compiled." else echo " " echo " The $xLibs libraries will be used." fi fi #--------------------------------------------------------- # Prepend approprate grapics library to target list #---------------------------------------------------------- case $xLibs in X11) targets=" libX11 $targets";; GTK) targets=" libGTK $targets";; noX) targets=" libnoX $targets";; esac #--------------------------------------------------------- # Query about debugging, installation of training and # database files #--------------------------------------------------------- if [ "$mode" = "interactive" ]; then # Debugging B="none" while [ "$B" != "y" ] && [ "$B" != "n" ] && [ "$B" != "Y" ] && [ "$B" != "N" ] do if [ "$B" != "none" ]; then echo "" echo " Please answer yes or no (y/n)." else echo " " echo " ESP-r can optionally retain debugging symbols and " echo " object files for use with a debugging program such" echo " as GDB." echo " " fi case "${debugging}" in yes) echo " Retain debugging symbols? (y/n) [y]";; *) echo " Retain debugging symbols? (y/n) [n]";; esac read B if [ "$B" = "" ]; then case "${debugging}" in yes) B="y";; *) B="n";; esac fi done if [ "$B" = "y" ] || [ "$B" = "Y" ]; then debugging="yes" else debugging="no" fi # System databases B="none" while [ "$B" != "y" ] && [ "$B" != "n" ] && [ "$B" != "Y" ] && [ "$B" != "N" ] do if [ "$B" != "none" ]; then echo "" echo "Please answer yes or no (y/n)." fi case "${install_dbs}" in yes) echo " Install ESP-r database files? (y/n) [y]";; *) echo " Install ESP-r database files? (y/n) [n]";; esac read B if [ "$B" = "" ]; then case "${install_dbs}" in yes) B="y";; *) B="n";; esac fi done if [ "$B" = "y" ] || [ "$B" = "Y" ]; then install_dbs="yes" else install_dbs="no" fi # Training files B="none" while [ "$B" != "y" ] && [ "$B" != "n" ] && [ "$B" != "Y" ] && [ "$B" != "N" ] do if [ "$B" != "none" ]; then echo "" echo "Please answer yes or no (y/n)." fi case "${install_training}" in yes) echo " Install training files? (y/n) [y]";; *) echo " Install training files? (y/n) [n]";; esac read B if [ "$B" = "" ]; then case "${install_training}" in yes) B="y";; *) B="n";; esac fi done if [ "$B" = "y" ] || [ "$B" = "Y" ]; then install_training="yes" else install_training="no" fi fi #--------------------------------------------------------- # Assign universal flags and variables. #--------------------------------------------------------- #Enbable debug mode if [ "$debugging" = "yes" ]; then debug_flag="-g" else debug_flag=" " fi #--------------------------------------------------------- # Assign architecture-specific flags #--------------------------------------------------------- #ESP-r related header files LOCAL_INCLUDES="-I../include -I../shocc -I/usr/local/include -I../cetc/h3kreports" #---------- MCTYPE --------------------------------- # Create short strings for machine types case $platform in sun) MCTYPE=sun ;; linux) MCTYPE=lin ;; cygwin) MCTYPE=cygw;; mac) MCTYPE=osx ;; mingw) MCTYPE=mingw ;; # Custom hosts follow: nrn7) MCTYPE=sun;; esac #---------------- XINSTALLDIR ---------------------- # Default location of x libraries case $xLibs in GTK) XINSTALLDIR="`pkg-config gtk+-2.0 --cflags --libs`";; X11) X11_found="no" case $platform in sun) XDEFDIR="/usr/openwin" # Check if the libraries are in /usr/openwin if [ -d /usr/openwin/lib/X11 ]; then X11_found="yes" XINSTALLDIR="/usr/openwin" fi ;; *) # linux/mac/cygwin: we'll need to search for # the X11 libraries in a number of possible # locations: XDEFDIR="/usr/X11R6 or /usr" # Try /usr/X11R6 - legacy location on monolithic X locations if [ -d /usr/X11R6/lib/X11 ] ; then X11_found="yes" XINSTALLDIR="/usr/X11R6" fi # Try /usr --- location on new linux distros with 'modular X' if [ -d /usr/lib/X11 ] && [ "$X11_found" = "no" ]; then X11_found="yes" XINSTALLDIR="/usr" fi ;; esac # if X11 still hasn't been found, ask user where it's # installed. if [ "$X11_found" = "no" ] && [ "$mode" = "interactive" ]; then echo " The X11 libraries could not be found in the defualt" echo " location ($XDEFDIR)." try_agian="y" while [ "$try_agian" == "y" ] || [ "$try_agian" == "Y" ] do echo " Do you wish to search for the X11 libraries at" echo " an alternate location?" read try_again if [ "$try_agian" = "" ]; then try_again="y" fi if [ "$try_again" = "y" ] || [ "$try_agian" = "Y" ]; then echo " Location of X11 installation? " read XINSTALLDIR if [ -d $XINSTALLDIR/lib/X11 ]; then echo " X11 was found at $XINSTALLDIR." X11_found="yes" try_agian="no" else echo " X11 could not be found at $XINSTALLDIR!" fi fi done fi # If X11 still hasn't been found, issue error and quit. if [ "$X11_found" = "no" ]; then echo " " echo " ERROR:" echo " Could not find the X-window libraries!" echo " " exit fi # Now check if the appropriate include files are installed # on the system. if [ -r $XINSTALLDIR/include/X11/X.h ]; then X11INCLUDEDIR=$XINSTALLDIR/include else if [ -r /usr/include/X11/X.h ]; then X11INCLUDEDIR=/usr/include else echo " " echo " ERROR:" echo " The X-window libraries were found at $XINSTALLDIR," echo " but the X11 header files (e.g. X.h) could not be" echo " found at $XINSTALLDIR/include/X11." echo " " echo " This may indicate that you're missing the X11 header" echo " files necessary to compile the X11 version of ESP-r." echo " Check to see if you've installed the X11 development" echo " package (usually called xfree86-devel, xorg-X11-devel," echo " or libX11-devel.)" exit fi fi ;; noX) XINSTALLDIR="";; esac #--------------- CC, CPL, FC ----------------------- # Assign compilers case $compiler in sunF90) CC=cc; CPL=CC; FC=f90 ;; GNU) case $gnu_version in gcc3) CC=gcc; CPL=g++; FC=g77; ;; gcc32) CC=gcc32; CPL=g++32; FC=g77 ;; gcc4) CC=gcc; CPL=g++; FC=gfortran ;; esac;; intel) CC=icc; CPL=icpc; FC=ifort ;; esac if [ "$compiler_version" != "none" ]; then CC="$CC$compiler_version" CPL="$CPL$compiler_version" FC="$FC$compiler_version" fi #--------------- OPTIONS for extended debugging ----------- ExtendedDebugFlags="" if [ "$extendedDebugging" == "yes" ]; then case $compiler in sunF90) ExtendedDebugFlags="$ExtendedDebugFlags";; GNU) case $gnu_version in gcc3) ExtendedDebugFlags="$ExtendedDebugFlags -fbounds-check -Wuninitialized -O" ;; gcc32) ExtendedDebugFlags="$ExtendedDebugFlags -fbounds-check -Wuninitialized -O" ;; gcc4) ExtendedDebugFlags="$ExtendedDebugFlags -fbounds-check -Wunderflow -Wconversion -frange-check" ;; esac;; intel) ExtendedDebugFlags="$ExtendedDebugFlags -debug all -C -fp-stack-check -traceback -inline-debug-info -fpe0 " ;; esac fi #--------------- WWLINK ----------------------- # Assign wwlink variable --- is this used anymore? case $compiler in sunF90) WWLINK="shared_solaris" ;; GNU) WWLINK="unshared" ;; esac #--------------- FFLAGS ----------------------- # Write out platform specific ifdef variables. # These will be inserted into FFLAGS, below. case $platform in sun) fDefType="-DSUN";; linux) fDefType="-DLIN";; cygwin) fDefType="-DCYGW";; mac) fDefType="-DOSX -DLIN";; mingw) fDefType="-DMINGW";; esac # Append -DX11 flag as necessary if [ "$xLibs" = "X11" ]; then fDefType="$fDefType -DX11" fi if [ "$xLibs" = "GTK" ]; then fDefType="$fDefType -DGTK" fi # Assign fortran compilation flags case $compiler in # Note '-C' flag causes some grief on older sun F90 compilers (~v5.0) sunF90) FFLAGS="$LOCAL_INCLUDES $fDefType -DF90 $debug_flag $ExtendedDebugFlags -C " ;; GNU) FFLAGS="$LOCAL_INCLUDES $fDefType $debug_flag $ExtendedDebugFlags -fno-automatic"; case $gnu_version in # set -finit-local-zero for gcc3 gcc4) FFLAGS="$FFLAGS -DGCC4" ;; *) FFLAGS="$FFLAGS -finit-local-zero -m32" ;; esac ;; intel) FFLAGS="$LOCAL_INCLUDES $fDefType -save -zero -assume byterecl $debug_flag $ExtendedDebugFlags" ;; esac if [ "$platform" = "mingw" ] && [ "$xLibs" = "GTK" ]; then FFLAGS="$FFLAGS -mwindows -mms-bitfields" fi #-------------- CFLAGS --------------------- # set up paths to c/c++ include files --- append X11 include # path for X11 builds case $xLibs in X11) cINCLUDES="$LOCAL_INCLUDES -I$X11INCLUDEDIR";; *) cINCLUDES="$LOCAL_INCLUDES";; esac # Append XML include paths, if needed case $xml_support in yes) cINCLUDES="$cINCLUDES $LIBXML2_INCLUDE";; no) cINCLUDES="$cINCLUDES";; esac # assign c/c++ IDFEF flags. These will be inserted into CFLAGS, below. cDefType="$fDefType" # Set xsl ifdef flag depending on whether xslt libraries are available # and XML support is active, if [ "$xml_support" = "yes" ] && [ "$xsl_libs_available" = "yes" ]; then cDefType="$cDefType -DXSL" fi # set up c compilation flags case $compiler in sunF90) CFLAGS="$cINCLUDES $cDefType $debug_flag $ExtendedDebugFlags";; GNU) CFLAGS="$cINCLUDES $cDefType $debug_flag $ExtendedDebugFlags -m32 ";; intel) CFLAGS="$cINCLUDES $cDefType -save -zero $debug_flag $ExtendedDebugFlags";; esac # Add '-mms-bitfields' and '-mwindows' on Mingw+GTK if [ "$platform" = "mingw" ] && [ "$xLibs" = "GTK" ]; then CFLAGS="$CFLAGS -mwindows -mms-bitfields" fi #------------- ULIBS ------------------------- # Assign library paths/flags case $platform in sun) ULIBS="-L${SRCdir}/lib ";; linux) ULIBS="-L${SRCdir}/lib ";; cygwin) ULIBS="-L${SRCdir}/lib ";; mac) ULIBS="-L${SRCdir}/lib ";; mingw) ULIBS="-L${SRCdir}/lib -L/usr/local/lib";; esac # Append versioning information library ULIBS="$ULIBS -lversion" # Append exception-handling library (which may contain a dummy # function if FPE handling is disabled) ULIBS="$ULIBS -lfpe" # Append X11 library paths to ULIBS as required (patch for 64 bit RH enterprise) case $xLibs in X11) ULIBS="$ULIBS -lxesru -L/usr/X11R6/lib -lX11";; GTK) ULIBS="$ULIBS -lgtkesru -L${XINSTALLDIR}";; noX) ULIBS="$ULIBS -lnoxesru";; esac # Append XML output libararies to ULIBS as required (libxml2 and libstdc++) case $xml_support in yes) # Link xml libraries, along with stdc++. ULIBS="$ULIBS -lXML -lstdc++"; # If libxslt is available, link it too case $xsl_libs_available in "yes") ULIBS="$ULIBS -lxslt";; "no") ULIBS="$ULIBS ";; esac; # Add link to libxml2. This must follow # -lxslt on cygwin/mingw. ULIBS="$ULIBS -lxml2"; # Append ws2_32 library on mingw. case $platform in mingw) ULIBS="$ULIBS -lws2_32";; *) ULIBS="$ULIBS";; esac; # Flag xml for inclusion in bps targets="enableXML $targets";; no) ULIBS="$ULIBS -lXML "; # Flag xml for exclusion in bps targets="disableXML $targets";; esac #-------------- LDFLAGS ------------------------ # What does this do, and how does it differ from platform-specific # flags set in 'fDefType'? case $platform in mingw) LD_FLAGS="-DMINGW";; *) LD_FLAGS="";; esac #-------------- EXE ------------------------ # Set exe file extention case $platform in sun) EXE="";; linux) EXE="";; cygwin) EXE=".exe";; mac) EXE="";; mingw) EXE=".exe";; #Custom housts follow nrn7) EXE="" ;; esac #-------------- FPE ------------------------ # Possibly enable compiler-specific exception handling # Target for primitive gcc3 exception handling gcc3_fpe_target="disableGccFPE" if [ "$enableFPE" == "yes" ]; then case $compiler in sunF90) ;; GNU) case $gnu_version in gcc3) gcc3_fpe_target="enableGccFPE" ;; gcc32) gcc3_fpe_target="disableGccFPE" ;; gcc4) gcc3_fpe_target="disableGccFPE" ;; esac;; esac fi # Append GCC3 fpe target to targets list targets="$gcc3_fpe_target $targets" #=========================================== ##### End Computer Architecture ##### ##### Create esp-r directory tree #=========================================== #--------------------------------------------------------- # Check if installation directories exist, and create # if necessary #--------------------------------------------------------- create_espr_dir="no" # Does top-level installation directory exist? if [ ! -d $DESTdir ]; then # NO! Is script running interactively, or has user specified a 'force?' if [ $mode = "interactive" ] && [ "$preserve_espr_dir" == "yes" ] ; then # Does user want to create it? echo " " echo " The esp-r installation directory does not exist. " echo " (${DESTdir})" A=none while [ "$A" != "y" ] && [ "$A" != "n" ] do echo " " echo " Do you wish to create this directory? (y/n) [y]" echo " " read A if [ "$A" = "" ]; then A="y" fi done if [ "$A" = "n" ]; then create_espr_dir="no" else create_espr_dir="yes" preserve_espr_dir="no" fi else create_espr_dir="yes" preserve_espr_dir="no" fi if [ "$create_espr_dir" = "yes" ]; then # Attempt to create directory mkdir ${DESTdir} # Was directory successfully created? if [ ! -d ${DESTdir} ]; then # No! User may not have write permissions on installation dir. # warn, and exit. echo " " echo " Installation error: Destination directory (${DESTdir})" echo " could not be created. Installation aborted." echo " " exit fi # This flag will be used later when the script checks # if the directory tree is correct. else # User doesn't want to create directory, but it doesn't exist. # Issue warning and quit. echo " " echo " Installation error: Destination directory (${DESTdir})" echo " does not exist. Installation aborted" echo " " exit fi fi # Determine if master path is writable. if [ ! -w $DESTdir ] || [ ! -d $DESTdir ]; then # Warn user and quit. echo " " echo " Installation error: Cannot write to installation directory:" echo " $DESTdir" echo " Installation aborted." echo " " exit fi #----------------------------------------------------------- # Now check if ESP-r directory tree exists. Note: If we # created the master directory (above), there's no need to prompt # the user since the directory will obviously be empty. Check # value of DirCreated variable. #----------------------------------------------------------- # Strip trailing space from DESTdir DESTdir=`echo "$DESTdir" | sed "s/\/$//"` ESPdir=${DESTdir}/esp-r ESPbin=${DESTdir}/esp-r/bin corrupted_tree="no" if [ "$create_espr_dir" = "no" ]; then if [ ! -d $ESPdir ] || [ ! -d $ESPdir/bin ] || [ ! -d $ESPdir/climate ] || [ ! -d $ESPdir/databases ] || [ ! -d $ESPdir/electric_loads ] || [ ! -d $ESPdir/lib ] || [ ! -d $ESPdir/manual ] || [ ! -d $ESPdir/xsl ]; then # ESP-r directory tree does not exist, or has been corrupted. corrupted_tree="yes" if [ "$create_espr_dir" = "no" ]; then echo " " echo " The ESP-r directory tree does not exist at ${DESTdir}," echo " or may have been corrupted. The following directories are" echo " required: " echo " $ESPdir" echo " $ESPdir/bin " echo " $ESPdir/climate " echo " $ESPdir/databases " echo " $ESPdir/electric_loads " echo " $ESPdir/lib " echo " $ESPdir/manual " echo " $ESPdir/xsl " fi if [ "$mode" = "interactive" ] && [ "$preserve_espr_dir" = "yes" ] ; then # IF we've created the destination directory, there's # no need to warn the user. A=none while [ "$A" != "y" ] && [ "$A" != "n" ] do echo " " echo " Do you wish to create the ESP-r directory tree at" echo " this location? (y/n) [y]" read A if [ "$A" = "" ]; then A="y" fi done if [ "$A" = "y" ]; then preserve_espr_dir="no" else preserve_espr_dir="yes" fi fi fi fi #-------------------------------------------------------------- # Now build directory tree, if necessary. #-------------------------------------------------------------- if [ "$corrupted_tree" = "yes" ] || [ "$create_espr_dir" = "yes" ]; then if [ "$preserve_espr_dir" = "yes" ]; then echo " " echo " Installation error: Will not not overwrite ESP-r " echo " directory structure at ${DESTdir}. Installation" echo " aborted." echo " " if [ "$mode" = "silent" ]; then echo " Use the '--force' option to overwrite the directory" echo " structure. Run 'Install --help' for more information." echo " " exit fi fi rm -fr $ESPdir mkdir $ESPdir mkdir $ESPdir/bin mkdir $ESPdir/climate mkdir $ESPdir/databases mkdir $ESPdir/electric_loads mkdir $ESPdir/lib mkdir $ESPdir/manual mkdir $ESPdir/xsl fi #-------------------------------------------------------------- # End ESP-r directory management #-------------------------------------------------------------- #-------------------------------------------------------------- # #-------------------------------------------------------------- ####### create an installdir.h file so startup.F knows where to look echo "c this is where esp-r is installed" > ${SRCdir}/include/espinstalldir.h echo " character instpath*48" >> ${SRCdir}/include/espinstalldir.h echo " instpath = '${ESPdir}'" >> ${SRCdir}/include/espinstalldir.h ##### Initiate make: if [ "${make_msg_file}" = "" ]; then echo " " echo " Intended shell command:" echo " make MCTYPE=${MCTYPE} MCC=${CC} MCPL=${CPL} MFC=${FC} DESTdir=${DESTdir} ESPdir=${ESPdir} WWLINK=${WWLINK} EXE="${EXE}" XINSTALLDIR=${XINSTALLDIR} CFLAGS=${CFLAGS} FFLAGS=${FFLAGS} LD_FLAGS=${LD_FLAGS} ULIBS=${ULIBS} xml_status=${xml_status} $targets" echo " " echo " where the $xlibs libraries are in ${XINSTALLDIR}" fi if [ "$mode" = "interactive" ]; then A=x while [ "$A" != y ] && [ "$A" != n ] && [ "$A" != "" ] do echo " " echo " Proceed with installation of esp-r modules (y/n) [y]?" read A done if [ "$A" = "n" ]; then echo " " echo " Aborting ESP-r installation. " echo " " exit fi fi echo " " echo " Installing ESP-r system. This may take some time." #-------------------------------------------------------------- # Get SVN build info for versioning purposes. #-------------------------------------------------------------- echo -n " - gathering versioning information from svn..." # Ensure that build information is always recompiled into # every binary - touch common file version.F, and delete # library/object files. touch ${SRCdir}/lib/version.F >/dev/null 2>&1 rm ${SRCdir}/lib/libversion.a ${SRCdir}/lib/version.o >/dev/null 2>&1 # Get time of build time=`date` # Get system information. (host not used at present) architecture=`uname -m` system=`uname -s` os_flavour=`uname -r` host=`uname -n` # Digest version information in Version text file release=`cat ${SRCdir}/Version | grep "ESP-r release " | sed "s/ESP-r release //g"` # Try to collect svn information svn_info_command="svn info" svn_status_command="svn status" # For debugging... # svn_info_command="cat ~/svn_info.txt" # svn_status_command="cat ~svn_status.txt" svnrevision=`$svn_info_command 2>&1 | grep "^Revision:"` svnnotfound=`$svn_info_command 2>&1 | grep "command not found"` notworkingcopy=`$svn_info_command 2>&1 | grep "is not a working copy"` # Attempt to collect URL from svn info URL=`$svn_info_command 2>&1 | grep "^URL" | sed "s/URL: //g"` # Ensure that the URL is from ESP-r central. Code built from # other repositories is to be designated 'unversioned' URLcvsdude=` echo $URL | grep "https*://[a-zA-Z0-9]*@*svn[0-9]*.cvsdude.com/espr/esp-r/"` URLesprcentral=` echo $URL | grep "https*://[a-zA-Z0-9]*@*esp-r.net/espr/esp-r/"` if [ "$svnnotfound" != "" ] || [ "$notworkingcopy" != "" ] || [ "$svnrevision" = "" ] ; then versioned_repository="no"; else if [ "$URLcvsdude" != "" ] || [ "$URLesprcentral" != "" ]; then versioned_repository="yes" else versioned_repository="no" fi fi # If svn is available and repository is under versioning, # get misc svn information if [ "$versioned_repository" = "yes" ]; then revision_number=`$svn_info_command 2>&1 | grep "^Revision" | sed "s/Revision: //g"` # Get branch name: Strip ESP-r.net/espr/esp-r portion of url branch_name=`echo $URL | sed "s/^.*\/esp-r\///g"` # Strip leading 'branches', if any branch_name=`echo $branch_name | sed "s/branches\///g"` # Strip trailing 'src' branch_name=`echo $branch_name | sed "s/\/src//g"` # Now determine if URL describes development branch, a sub-branch, # or the trunk # Default version to sub-branch... source="Sub-branch" if [ "$branch_name" = "trunk" ]; then source="Trunk" fi if [ "$branch_name" = "development_branch" ]; then source="Development branch" fi # Use svn status to deterine if repository has # been locally modified (denoted by M/G/C status) # svn_status=`$svn_status_command 2>&1 | grep "^[MGC]" ` if [ "$svn_status" != "" ]; then state="Locally modified" else state="Vanilla" fi echo " Done." else echo " Unavailable!" fi #-------------------------------------------------------------- # Now write out build information into automatically generated # header file. #-------------------------------------------------------------- echo "C build_info.h" > ${SRCdir}/include/build_info.h echo "C " >> ${SRCdir}/include/build_info.h echo "C This file contains versioning and build information" >> ${SRCdir}/include/build_info.h echo "C for the ESP-r system. It is generated automatically" >> ${SRCdir}/include/build_info.h echo "C by the Install script each time ESP-r is recompiled---" >> ${SRCdir}/include/build_info.h echo "C any changes should be made in the Install scipt, and " >> ${SRCdir}/include/build_info.h echo "C not in this file" >> ${SRCdir}/include/build_info.h echo "C " >> ${SRCdir}/include/build_info.h echo "C The following fortran variable assignments are " >> ${SRCdir}/include/build_info.h echo "C digested by procedure ESPrVersion() in esrucom/Startup.F" >> ${SRCdir}/include/build_info.h echo " " >> ${SRCdir}/include/build_info.h echo " cBuilder = \"${USER}\" " >> ${SRCdir}/include/build_info.h echo " cHost = \"${host}\"" >> ${SRCdir}/include/build_info.h # echo " cDate = \"${time}\"" >> ${SRCdir}/include/build_info.h echo " cArchitecture = \"${architecture}\"" >> ${SRCdir}/include/build_info.h echo " cOperSystem = \"${system}\"" >> ${SRCdir}/include/build_info.h echo " cOSversion = \"${os_flavour}\"" >> ${SRCdir}/include/build_info.h # Set flag indicating if this is a 'release' build # A release MUST be built from a versioned copy # of TRUNK in a Vanilla state. if [ "$versioned_repository" = "yes" ] && [ "$source" = "Trunk" ] && [ "$state" = "Vanilla" ]; then echo " bRelease = .TRUE." >> ${SRCdir}/include/build_info.h else echo " bRelease = .FALSE." >> ${SRCdir}/include/build_info.h fi echo " cRelease_num = \"${release}\"" >> ${SRCdir}/include/build_info.h if [ "${versioned_repository}" = "yes" ]; then echo " bVersioned = .TRUE. " >> ${SRCdir}/include/build_info.h else echo " bVersioned = .FALSE. " >> ${SRCdir}/include/build_info.h fi if [ "$state" = "Vanilla" ]; then echo " bModified = .FALSE." >> ${SRCdir}/include/build_info.h else echo " bModified = .TRUE." >> ${SRCdir}/include/build_info.h fi echo "C URL commented out, as it likely exceeds g77's " >> ${SRCdir}/include/build_info.h echo "C 72 character-per-line limit." >> ${SRCdir}/include/build_info.h echo "C cURL = \"${URL}\"" >> ${SRCdir}/include/build_info.h echo " cSource = \"$source\"" >> ${SRCdir}/include/build_info.h echo " cBranch = \"$branch_name\" " >> ${SRCdir}/include/build_info.h echo " cRevision = \"$revision_number\"" >> ${SRCdir}/include/build_info.h echo " cState = \"${state}\"" >> ${SRCdir}/include/build_info.h # Add compilers, x-libraries & xml/xsl status echo " cCC = \"$CC\"" >> ${SRCdir}/include/build_info.h echo " cFC = \"$FC\"" >> ${SRCdir}/include/build_info.h echo " cCPL = \"$CPL\"" >> ${SRCdir}/include/build_info.h if [ "$xml_support" = "yes" ]; then echo " cXML_support = \"supported\"" >> ${SRCdir}/include/build_info.h else echo " cXML_support = \"unsupported\"" >> ${SRCdir}/include/build_info.h fi echo " cXlibrary = \"$xLibs\" " >> ${SRCdir}/include/build_info.h #--------------------------------------------------------------------- # Begin build #--------------------------------------------------------------------- targets="${targets} end_of_exes" # Build each executable, 1 by 1. while [ "${targets}" != "end_of_exes" ] do # The following chunk of code is an ugly, but sh-compatable # string-based shift register. # strip any leading spaces targets=`echo $targets | sed 's/^ *//g'` # Extract leading execuitable from targets target=`echo $targets | sed 's/ .*$//g'` # Now remove exe from targets targets=`echo $targets | sed 's/^[^ ]* //g'` # Let user know what's going on echo -n " - building ${target}... " # Empty 'make_msg_file' if it's defined if [ "$make_msg_file" != "" ]; then echo "Compilation of $target on `date`"> $make_msg_file fi # Delete existing binary case $target in libX11) result="${SRCdir}/lib/libxesru.a" ;; libGTK) result="${SRCdir}/lib/libgtkesru.a" ;; libnoX) result="${SRCdir}/lib/libnoxesru.a" ;; enableXML | disableXML ) result="${SRCdir}/lib/libXML.a" ;; disableGccFPE | enableGccFPE) result="${SRCdir}/lib/libfpe.a" ;; ecnv) result="${SRCdir}/esrucnv/ecnv${EXE}" ;; vew) result="${SRCdir}/esruvew/viewer${EXE}" ;; *) result="${SRCdir}/esru${target}/$target${EXE}" ;; esac if [ -r $result ]; then if [ "${make_msg_file}" != "" ]; then echo " Deleting $result " >> $make_msg_file rm $result >> $make_msg_file 2>&1 else echo " Deleting $result " rm $result fi fi # execute make with redirection, if make_msg_file specified. Otherwise # display messages in buffer. if [ "${make_msg_file}" != "" ]; then echo " Make command:" >>$make_msg_file echo " -------------" >>$make_msg_file echo " make MCTYPE=${MCTYPE} MCC=${CC} MCPL=${CPL} MFC=${FC} DESTdir="${DESTdir}" ESPdir="${ESPdir}" WWLINK="${WWLINK}" EXE="${EXE}" XINSTALLDIR="${XINSTALLDIR}" CFLAGS="${CFLAGS}" FFLAGS="${FFLAGS}" LD_FLAGS="${LD_FLAGS}" ULIBS="${ULIBS}" xml_status="${xml_status}" -f Makefile ${target} >>$make_msg_file 2>&1 " >> $make_msg_file echo " " >>$make_msg_file echo " Make output:" >>$make_msg_file echo " ------------" >>$make_msg_file make MCTYPE=${MCTYPE} MCC=${CC} MCPL=${CPL} MFC=${FC} DESTdir="${DESTdir}" ESPdir="${ESPdir}" WWLINK="${WWLINK}" EXE="${EXE}" XINSTALLDIR="${XINSTALLDIR}" CFLAGS="${CFLAGS}" FFLAGS="${FFLAGS}" LD_FLAGS="${LD_FLAGS}" ULIBS="${ULIBS}" xml_status="${xml_status}" -f Makefile ${target} >>$make_msg_file 2>&1 else echo "" make MCTYPE=${MCTYPE} MCC=${CC} MCPL=${CPL} MFC=${FC} DESTdir="${DESTdir}" ESPdir="${ESPdir}" WWLINK="${WWLINK}" EXE="${EXE}" XINSTALLDIR="${XINSTALLDIR}" CFLAGS="${CFLAGS}" FFLAGS="${FFLAGS}" LD_FLAGS="${LD_FLAGS}" ULIBS="${ULIBS}" xml_status="${xml_status}" -f Makefile ${target} fi # was target built successfully? if [ ! -r $result ]; then #ignore if a clean command was invoked. if [ "$target" != "clean" ]; then # file has not changed --- installation failed. # Warn user and quit. echo " " echo " ERROR: could not build executable ${target}! " # If redirection in use, dump messages. if [ "${make_msg_file}" != "" ]; then echo " Compilation messages follow: " echo " ----------------------------------------- " cat ${make_msg_file} echo " ----------------------------------------- " rm -f ${make_msg_file} fi echo " Install: Fatal error. " echo " Executable ${target} could not be built!" echo " Installation aborted." echo " " exit fi else echo "Done." fi # delete message file, if necessary if [ "${make_msg_file}" != "" ]; then rm -f ${make_msg_file} fi done #### End Initiate make ##### Install training, manual & support files. # Set executables to be the just compiled versions (default to users default # if any not found). BPS=bps CLM=clm ISH=ish PRJ=prj PDB=pdb if [ -f esrubps/bps ] ; then BPS=${SRCdir}/esrubps/bps fi if [ -f esruclm/clm ] ; then CLM=${SRCdir}/esruclm/clm fi if [ -f esruish/ish ] ; then ISH=${SRCdir}/esruish/ish fi if [ -f esruprj/prj ] ; then PRJ=${SRCdir}/esruprj/prj fi if [ -f esrupdb/pdb ] ; then PDB=${SRCdir}/esrupdb/pdb fi echo " " echo -n " Installing esprc and default (configuration files) into ${ESPdir}..." #----------------------------- # Write out default ESP-r file #----------------------------- # Header tag for default file echo "*ESP-r Defaults" > ${ESPdir}/default # Installation path? echo "*ipth ${ESPdir}" >> ${ESPdir}/default # Default names for model files (why do they point to explicit paths # in the training directory, and what about all the files that aren't # included in this list/ echo "*cfg ${ESPdir}/training/basic/cfg/bld_basic.cfg" >> ${ESPdir}/default echo "*ctl ${ESPdir}/training/basic/ctl/bld_basic.ctl" >> ${ESPdir}/default echo "*mfn ${ESPdir}/training/basic/networks/bld_basic_af1.afn" >> ${ESPdir}/default echo "*dfd ${ESPdir}/training/cfd/template.dfd" >> ${ESPdir}/default echo "*pnf ${ESPdir}/training/plant/vent_simple/cfg/vent.cfg" >> ${ESPdir}/default # Will we install databases? case "${install_dbs}" in yes) # Use current installation folder for default databses DBInstDir="${ESPdir}" LinkDB="yes" ;; no) # Check if databases were previously installed in this folder if [ -r ${ESPdir}/databases/pressc.db1 ]; then # They were previously installed. Link to installation folder DBInstDir="${ESPdir}"; LinkDB="yes" else # They were not installed. Perhaps they're available in usr/esru? if [ -r /usr/esru/esp-r/databases/pressc.db1 ]; then DBInstDir="/usr/esru/esp-r"; LinkDB="yes" else LinkDB="no" fi fi ;; esac if [ "${LinkDB}" = "yes" ]; then # Are these default names for results files, or pointers # to example database files? echo "*res ${ESPdir}/databases/test.res" >> ${ESPdir}/default echo "*mfr ${ESPdir}/databases/test.mfr" >> ${ESPdir}/default # Default database file locations? echo "*clm ${DBInstDir}/climate/clm67" >> ${ESPdir}/default echo "*prs ${DBInstDir}/databases/pressc.db1" >> ${ESPdir}/default echo "*prm ${DBInstDir}/databases/material.db3.a" >> ${ESPdir}/default echo "*mlc ${DBInstDir}/databases/multicon.db2" >> ${ESPdir}/default echo "*opt ${DBInstDir}/databases/optics.db2" >> ${ESPdir}/default echo "*evn ${DBInstDir}/databases/profiles.db2" >> ${ESPdir}/default echo "*pdb ${DBInstDir}/databases/plantc.db1" >> ${ESPdir}/default echo "*ecdb ${DBInstDir}/databases/elcomp.db1" >> ${ESPdir}/default echo "*mcdb ${DBInstDir}/databases/mscomp.db1" >> ${ESPdir}/default echo "*icdb ${DBInstDir}/databases/icons.db1" >> ${ESPdir}/default echo "*mldb ${DBInstDir}/databases/mould.db1" >> ${ESPdir}/default echo "*sbem ${DBInstDir}/databases/SBEM.db1" >> ${ESPdir}/default fi # End of default file. echo "*end" >> ${ESPdir}/default #----------------------------------- # Write out ESP-r configuration file #----------------------------------- echo "*ESPRC" > ${ESPdir}/esprc echo "*gprn,rectangular dump,import" >> ${ESPdir}/esprc echo "*tprn,Text dump,/tmp/tx_dump" >> ${ESPdir}/esprc echo "*gxwd,screen dump,import -window root" >> ${ESPdir}/esprc echo "*cad,CAD package,xzip,ZIP" >> ${ESPdir}/esprc # Image viewer program is platform specific: case "${MCTYPE}" in mingw) # Use IE as image viewer (does this work?) echo "*image_display,TIF,iexplore.exe" >> ${ESPdir}/esprc echo "*image_display,XBMP,iexplore.exe" >> ${ESPdir}/esprc echo "*image_display,GIF,iexplore.exe" >> ${ESPdir}/esprc echo "*image_display,XWD,iexplore.exe" >> ${ESPdir}/esprc ;; *) # Use xv as image editor (and what if it's not available?) echo "*image_display,TIF,xv" >> ${ESPdir}/esprc echo "*image_display,XBMP,xv" >> ${ESPdir}/esprc echo "*image_display,GIF,xv" >> ${ESPdir}/esprc echo "*image_display,XWD,xv" >> ${ESPdir}/esprc ;; esac echo "*journal,OFF" >> ${ESPdir}/esprc # Text editor is platform specific: case "${MCTYPE}" in mingw) # Use Wordpad echo "*editor,editor,wordpad.exe" >> ${ESPdir}/esprc ;; *) # Use nedit --- but what if it's not available? # We could use the value of the EDITOR environment # variable, but it might point to a command-line # editor such as vi/nano that wouldn't initialize # correctly outside a terminal. echo "*editor,editor,nedit" >> ${ESPdir}/esprc ;; esac echo "*report_gen,Reporting tool,xfs" >> ${ESPdir}/esprc # Pointer to exemplar files. Will we install exemplar and validation # standards? case "${install_training}" in yes) # Use current installation folder for default databses TVInstDir="${ESPdir}" LinkTV="yes" ;; no) # Check if training/ were previously installed in this folder if [ -r ${ESPdir}/training/exemplars ] && [ -r ${ESPdir}/validation/stds_list ]; then # They were previously installed. Link to installation folder TVInstDir="${ESPdir}"; LinkTV="yes" else # They were not installed. Perhaps they're available in usr/esru? if [ -r /usr/esru/esp-r/training/exemplars ] && [ -r /usr/esru/esp-r/validation/stds_list ]; then TVInstDir="/usr/esru/esp-r"; LinkTV="yes" else LinkTV="no" fi fi ;; esac if [ "${LinkTV}" = "yes" ]; then echo "*exemplars,Exemplars,${TVInstDir}/training/exemplars" >> ${ESPdir}/esprc echo "*validation_stds,Validation standards,${TVInstDir}/validation/stds_list" >> ${ESPdir}/esprc fi # Pointer to defaults file. echo "*db_defaults,Defaults,${ESPdir}/default" >> ${ESPdir}/esprc # Pointer to climate list. Depends on whether databases were installed/found. if [ "${LinkDB}" = "yes" ]; then echo "*db_climates,climatelist,${DBInstDir}/climate/climatelist" >> ${ESPdir}/esprc fi # End of file. echo "*end" >> ${ESPdir}/esprc echo " Done." #--------------------------------------- # Write out training files. #--------------------------------------- if [ "$install_training" = "yes" ]; then echo " " echo " Installing training and validation models. This may take some time." echo -n " - Installing standard bitmaps into ${ESPdir}/lib..." cp ${SRCdir}/bitmaps/*.xbm ${ESPdir}/lib echo " Done." echo -n " - Removing previous training and validation models..." rm -rf ${ESPdir}/training ${ESPdir}/validation echo " Done." echo -n " - Updating materials and climate databases in training models..." cd ${SRCdir} # Note: We're dumping the output to /dev/null, which will suppress # error messsages that would otherwise warn the user if a # database failed to install. But this section of the # installation script is otherwise so verbose, it's extremely # unlikely a user (or developer) would ever notice such a # message. # # In the future, we could wrap the database conversion commands # in a low-level script that would silently invoke prj/clm/pdb/ish, # check if the target binary database was actually created, and # verify its intregity. The script could then stop when an error # was encountered, and provide meaningful output to the user. # # Maybe someday... ./bin/materials_db_conv training/plant/wch/dbs db_prc.a db_prc >/dev/null cd ${SRCdir}/training/cg_ctl/daylit_coef/cfg $CLM -mode text -file dec94.clm -act asci2bin silent dec94_clm.txt >/dev/null cd ${SRCdir} ./bin/materials_db_conv training/plant/hvac_vav/dbs materials.db.a materials.db >/dev/null ./bin/materials_db_conv training/constr/tp_sub/dbs tp_sub.material.asci tp_sub.material >/dev/null echo " Done." echo -n " - Updating materials and climate databases in validation models..." cd ${SRCdir}/validation/CEN/13791/databases $CLM -mode text -file Cond.clm -act asci2bin silent Cond.clm.a >/dev/null $CLM -mode text -file WM_A.clm -act asci2bin silent WM_A.clm.a >/dev/null $CLM -mode text -file WM_B.clm -act asci2bin silent WM_B.clm.a >/dev/null cd ${SRCdir} ./bin/materials_db_conv validation/CEN/13791/databases prim.db.a prim.db >/dev/null echo " Done." echo -n " - Copying training and validation models..." cp -r ${SRCdir}/training ${ESPdir}/training sed -e 's|/usr/esru/esp-r|'"${ESPdir}"'|' ${SRCdir}/training/exemplars > ${ESPdir}/training/exemplars cp -r ${SRCdir}/validation ${ESPdir}/validation sed -e 's|/usr/esru/esp-r|'"${ESPdir}"'|' ${SRCdir}/validation/stds_list > ${ESPdir}/validation/stds_list echo " Done." echo -n " - Removing versioning information from training and validation files..." find ${ESPdir}/training -name "\.svn" | xargs rm -fr find ${ESPdir}/validation -name "\.svn" | xargs rm -fr echo " Done." echo -n " - Removing binary materials db from training models ..." cd ${SRCdir}/ rm -f training/cellular_pv/dbs/cellular_pv.materials rm -f training/constr/tp_sub/dbs/tp_sub.material rm -f training/plant/wch/dbs/db_prc rm -f training/cg_ctl/daylit_coef/cfg/dec94.clm rm -f validation/CEN/13791/databases/prim.db rm -f validation/CEN/13791/databases/WM_A.clm rm -f validation/CEN/13791/databases/WM_B.clm rm -f validation/CEN/13791/databases/Cond.clm echo " Done." # Update directory names in training models to reflect DESTdir # # Scan training and validation folders for configuration files. # echo " - Updating model shading and database records..." cfgnames=(`find ./training ./validation -name "*.cfg" -print`) # Count cfg files cfgcount=`find ./training ./validation -name "*.cfg" -print | wc -l` # # For each cfg file check for shading dbs # cfgnum=0 for file in "${cfgnames[@]}"; do cfgnum=$((${cfgnum} + 1)) printf " -> model ${cfgnum}/${cfgcount} (${file})" # echo FILE: $file # # Create a list of zone ref numbers and isi files in this cfg file # if [ "${skip_ish_calcs}" = "no" ]; then isi=(`egrep '(\*isi\ |\*zon\ )' $file | cut -d# -f1`) # Count zones with shading ish_tag_count=(`egrep '(\*isi\ )' $file | cut -d# -f1 | wc -l `) hits=${#isi[@]} i=0 # # Get the zone number and check if there is a isi file associated # with this zone. The format of the isi variable is # "*zon 1 *zon 2 *isi ../zones/xx.shd" and so on where hits # is the number of words in the list isi. # ish_processed_count=0 while [ $((i)) -lt $((hits-2)) ]; do if [ ${isi[$((i))]} == "*zon" ]; then if [ ${isi[$((i+2))]} == "*isi" ]; then ish_processed_count=$((${ish_processed_count}+1)) printf "\r -> model ${cfgnum}/${cfgcount} (${file}); zone ${ish_processed_count}/${ish_tag_count}" $ISH -mode text -file ${file:2} -zone ${isi[$((i+1))]} -act update_silent > /dev/null shdfile=${file%/*}/${isi[$((i+3))]} mv -f ${shdfile} ${ESPdir}/${shdfile} fi fi i=2+$(($i)) done fi printf "\n" # # Now update the paths in models to reflect install dir. # # Note: This approach will not work for models with plant # networks. ESP-r saves the plant database path in # two locations: a) in the .cfg file, and in the # .pln file. prj uses the record in the .cfg file, # while bps references the record in the .pln file. # Thus training models containing plant networks will # bre browsable, but will not run. # # This code should either be updated to edit the .pln # file as well, or (preferably) bps should be updated # to reference the plant database record in the cfg # file. # sed -e 's|/usr/esru|'"${DESTdir}"'|' ${file} > ${ESPdir}/${file:2} done echo " Done." # Sample result set. echo -n " - Creating example binary results database..." rm -f ${ESPdir}/databases/test.res $BPS -mode text >/dev/null 2>&1 </dev/null ./bin/materials_db_conv databases constr.db2.a ${DESTdir}/esp-r/databases/constr.db2 >/dev/null ./bin/materials_db_conv databases constr.db3.a ${DESTdir}/esp-r/databases/constr.db3 >/dev/null ./bin/materials_db_conv databases north_american.materialdb.a ${DESTdir}/esp-r/databases/north_american.materialdb >/dev/null cp ${SRCdir}/databases/constr.db1.a ${DESTdir}/esp-r/databases/constr.db1.a cp ${SRCdir}/databases/constr.db2.a ${DESTdir}/esp-r/databases/constr.db2.a cp ${SRCdir}/databases/constr.db3.a ${DESTdir}/esp-r/databases/constr.db3.a cp ${SRCdir}/databases/north_american.materialdb.a ${DESTdir}/esp-r/databases/north_american.materialdb.a cp ${SRCdir}/databases/material.db3.a ${DESTdir}/esp-r/databases/material.db3.a cp ${SRCdir}/databases/SBEM.db1 ${DESTdir}/esp-r/databases/SBEM.db1 cp ${SRCdir}/databases/UK_notional.constrdb ${DESTdir}/esp-r/databases/UK_notional.constrdb echo " Done." cd ${SRCdir}/databases echo -n " - Creating binary event profiles databases ..." $PRJ -mode text >/dev/null 2>/dev/null </dev/null 2>/dev/null </dev/null 2>/dev/null </dev/null 2>/dev/null </dev/null 2>/dev/null < ${ESPdir}/climate/climatelist cp README ${DESTdir}/esp-r/climate/Readme cp README_IWEC ${DESTdir}/esp-r/climate/Readme_iwec #Find all assci files (we use the convention of .a) for file in *.a do #Assign asscii file to variable. CLIM_a=${file} #Create binary file name by cutting off the .a suffix. CLIM_b=`echo $file | sed 's/\.a$//g'` #Convert. clim_convert ${ESPdir}/climate/${CLIM_b} ${CLIM_a} done echo " Done." cd ${SRCdir}/databases echo -n " - Copying ASCII databases..." cp multicon.db1 multicon.db2 north_american.constrdb optics.db1 optics.db2 mould.db1 pressc.db1 mscomp.db1 *.desc ${DESTdir}/esp-r/databases echo " Done." fi ##### End Install databases ##### If xml support requested install the XSLT files. if [ "$xml_support" = "yes" ]; then echo " " echo -n " Installing xslt files ..." cp ${SRCdir}/cetc/h3kreports/xsl/*.xsl ${DESTdir}/esp-r/xsl echo " Done." fi ##### Install and Clean up cd ${SRCdir} echo " " echo -n " Installing executables..." if [ "$debugging" = "no" ]; then make ESPdir=${ESPdir} EXE=${EXE} strip >/dev/null 2>&1 fi make ESPBinDir=${ESPbin} EXE=${EXE} InstBins >/dev/null 2>&1 if [ "$debugging" = "no" ]; then make EXE=${EXE} clean >/dev/null 2>&1 fi echo "Done." # Makeup an appropriate esp-r script. if [ ${MCTYPE} = sun ]; then echo "#!/bin/sh" > ${ESPdir}/bin/esp-r echo "if [ X$EFONT_0 = X ]; then" >> ${ESPdir}/bin/esp-r echo " EFONT_0=6x12" >> ${ESPdir}/bin/esp-r echo " EFONT_1=6x13" >> ${ESPdir}/bin/esp-r echo " EFONT_2=8x13" >> ${ESPdir}/bin/esp-r echo " EFONT_3=9x15" >> ${ESPdir}/bin/esp-r echo "fi" >> ${ESPdir}/bin/esp-r echo "prj \$@ &" >> ${ESPdir}/bin/esp-r chmod a+x ${ESPdir}/bin/esp-r elif [ ${MCTYPE} = lin ]; then echo "#!/bin/sh" > ${ESPdir}/bin/esp-r echo "if [ X$EFONT_0 = X ]; then" >> ${ESPdir}/bin/esp-r echo " EFONT_0=6x12" >> ${ESPdir}/bin/esp-r echo " EFONT_1=6x13" >> ${ESPdir}/bin/esp-r echo " EFONT_2=8x13" >> ${ESPdir}/bin/esp-r echo " EFONT_3=9x15" >> ${ESPdir}/bin/esp-r echo "fi" >> ${ESPdir}/bin/esp-r echo "prj \$@ &" >> ${ESPdir}/bin/esp-r chmod a+x ${ESPdir}/bin/esp-r elif [ ${MCTYPE} = cygw ]; then echo "#!/bin/sh" > ${ESPdir}/bin/esp-r echo "if [ X$EFONT_0 = X ]; then" >> ${ESPdir}/bin/esp-r echo " EFONT_0=6x12" >> ${ESPdir}/bin/esp-r echo " EFONT_1=6x13" >> ${ESPdir}/bin/esp-r echo " EFONT_2=8x13" >> ${ESPdir}/bin/esp-r echo " EFONT_3=9x15" >> ${ESPdir}/bin/esp-r echo "fi" >> ${ESPdir}/bin/esp-r echo "prj \$@ &" >> ${ESPdir}/bin/esp-r chmod a+x ${ESPdir}/bin/esp-r elif [ ${MCTYPE} = osx ]; then echo "#!/bin/sh" > ${ESPdir}/bin/esp-r echo "if [ X$EFONT_0 = X ]; then" >> ${ESPdir}/bin/esp-r echo " EFONT_0=6x12" >> ${ESPdir}/bin/esp-r echo " EFONT_1=6x13" >> ${ESPdir}/bin/esp-r echo " EFONT_2=8x13" >> ${ESPdir}/bin/esp-r echo " EFONT_3=9x15" >> ${ESPdir}/bin/esp-r echo "fi" >> ${ESPdir}/bin/esp-r echo "prj \$@ &" >> ${ESPdir}/bin/esp-r chmod a+x ${ESPdir}/bin/esp-r elif [ ${MCTYPE} = mingw ]; then echo "@rem batch file to start project manager - associate with cfg files" > ${ESPdir}/bin/esp-r.cmd echo "start prj -file %1" >> ${ESPdir}/bin/esp-r.cmd fi echo " " echo " Installation complete. Please consult file ${SRCdir}/env/README." echo " " echo " NOTE: Be sure that you have updated your PATH environment" echo " to include directives for the location of the ESP-r" echo " executables. You should ensure that: " echo " "${ESPdir}"/bin" echo " is included in the definition." echo " " exit