$OpenBSD: patch-Makefile,v 1.10 2020/07/25 17:27:00 sthen Exp $

Index: Makefile
--- Makefile.orig
+++ Makefile
@@ -34,8 +34,10 @@ DEFINES   = -DVERSION=\"$(GIT_VERSION)\"
 # for dynamic linking
 LIBS      = -lssl -lcrypto
 ifneq ($(OS), FreeBSD)
+ifneq ($(OS), OpenBSD)
 	LIBS += -ldl
 endif
+endif
 ifeq ($(OS), SunOS)
 	CFLAGS += -m64
 	LIBS   += -lsocket -lnsl
@@ -44,14 +46,16 @@ endif
 # Enable checks for buffer overflows, add stack protectors, generate position
 # independent code, mark the relocation table read-only, and mark the global
 # offset table read-only.
-CFLAGS  += -D_FORTIFY_SOURCE=2 -fstack-protector-all -fPIE
+CFLAGS  += -D_FORTIFY_SOURCE=2 -fstack-protector-all
 
 # Don't enable some hardening flags on OS X because it uses an old version of Clang
 ifneq ($(OS), Darwin)
 ifneq ($(OS), SunOS)
+ifneq ($(OS), OpenBSD)
 	LDFLAGS += -pie -z relro -z now
 endif
 endif
+endif
 
 # Force C11 mode to fix the build on very old version of GCC
 CFLAGS += -std=gnu11
@@ -63,8 +67,10 @@ LDFLAGS      += -L${PWD}/
 CFLAGS       += -I${PWD}/include/ -I${PWD}/
 LIBS         = -lssl -lcrypto -lz -lpthread
 ifneq ($(OS), FreeBSD)
+ifneq ($(OS), OpenBSD)
 	LIBS += -ldl
 endif
+endif
 ifeq ($(OS), SunOS)
 	LIBS += -lsocket -lnsl
 endif
@@ -118,6 +124,7 @@ uninstall:
 	rm -f $(DESTDIR)$(BINDIR)/sslscan
 	rm -f $(DESTDIR)$(MAN1DIR)/sslscan.1
 
+ifneq ($(OS), OpenBSD)
 .openssl.is.fresh: opensslpull
 	true
 opensslpull:
@@ -126,6 +133,7 @@ opensslpull:
 	else \
 		git clone --depth 1 -b OpenSSL_1_1_1-stable https://github.com/openssl/openssl ./openssl && cd ./openssl && touch ../.openssl.is.fresh ; \
 	fi
+endif
 
 # Need to build OpenSSL differently on OSX
 ifeq ($(OS), Darwin)
@@ -135,6 +143,7 @@ openssl/Makefile: .openssl.is.fresh
 else
 openssl/Makefile: .openssl.is.fresh
 	cd ./openssl; ./config -v -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC no-shared enable-weak-ssl-ciphers zlib
+# XXX had no-cast here
 endif
 
 openssl/libcrypto.a: openssl/Makefile
