Index: trunk/examples/app-fermi/matlab/Makefile.example
===================================================================
--- trunk/examples/app-fermi/matlab/Makefile.example	(revision 1209)
+++ trunk/examples/app-fermi/matlab/Makefile.example	(revision 1209)
@@ -0,0 +1,31 @@
+APPNAME = fermi
+
+${APPNAME}: fermi_main.m fermi.m
+	mcc -m -R -nojvm -I /apps/rappture/lib/matlab -o $@ $^
+
+all: ${APPNAME}
+
+install: ${APPNAME}
+	sed s/YOURAPPNAME/$^/ < run_app.patch | patch run_$^.sh
+	chmod +x run_$^.sh
+	mv $^ $^.ctf run_$^.sh ../bin
+	mv readme.txt ../bin/$^.readme
+	simsim --tool tool.xml --values default --nosim --driver driver.$^
+	LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/apps/rappture/lib `pwd`/../bin/run_$^.sh /apps/matlab/mcr `pwd`/driver.$^
+	rm -f run*.xml driver.$^
+	@echo "Install Successful"
+
+clean:
+	rm -rf ${APPNAME} \
+		${APPNAME}_main.c \
+		${APPNAME}.ctf \
+		${APPNAME}.prj \
+		${APPNAME}_mcc_component_data.c \
+		run_${APPNAME}.sh \
+		mccExcludedFiles.log \
+		${APPNAME}.readme \
+		readme.txt \
+		${APPNAME}_mcr
+
+distclean: clean
+	rm -rf ../bin/*
Index: trunk/examples/app-fermi/matlab/Makefile.in
===================================================================
--- trunk/examples/app-fermi/matlab/Makefile.in	(revision 1139)
+++ trunk/examples/app-fermi/matlab/Makefile.in	(revision 1209)
@@ -1,6 +1,6 @@
 
 bindir          = @bindir@
-datadir		= @datadir@
-datarootdir	= @datarootdir@
+datadir         = @datadir@
+datarootdir     = @datarootdir@
 exec_prefix     = @exec_prefix@
 includedir      = @includedir@
@@ -8,26 +8,53 @@
 mandir          = @mandir@
 prefix          = @prefix@
-srcdir		= @srcdir@
+srcdir          = @srcdir@
 
-destdir		= $(prefix)/examples/app-fermi/matlab
+destdir         = $(prefix)/examples/app-fermi/matlab
 
-INSTALL		= @INSTALL@
-MKDIR_P		= @MKDIR_P@
+INSTALL         = @INSTALL@
+MKDIR_P         = @MKDIR_P@
+MCC             = @MCC@
 
-FILES 		= \
+MCC_FLAGS       = -m -R -nojvm
+INCLUDES        = -I ../../../lang/matlab
+MCC_SWITCHES    = $(MCC_FLAGS) $(INCLUDES)
+VPATH           = $(srcdir)
+
+APPNAME = fermi
+
+FILES   = \
 		$(srcdir)/tool.xml \
-		$(srcdir)/fermi.m
+		$(srcdir)/Makefile.example \
+		${APPNAME}.ctf
 
-all:	
+${APPNAME}: fermi_main.m fermi.m
+	$(MCC) $(MCC_SWITCHES) -o $@ $^
 
-install: 
+all: ${APPNAME}
+
+install: ${APPNAME}
+	sed s/YOURAPPNAME/$^/ < $(srcdir)/run_app.patch | patch run_$^.sh
 	$(MKDIR_P) $(destdir)
 	for i in $(FILES) ; do \
 	  $(INSTALL) -m 444 $$i $(destdir) ; \
 	done
+	$(INSTALL) -m 444 readme.txt $(destdir)/$^.readme
+	$(INSTALL) -m 555 run_$^.sh $^ $(destdir)
+	$(bindir)/simsim --tool $(srcdir)/tool.xml --values default --nosim --driver driver.$^
+	LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$(libdir) $(destdir)/run_$^.sh /apps/matlab/mcr driver.$^
+	rm -f run*.xml driver.$^
+	@echo "Install Successful"
 
 clean:
+	rm -rf ${APPNAME} \
+		${APPNAME}_main.c \
+		${APPNAME}.ctf \
+		${APPNAME}.prj \
+		${APPNAME}_mcc_component_data.c \
+		run_${APPNAME}.sh \
+		mccExcludedFiles.log \
+		readme.txt \
+		${APPNAME}_mcr
 
 distclean: clean
 	$(RM) Makefile
-
Index: trunk/examples/app-fermi/matlab/compiled/Makefile
===================================================================
--- trunk/examples/app-fermi/matlab/compiled/Makefile	(revision 1139)
+++ 	(revision )
@@ -1,31 +1,0 @@
-APPNAME = fermi
-
-${APPNAME}: fermi_main.m fermi.m
-	mcc -m -R -nojvm -I /apps/rappture/lib/matlab -o $@ $^
-
-all: ${APPNAME}
-
-install: ${APPNAME}
-	sed s/YOURAPPNAME/$^/ < run_app.patch | patch run_$^.sh
-	chmod +x run_$^.sh
-#	mv $^ $^.ctf run_$^.sh ../bin
-#	mv readme.txt ../bin/$^.readme
-#	LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/apps/rappture/lib `pwd`/../bin/run_$^.sh /apps/matlab/mcr `pwd`/driver.xml `pwd`/../data
-	simsim --tool tool.xml --driver-only driver.${APPNAME}
-	LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/apps/rappture/lib `pwd`/run_$^.sh /apps/matlab/mcr `pwd`/driver.${APPNAME}
-	rm -f run*.xml driver.${APPNAME}
-	@echo "Install Successful"
-
-clean:
-	rm -rf ${APPNAME} \
-		${APPNAME}_main.c \
-		${APPNAME}.ctf \
-		${APPNAME}.prj \
-		${APPNAME}_mcc_component_data.c \
-		run_${APPNAME}.sh \
-		mccExcludedFiles.log \
-		readme.txt \
-		${APPNAME}_mcr
-
-distclean: clean
-#	rm -rf ../bin/*
Index: trunk/examples/app-fermi/matlab/compiled/fermi_main.m
===================================================================
--- trunk/examples/app-fermi/matlab/compiled/fermi_main.m	(revision 1139)
+++ 	(revision )
@@ -1,17 +1,0 @@
-function fermi_main(infile)
-
-global lib;
-
-try
-    lib = rpLib(infile);
-    fermi;
-catch
-    lastmsg = lasterr
-    fid = fopen('errorDetected.txt','wt');
-    fprintf(fid,'1\n');
-    fprintf(fid,'%s\n',lastmsg);
-    fclose(fid);
-    append = 1;
-    rpLibPutString(lib,'output.log',lastmsg,append)
-    rpLibResult(lib,1);
-end
Index: trunk/examples/app-fermi/matlab/compiled/run_app.patch
===================================================================
--- trunk/examples/app-fermi/matlab/compiled/run_app.patch	(revision 1139)
+++ 	(revision )
@@ -1,38 +1,0 @@
-7c7
-< echo "------------------------------------------"
----
-> #echo "------------------------------------------"
-12c12
-<   echo Setting up environment variables
----
-> #  echo Setting up environment variables
-14c14
-<   echo ---
----
-> #  echo ---
-17c17
-< 	LD_LIBRARY_PATH=.:/usr/lib/lwp:${MCRROOT}/runtime/glnx86 ; 
----
-> 	LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH}:/usr/lib/lwp:${MCRROOT}/runtime/glnx86 ; 
-19c19
-<   	LD_LIBRARY_PATH=.:${MCRROOT}/runtime/glnx86 ;
----
->   	LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH}:${MCRROOT}/runtime/glnx86 ;
-27c27
-< 	echo Found MCR Java JRE version: $MCRJREVER ; 
----
-> #	echo Found MCR Java JRE version: $MCRJREVER ; 
-37c37
-<   echo LD_LIBRARY_PATH is ${LD_LIBRARY_PATH};
----
-> #  echo LD_LIBRARY_PATH is ${LD_LIBRARY_PATH};
-39c39,45
-< ./YOURAPPNAME $*
----
-> #./YOURAPPNAME $*
-> 
->   appPath=`dirname $0`
->   if [ "$appPath" = "" ]; then
->     appPath="."
->   fi
->   $appPath/YOURAPPNAME $*
Index: trunk/examples/app-fermi/matlab/fermi.m
===================================================================
--- trunk/examples/app-fermi/matlab/fermi.m	(revision 1139)
+++ trunk/examples/app-fermi/matlab/fermi.m	(revision 1209)
@@ -1,4 +1,4 @@
 % ----------------------------------------------------------------------
-%  EXAMPLE: Fermi-Dirac function in Octave.
+%  EXAMPLE: Fermi-Dirac function in Matlab.
 %
 %  This script represents a newly written application with rappture 
@@ -8,5 +8,5 @@
 %  AUTHOR:  Michael McLennan, Purdue University
 %  AUTHOR:  Derrick Kearney, Purdue University
-%  Copyright (c) 2004-2007  Purdue Research Foundation
+%  Copyright (c) 2004-2008  Purdue Research Foundation
 %
 %  See the file "license.terms" for information on usage and
@@ -14,13 +14,8 @@
 % ======================================================================
 
-% get out input file from the command line
-% invoke this script with the following command:
-% matlab -nodisplay -r infile=\'driver1234.xml\',fermi
-% the above command sets variable infile to the name 'driver1234.xml'
+function retVal=fermi;
 
-% infile = 'driver31619.xml'
-
-% open our xml input file.
-lib = rpLib(infile);
+% We open the xml file in the main function and make lib global
+global lib;
 
 % retrieve user specified data out of the input file
@@ -56,3 +51,3 @@
 rpLibResult(lib);
 
-quit;
+retVal = 0;
Index: trunk/examples/app-fermi/matlab/fermi_main.m
===================================================================
--- trunk/examples/app-fermi/matlab/fermi_main.m	(revision 1209)
+++ trunk/examples/app-fermi/matlab/fermi_main.m	(revision 1209)
@@ -0,0 +1,17 @@
+function fermi_main(infile)
+
+global lib;
+
+try
+    lib = rpLib(infile);
+    fermi;
+catch
+    lastmsg = lasterr
+    fid = fopen('errorDetected.txt','wt');
+    fprintf(fid,'1\n');
+    fprintf(fid,'%s\n',lastmsg);
+    fclose(fid);
+    append = 1;
+    rpLibPutString(lib,'output.log',lastmsg,append)
+    rpLibResult(lib,1);
+end
Index: trunk/examples/app-fermi/matlab/run_app.patch
===================================================================
--- trunk/examples/app-fermi/matlab/run_app.patch	(revision 1209)
+++ trunk/examples/app-fermi/matlab/run_app.patch	(revision 1209)
@@ -0,0 +1,38 @@
+7c7
+< echo "------------------------------------------"
+---
+> #echo "------------------------------------------"
+12c12
+<   echo Setting up environment variables
+---
+> #  echo Setting up environment variables
+14c14
+<   echo ---
+---
+> #  echo ---
+17c17
+< 	LD_LIBRARY_PATH=.:/usr/lib/lwp:${MCRROOT}/runtime/glnx86 ; 
+---
+> 	LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH}:/usr/lib/lwp:${MCRROOT}/runtime/glnx86 ; 
+19c19
+<   	LD_LIBRARY_PATH=.:${MCRROOT}/runtime/glnx86 ;
+---
+>   	LD_LIBRARY_PATH=.:${LD_LIBRARY_PATH}:${MCRROOT}/runtime/glnx86 ;
+27c27
+< 	echo Found MCR Java JRE version: $MCRJREVER ; 
+---
+> #	echo Found MCR Java JRE version: $MCRJREVER ; 
+37c37
+<   echo LD_LIBRARY_PATH is ${LD_LIBRARY_PATH};
+---
+> #  echo LD_LIBRARY_PATH is ${LD_LIBRARY_PATH};
+39c39,45
+< ./YOURAPPNAME $*
+---
+> #./YOURAPPNAME $*
+> 
+>   appPath=`dirname $0`
+>   if [ "$appPath" = "" ]; then
+>     appPath="."
+>   fi
+>   $appPath/YOURAPPNAME $*
Index: trunk/examples/app-fermi/matlab/tool.xml
===================================================================
--- trunk/examples/app-fermi/matlab/tool.xml	(revision 1139)
+++ trunk/examples/app-fermi/matlab/tool.xml	(revision 1209)
@@ -3,5 +3,5 @@
     <tool>
         <about>Press Simulate to view results.</about>
-        <command>matlab -nodisplay -r infile='@driver',path('@tool',path),fermi</command>
+        <command>@tool/run_fermi.sh /apps/matlab/mcr @driver</command>
     </tool>
     <input>
