| 1 | #!/bin/bash | 
|---|
| 2 |  | 
|---|
| 3 | # ISSM_DIR and MATLAB_DIR must be set correctly. | 
|---|
| 4 | # {{{ | 
|---|
| 5 | if [ "${ISSM_DIR}x" == "x" ]; then | 
|---|
| 6 | echo "ISSM_DIR is not set!" >&2 | 
|---|
| 7 | exit 1; | 
|---|
| 8 | elif [ -d ${ISSM_DIR} ]; then | 
|---|
| 9 | echo "ISSM_DIR: ${ISSM_DIR}" | 
|---|
| 10 | else | 
|---|
| 11 | echo "ISSM_DIR: ${ISSM_DIR} does not exist!" >&2 | 
|---|
| 12 | exit 1; | 
|---|
| 13 | fi | 
|---|
| 14 |  | 
|---|
| 15 | if [ "${MATLAB_DIR}x" == "x" ]; then | 
|---|
| 16 | echo "MATLAB_DIR is not set!" | 
|---|
| 17 | exit 1; | 
|---|
| 18 | elif [ -d ${MATLAB_DIR} ]; then | 
|---|
| 19 | echo "MATLAB_DIR: ${MATLAB_DIR}" | 
|---|
| 20 | else | 
|---|
| 21 | echo "MATLAB_DIR: ${MATLAB_DIR} does not exist!" >&2 | 
|---|
| 22 | exit 1; | 
|---|
| 23 | fi | 
|---|
| 24 | # }}} | 
|---|
| 25 |  | 
|---|
| 26 | #List of external pakages to be installed and their installation scripts | 
|---|
| 27 | EXTERNALPACKAGES="autotools install.sh | 
|---|
| 28 | mpich     install-3.0-macosx64-static.sh | 
|---|
| 29 | cmake     install.sh | 
|---|
| 30 | petsc     install-3.5-macosx64-static.sh | 
|---|
| 31 | m1qn3     install.sh | 
|---|
| 32 | triangle  install-macosx64.sh " | 
|---|
| 33 |  | 
|---|
| 34 | # Install Externalpackages | 
|---|
| 35 | # {{{ | 
|---|
| 36 |  | 
|---|
| 37 | #Files source environment to make sure installed packages are in PATH | 
|---|
| 38 | source $ISSM_DIR/etc/environment.sh | 
|---|
| 39 |  | 
|---|
| 40 | #number of packages: | 
|---|
| 41 | NUMPACKAGES=$(($(echo $EXTERNALPACKAGES | wc -w )/2)) | 
|---|
| 42 |  | 
|---|
| 43 | for ((i=1;i<=$NUMPACKAGES;i++)) | 
|---|
| 44 | do | 
|---|
| 45 | NUM1=$((2*$i-1)) | 
|---|
| 46 | NUM2=$((2*$i)) | 
|---|
| 47 | PACKAGENAME=$(echo $EXTERNALPACKAGES | cut -d " " -f $NUM1-$NUM1) | 
|---|
| 48 | PACKAGEINST=$(echo $EXTERNALPACKAGES | cut -d " " -f $NUM2-$NUM2) | 
|---|
| 49 |  | 
|---|
| 50 | cd $ISSM_DIR/externalpackages/$PACKAGENAME | 
|---|
| 51 |  | 
|---|
| 52 | if [[ $PACKAGEINST -nt  install ]]; then | 
|---|
| 53 | #go ahead and reinstall. | 
|---|
| 54 | echo "Triggering new install of $PACKAGENAME" | 
|---|
| 55 | install_test=1 | 
|---|
| 56 | else | 
|---|
| 57 | #ok, we want to skip, unless the package is not installed: | 
|---|
| 58 | if [ -d install ]; then | 
|---|
| 59 | #could be empty, signaling a failed previous install: | 
|---|
| 60 | if [ "$(ls -A install)" ];then | 
|---|
| 61 | echo "and install directory exists, so skipping install of $PACKAGENAME" | 
|---|
| 62 | install_test=0; | 
|---|
| 63 | else | 
|---|
| 64 | echo "and install directory exists, however, it is empty, so triggering install of $PACKAGENAME" | 
|---|
| 65 | install_test=1; | 
|---|
| 66 | fi | 
|---|
| 67 | else | 
|---|
| 68 | echo "However, install directory does not exist, so triggering install of $PACKAGENAME" | 
|---|
| 69 | install_test=1; | 
|---|
| 70 | fi | 
|---|
| 71 | fi | 
|---|
| 72 |  | 
|---|
| 73 | if [[ $install_test == 1 ]]; then | 
|---|
| 74 | echo "======================================================"; | 
|---|
| 75 | echo "       Installing $PACKAGENAME                        "; | 
|---|
| 76 | echo "======================================================"; | 
|---|
| 77 | ./$PACKAGEINST |  tee compil.log | 
|---|
| 78 | if [ $? -ne 0 ]; then | 
|---|
| 79 | echo "======================================================"; | 
|---|
| 80 | echo "    ERROR: installation of $PACKAGENAME failed        "; | 
|---|
| 81 | echo "======================================================"; | 
|---|
| 82 | #erase install directory, so that next time, we still try and compile this! | 
|---|
| 83 | rm -rf install | 
|---|
| 84 | fi | 
|---|
| 85 | source $ISSM_DIR/etc/environment.sh | 
|---|
| 86 | else | 
|---|
| 87 | echo "======================================================"; | 
|---|
| 88 | echo "       Skipping install of $PACKAGENAME                        "; | 
|---|
| 89 | echo "======================================================"; | 
|---|
| 90 | fi | 
|---|
| 91 | cd .. | 
|---|
| 92 | done | 
|---|
| 93 | # }}} | 
|---|
| 94 |  | 
|---|
| 95 | # Compile ISSM | 
|---|
| 96 | #{{{ | 
|---|
| 97 | cd $ISSM_DIR | 
|---|
| 98 | echo "Uinstalling..." | 
|---|
| 99 | make uninstall | 
|---|
| 100 | echo "Cleaning..." | 
|---|
| 101 | make clean | 
|---|
| 102 | echo "Even cleaner..." | 
|---|
| 103 | make distclean | 
|---|
| 104 | echo "Aureconf..." | 
|---|
| 105 | autoreconf -if | 
|---|
| 106 | echo "Configuring..." | 
|---|
| 107 | ./configure \ | 
|---|
| 108 | --prefix=$ISSM_DIR \ | 
|---|
| 109 | --disable-static \ | 
|---|
| 110 | --enable-standalone-executables \ | 
|---|
| 111 | --enable-standalone-libraries \ | 
|---|
| 112 | --with-matlab-dir="/Applications/MATLAB_R2011b.app/" \ | 
|---|
| 113 | --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \ | 
|---|
| 114 | --with-metis-dir=$ISSM_DIR/externalpackages/petsc/install \ | 
|---|
| 115 | --with-m1qn3-dir=$ISSM_DIR/externalpackages/m1qn3/install \ | 
|---|
| 116 | --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install  \ | 
|---|
| 117 | --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install \ | 
|---|
| 118 | --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install \ | 
|---|
| 119 | --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \ | 
|---|
| 120 | --with-mpi-include=$ISSM_DIR/externalpackages/mpich/install/include  \ | 
|---|
| 121 | --with-mpi-libflags=" -L$ISSM_DIR/externalpackages/mpich/install/lib -lmpich -lpmpich" \ | 
|---|
| 122 | --with-fortran-lib="/usr/local/lib/libgfortran.a" \ | 
|---|
| 123 | --enable-debugging \ | 
|---|
| 124 | --with-numthreads=4 | 
|---|
| 125 |  | 
|---|
| 126 |  | 
|---|
| 127 | if [ $? -ne 0 ]; then echo "FAILED TO CONFIGURE!" && exit 1; fi | 
|---|
| 128 |  | 
|---|
| 129 | echo "Building..." | 
|---|
| 130 | make -j 4 | 
|---|
| 131 | if [ $? -ne 0 ]; then echo "FAILED TO BUILD!" && exit 1; fi | 
|---|
| 132 |  | 
|---|
| 133 | echo "Installing..." | 
|---|
| 134 | make install | 
|---|
| 135 | if [ $? -ne 0 ]; then echo "FAILED TO INSTALL!" && exit 1; fi | 
|---|
| 136 | #}}} | 
|---|