diff --git a/Makefile b/Makefile
index e624abf7787c774004a3766dfc7b3903b61423ac..54368f7c62099e30d323c2780683a85e407a88c8 100644
--- a/Makefile
+++ b/Makefile
@@ -217,7 +217,9 @@ ifeq ($(AST_DEVMODE),yes)
   endif
 endif
 
-ifneq ($(findstring BSD,$(OSARCH)),)
+ifeq ($(OSARCH),NetBSD)
+  _ASTCFLAGS+=-isystem /usr/pkg/include
+else ifneq ($(findstring BSD,$(OSARCH)),)
   _ASTCFLAGS+=-isystem /usr/local/include
 endif
 
@@ -284,7 +286,9 @@ else
 # These are used for all but Darwin
   SOLINK=-shared
   DYLINK=$(SOLINK)
-  ifneq ($(findstring BSD,$(OSARCH)),)
+  ifeq ($(OSARCH),NetBSD)
+    _ASTLDFLAGS+=-L/usr/pkg/lib
+  else ifneq ($(findstring BSD,$(OSARCH)),)
     _ASTLDFLAGS+=-L/usr/local/lib
   endif
 endif
diff --git a/configure b/configure
index b827374cfa7ea014d8578293fbaa0fd0108a7ce4..8c5208bb75e69eb5b53f29f56ffef51b7ece6717 100755
--- a/configure
+++ b/configure
@@ -4679,6 +4679,11 @@ case "${host_os}" in
 esac
 
 case "${host_os}" in
+     netbsd*)
+     ac_default_prefix=/usr/pkg
+     CPPFLAGS=-I/usr/pkg/include
+     LDFLAGS=-L/usr/pkg/lib
+     ;;
      freebsd*)
      ac_default_prefix=/usr/local
      CPPFLAGS=-I/usr/local/include
@@ -18634,6 +18639,9 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use rpath" >&5
 $as_echo_n "checking whether to use rpath... " >&6; }
 AST_RPATH=
+if test "${OSARCH}" = "NetBSD"; then
+	AST_RPATH="-Wl,-rpath,/usr/pkg/lib"
+fi
 if test "${check_rpath}" != yes; then
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5
 $as_echo "skipped" >&6; }
diff --git a/configure.ac b/configure.ac
index 1895c41850d934b89634ce594e26867783601a79..077cf83521ea2879b0893db65737d602a18bd2b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,11 @@ case "${host_os}" in
 esac
 
 case "${host_os}" in
+     netbsd*)
+     ac_default_prefix=/usr/pkg
+     CPPFLAGS=-I/usr/pkg/include
+     LDFLAGS=-L/usr/pkg/lib
+     ;;
      freebsd*)
      ac_default_prefix=/usr/local
      CPPFLAGS=-I/usr/local/include
@@ -1316,6 +1321,9 @@ AC_ARG_ENABLE(rpath,
 
 AC_MSG_CHECKING(whether to use rpath)
 AST_RPATH=
+if test "${OSARCH}" = "NetBSD"; then
+	AST_RPATH="-Wl,-rpath,/usr/pkg/lib"
+fi
 if test "${check_rpath}" != yes; then
 	AC_MSG_RESULT(skipped)
 elif test "${prefix}" = /usr || test "${prefix}" = NONE; then