Index: Makefile.in
--- Makefile.in.orig	2017-07-17 15:39:53.000000000 +0200
+++ Makefile.in	2017-11-30 18:46:28.371866000 +0100
@@ -115,14 +115,14 @@
 	$(EDIT) $(srcdir)/nsd-control.8.in > nsd-control.8
 
 install: all
-	$(INSTALL) -d $(DESTDIR)$(sbindir)
-	$(INSTALL) -d $(DESTDIR)$(configdir)
-	$(INSTALL) -d $(DESTDIR)$(piddir)
-	$(INSTALL) -d $(DESTDIR)$(xfrdir)
-	$(INSTALL) -d $(DESTDIR)$(dbdir)
-	$(INSTALL) -d $(DESTDIR)$(mandir)
-	$(INSTALL) -d $(DESTDIR)$(mandir)/man8
-	$(INSTALL) -d $(DESTDIR)$(mandir)/man5
+	-$(INSTALL) -d $(DESTDIR)$(sbindir)
+	-$(INSTALL) -d $(DESTDIR)$(configdir)
+	-$(INSTALL) -d $(DESTDIR)$(piddir)
+	-$(INSTALL) -d $(DESTDIR)$(xfrdir)
+	-$(INSTALL) -d $(DESTDIR)$(dbdir)
+	-$(INSTALL) -d $(DESTDIR)$(mandir)
+	-$(INSTALL) -d $(DESTDIR)$(mandir)/man8
+	-$(INSTALL) -d $(DESTDIR)$(mandir)/man5
 	$(INSTALL) nsd $(DESTDIR)$(sbindir)/nsd
 	$(INSTALL) nsd-control-setup.sh $(DESTDIR)$(sbindir)/nsd-control-setup
 	$(INSTALL) nsd-checkconf $(DESTDIR)$(sbindir)/nsd-checkconf
Index: tsig.c
--- tsig.c.orig	2017-01-19 16:32:27.000000000 +0100
+++ tsig.c	2017-11-30 18:46:28.372035000 +0100
@@ -345,11 +345,19 @@
 		time_t clock;
 
 		clock = (time_t) current_time;
+#ifdef __sun__
+		ctime_r(&clock, current_time_text, sizeof(current_time_text));
+#else
 		ctime_r(&clock, current_time_text);
+#endif
 		current_time_text[24] = '\0';
 
 		clock = (time_t) signed_time;
+#ifdef __sun__
+		ctime_r(&clock, signed_time_text, sizeof(signed_time_text));
+#else
 		ctime_r(&clock, signed_time_text);
+#endif
 		signed_time_text[24] = '\0';
 
 		log_msg(LOG_ERR,
Index: util.c
--- util.c.orig	2017-01-03 16:55:39.000000000 +0100
+++ util.c	2017-11-30 18:46:28.372227000 +0100
@@ -831,7 +831,7 @@
    http://www.tsfr.org/~orc/Code/bsd/bsd-current/cksum/crc.c.
    or http://gobsd.com/code/freebsd/usr.bin/cksum/crc.c
    The polynomial is 0x04c11db7L. */
-static u_long crctab[] = {
+static unsigned long crctab[] = {
 	0x0,
 	0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
 	0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
Index: xfrd-tcp.c
--- xfrd-tcp.c.orig	2017-08-29 14:42:20.000000000 +0200
+++ xfrd-tcp.c	2017-11-30 18:48:53.496329000 +0100
@@ -13,6 +13,8 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 #include <sys/uio.h>
 #include "nsd.h"
 #include "xfrd-tcp.h"
@@ -25,6 +27,13 @@
 #include "xfrd-disk.h"
 #include "util.h"
 
+#ifndef PF_INET
+#define PF_INET AF_INET
+#endif
+#ifndef PF_INET6
+#define PF_INET6 AF_INET6
+#endif
+
 /* sort tcppipe, first on IP address, for an IPaddresss, sort on num_unused */
 static int
 xfrd_pipe_cmp(const void* a, const void* b)
Index: xfrd.c
--- xfrd.c.orig	2017-09-14 12:44:44.000000000 +0200
+++ xfrd.c	2017-11-30 18:46:28.372937000 +0100
@@ -30,6 +30,13 @@
 #include "ipc.h"
 #include "remote.h"
 
+#ifndef PF_INET
+#define PF_INET AF_INET
+#endif
+#ifndef PF_INET6
+#define PF_INET6 AF_INET6
+#endif
+
 #define XFRD_UDP_TIMEOUT 10 /* seconds, before a udp request times out */
 #define XFRD_NO_IXFR_CACHE 172800 /* 48h before retrying ixfr's after notimpl */
 #define XFRD_LOWERBOUND_REFRESH 1 /* seconds, smallest refresh timeout */
