$OpenBSD: patch-setup_build_py,v 1.8 2021/10/25 13:11:46 sthen Exp $

Index: setup/build.py
--- setup/build.py.orig
+++ setup/build.py
@@ -72,15 +72,7 @@ class Extension:
 
         self.ldflags = d['ldflags'] = kwargs.get('ldflags', [])
         self.optional = d['options'] = kwargs.get('optional', False)
-        of = kwargs.get('optimize_level', None)
-        if of is None:
-            of = '/Ox' if iswindows else '-O3'
-        else:
-            flag = '/O%d' if iswindows else '-O%d'
-            of = flag % of
-        self.cflags.insert(0, of)
 
-
 def lazy_load(name):
     if name.startswith('!'):
         name = name[1:]
@@ -196,6 +188,8 @@ def init_env(debug=False, sanitize=False):
     if isbsd:
         cflags.append('-pthread')
         ldflags.append('-shared')
+        cflags.append('-I'+os.path.join(sysconfig.PREFIX, 'include'))
+        ldflags.append('-L'+os.path.join(sysconfig.PREFIX, 'lib'))
 
     if ishaiku:
         cflags.append('-lpthread')
