--- Portfile.old	2014-03-22 22:31:11.000000000 +0100
+++ Portfile	2014-04-26 01:31:26.000000000 +0200
@@ -6,6 +6,7 @@
 name                samba3
 conflicts           talloc
 version             3.6.23
+revision            1
 categories          net
 platforms           darwin
 maintainers         nomaintainer
@@ -47,6 +48,8 @@
                     --without-ldap \
                     --without-krb5
 
+patchfiles          patch-source_pkgconfig_all_pc_in.diff
+
 variant kerberos description "Enable Kerberos support" {
     configure.args-delete --without-krb5
     depends_lib-append port:kerberos5
@@ -66,6 +69,9 @@
         ${destroot}${prefix}/var/db/smb/
     xinstall -m 644 ${worksrcpath}/../examples/smb.conf.default \
         ${destroot}${prefix}/etc/${name}/smb.conf.sample
+    xinstall -d -m 755 ${destroot}${prefix}/lib/pkgconfig
+    eval file copy [glob ${worksrcpath}/pkgconfig/*.pc] \
+                   ${destroot}${prefix}/lib/pkgconfig
     system "touch ${destroot}${prefix}/etc/${name}/lmhosts.sample"
     system "touch ${destroot}${prefix}/var/db/smb/secrets.tdb.sample"
 
--- /dev/null	2014-04-26 01:33:14.000000000 +0200
+++ files/patch-source_pkgconfig_all_pc_in.diff	2014-04-26 00:07:03.000000000 +0200
@@ -0,0 +1,43 @@
+--- pkgconfig/netapi.pc.in.old	2014-04-26 00:02:20.000000000 +0200
++++ pkgconfig/netapi.pc.in	2014-04-26 00:03:55.000000000 +0200
+@@ -8,7 +8,7 @@
+ Version: 0
+ URL: http://www.samba.org/
+ #Libs: -L@libdir@ -lnetapi
+-Libs: -lnetapi
++Libs: -L${libdir} -lnetapi
+ Libs.private: -lnetapi @KRB5_LIBS@ @LDAP_LIBS@ @LIBS@
+ Cflags: -I@includedir@
+ 
+--- pkgconfig/smbclient.pc.in.old	2014-04-26 00:02:20.000000000 +0200
++++ pkgconfig/smbclient.pc.in	2014-04-26 00:03:36.000000000 +0200
+@@ -8,7 +8,7 @@
+ Version: 0
+ URL: http://www.samba.org/
+ #Libs: -L@libdir@ -lsmbclient
+-Libs: -lsmbclient
++Libs: -L${libdir} -lsmbclient
+ Libs.private: -lsmbclient @KRB5_LIBS@ @LDAP_LIBS@ @LIBS@
+ Cflags: -I@includedir@
+ 
+--- pkgconfig/smbsharemodes.pc.in.old	2014-04-26 00:02:20.000000000 +0200
++++ pkgconfig/smbsharemodes.pc.in	2014-04-26 00:04:09.000000000 +0200
+@@ -8,7 +8,7 @@
+ Version: 0
+ URL: http://www.samba.org/
+ #Libs: -L@libdir@ -lsmbsharemodes
+-Libs: -lsmbsharemodes
++Libs: -L${libdir} -lsmbsharemodes
+ Libs.private: -lsmbsharemodes @LIBS@
+ Cflags: -I@includedir@
+ 
+--- pkgconfig/wbclient.pc.in.old	2014-04-26 00:02:20.000000000 +0200
++++ pkgconfig/wbclient.pc.in	2014-04-26 00:04:25.000000000 +0200
+@@ -8,6 +8,6 @@
+ Version: 0
+ URL: http://www.samba.org/
+ #Libs: -L@libdir@ -lwbclient
+-Libs: -lwbclient
++Libs: -L${libdir} -lwbclient
+ Libs.private: -lwbclient
+ Cflags: -I@includedir@
