$NetBSD$

Adapt for NetBSD & pkgsrc.

--- Makefile.orig	2019-10-27 10:55:35.000000000 +0000
+++ Makefile
@@ -25,10 +25,17 @@
 ifeq ($(shell uname -s),Darwin)
 CONFIG_DARWIN=y
 endif
+ifeq ($(shell uname -s),NetBSD)
+CONFIG_NETBSD=y
+endif
 # Windows cross compilation from Linux
 #CONFIG_WIN32=y
 # use link time optimization (smaller and faster executables but slower build)
 CONFIG_LTO=y
+# Skip this for now, to support gcc5 without gcc-ar
+ifdef CONFIG_NETBSD
+CONFIG_LTO=
+endif
 # consider warnings as errors (for development)
 #CONFIG_WERROR=y
 # force 32 bit build for some utilities
@@ -41,7 +48,7 @@ CONFIG_DEFAULT_AR=y
 endif
 
 # installation directory
-prefix=/usr/local
+prefix=/usr/pkg
 
 # use the gprof profiler
 #CONFIG_PROFILE=y
@@ -174,10 +181,22 @@ QJS_LIB_OBJS+=$(OBJDIR)/libbf.o 
 QJS_OBJS+=$(OBJDIR)/qjscalc.o
 endif
 
-HOST_LIBS=-lm -ldl -lpthread
+HOST_LIBS=-lm
+ifndef CONFIG_NETBSD
+HOST_LIBS+=-ldl
+HOST_LIBS+=-lpthread
+else
+HOST_LIBS+=-pthread
+endif
 LIBS=-lm
+
 ifndef CONFIG_WIN32
-LIBS+=-ldl -lpthread
+ifndef CONFIG_NETBSD
+LIBS+=-ldl
+LIBS+=-lphtread
+else
+LIBS+=-pthread
+endif
 endif
 
 $(OBJDIR):
