--- Portfile.orig
+++ Portfile
@@ -1,71 +1,61 @@
 # $Id: Portfile 85443 2011-10-13 23:51:45Z dports@macports.org $
 
-PortSystem		1.0
-PortGroup		xcode 1.0
-
-name			aquaterm
-version			1.0.1
-revision		5
-categories		aqua math science
-maintainers		mcalhoun openmaintainer
-license			BSD
-description		AquaTerm is a viewer that displays vector graphics on Mac OS X
-long_description	AquaTerm is a viewer app that displays vector \
-					graphics.  Other apps connect to AquaTerm using a \
-					simple remote object messaging protocol.  By adding \
-					\"adapters\" to legacy code very little coding is \
-					needed to bring it to OS X.
-platforms		darwin
-homepage		http://aquaterm.sourceforge.net/
-master_sites	sourceforge
-distname		${name}_src.${version}
-
-checksums		md5 e9d3ecdfe770d6f09a748add9886d1a9 \
-				sha1 d5770bb3a95cfae21c5c39c96171a52d9af8ae24 \
-				rmd160 24410589dd8c3071b6e0d5e652b7d92933d86b5f
-
-worksrcdir		${name}
-
-# Allow xcode PortGroup to set ARCHS (for universal builds), MACOSX_DEPLOYMENT_TARGET, and SDKROOT.
-# Modify INSTALL_PATH to ensure aquaterm is installed into FRAMEWORKS_DIR.
-patchfiles	patch-project.pbxproj.diff
-
-xcode.target	AquaTerm
-
-xcode.build.settings	USER_APPS_DIR=${applications_dir} \
-						FRAMEWORKS_DIR=${frameworks_dir}
-
-xcode.destroot.type		mixed
-xcode.destroot.settings USER_APPS_DIR=${applications_dir} \
-						FRAMEWORKS_DIR=${frameworks_dir}
+PortSystem              1.0
+PortGroup               xcode 1.0
+PortGroup               github 1.0
+
+github.setup            AquaTerm AquaTerm 1.1.1 v
+name                    aquaterm
+categories              aqua math science
+maintainers             mcalhoun openmaintainer
+license                 BSD
+description             AquaTerm is a viewer that displays vector graphics on Mac OS X
+long_description        AquaTerm is a viewer app that displays vector \
+                        graphics.  Other apps connect to AquaTerm using a \
+                        simple remote object messaging protocol.  By adding \
+                        \"adapters\" to legacy code very little coding is \
+                        needed to bring it to OS X.
+platforms               darwin
+homepage                http://aquaterm.github.com/
+
+checksums               rmd160  007db0806a2b1b1263043647035fa428b15560e3 \
+                        sha256  8e35cb81f5f024382ba4b2c96569631b34cf798966aa2870258f272e551c0e34
+
+build.dir               ${worksrcpath}/aquaterm
+
+xcode.target            AquaTerm
+xcode.configuration     Default
+
+xcode.build.settings    LOCAL_APPS_DIR=${applications_dir} LOCAL_FRAMEWORKS_DIR=${frameworks_dir}
+xcode.destroot.settings LOCAL_APPS_DIR=${applications_dir} LOCAL_FRAMEWORKS_DIR=${frameworks_dir}
+xcode.destroot.type     mixed
 
 post-patch {
-	reinplace "s|/usr/local|${prefix}|g" \
-		${workpath}/adapters/pgplot/ChangeLog \
-		${workpath}/adapters/pgplot/g77_gcc_AQT.conf \
-		${workpath}/adapters/pgplot/xlf_gcc_AQT.conf
-	reinplace "s|\$(HOME)|${prefix}|g" \
-		${workpath}/adapters/c/Makefile \
-		${workpath}/adapters/fortran/Makefile
-	reinplace "s|/*<PREFIX>|${prefix}|g" \
-		${workpath}/adapters/pgplot/g77_cc_AQT.conf \
-		${workpath}/adapters/pgplot/g77_gcc_AQT.conf \
-		${workpath}/adapters/pgplot/xlf_gcc_AQT.conf
-	reinplace "s|/sw|${prefix}|g" \
-		${workpath}/adapters/pgplot/ReadMe
+    # Try to open the right version of AquaTerm.app.
+    # (If incompatible version is installed in /Applications,
+    #  we need to make sure that the one from MacPorts is found first.)
+    reinplace "s|/Applications/AquaTerm.app|${applications_dir}/AquaTerm.app|" \
+        ${worksrcpath}/aquaterm/AQTClientManager.m
+
+    reinplace "s|# FRAMEWORKS_DIR.*|FRAMEWORKS_DIR = ${frameworks_dir}|" \
+        ${worksrcpath}/adapters/c/Makefile \
+        ${worksrcpath}/adapters/fortran/Makefile
+
+    reinplace "s|/usr/local|${prefix}|g" \
+        ${worksrcpath}/adapters/pgplot/ChangeLog \
+        ${worksrcpath}/adapters/pgplot/g77_gcc_AQT.conf \
+        ${worksrcpath}/adapters/pgplot/xlf_gcc_AQT.conf
+
+    # those are not really needed, it's just cosmetics
+    reinplace "s|/*<PREFIX>|${prefix}|g" \
+        ${worksrcpath}/adapters/pgplot/g77_cc_AQT.conf \
+        ${worksrcpath}/adapters/pgplot/g77_gcc_AQT.conf \
+        ${worksrcpath}/adapters/pgplot/xlf_gcc_AQT.conf
+    reinplace "s|/sw|${prefix}|g" \
+        ${worksrcpath}/adapters/pgplot/ReadMe
 }
 
 post-destroot {
-	set fdir ${frameworks_dir}/AquaTerm.framework/Versions/A
-	xinstall -d -m 755 ${destroot}${prefix}/include/aquaterm
-	foreach header [glob -tails -directory ${destroot}${fdir}/Headers/ *] {
-		ln -s ${fdir}/Headers/${header} ${destroot}${prefix}/include/aquaterm
-	}
-	ln -s ${fdir}/AquaTerm ${destroot}${prefix}/lib/libaquaterm.dylib
-	ln -s ${fdir}/AquaTerm ${destroot}${prefix}/lib/libaquaterm.${version}.dylib
-
-	xinstall -d -m 0755 ${destroot}${prefix}/share/${name}
-	copy ${workpath}/adapters ${destroot}${prefix}/share/${name}
+    xinstall -d -m 0755 ${destroot}${prefix}/share/AquaTerm
+    copy ${worksrcpath}/adapters ${destroot}${prefix}/share/AquaTerm
 }
-
-livecheck.regex "<title>AquaTerm v(\\d+(?:\\.\\d+)*) released.*</title>"
