Index: MCONFIG.in
--- MCONFIG.in.orig	2009-02-16 23:51:22 +0100
+++ MCONFIG.in	2009-02-18 10:19:59 +0100
@@ -21,6 +21,7 @@
 # Prefixes
 prefix      = @prefix@
 exec_prefix = @exec_prefix@
+datarootdir = @datarootdir@
 
 # Directory for user binaries
 BINDIR  = @bindir@
Index: Makefile
--- Makefile.orig	2009-02-16 23:51:22 +0100
+++ Makefile	2009-02-18 10:19:59 +0100
@@ -59,9 +59,9 @@
 # Adding "configure" to the dependencies serializes this with running
 # autoconf, because there are apparently race conditions between
 # autoconf and autoheader.
-aconfig.h.in: configure.in configure aclocal.m4
-	rm -f aconfig.h.in aconfig.h
-	autoheader
+#aconfig.h.in: configure.in configure aclocal.m4
+#	rm -f aconfig.h.in aconfig.h
+#	autoheader
 
 configure: configure.in aclocal.m4
 	rm -rf MCONFIG configure config.log aconfig.h *.cache
Index: configure
--- configure.orig	2009-02-16 23:51:35 +0100
+++ configure	2009-02-18 10:19:59 +0100
@@ -9852,6 +9852,9 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
 int
 main ()
 {
Index: tftpd/tftpd.c
--- tftpd/tftpd.c.orig	2009-02-16 23:51:22 +0100
+++ tftpd/tftpd.c	2009-02-18 10:20:18 +0100
@@ -31,6 +31,9 @@
  * SUCH DAMAGE.
  */
 
+#if defined(__NetBSD__)
+#define _NETBSD_SOURCE
+#endif
 #include "config.h"             /* Must be included first */
 #include "tftpd.h"
 
@@ -716,6 +719,22 @@
 #ifndef __CYGWIN__
         set_socket_nonblock(fd, 1);
 #endif
+#ifdef PID_FILE
+  /* Write PID file */
+  {
+    mode_t old_umask;
+    pid_t  pid;
+    FILE   *fp;
+
+    old_umask = umask((mode_t) 0022);
+    pid = getpid();
+    if ((fp = fopen(PID_FILE, "w")) == NULL)
+      syslog(LOG_ERR, "cannot write PID file '%s'", PID_FILE);
+    fprintf(fp, "%ld\n", (long)pid);
+    fclose(fp);
+    umask(old_umask);
+  }
+#endif
     }
 
     /* Disable path MTU discovery */
