Index: files/patch-autogen.sh.diff
===================================================================
--- files/patch-autogen.sh.diff	(revision 0)
+++ files/patch-autogen.sh.diff	(revision 0)
@@ -0,0 +1,31 @@
+--- autogen.sh.orig	2010-03-31 10:13:52.000000000 -0500
++++ autogen.sh	2011-09-11 00:47:04.000000000 -0500
+@@ -202,15 +202,6 @@
+   GNU_OR_DIE=0
+ }
+ 
+-WGET=`find_command 'wget*'`
+-($WGET --version) < /dev/null > /dev/null 2>&1 ||
+-{
+-  echo
+-  echo "You must have wget installed to compile $progname."
+-  echo "Download the appropriate package for your distribution, or get the"
+-  echo "source tarball from ftp://ftp.gnu.org/pub/gnu/wget"
+-  GNU_OR_DIE=0
+-}
+ 
+ if test "$GNU_OR_DIE" -eq 0; then
+   exit 1
+@@ -311,9 +302,9 @@
+ 
+ if [ ! -f libtool.m4.in ]; then
+   echo "    Finding libtool.m4.in"
+-  if [ -f /usr/local/share/aclocal/libtool.m4 ]; then
+-     echo "        .... found /usr/local/share/aclocal/libtool.m4"
+-     cp /usr/local/share/aclocal/libtool.m4 libtool.m4.in
++  if [ -f __PREFIX__/share/aclocal/libtool.m4 ]; then
++     echo "        .... found __PREFIX__/share/aclocal/libtool.m4"
++     cp __PREFIX__/share/aclocal/libtool.m4 libtool.m4.in
+   else
+      if [ -f /usr/share/aclocal/libtool.m4 ]; then
+       echo "        .... found /usr/share/aclocal/libtool.m4"
Index: files/patch-external-geoip.diff
===================================================================
--- files/patch-external-geoip.diff	(revision 87151)
+++ files/patch-external-geoip.diff	(working copy)
@@ -1,59 +0,0 @@
---- configure.in.orig	2009-08-05 19:30:31.141160363 +0530
-+++ configure.in	2009-08-05 19:34:11.076160092 +0530
-@@ -1962,40 +1962,23 @@
-     }'`
- fi
- 
--dnl> GeoIP (http://www.maxmind.com/)
--if test -f "GeoIP.tar.gz"; then
--   echo "GeoIP already present on this machine"
--else
--   wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
--fi
--tar xvfz GeoIP.tar.gz
--GEO_DIR=`find $PWD -type d -name "GeoIP-*"`
--cd $GEO_DIR; ./configure --prefix=${prefix}; make; cd ..
--# OSX Fix
--GEO_DYLIB="$GEO_DIR/libGeoIP/.libs/libGeoIP.dylib"
--if test -f $GEO_DYLIB; then
--   ln -s $GEO_DYLIB .
--fi
--
--if test -f "GeoLiteCity.dat"; then
--   echo "GeoLiteCity.dat already present"
--else
--   wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
--   gunzip GeoLiteCity.dat.gz
--fi
--
--if test -f "GeoIPASNum.dat"; then
--   echo "GeoIPASNum.dat already present"
--else
--   wget http://www.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
--   gunzip GeoIPASNum.dat.gz
-+#
-+#GeoIP
-+#
-+AC_CHECK_HEADERS(
-+    [GeoIP.h],
-+    [geoip_header="yes"],
-+    [AC_MSG_FAILURE([GeoIP header file is missing])]
-+)
-+if test "$geoip_header" = "yes"; then
-+    AC_CHECK_LIB(GeoIP, GeoIP_open,
-+        [geoip_libs="yes"],
-+	[AC_MSG_FAILURE([GeoIP library is missing])]
-+    )
-+fi
-+if test "$geoip_libs" = "yes"; then
-+    LDFLAGS="${LDFLAGS} -lGeoIP"
- fi
--
--
--GEO_DIR=`find $PWD -type d -name "GeoIP-*"`
--GEO_IP="$GEO_DIR/libGeoIP/"
--CFLAGS="$CFLAGS -I$GEO_IP"
--LDFLAGS="-L$GEO_IP.libs/ -lGeoIP $LDFLAGS"
- 
- dnl> NTOPCONFIGDEBUG_SETTINGS([precet])
- 
Index: files/ntop.sh
===================================================================
--- files/ntop.sh	(revision 87151)
+++ files/ntop.sh	(working copy)
@@ -1,5 +0,0 @@
-#!/bin/sh
-echo ntop will start in 60s
-sleep 60
-__PREFIX__/bin/ntop @__PREFIX__/etc/ntop/ntop.conf -d
-
Index: files/patch-configure.in.diff
===================================================================
--- files/patch-configure.in.diff	(revision 0)
+++ files/patch-configure.in.diff	(revision 0)
@@ -0,0 +1,67 @@
+--- configure.in.orig	2011-08-15 03:34:28.000000000 -0500
++++ configure.in	2011-11-12 23:59:24.000000000 -0600
+@@ -469,10 +469,6 @@
+     LOCALEDIR="/usr/lib/locale"
+ fi
+ 
+-dnl> Add /usr/local/ /opt/local
+-CFLAGS="${CFLAGS} -I/usr/local/include -I/opt/local/include"
+-CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/opt/local/include"
+-LDFLAGS="${LDFLAGS} -L/usr/local/lib -L/opt/local/lib"
+ 
+ PWD=`pwd`
+ 
+@@ -1450,25 +1446,8 @@
+ dnl> PYTHON
+ dnl>
+   AC_CHECK_TOOL(PYTHON, python-config)
+-  PYTHON_CONFIG=""
++  PYTHON_CONFIG="$ac_cv_prog_ac_ct_PYTHON"
+ 
+-  if test "x$ac_cv_prog_ac_ct_PYTHON" != "xpython-config"; then   
+-       if test -f "/etc/debian_version"; then
+-       	   AC_MSG_RESULT(Please install python-dev and rerun configure)
+-	   exit 1
+-	else
+-	AC_MSG_RESULT(>>>> Unable to locate python-config: using workaround <<<<)
+-        dnl> Silly workaround for RedHat-like distro
+-        AC_CHECK_TOOL(PYTHON, python)
+-        if test "x$ac_cv_prog_ac_ct_PYTHON" = "xpython"; then
+-          PYTHON_CONFIG="./configureextra/python-config"
+-        else
+-          PYTHON_CONFIG="python-config"
+-        fi
+-     fi
+-  else
+-     PYTHON_CONFIG="python-config"
+-  fi
+ 
+   if test "x$PYTHON_CONFIG" != "x"; then
+     PYTHON_LIBS="`$PYTHON_CONFIG --libs`"
+@@ -1480,7 +1459,7 @@
+ 
+     dnl remove unecessary path
+     dnl line below workaround for OSX 10.6 (Snow Leopard)/10.7 (Lion)
+-    PYTHON_INCS=`$PYTHON_CONFIG --cflags | sed -e "s/-arch i386// | sed -e "s/-arch ppc// | sed -e "s/-arch x86_64//"`
++    PYTHON_INCS=`$PYTHON_CONFIG --cflags | sed -e "s/-arch i386//" | sed -e "s/-arch ppc//" | sed -e "s/-arch x86_64//"`
+     INCS="${INCS} ${PYTHON_INCS}"
+ 
+ OLD_CFLAGS=$CFLAGS
+@@ -1956,16 +1935,8 @@
+ echo "#endif /* MEMORY_DEBUG */" >> version.c
+ 
+ case "${host}" in
+-    *darwin* )
+-        echo
+-	echo "Copying patched versions of some configure-related files for Mac OS X"
+-        cp packages/MacOSX/lt* .
+-	rm -f libtool
+-	ln -s  /usr/bin/glibtool libtool
+-        echo
+-        ;;
+ 	*)
+-	LIBTOOL_PATH="/usr/bin/libtool"
++	LIBTOOL_PATH="${prefix}/bin/glibtool"
+ 	if test -x ${LIBTOOL_PATH}; then
+ 	   rm -f libtool
+ 	   ln -s ${LIBTOOL_PATH} libtool
Index: files/patch-Makefile.am.diff
===================================================================
--- files/patch-Makefile.am.diff	(revision 87151)
+++ files/patch-Makefile.am.diff	(working copy)
@@ -1,6 +1,6 @@
---- Makefile.am.orig	2009-04-17 17:27:57.000000000 -0300
-+++ Makefile.am	2009-09-15 13:07:19.000000000 -0300
-@@ -76,9 +76,7 @@
+--- Makefile.am.orig	2011-03-03 07:44:59.000000000 -0600
++++ Makefile.am	2011-11-12 23:33:32.000000000 -0600
+@@ -67,9 +67,7 @@
  NTOPDATA = ntop-cert.pem \
             $(ETTER_PASSIVE) \
             oui.txt.gz \
