# $Id: Portfile,v 1.4 2005/08/11 21:33:24 rshaw Exp $
PortSystem 1.0

name			wap11gui
version			0.12
revision		2
categories		net
maintainers		darwinports@opendarwin.org
description		Linksys WAP11 Unix Configuration Utility
long_description	QT based SNMP client you can use to configure a \
					Linksys WAP11, similar to the one provided by the \
					Linksys client.  Supports most of the WAP11's \
					features.
platforms		darwin
homepage		http://wap11gui.sourceforge.net/
master_sites	sourceforge
checksums		md5 0fbf23ff6112d922daa984cf85871e53

depends_lib		lib:libjpeg:jpeg \
				lib:libnetsnmp.5.2:net-snmp \
				lib:libpng:libpng \
				path:${prefix}/include/qt3/qt_x11.h:qt3 \
				lib:libssl.0.9:openssl \
				lib:libX11.6:XFree86 \
				lib:libz.1:zlib

patchfiles		patch-configure \
				patch-Makefile.in \
				patch-wap11gui-Makefile.in \
				patch-wap11gui-wap11config.cpp

platform darwin {
	if {[file isfile ${prefix}/include/qt3/qt_mac.h] || \
		![file isfile ${prefix}/include/qt3/qt_x11.h]} {
		depends_lib-delete	path:${prefix}/include/qt3/qt_x11.h:qt3
		depends_lib-append	path:${prefix}/include/qt3/qt_mac.h:qt3-mac
	}

	patchfiles-append	patch-admin-ltmain.sh \
						patch-wap11gui-wap11config.h
}

configure.args	--with-extra-includes='${prefix}/include' \
				--with-extra-libs='${prefix}/lib' \
				--with-qt-dir='${prefix}' \
				--with-qt-includes='${prefix}/include/qt3' \
				--with-mibsdir=${prefix}/share/snmp/mibs \
				--without-xinerama \
				--disable-warnings \
				--disable-debug
configure.env	CFLAGS='-I${prefix}/include' \
				CPPFLAGS='-I${prefix}/include' \
				CXXFLAGS='-I${prefix}/include' \
				LDFLAGS='-L${prefix}/lib'

post-build		{
	if {[file isfile ${prefix}/include/qt3/qt_mac.h]} {
		cd ${worksrcpath}/${name}
		set appName [string toupper ${name}]
		xinstall -d -m 0755 ${appName}.app/Contents
		set plist ${appName}.app/Contents/Info.plist
		xinstall -m 0644 ${filespath}/Info.plist.in ${plist}
		reinplace "s|@APPLNAME@|${appName}|" ${plist}
		reinplace "s|@VERSION@|${version}|" ${plist}
		system "echo 'APPL????' >${appName}.app/Contents/PkgInfo"
		xinstall -d -m 0755 ${appName}.app/Contents/Resources
		set icns ${appName}.app/Contents/Resources/wap11.icns
		xinstall -m 0644 ${filespath}/[file tail ${icns}] ${icns}
		reinplace "s|@ICONFILE@|[file tail ${icns}]|" ${plist}
		xinstall -d -m 0755 ${appName}.app/Contents/MacOS
		xinstall -m 0755 ${name} ${appName}.app/Contents/MacOS/${appName}
		reinplace "s|@EXECFILE@|${appName}|" ${plist}
	}
}

post-destroot	{
	if {[file isfile ${prefix}/include/qt3/qt_mac.h]} {
		cd ${worksrcpath}/${name}
		set appPath ${destroot}/Applications/DarwinPorts
		set appName [string toupper ${name}]
		xinstall -d -m 0755 ${appPath}
		system "cp -R ${appName}.app ${appPath}/${appName}.app"
		file delete ${destroot}${prefix}/bin/${name}
	}
}

