$OpenBSD: patch-Makefile,v 1.9 2019/03/03 15:14:49 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,17 +46,19 @@ 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)
 # Cygwin's linker does not support -z option.
 ifneq ($(findstring CYGWIN,$(OS)),CYGWIN)
 	LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now
 endif
 endif
 endif
+endif
 
 # for static linking
 ifeq ($(STATIC_BUILD), TRUE)
@@ -63,8 +67,10 @@ LDFLAGS      += -L${PWD}/
 CFLAGS       += -I${PWD}/include/ -I${PWD}/
 LIBS         = -lssl -lcrypto -lz
 ifneq ($(OS), FreeBSD)
+ifneq ($(OS), OpenBSD)
 	LIBS += -ldl
 endif
+endif
 ifeq ($(OS), SunOS)
 	LIBS += -lsocket -lnsl
 endif
@@ -126,7 +132,7 @@ openssl/Makefile: .openssl.is.fresh
 # Any other *NIX platform
 else
 openssl/Makefile: .openssl.is.fresh
-	cd ./openssl; ./config -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC no-shares enable-weak-ssl-ciphers enable-ssl2 zlib
+	cd ./openssl; ./config -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC no-shared enable-weak-ssl-ciphers enable-ssl2 zlib no-cast
 endif
 
 openssl/libcrypto.a: openssl/Makefile
