# $Id: Portfile 64763 2010-03-15 16:31:33Z nox@macports.org $
PortSystem 1.0

name			wap11gui
version			0.12
revision		6
categories		net
maintainers		nomaintainer
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:include/qt3/qt_x11.h:qt3 \
				lib:libssl.0.9:openssl \
				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:include/qt3/qt_x11.h:qt3
		depends_lib-append	path: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.cflags-append	'-I${prefix}/include'
configure.cxxflags-append '-I${prefix}/include'

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

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

