Debian build fixes for kFreeBSD
diff --git a/debian/changelog b/debian/changelog
index a43dffe..2015e89 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+dnsmasq (2.72-2) unstable; urgency=low
+
+   * Fix build in Debian-kFreeBSD. (closes: #763693)
+
+ -- Simon Kelley <simon@thekelleys.org.uk>  Thu, 02 Oct 2014 22:34:12 +0000
+
 dnsmasq (2.72-1) unstable; urgency=low
 
    * New upstream.
diff --git a/debian/control b/debian/control
index 78f6c13..6ed259d 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@
 Priority: optional
 Build-depends: gettext, libnetfilter-conntrack-dev [linux-any],
                libidn11-dev, libdbus-1-dev (>=0.61), libgmp-dev, 
-               nettle-dev (>=2.4-3)
+               nettle-dev (>=2.4-3), libbsd-dev [!linux-any]
 Maintainer: Simon Kelley <simon@thekelleys.org.uk>
 Standards-Version: 3.9.5
 
diff --git a/debian/rules b/debian/rules
index 84cfd56..0dcbb30 100755
--- a/debian/rules
+++ b/debian/rules
@@ -23,7 +23,7 @@
 
 TARGET = install-i18n
 
-DEB_BUILD_ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
+DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
 
 # Force package version based on git tags.
 ifneq (,$(filter gitversion,$(DEB_BUILD_OPTIONS)))
@@ -35,7 +35,7 @@
 endif
 
 ifeq (,$(filter noconntrack,$(DEB_BUILD_OPTIONS)))
-ifeq ($(DEB_BUILD_ARCH_OS),linux)
+ifeq ($(DEB_HOST_ARCH_OS),linux)
      DEB_COPTS += -DHAVE_CONNTRACK
 endif
 endif
@@ -83,6 +83,11 @@
      DEB_COPTS += -DHAVE_DNSSEC
 endif
 
+ifneq ($(DEB_HOST_ARCH_OS),linux)
+     # For strlcpy in FreeBSD
+     LDFLAGS += -lbsd
+endif
+
 clean:
 	$(checkdir)
 	rm -rf debian/daemon debian/base debian/utils debian/*~ debian/files debian/substvars debian/utils-substvars
@@ -171,7 +176,7 @@
 	chmod -R g-ws debian/base 
 	dpkg --build debian/base ..
 
-ifeq ($(DEB_BUILD_ARCH_OS),linux)
+ifeq ($(DEB_HOST_ARCH_OS),linux)
 	rm -rf debian/utils
 	install -m 755 -d debian/utils/DEBIAN \
                        -d debian/utils/usr/share/man/man1 \
diff --git a/src/tables.c b/src/tables.c
index 834f119..dcdef79 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -20,6 +20,10 @@
 
 #if defined(HAVE_IPSET) && defined(HAVE_BSD_NETWORK)
 
+#ifndef __FreeBSD__
+#include <bsd/string.h>
+#endif
+
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
@@ -136,7 +140,7 @@
       return -1;
     }
   
-  if (rc = pfr_add_tables(&table, 1, &n, 0)) 
+  if ((rc = pfr_add_tables(&table, 1, &n, 0))) 
     {
       my_syslog(LOG_WARNING, _("warning: pfr_add_tables: %s(%d)"),
 		pfr_strerror(errno),rc);