Index: files/patch-pg2xbase-cpp.diff
===================================================================
--- files/patch-pg2xbase-cpp.diff	(revision 0)
+++ files/patch-pg2xbase-cpp.diff	(revision 0)
@@ -0,0 +1,12 @@
+--- pg2xbase.cpp.orig	2004-12-10 15:19:07.000000000 +0100
++++ pg2xbase.cpp	2010-10-03 01:32:34.000000000 +0200
+@@ -44,7 +44,8 @@
+ #include <sstream>
+ #include <string>
+ #include <strings.h>
+-#include <xbase.h>
++#include <fcntl.h>
++#include <xbase64/xbase64.h>
+ #include <strings.h>
+ #include <libpq-fe.h>
+ #include <postgres_fe.h>
Index: files/patch-xbase2pg-cpp.diff
===================================================================
--- files/patch-xbase2pg-cpp.diff	(revision 0)
+++ files/patch-xbase2pg-cpp.diff	(revision 0)
@@ -0,0 +1,13 @@
+--- xbase2pg.cpp.orig	2010-10-03 01:13:32.000000000 +0200
++++ xbase2pg.cpp	2010-10-03 01:14:38.000000000 +0200
+@@ -38,7 +38,9 @@
+ #include <sstream>
+ #include <string>
+ #include <strings.h>
+-#include <xbase.h>
++#include <fcntl.h>
++#include <sys/types.h>
++#include <xbase64/xbase64.h>
+ #include <errno.h>
+ #include <libpq-fe.h>
+ #include "xbase2pg.hh"
Index: files/patch-xbasenew-cpp.diff
===================================================================
--- files/patch-xbasenew-cpp.diff	(revision 0)
+++ files/patch-xbasenew-cpp.diff	(revision 0)
@@ -0,0 +1,12 @@
+--- xbasenew.cpp.orig	2010-10-03 01:20:36.000000000 +0200
++++ xbasenew.cpp	2010-10-03 01:21:37.000000000 +0200
+@@ -31,7 +31,8 @@
+  #endif
+  #include <unistd.h>
+ #endif
+-#include <xbase.h>
++#include <fcntl.h>
++#include <xbase64/xbase64.h>
+ #include <strings.h>
+ #include "xbase2pg.hh"
+ 
Index: files/patch-Makefile.diff
===================================================================
--- files/patch-Makefile.diff	(revision 0)
+++ files/patch-Makefile.diff	(revision 0)
@@ -0,0 +1,44 @@
+--- Makefile.orig	2004-06-02 11:36:58.000000000 +0200
++++ Makefile	2010-10-03 01:33:55.000000000 +0200
+@@ -1,6 +1,6 @@
+ # vim: set noexpandtab :
+ 
+-INCLUDES = -I/usr/local/include -I/usr/include/pgsql -I/usr/include/pgsql/internal -I/usr/local/pgsql/include/internal -I/usr/include/xbase -I/usr/local/pgsql/include -I/usr/local/include/xbase
++INCLUDES = -I/opt/local/include -I/opt/local/include/postgresql81 -I/opt/local/include/postgresql81/internal -I/opt/local/include/xbase64
+ OPTIMIZE=-O2
+ CFLAGS = -g -Wall $(OPTIMIZE)
+ CFLAGS += -Wno-deprecated
+@@ -8,7 +8,7 @@
+ #CFLAGS = -g -ggdb -Wall
+ # for xbase sys/locking problem in 1.8.0a
+ CFLAGS += -DHAVE_CONFIG_H
+-LIBS = -L/usr/local/pgsql/lib -lpq -lxbase
++LIBS = -L/opt/local/lib -L/opt/local/lib/postgresql81 -lpq -lxbase64
+ 
+ ifeq ($(OSTYPE),solaris)
+ # uncomment for Solaris
+@@ -16,9 +16,9 @@
+ prefix=/usr/local
+ else
+ # -- LINUX DEFS --
+-LIBS += -lcrypt
+-CFLAGS += -DLINUX
+-prefix=/usr
++#LIBS += -lcrypt
++#CFLAGS += -DLINUX
++prefix=/opt/local
+ endif
+ 
+ # CFLAGS += -static
+@@ -60,9 +60,9 @@
+ 	tar cvf - README INSTALL COPYING-2.0 *.h *.hh *.cpp *.1 convenctable Makefile | gzip -c > xbase2pg.tgz
+ 
+ install: xbase2pg pg2xbase xbasenew xbaseconv
+-	mkdir -p $(prefix)/bin/ $(prefix)/man/man1/
++	mkdir -p $(prefix)/bin/ $(prefix)/share/man/man1/
+ 	mkdir -p $(prefix)/share/pg2xbase
+ 	$(CP) $(PROGS) $(prefix)/bin/
+ 	$(CP) convenctable $(convtable)
+-	$(CP) xbase2pg.1 pg2xbase.1 xbaseconv.1 xbasenew.1 $(prefix)/man/man1/
++	$(CP) xbase2pg.1 pg2xbase.1 xbaseconv.1 xbasenew.1 $(prefix)/share/man/man1/
+ 	
Index: files/patch-xbaseconv-cpp.diff
===================================================================
--- files/patch-xbaseconv-cpp.diff	(revision 0)
+++ files/patch-xbaseconv-cpp.diff	(revision 0)
@@ -0,0 +1,12 @@
+--- xbaseconv.cpp.orig	2010-10-03 01:20:54.000000000 +0200
++++ xbaseconv.cpp	2010-10-03 01:21:44.000000000 +0200
+@@ -30,7 +30,8 @@
+ #include <fstream>
+ #include <sstream>
+ #include <string>
+-#include <xbase.h>
++#include <fcntl.h>
++#include <xbase64/xbase64.h>
+ #include <strings.h>
+ #include <ctype.h>
+ #include <unistd.h>
Index: Portfile
===================================================================
--- Portfile	(revision 71993)
+++ Portfile	(working copy)
@@ -8,19 +8,33 @@
 platforms		darwin
 maintainers		gmail.com:seanasy
 description		Convert data between PostgreSQL and DBF files
-long_description	pg2xbase provides utilities for converting between PostgreSQL databases and DBF files.
+long_description	pg2xbase provides utilities for converting between \
+    PostgreSQL databases and DBF files.
+    
+homepage        
+depends_lib		port:postgresql81 port:xbase
 
-homepage		http://www.klaban.torun.pl/prog/pg2xbase/
 master_sites		${homepage}
 
-extract.suffix		.tgz
 checksums		sha1 695625b19bea40748916c9e4c4185e82bdb808cc
 
-depends_lib		port:postgresql81 port:xbase
+extract.suffix  .tgz
+post-extract {
+    #get rid of ELF binaries(!) extracted from tarball
+    system "cd ${worksrcpath} && make clean"
+}
 
+patchfiles      patch-pg2xbase-cpp.diff \
+                patch-xbase2pg-cpp.diff \
+                patch-xbaseconv-cpp.diff \
+                patch-xbasenew-cpp.diff \
+                patch-Makefile.diff
+
+post-patch {
+    reinplace "s|@@PREFIX@@|${prefix}|g"   ${worksrcpath}/Makefile
+}
+
 use_configure 		no
+use_parallel_build  no
 
-build.args		INCLUDES="-I${prefix}/include -I${prefix}/include/postgresql81  -I${prefix}/include/postgresql81/internal  -I${prefix}/include/xbase" \
-			LIBS="-L${prefix}/lib -L${prefix}/lib/postgresql81 -lpq -lxbase"
-
 destroot.destdir 	prefix=${destroot}${prefix}
