$OpenBSD: patch-setup_py,v 1.4 2009/01/01 21:03:27 djm Exp $
--- setup.py.orig	Mon Oct  9 03:41:25 2006
+++ setup.py	Fri Dec 26 13:14:40 2008
@@ -17,6 +17,11 @@ from distutils.command.install_lib import install_lib
 # This global variable is used to hold the list of modules to be disabled.
 disabled_module_list = []
 
+def usrlocal(p):
+    return os.path.join(os.environ['LOCALBASE'], p)
+def usrx11r6(p):
+    return os.path.join(os.environ['X11BASE'], p)
+
 def add_dir_to_list(dirlist, dir):
     """Add the directory 'dir' to the list 'dirlist' (at the front) if
     1) 'dir' is not already in 'dirlist'
@@ -240,8 +245,8 @@ class PyBuildExt(build_ext):
 
     def detect_modules(self):
         # Ensure that /usr/local is always used
-        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
-        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+        add_dir_to_list(self.compiler.library_dirs, usrlocal('lib'))
+        add_dir_to_list(self.compiler.include_dirs, usrlocal('include'))
 
         # Add paths to popular package managers on OS X/darwin
         if sys.platform == "darwin":
@@ -485,9 +490,7 @@ class PyBuildExt(build_ext):
                                depends = ['socketmodule.h']) )
         # Detect SSL support for the socket module (via _ssl)
         ssl_incs = find_file('openssl/ssl.h', inc_dirs,
-                             ['/usr/local/ssl/include',
-                              '/usr/contrib/ssl/include/'
-                             ]
+                             [ ]
                              )
         if ssl_incs is not None:
             krb5_h = find_file('krb5.h', inc_dirs,
@@ -495,8 +498,7 @@ class PyBuildExt(build_ext):
             if krb5_h:
                 ssl_incs += krb5_h
         ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
-                                     ['/usr/local/ssl/lib',
-                                      '/usr/contrib/ssl/lib/'
+                                     [
                                      ] )
 
         if (ssl_incs is not None and
@@ -522,9 +524,9 @@ class PyBuildExt(build_ext):
         #
         # http://www.sleepycat.com/update/index.html
 
-        max_db_ver = (4, 4)
+        max_db_ver = (4, 7)
         min_db_ver = (3, 2)
-        db_setup_debug = False   # verbose debug prints from this script?
+        db_setup_debug = True   # verbose debug prints from this script?
 
         # construct a list of paths to look for the header file in on
         # top of the normal inc_dirs.
@@ -570,6 +572,7 @@ class PyBuildExt(build_ext):
                 std_variants.append(os.path.join(dn, "db3.%d"%x))
 
         db_inc_paths = std_variants + db_inc_paths
+        db_inc_paths = [ usrlocal('include/db4') ]
 
         db_ver_inc_map = {}
 
@@ -600,7 +603,7 @@ class PyBuildExt(build_ext):
                             if db_setup_debug: print "db.h: ignoring", d
                     else:
                         # ignore this header, it didn't contain a version number
-                        if db_setup_debug: print "db.h: unsupported version", db_ver, "in", d
+                        if db_setup_debug: print "db.h: no version in", d
 
             db_found_vers = db_ver_inc_map.keys()
             db_found_vers.sort()
@@ -617,12 +620,14 @@ class PyBuildExt(build_ext):
                     os.path.join(db_incdir, '..', '..', 'lib'),
                 ]
                 db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
+                db_dirs_to_check = [ usrlocal('lib/db4') ]
 
                 # Look for a version specific db-X.Y before an ambiguoius dbX
                 # XXX should we -ever- look for a dbX name?  Do any
                 # systems really not name their library by version and
                 # symlink to more general names?
                 for dblib in (('db-%d.%d' % db_ver),
+                              ('db'),
                               ('db%d%d' % db_ver),
                               ('db%d' % db_ver[0])):
                     dblib_file = self.compiler.find_library_file(
@@ -814,10 +819,8 @@ class PyBuildExt(build_ext):
                               define_macros = define_macros,
                               include_dirs = [expatinc],
                               sources = ['pyexpat.c',
-                                         'expat/xmlparse.c',
-                                         'expat/xmlrole.c',
-                                         'expat/xmltok.c',
                                          ],
+                              libraries = ['expat'],
                               ))
 
         # Hye-Shik Chang's CJKCodecs modules.
@@ -842,6 +845,9 @@ class PyBuildExt(build_ext):
 
         if platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6'):
             exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
+        if platform in ('openbsd4'):
+            exts.append( Extension('ossaudiodev', ['ossaudiodev.c'],
+                                   libraries=['ossaudio']) )
 
         if platform == 'sunos5':
             # SunOS specific modules
@@ -996,7 +1002,7 @@ class PyBuildExt(build_ext):
         # For 8.4a2, the X11 headers are not included. Rather than include a
         # complicated search, this is a hard-coded path. It could bail out
         # if X11 libs are not found...
-        include_dirs.append('/usr/X11R6/include')
+        include_dirs.append(usrx11r6('include'))
         frameworks = ['-framework', 'Tcl', '-framework', 'Tk']
 
         ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
@@ -1025,8 +1031,7 @@ class PyBuildExt(build_ext):
         # The versions with dots are used on Unix, and the versions without
         # dots on Windows, for detection by cygwin.
         tcllib = tklib = tcl_includes = tk_includes = None
-        for version in ['8.5', '85', '8.4', '84', '8.3', '83', '8.2',
-                        '82', '8.1', '81', '8.0', '80']:
+        for version in ['84']:
             tklib = self.compiler.find_library_file(lib_dirs, 'tk' + version)
             tcllib = self.compiler.find_library_file(lib_dirs, 'tcl' + version)
             if tklib and tcllib:
@@ -1067,17 +1072,9 @@ class PyBuildExt(build_ext):
         if platform == 'sunos5':
             include_dirs.append('/usr/openwin/include')
             added_lib_dirs.append('/usr/openwin/lib')
-        elif os.path.exists('/usr/X11R6/include'):
-            include_dirs.append('/usr/X11R6/include')
-            added_lib_dirs.append('/usr/X11R6/lib64')
-            added_lib_dirs.append('/usr/X11R6/lib')
-        elif os.path.exists('/usr/X11R5/include'):
-            include_dirs.append('/usr/X11R5/include')
-            added_lib_dirs.append('/usr/X11R5/lib')
-        else:
-            # Assume default location for X11
-            include_dirs.append('/usr/X11/include')
-            added_lib_dirs.append('/usr/X11/lib')
+        elif True:
+            include_dirs.append(usrx11r6('include'))
+            added_lib_dirs.append(usrx11r6('lib'))
 
         # If Cygwin, then verify that X is installed before proceeding
         if platform == 'cygwin':
@@ -1224,8 +1221,7 @@ def main():
           ext_modules=[Extension('struct', ['structmodule.c'])],
 
           # Scripts to install
-          scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle',
-                     'Lib/smtpd.py']
+          scripts = []
         )
 
 # --install-platlib