@@ -11,20 +11,12 @@
  
  NTOPHTML = html html/*.js html/*.html  html/*.gif html/*.jpg html/*.ico html/*.png \
             html/*.css html/*.dtd \
-@@ -270,8 +268,6 @@
- 
- install: install-recursive
- 
--	cd @GEO_DIR@; make install
--
- 	@mkdir -p $(DESTDIR)/$(CFG_DBFILE_DIR)
- 
- 	@echo ""
-@@ -341,7 +337,6 @@
+@@ -328,7 +326,7 @@
+ install-selinux-policy:
  	chcon -t textrel_shlib_t $(DESTDIR)$(libdir)/*ntop*.so
  
- install-data-local: ntop.txt ntop.html faq.html
--	@$(top_srcdir)/mkinstalldirs $(DESTDIR)/$(libdir)/plugins;
+-install-data-local: ntop.txt ntop.html faq.html dnetter
++install-data-local: ntop.txt ntop.html faq.html
+ 	@$(top_srcdir)/mkinstalldirs $(DESTDIR)/$(libdir)/plugins;
  	@if ! test -d $(DESTDIR)/$(datadir)/ntop; then \
  	  $(top_srcdir)/mkinstalldirs $(DESTDIR)/$(datadir)/ntop; \
- 	  touch $(DESTDIR)/$(datadir)/ntop/warnuser; \
Index: Portfile
===================================================================
--- Portfile	(revision 87151)
+++ Portfile	(working copy)
@@ -4,8 +4,7 @@
 PortSystem 1.0
 
 name			ntop
-version			3.3.10
-revision		5
+version			4.1.0
 categories		net
 maintainers		markd openmaintainer
 description		network traffic probe
@@ -14,64 +13,75 @@
 				usage, similar to what the popular top Unix command does.
 
 homepage		http://www.ntop.org/
-master_sites		sourceforge
-checksums		md5 6e2ffa90d5f935c8f03d88a5dd19a866
+master_sites		sourceforge:project/ntop/ntop/Stable/
 
-patchfiles		patch-external-geoip.diff \
-			patch-Makefile.am.diff
+checksums		rmd160  6f10e30e1b2870fc1ec327512e17cfbe0783faa4 \
+			sha256  c71e5563879ec1866296825e1705f30b5a67eb87c9abfbd7dc1c5baeed0384a4
 
 depends_build		port:gawk \
-			port:wget \
+			port:automake \
+			port:autoconf \
+			port:libtool \
 			port:rrdtool \
 			port:libevent
+
 depends_lib		port:libpcap \
 			port:gd2 \
 			port:libpng \
 			port:gdbm \
-			port:libgeoip
+			port:libgeoip \
+			port:python27
 
-configure.cflags-append	-I${prefix}/include
-configure.args		--mandir=${prefix}/share/man \
-			--with-localedir=${prefix}/share/locale \
-			--with-rrd-home=${prefix} \
+patchfiles		patch-Makefile.am.diff \
+			patch-autogen.sh.diff \
+			patch-configure.in.diff
+#patch-external-geoip.diff
+
+post-patch {
+	reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/autogen.sh
+}
+
+use_autoconf		yes
+autoconf.cmd		${worksrcpath}/autogen.sh
+autoconf.args		--noconfig
+
+configure.env		LOCALEDIR=${prefix}/share/locale \
+			PYTHON=${prefix}/bin/python2.7-config
+
+configure.args		--with-rrd-home=${prefix} \
 			--without-ssl
 
-use_autoconf		yes
 build.type		gnu
 
-# Create a startupitem to start/stop the server
-	startupitem.create    yes
-	startupitem.start    "${prefix}/share/${name}/ntop.sh"
-	startupitem.stop     "${prefix}/share/${name}/ntop.sh"
+startupitem.create	yes
+startupitem.executable	${prefix}/bin/ntop @${prefix}/etc/ntop/ntop.conf
 
-pre-configure {
-	system "cd ${worksrcpath} && ./autogen.sh --noconfig"
-}
+destroot.keepdirs ${destroot}${prefix}/var/ntop/rrd
 
 post-destroot	{
 	xinstall -m 755 -o nobody -d ${destroot}${prefix}/var/ntop \
 		${destroot}${prefix}/var/ntop/rrd
-	system "cd ${destroot}${prefix}/var/ntop && \
-		touch addressQueue.db dnsCache.db macPrefix.db \
-		ntop_pw.db prefsCache.db rrd/.turd"
-	system "chown -R nobody ${destroot}${prefix}/var/ntop"
 
 	xinstall -m 755 -d ${destroot}${prefix}/etc/ntop
 	xinstall -m 755 \
 		${worksrcpath}/packages/FreeBSD-ports/net/ntop/files/ntop.conf.sample \
-		${destroot}${prefix}/etc/ntop/ntop.conf
+		${destroot}${prefix}/etc/ntop
 	reinplace "s|%%DBDIR%%/ntop|${prefix}/var/ntop|g" \
-		${destroot}${prefix}/etc/ntop/ntop.conf            
+		${destroot}${prefix}/etc/ntop/ntop.conf.sample
 	reinplace "s|#--interface sis0|--interface en0|g" \
-		${destroot}${prefix}/etc/ntop/ntop.conf
+		${destroot}${prefix}/etc/ntop/ntop.conf.sample
+}
 
-    xinstall -m 755 ${filespath}/ntop.sh \
-        ${destroot}${prefix}/share/ntop/ntop.sh
-    reinplace "s|__PREFIX__|${prefix}|g" \
-        ${destroot}${prefix}/share/ntop/ntop.sh
+post-activate {
+	foreach f {addressQueue.db dnsCache.db macPrefix.db ntop_pw.db prefsCache.db} {
+		if {![file exists ${prefix}/var/ntop/${f}]} {
+			touch ${prefix}/var/ntop/${f}
+			file attributes ${prefix}/var/ntop/${f} -owner nobody
+		}
+	}
+	if {![file exists ${prefix}/etc/ntop/ntop.conf]} {
+		copy ${prefix}/etc/ntop/ntop.conf.sample ${prefix}/etc/ntop/ntop.conf
+	}
 }
 
-# ticket #27472; check if this is still a problem when updating to 4.1.x
-universal_variant		no
-
 livecheck.regex		/${name}-(\[0-9.\]+)${extract.suffix}
