--- ../../../ports/math/octave/Portfile	2008-05-06 15:35:12.000000000 +0900
+++ Portfile	2008-05-09 21:54:49.000000000 +0900
@@ -1,12 +1,11 @@
-# $Id: Portfile 36526 2008-05-05 07:28:18Z takeshi@macports.org $
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
+# $Id: Portfile $
 
 PortSystem 1.0
-
 name		octave
-version		2.9.15
-revision        2
+version		3.0.1
 categories	math science
-maintainers     stechert@macports.org
+maintainers     stechert@macports.org alakazam@melix.net
 platforms	darwin
 description     a Matlab-like environment for numerical analysis
 long_description	\
@@ -18,22 +17,22 @@
 		modules written in e.g. C++, C or Fortran.
 
 homepage	http://www.octave.org
-master_sites	ftp://ftp.octave.org/pub/octave/bleeding-edge/
+master_sites	ftp://ftp.octave.org/pub/octave/
 
 use_bzip2	yes
-checksums	md5    c7c0449a5e1418479bebbdd565eb9cc2 \
-                sha1   4643c9681749bcb6cf7dd7190d82cc28484524b0 \
-                rmd160 bf0b56ae2a1c5baaacf65483f6fe98c1b885da03
-
-patch.args	-p1
-patchfiles	patch-configure.diff \
-		patch-configure-2.diff \
-		patch-dynamic-ld-cc.diff
+checksums	md5 230f3895a42386ec625bf2593a44c441 \
+    sha1 e4cebe74a1182df610d91e45974653227dd4b342 \
+    rmd160 3141454b1e9a8efcac0772aed63c27aaad082861
 
 depends_build   bin:texinfo:texinfo	\
 		bin:tex:teTeX \
+		bin:tex:texlive \
+		bin:tex:ptex \
+		port:ghostscript \
 		port:gawk \
-		port:gsed
+		port:gsed \
+		port:perl5.8 \
+		port:texinfo
 
 depends_lib     port:readline			\
                 port:curl                       \
@@ -43,59 +42,56 @@
 		port:SuiteSparse		\
 		port:pcre			\
 		port:glpk			\
-		port:gnuplot
+		port:gnuplot \
+		port:ncurses \
+		port:qhull \
 
 configure.args	--enable-shared	\
 		--enable-dl	\
 		--disable-static \
 		--with-hdf5	\
 		--with-fftw	\
-		--without-mpi	\
-		--with-blas="-framework Accelerate"
+		--with-blas="-framework Accelerate" \
+		--enable-static \
+		--enable-readline \
+		--with-zlib	\
+		--with-glpk	\
+		--with-curl	\
+		--with-lapack \
+		--with-umfpack \
+		--with-colamd \
+		--with-ccolamd \
+		--with-cholmod \
+		--with-cxsparse
 
 configure.env-append	AWK="${prefix}/bin/gawk" \
-			SED="${prefix}/bin/gsed"
-build.env-append	AWK="${prefix}/bin/gawk" \
-			SED="${prefix}/bin/gsed"
-
-post-patch {
-	# Avoid using heimdal's broken fnmatch.h
-	reinplace "s|<\\(fnmatch\.h\\)>|\"/usr/include/\\1\"|" ${worksrcpath}/liboctave/glob-match.cc
+			SED="${prefix}/bin/gsed" \
+			PERL="${prefix}/bin/perl" \
+			PYTHON=' ' \
+			GHOSTSCRIPT="${prefix}/bin/gs" \
+			MAKEINFO="${prefix}/bin/makeinfo" \
+			TEXI2DVI="${prefix}/bin/texi2dvi" \
+			TEXI2PDF="${prefix}/bin/texi2pdf"
+
+test.run	yes
+test.target	check
+
+variant gcc43 {
+	depends_lib-append	port:gcc43
+	configure.f77		"${prefix}/bin/gfortran-mp-4.3"
 }
 
-pre-destroot {
-	file copy ${worksrcpath}/src/defaults.h ${worksrcpath}/src/defaults.h.tmp
-	file copy ${worksrcpath}/src/oct-conf.h ${worksrcpath}/src/oct-conf.h.tmp
-}
-destroot.destdir	prefix=${destroot}${prefix}
-post-destroot {
-	file rename -force ${worksrcpath}/src/defaults.h.tmp ${destroot}${prefix}/include/${name}-${version}/${name}/defaults.h
-	file rename -force ${worksrcpath}/src/oct-conf.h.tmp ${destroot}${prefix}/include/${name}-${version}/${name}/oct-conf.h
-}
-
-if {![variant_isset g95]} {
-	depends_lib-append	port:gcc42
-	configure.compiler	macports-gcc-4.2
-}
-
-default_variants +test
-variant test description {runs tests} {
-		  depends_build-append bin:runtest:dejagnu
-		  test.run	yes
-		  test.target	check
-		}
-
-variant ptex description {use pTeX instead of teTeX } {
-	depends_build-delete	bin:tex:teTeX
-	depends_build-append	bin:tex:pTeX
-}
-
-variant g95 description {build with g95} {
+if {![variant_isset gcc43]} {
 	depends_lib-append	port:g95
 	configure.f77	"${prefix}/bin/g95"
-        configure.fflags -O2
+}
+
+post-patch {
+    reinplace "s|glp_lpx_simplex|_glp_lpx_simplex|g" ${worksrcpath}/configure
+    reinplace "s|-lcholmod|-lcholmod -lmetis|g" ${worksrcpath}/configure
+    reinplace "s|#define GLPK_PRE_4_14 1|#undef GLPK_PRE_4_14|g" ${worksrcpath}/configure
 }
 
 livecheck.check		regex
 livecheck.url		http://www.gnu.org/software/octave/news.html
-livecheck.regex		Version (\\d+(\\.\\d+)*) is now available
+livecheck.regex		Version (\\d+(\\.\\d+)*)
