Index: sm/trunk-jpl/packagers/ubuntu/README
===================================================================
--- /issm/trunk-jpl/packagers/ubuntu/README	(revision 18435)
+++ 	(revision )
@@ -1,60 +1,0 @@
-TARBALL INSTALLATION:
-
-To install ISSM, untar ISSM-Ubuntu32.tar.gz 
-You will get an ISSM directory. 
-
-You then need to setup the following environment variable in your 
-.bashrc or .cshrc: 
-
-in your .bashrc: 
-export ISSM_TIER='path_to_untarred_ISSM/bin'
-
-or in your .cshrc: 
-setenv ISSM_TIER 'path_to_untarred_ISSM'
-
-Once this is done, fireup matlab from inside the ISSM directory: 
-matlab -nojvm -r "startup;"
-
-
-UNDER CONSTRUCTION - UNDER CONSTRUCTION - UNDER CONSTRUCTION - UNDER CONSTRUCTION 
--------------------------------------------------------------------------------
-				OR THE RIGHT WAY....
-DPKG/DEB INSTALLATION:
-
-To install from deb archives (*.deb), use:
-
-	> sudo dpkg --install <debarchive>
-
-That's it! But not really. Do make sure that you install petsc and metis first.
-When you first try to install issm, dpkg will tell you that you are missing
-dependencies. Just:
-
-	> sudo apt-get install -f
-
-to fix the dependencies and complete the install. When apt-get is done, you 
-should see something that says that ISSM is installed correctly on your 
-machine. That's it! For real this time.
-
-Uninstalling is simple too:
-
-	> sudo apt-get remove <issmPackageName>
-
-That'll do all the work for you. This won't delete any configuration or user
-defined environment stuff. Just swap "remove" out for "purge" and that'll
-delete everything. And apt-get might ask you to remove unneeded dependencies,
-so you should probably do that to keep your system clean.
-
-To create your own custom debian archive, see the README in issmpkg.
-
--------------------------------------------------------------------------------
-
-APT-GET INSTALLATION: (this doesnot work yet)
-
-To install from apt-get:
-
-	> sudo add-apt-repository <issm_PPA_URL>
-	> sudo apt-get install <issmPackageName>
-
-Just say yes to everything apt asks you, and you're good.
-
-UNDER CONSTRUCTION - UNDER CONSTRUCTION - UNDER CONSTRUCTION - UNDER CONSTRUCTION 
Index: /issm/trunk-jpl/packagers/ubuntu/install.sh
===================================================================
--- /issm/trunk-jpl/packagers/ubuntu/install.sh	(revision 18436)
+++ /issm/trunk-jpl/packagers/ubuntu/install.sh	(revision 18436)
@@ -0,0 +1,127 @@
+#!/bin/bash
+
+# ISSM_DIR and MATLAB_DIR must be set correctly.
+# {{{
+if [ "${ISSM_DIR}x" == "x" ]; then
+   echo "ISSM_DIR is not set!" >&2
+   exit 1;
+elif [ -d ${ISSM_DIR} ]; then
+   echo "ISSM_DIR: ${ISSM_DIR}"
+else
+   echo "ISSM_DIR: ${ISSM_DIR} does not exist!" >&2
+   exit 1;
+fi
+
+if [ "${MATLAB_DIR}x" == "x" ]; then
+   echo "MATLAB_DIR is not set!"
+   exit 1;
+elif [ -d ${MATLAB_DIR} ]; then
+   echo "MATLAB_DIR: ${MATLAB_DIR}"
+else
+   echo "MATLAB_DIR: ${MATLAB_DIR} does not exist!" >&2
+   exit 1;
+fi
+# }}}
+
+#List of external pakages to be installed and their installation scripts
+EXTERNALPACKAGES="autotools install.sh                
+                  cmake     install.sh                
+                  petsc     install-3.5-linux64-static.sh
+                  triangle  install-linux64.sh "
+
+# Install Externalpackages
+# {{{
+
+#Files source environment to make sure installed packages are in PATH
+source $ISSM_DIR/etc/environment.sh
+
+#number of packages: 
+NUMPACKAGES=$(($(echo $EXTERNALPACKAGES | wc -w )/2))
+
+for ((i=1;i<=$NUMPACKAGES;i++))
+do
+	NUM1=$((2*$i-1))
+	NUM2=$((2*$i))
+	PACKAGENAME=$(echo $EXTERNALPACKAGES | cut -d " " -f $NUM1-$NUM1)
+	PACKAGEINST=$(echo $EXTERNALPACKAGES | cut -d " " -f $NUM2-$NUM2)
+
+	cd $ISSM_DIR/externalpackages/$PACKAGENAME
+
+	if [[ $PACKAGEINST -nt  install ]]; then 
+		#go ahead and reinstall. 
+		echo "Triggering new install of $PACKAGENAME"
+		install_test=1
+	else
+		#ok, we want to skip, unless the package is not installed: 
+		if [ -d install ]; then 
+			#could be empty, signaling a failed previous install: 
+			if [ "$(ls -A install)" ];then
+				echo "and install directory exists, so skipping install of $PACKAGENAME"
+				install_test=0;
+			else
+				echo "and install directory exists, however, it is empty, so triggering install of $PACKAGENAME"
+				install_test=1;
+			fi
+		else
+			echo "However, install directory does not exist, so triggering install of $PACKAGENAME"
+			install_test=1;
+		fi
+	fi
+
+	if [[ $install_test == 1 ]]; then 
+		echo "======================================================";
+		echo "       Installing $PACKAGENAME                        ";
+		echo "======================================================";
+		./$PACKAGEINST |  tee compil.log
+		if [ $? -ne 0 ]; then
+			echo "======================================================";
+			echo "    ERROR: installation of $PACKAGENAME failed        ";
+			echo "======================================================";
+			#erase install directory, so that next time, we still try and compile this!
+			rm -rf install
+		fi
+		source $ISSM_DIR/etc/environment.sh
+	else
+		echo "======================================================";
+		echo "       Skipping install of $PACKAGENAME                        ";
+		echo "======================================================";
+	fi
+	cd ..
+done
+# }}}
+
+# Compile ISSM
+#{{{
+cd $ISSM_DIR
+echo "Aureconf..."
+autoreconf -if
+echo "Configuring..."
+./configure \
+	--prefix=$ISSM_DIR \
+	--disable-static \
+	--enable-standalone-executables \
+	--enable-standalone-libraries \
+	--with-matlab-dir="/Applications/MATLAB_R2011b.app/" \
+	--with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install \
+	--with-metis-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install  \
+	--with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install \
+	--with-mpi-include=$ISSM_DIR/externalpackages/petsc/install/include  \
+	--with-mpi-libflags=" -L$ISSM_DIR/externalpackages/petsc/install/lib -lmpich -lmpl " \
+	--with-fortran-lib="-L/usr/lib/gcc/x86_64-linux-gnu/4.6/ -lgfortran" \
+	--enable-debugging \
+	--with-numthreads=4
+
+
+if [ $? -ne 0 ]; then echo "FAILED TO CONFIGURE!" && exit 1; fi
+
+echo "Building..."
+make -j 8
+if [ $? -ne 0 ]; then echo "FAILED TO BUILD!" && exit 1; fi
+
+echo "Installing..."
+make install 
+if [ $? -ne 0 ]; then echo "FAILED TO INSTALL!" && exit 1; fi
+#}}}
Index: /issm/trunk-jpl/packagers/ubuntu/package.sh
===================================================================
--- /issm/trunk-jpl/packagers/ubuntu/package.sh	(revision 18435)
+++ /issm/trunk-jpl/packagers/ubuntu/package.sh	(revision 18436)
@@ -1,15 +1,31 @@
-#/bin/bash
+#!/bin/bash
 
