$OpenBSD: patch-Makerules,v 1.16 2016/12/12 10:54:39 sthen Exp $
--- Makerules.orig	Mon Nov 28 13:34:04 2016
+++ Makerules	Mon Dec 12 09:41:21 2016
@@ -21,6 +21,7 @@ else
 LDREMOVEUNREACH = -Wl,--gc-sections
 endif
 
+ifneq "$(OS)" "OpenBSD" # don't override C optimizer flags for ports builds
 ifeq "$(build)" "debug"
 CFLAGS += -pipe -g -DDEBUG
 LDFLAGS += -g
@@ -55,6 +56,7 @@ LIBS += -lprofiler
 else
 $(error unknown build setting: '$(build)')
 endif
+endif
 
 ifeq "$(largefile)" "yes"
 CFLAGS += -DFZ_LARGEFILE
@@ -103,7 +105,7 @@ LD = xcrun ld
 RANLIB_CMD = xcrun ranlib $@
 
 # Linux uses pkg-config for system libraries.
-else ifeq "$(OS)" "Linux"
+else
 
 HAVE_PTHREADS ?= yes
 
@@ -123,7 +125,7 @@ SYS_CURL_CFLAGS += $(shell pkg-config --cflags openssl
 SYS_CURL_DEPS += $(shell pkg-config --libs openssl)
 endif
 endif
-SYS_CURL_DEPS += -lpthread -lrt
+SYS_CURL_DEPS += -lpthread
 
 ifeq "$(shell pkg-config --exists x11 xext && echo yes)" "yes"
 HAVE_X11 = yes
@@ -147,6 +149,7 @@ SYS_OPENJPEG_LIBS = $(shell pkg-config --libs libopenj
 endif
 
 SYS_JBIG2DEC_LIBS = -ljbig2dec
+SYS_JPEG_CFLAGS = -I/usr/local/include
 SYS_JPEG_LIBS = -ljpeg
 SYS_ZLIB_LIBS = -lz
 
