--- Portfile.orig	2008-02-21 05:35:01.000000000 -0700
+++ Portfile	2008-03-17 08:10:32.000000000 -0700
@@ -2,8 +2,7 @@
 
 PortSystem 1.0
 name			doxygen
-version			1.5.4
-revision		2
+version			1.5.5
 categories		textproc devel
 maintainers		css@macports.org
 description		Documentation system for several programming languages
@@ -27,29 +26,33 @@
 master_sites		ftp://ftp.stack.nl/pub/users/dimitri/
 distfiles		${distname}.src${extract.suffix}
 
-checksums		md5 10ffe8d445dc1bf7dd69292b266906ff \
-			sha1 1a815f7de6b412f7852d57dec9eb50f7c4b03268 \
-			rmd160 263e2287da4fbe91a429dc53fe3569b150c76fdf
+checksums		md5 95813ecd95b371d13d63844ddb9b5c46 \
+			sha1 16b555f5d191cc0f854ae9856c49e4823a51c595 \
+			rmd160 212ef3eca6a43c33189b11d3ab400f5b2069b019
 
 depends_lib		path:${prefix}/bin/pdflatex:texlive \
 			bin:gs:ghostscript lib:libpng:libpng \
 			bin:dot:graphviz bin:ginstall:coreutils port:libiconv
 
-# setup to work smoothly with Qt3
 post-patch {
+	# Change QTDIR include direcotory: include -> include/qt3
 	reinplace "s|\$(QTDIR)/include|\$(QTDIR)/include/qt3|g" \
 		"${worksrcpath}/tmake/lib/macosx-c++/tmake.conf"
-	reinplace "s|@@PREFIX@@|${prefix}|g" \
-		${worksrcpath}/addon/doxywizard/Makefile.doxywizard
-	reinplace "s|@@X11PREFIX@@|${x11prefix}|g" \
-		${worksrcpath}/addon/doxywizard/Makefile.doxywizard
+	
+	# Prepend -L${prefix}/lib to TMAKE_LIBS
+	reinplace -E "s|^(TMAKE_LIBS\[ \t\]*=)(\[ \t\]*)(.*)$|\\1\\2-L${prefix}/lib \\3|g" \
+		"${worksrcpath}/tmake/lib/macosx-c++/tmake.conf"
+	
+	# Append ${prefix}/include to TMAKE_INCDIR
+	reinplace -E "s|^TMAKE_INCDIR(\[ \t\]*=.*)$|INCLUDEPATH\\1 ${prefix}/include|g" \
+		"${worksrcpath}/tmake/lib/macosx-c++/tmake.conf"
 }
 
-# Using libiconv should negate the need for this patch.
-#patchfiles		patch-portable.cpp
+# This patch has no effect on Leopard
+patchfiles		qfiledefs_p.patch
 
 configure.pre_args	--prefix ${prefix}
-configure.args		--docdir ${prefix}/share/doc
+configure.args		--docdir ${prefix}/share/doc --dot ${prefix}/bin/dot
 configure.env		QTDIR=${prefix}
 
 build.env		QTDIR=${prefix}
@@ -65,34 +71,29 @@
 	configure.args-append	--with-doxywizard
 }
 
+# This variant fails on Leopard (LSOpenFromURLSpec() failed with error -10810)
+variant wizardapp requires wizard {
+	post-destroot {
+		set appdir      /Applications/MacPorts
+		set dpappdir	${destroot}${appdir}
+		xinstall -m 755 -d ${dpappdir}/Doxywizard.app/Contents/MacOS
+		file rename ${destroot}${prefix}/bin/doxywizard \
+			${dpappdir}/Doxywizard.app/Contents/MacOS/
+		system "ln -s ${appdir}/Doxywizard.app/Contents/MacOS/doxywizard ${destroot}${prefix}/bin"
+		xinstall -m 644 ${filespath}/Info.plist \
+			${dpappdir}/Doxywizard.app/Contents/
+	}
+}
+
 platform darwin {
 	# Specify the platform explicitly to avoid a universal build.
 	configure.args-append	--platform macosx-c++
-	if {[variant_isset wizard]} {
-		post-destroot {
-			set dpappdir	${destroot}/Applications/MacPorts
-			xinstall -m 755 -d ${dpappdir}/doxywizard.app/Contents/MacOS
-			file rename ${destroot}${prefix}/bin/doxywizard \
-				${dpappdir}/doxywizard.app/Contents/MacOS/
-			xinstall -m 644 ${filespath}/Info.plist \
-				${dpappdir}/doxywizard.app/Contents/
-		}
-	}
 }
 
 platform darwin 9 {
-	# Account for an iconv difference on Leopard.
-	patchfiles-append	patch-portable.cpp
-	# Specify the platform explicitly to avoid a universal build.
-	configure.args-append	--platform macosx-c++
-	if {[variant_isset wizard]} {
-		post-destroot {
-			set dpappdir	${destroot}/Applications/MacPorts
-			xinstall -m 755 -d ${dpappdir}/doxywizard.app/Contents/MacOS
-			file rename ${destroot}${prefix}/bin/doxywizard \
-				${dpappdir}/doxywizard.app/Contents/MacOS/
-			xinstall -m 644 ${filespath}/Info.plist \
-				${dpappdir}/doxywizard.app/Contents/
-		}
+	post-patch {
+		# _OS_MAC_ is only defined in the doygen subset of Qt (not in qt3)
+		reinplace "s|_OS_MAC_|Q_OS_DARWIN|g" \
+			"${worksrcpath}/addon/doxywizard/portable.cpp"
 	}
 }

