Commits

Jelmer Vernooij committed 45a01a8

Use apu include path, apr link flags.

Comments (0)

Files changed (1)

 #!/usr/bin/env python
 # Setup file for subvertpy
-# Copyright (C) 2005-2009 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2005-2010 Jelmer Vernooij <jelmer@samba.org>
 
 from distutils.core import setup
 from distutils.extension import Extension
 # * Set SVN_BDB and SVN_LIBINTL to point at these dirs.
 
 class CommandException(Exception):
-    """Encapsulate exit status of apr-config execution"""
+    """Encapsulate exit status of command execution"""
     def __init__(self, msg, cmd, arg, status, val):
         self.message = msg % (cmd, val)
         Exception.__init__(self, self.message)
         return os.WIFEXITED(self.status) and os.WEXITSTATUS(self.status) == 127
 
 
+def split_shell_results(line):
+    return [s for s in line.split(" ") if s != ""]
+
+
 def run_cmd(cmd, arg):
     """Run specified command with given arguments, handling status"""
     f = os.popen("'%s' %s" % (cmd, arg))
 def apu_config(arg):
     config_cmd = os.getenv("APU_CONFIG")
     if config_cmd is None:
-        return config_value("apu-config", arg)
+        return config_value("apu-1-config", arg)
     else:
         return run_cmd(config_cmd, arg)
 
     includedir = apr_config("--includedir")
     if not os.path.isdir(includedir):
         raise Exception("APR development headers not found")
-    return (includedir,)
+    extra_link_flags = apr_config("--link-ld --libs")
+    return (includedir, split_shell_results(extra_link_flags))
 
 
 def apu_build_data():
     includedir = apu_config("--includedir")
     if not os.path.isdir(includedir):
         raise Exception("APR util development headers not found")
-    return (includedir,)
+    extra_link_flags = apr_config("--link-ld --libs")
+    return (includedir, split_shell_results(extra_link_flags))
 
 
 def svn_build_data():
     """Determine the Subversion header file location."""
     if "SVN_HEADER_PATH" in os.environ and "SVN_LIBRARY_PATH" in os.environ:
-        return ([os.getenv("SVN_HEADER_PATH")], [os.getenv("SVN_LIBRARY_PATH")], [])
+        return ([os.getenv("SVN_HEADER_PATH")], [os.getenv("SVN_LIBRARY_PATH")], [], [])
     svn_prefix = os.getenv("SVN_PREFIX")
     if svn_prefix is None:
         basedirs = ["/usr/local", "/usr"]
                 break
     if svn_prefix is not None:
         return ([os.path.join(svn_prefix, "include/subversion-1")], 
-                [os.path.join(svn_prefix, "lib")], [])
+                [os.path.join(svn_prefix, "lib")], [], [])
     raise Exception("Subversion development files not found. "
                     "Please set SVN_PREFIX or (SVN_LIBRARY_PATH and SVN_HEADER_PATH) environment variable. ")
 
     Checks for the availability of the Keychain simple authentication provider in Subversion by compiling a simple test program.
     """
     abd = apr_build_data()
-    abud = apu_build_data()
     sbd = svn_build_data()
-    gcc_command_args = ['gcc'] + ['-I' + inc for inc in sbd[0]] + ['-L' + lib for lib in sbd[1]] + ['-I' + abd[0], '-I' + abud[0], '-lsvn_subr-1', '-x', 'c', '-']
+    gcc_command_args = ['gcc'] + ['-I' + inc for inc in sbd[0]] + ['-L' + lib for lib in sbd[1]] + ['-I' + abd[0], '-lsvn_subr-1', '-x', 'c', '-']
     (gcc_in, gcc_out, gcc_err) = os.popen3(gcc_command_args)
     gcc_in.write("""
 #include <svn_auth.h>
     gcc_out.read()
     return (gcc_out.close() is None)
 
+
 class VersionQuery(object):
+
     def __init__(self, filename):
         self.filename = filename
         f = file(filename, "rU")
     # just clobber the functions above we can't use
     # for simplicitly, everything is done in the 'svn' one
     def apr_build_data():
-        return '.',
+        return '.', []
 
     def apu_build_data():
-        return '.',
+        return '.', []
 
     def svn_build_data():
         # environment vars for the directories we need.
             # Since 1.5.0 libsvn_ra_dav-1 was removed
             libs.remove("libsvn_ra_dav-1")
 
-        return includes, lib_dirs, aprlibs+libs,
+        return includes, lib_dirs, [], aprlibs+libs,
 
-(apr_includedir, ) = apr_build_data()
-(apu_includedir, ) = apu_build_data()
-(svn_includedirs, svn_libdirs, extra_libs) = svn_build_data()
+(apr_includedir, apr_link_flags) = apr_build_data()
+(apu_includedir, apu_link_flags) = apu_build_data()
+(svn_includedirs, svn_libdirs, svn_link_flags, extra_libs) = svn_build_data()
 
 def SvnExtension(name, *args, **kwargs):
     kwargs["include_dirs"] = [apr_includedir, apu_includedir] + svn_includedirs + ["subvertpy"]
     kwargs["library_dirs"] = svn_libdirs
+    # Note that the apr-util link flags are not included here, as
+    # subvertpy only uses some apr util constants but does not use
+    # the library directly.
+    kwargs["extra_link_args"] = apr_link_flags + svn_link_flags
     if os.name == 'nt':
         # on windows, just ignore and overwrite the libraries!
         kwargs["libraries"] = extra_libs