From: Evgeni Golov <evgeni@debian.org>
Date: Sun, 20 Apr 2014 17:48:54 +0200
Subject: scope: build properly on GNU/Hurd
 The scope plugin currently does not build on GNU/Hurd.
 These patches fix the issue by properly detecting BSD
 flavours (and not misdetecting GNU/Hurd as one) and
 defining PATH_MAX as GNU/Hurd has no such limitation.

diff --git a/scope/src/conterm.c b/scope/src/conterm.c
index e09cfff..9a2bfc7 100644
--- a/scope/src/conterm.c
+++ b/scope/src/conterm.c
@@ -33,9 +33,12 @@
 #if (defined(__unix__) || defined(unix)) && !defined(USG)
 #include <sys/param.h>
 #endif
-#ifdef BSD
+#if defined(__FreeBSD__) || defined(__DragonFly__)
 #include <termios.h>
 #include <libutil.h>
+#elif defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__APPLE__) && defined(__MACH__))
+#include <termios.h>
+#include <util.h>
 #else
 #include <pty.h>
 #endif
diff --git a/scope/src/program.c b/scope/src/program.c
index e939c3b..5f8f2c0 100644
--- a/scope/src/program.c
+++ b/scope/src/program.c
@@ -23,6 +23,10 @@
 
 #include "common.h"
 
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
 static StashGroup *program_group;
 static StashGroup *options_group;
 static StashGroup *thread_group;