-#Just tar gz the bin/ directory and test/ directory and put a startup.m file.
+echo "modify generic" 
+cd $ISSM_DIR/bin
+cat generic_static.m | sed -e "s/generic_static/generic/g" > generic.m
+echo "move mpiexec to bin" 
+cp ../externalpackages/mpich/install/bin/mpiexec .
+cp ../externalpackages/mpich/install/bin/hydra_pmi_proxy .
 
-rm -rf ISSM ISSM-Ubuntu32.tar.gz
+#Check that test101 runs
+cd $ISSM_DIR/test/NightlyRun
+rm matlab.log
+$MATLAB_DIR/bin/matlab -nojvm -nosplash -r "try, addpath $ISSM_DIR/bin $ISSM_DIR/lib; runme('id',101);exit; catch me,fprintf('%s',getReport(me)); exit; end" -logfile matlab.log
 
-mkdir ISSM
-cd ISSM
-ln -s $ISSM_TIER/bin ./bin
-ln -s $ISSM_TIER/test ./test
-cp ../startup.m ./
-cp ../README.m ./
-cd ..
-tar  zcvfh  ISSM-Ubuntu32.tar.gz --exclude='.svn' ./ISSM
-rm -rf ISSM
+if [[ $(cat matlab.log | grep -c SUCCESS) -lt 10 ]]; then
+	echo "test101 FAILED"
+	exit 1;
+else
+	echo "test101 passed"
+fi
+
+tarball_name='issm-ubuntu-static_build.tar.gz'
+
+echo "Cleanup first" 
+cd $ISSM_DIR
+rm $tarball_name
+
+echo "Creating tarball: ${tarball_name}"
+cd $ISSM_DIR
+tar -czf $tarball_name ./bin ./lib ./test ./examples
+ls -lah $tarball_name
Index: sm/trunk-jpl/packagers/ubuntu/startup.m
===================================================================
--- /issm/trunk-jpl/packagers/ubuntu/startup.m	(revision 18435)
+++ 	(revision )
@@ -1,40 +1,0 @@
-%STARTUP - Matlab startup script
-%
-%   startup.m is a script run by matlab at the beginning of a session, just
-%   before handing over the prompt to the user. This delivery startup.m script
-%   has been customized here for the ISSM code. This startup script should be
-%   run by users before trying to use ISSM. The best way to do that is to put
-%   the startup file in the location where Matlab starts and established its
-%   root directory.
-
-% clear the last warning to focus on the warnings of the ISSM path
-lastwarn(''); 
-
-%Recover ISSM_TIER , or if on a Windows machine, ISSM_TIER_WIN
-ISSM_TIER=getenv('ISSM_TIER');
-
-if (isempty(ISSM_TIER)),
-	error('issmdir error message: ''ISSM_TIER'' environment variable is empty! You should define ISSM_TIER in your .cshrc or .bashrc!');
-end
-
-%Now add all issm code paths necessary to run issm smoothly. 
-%We capture the error output, so that we can warn the user to update 
-%the variable ISSM_TIER in this file, in case it is not correctly setup. 
-
-%ISSM path
-addpath(ISSM_TIER);
-addpath([ISSM_TIER '/bin']);
-
-%Check on any warning messages that might indicate that the paths were not correct. 
-if ~isempty(lastwarn),
-	fprintf('\n  Error trying to setup ''ISSM'' code paths. Try and update the ISSM_TIER variable in your .cshrc or .bashrc!\n');
-	fprintf('  ''ISSM'' will not  work at all until this is resolved\n\n');
-else
-	fprintf('\n  To get started with ISSM, type issmdoc at the command prompt.\n\n');
-end
-
-%disable matlab bell!
-beep off;
-
-% no warning if we try to plot while in nojvm (will not be supported in future releases)
-warning off MATLAB:HandleGraphics:noJVM
