$NetBSD: patch-Makefile,v 1.3 2020/02/10 13:06:08 he Exp $

Portability patch for NetBSD.

--- Makefile.orig	2020-01-19 10:12:01.000000000 +0000
+++ Makefile
@@ -22,13 +22,19 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 
-ifeq ($(shell uname -s),Darwin)
+OPSYS=$(shell uname -s)
+ifeq ($(OPSYS),Darwin)
 CONFIG_DARWIN=y
 endif
+ifeq ($(OPSYS),NetBSD)
+CONFIG_NETBSD=y
+endif
 # Windows cross compilation from Linux
 #CONFIG_WIN32=y
 # use link time optimization (smaller and faster executables but slower build)
+ifndef CONFIG_NETBSD
 CONFIG_LTO=y
+endif
 # consider warnings as errors (for development)
 #CONFIG_WERROR=y
 # force 32 bit build for some utilities
@@ -40,6 +46,10 @@ CONFIG_CLANG=y
 CONFIG_DEFAULT_AR=y
 endif
 
+ifndef CONFIG_NETBSD
+CONFIG_LDL=y
+endif
+
 # installation directory
 prefix=/usr/local
 
@@ -47,8 +57,10 @@ prefix=/usr/local
 #CONFIG_PROFILE=y
 # use address sanitizer
 #CONFIG_ASAN=y
+
 # include the code for BigInt/BigFloat/BigDecimal and math mode
-CONFIG_BIGNUM=y
+# Set via environment in pkg Makefile if supported:
+# CONFIG_BIGNUM=y
 
 OBJDIR=.obj
 
@@ -168,8 +180,10 @@ endif
 
 LIBS=-lm
 ifndef CONFIG_WIN32
+ifndef CONFIG_NETBSD
 LIBS+=-ldl
 endif
+endif
 
 $(OBJDIR):
 	mkdir -p $(OBJDIR) $(OBJDIR)/examples $(OBJDIR)/tests
@@ -195,6 +209,9 @@ QJSC_DEFINES:=-DCONFIG_CC=\"$(QJSC_CC)\"
 ifdef CONFIG_LTO
 QJSC_DEFINES+=-DCONFIG_LTO
 endif
+ifdef CONFIG_LDL
+QJSC_DEFINES+= -DCONFIG_LDL
+endif
 QJSC_HOST_DEFINES:=-DCONFIG_CC=\"$(HOST_CC)\" -DCONFIG_PREFIX=\"$(prefix)\"
 
 $(OBJDIR)/qjsc.o: CFLAGS+=$(QJSC_DEFINES)
