$OpenBSD: patch-Source_setup_configure_py,v 1.6 2017/02/27 18:03:45 jca Exp $

1) Fix broken lib auto-detection. The configure script will try to stat a
   shared library file, but we don't know the exact filename because it depends
   on the shared library version. So look for a .la file instead. These are
   present for all libraries the script is looking for.

2) Add missing OpenBSD-specific bits.

--- Source/setup_configure.py.orig	Sat May 14 11:45:00 2016
+++ Source/setup_configure.py	Mon Feb 27 16:29:52 2017
@@ -184,6 +184,9 @@ class Setup:
             elif sys.platform.startswith('freebsd'):
                 self.platform = 'freebsd'
 
+            elif sys.platform.startswith('openbsd'):
+                self.platform = 'openbsd'
+
             elif sys.platform == 'cygwin':
                 self.platform = 'cygwin'
 
@@ -206,6 +209,10 @@ class Setup:
             self.c_utils = FreeBsdCompilerGCC( self )
             self.c_pysvn = FreeBsdCompilerGCC( self )
 
+        elif self.platform == 'openbsd':
+            self.c_utils = OpenBsdCompilerGCC( self )
+            self.c_pysvn = OpenBsdCompilerGCC( self )
+
         elif self.platform == 'cygwin':
             self.c_utils = CygwinCompilerGCC( self )
             self.c_pysvn = CygwinCompilerGCC( self )
@@ -876,8 +883,8 @@ class CompilerGCC(Compiler):
     def __init__( self, setup ):
         Compiler.__init__( self, setup )
 
-        self._addVar( 'CCC',            'g++' )
-        self._addVar( 'CC',             'gcc' )
+        self._addVar( 'CCC',            '${CXX} ${CXXFLAGS}' )
+        self._addVar( 'CC',             '${CC} ${CFLAGS}' )
 
     def getPythonExtensionFileExt( self ):
         return '.so'
@@ -905,8 +912,7 @@ class CompilerGCC(Compiler):
         rules = []
 
         rules.append( '%s : %s' % (target_filename, ' '.join( all_objects )) )
-        rules.append( '\t@echo Link %s' % (target_filename,) )
-        rules.append( '\t@%%(LDEXE)s -o %s %%(CCCFLAGS)s %s' % (target_filename, ' '.join( all_objects )) )
+        rules.append( '\t%%(LDEXE)s -o %s %%(CCCFLAGS)s %s' % (target_filename, ' '.join( all_objects )) )
 
         self.makePrint( self.expand( '\n'.join( rules ) ) )
 
@@ -918,8 +924,7 @@ class CompilerGCC(Compiler):
         rules = []
 
         rules.append( '%s : %s' % (target_filename, ' '.join( all_objects )) )
-        rules.append( '\t@echo Link %s' % (target_filename,) )
-        rules.append( '\t@%%(LDSHARED)s -o %s %%(CCCFLAGS)s %s %%(LDLIBS)s' % (target_filename, ' '.join( all_objects )) )
+        rules.append( '\t%%(LDSHARED)s -o %s %%(CCCFLAGS)s %s %%(LDLIBS)s' % (target_filename, ' '.join( all_objects )) )
 
         self.makePrint( self.expand( '\n'.join( rules ) ) )
 
@@ -929,8 +934,7 @@ class CompilerGCC(Compiler):
         rules = []
 
         rules.append( '%s: %s %s' % (obj_filename, target.src_filename, ' '.join( target.all_dependencies )) )
-        rules.append( '\t@echo Compile: %s into %s' % (target.src_filename, obj_filename) )
-        rules.append( '\t@%%(CCC)s -c %%(CCCFLAGS)s -o%s  %s' % (obj_filename, target.src_filename) )
+        rules.append( '\t%%(CCC)s -c %%(CCCFLAGS)s -o%s  %s' % (obj_filename, target.src_filename) )
 
         self.makePrint( self.expand( '\n'.join( rules ) ) )
 
@@ -940,8 +944,7 @@ class CompilerGCC(Compiler):
         rules = []
 
         rules.append( '%s: %s %s' % (obj_filename, target.src_filename, ' '.join( target.all_dependencies )) )
-        rules.append( '\t@echo Compile: %s into %s' % (target.src_filename, obj_filename) )
-        rules.append( '\t@%%(CC)s -c %%(CCFLAGS)s -o%s  %s' % (obj_filename, target.src_filename) )
+        rules.append( '\t%%(CC)s -c %%(CCFLAGS)s -o%s  %s' % (obj_filename, target.src_filename) )
 
         self.makePrint( self.expand( '\n'.join( rules ) ) )
 
@@ -1206,6 +1209,8 @@ class UnixCompilerGCC(CompilerGCC):
     def get_lib_name_for_platform( self, libname ):
         if self.setup.platform == 'cygwin':
             return ['%s.dll.a' % libname]
+        elif self.setup.platform == 'openbsd':
+            return ['%s.la' % libname]
         else:
             return ['%s.so' % libname]
 
@@ -1298,6 +1303,25 @@ class FreeBsdCompilerGCC(UnixCompilerGCC):
                 '-lcom_err',
                 '-lexpat',
                 '-lneon',
+                ] )
+        return py_ld_libs
+
+class OpenBsdCompilerGCC(UnixCompilerGCC):
+    def __init__( self, setup ):
+        UnixCompilerGCC.__init__( self, setup )
+
+    def _getLdLibs( self ):
+        py_ld_libs = [
+                '-L%(SVN_LIB)s',
+                '-Wl,--rpath',
+                '-Wl,/usr/lib:/usr/local/lib',
+                '-lsvn_client-1',
+                '-lsvn_diff-1',
+                '-lsvn_repos-1',
+                ]
+
+        py_ld_libs.extend( [
+                '-lexpat',
                 ] )
         return py_ld_libs
 
