summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-03-04 20:09:11 (GMT)
committerThomas Heller <theller@ctypes.org>2008-03-04 20:09:11 (GMT)
commit8bdf81d2df388ce06088193f95c992a7ee1eb553 (patch)
treed116a98944af811c3b5262d6318ddd1379bff8ff /setup.py
parent4a50d26ba229e5154b9c28c7e4073848f1850585 (diff)
downloadcpython-8bdf81d2df388ce06088193f95c992a7ee1eb553.zip
cpython-8bdf81d2df388ce06088193f95c992a7ee1eb553.tar.gz
cpython-8bdf81d2df388ce06088193f95c992a7ee1eb553.tar.bz2
Merged changes from libffi3-branch.
The bundled libffi copy is now in sync with the recently released libffi3.0.4 version, apart from some small changes to Modules/_ctypes/libffi/configure.ac. I gave up on using libffi3 files on os x. Instead, static configuration with files from pyobjc is used.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index c643845..acd882e 100644
--- a/setup.py
+++ b/setup.py
@@ -1455,8 +1455,37 @@ class PyBuildExt(build_ext):
# *** Uncomment these for TOGL extension only:
# -lGL -lGLU -lXext -lXmu \
+ def configure_ctypes_darwin(self, ext):
+ # Darwin (OS X) uses preconfigured files, in
+ # the Modules/_ctypes/libffi_osx directory.
+ (srcdir,) = sysconfig.get_config_vars('srcdir')
+ ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
+ '_ctypes', 'libffi_osx'))
+ sources = [os.path.join(ffi_srcdir, p)
+ for p in ['ffi.c',
+ 'x86/x86-darwin.S',
+ 'x86/x86-ffi_darwin.c',
+ 'x86/x86-ffi64.c',
+ 'powerpc/ppc-darwin.S',
+ 'powerpc/ppc-darwin_closure.S',
+ 'powerpc/ppc-ffi_darwin.c',
+ 'powerpc/ppc64-darwin_closure.S',
+ ]]
+
+ # Add .S (preprocessed assembly) to C compiler source extensions.
+ self.compiler.src_extensions.append('.S')
+
+ include_dirs = [os.path.join(ffi_srcdir, 'include'),
+ os.path.join(ffi_srcdir, 'powerpc')]
+ ext.include_dirs.extend(include_dirs)
+ ext.sources.extend(sources)
+ return True
+
def configure_ctypes(self, ext):
if not self.use_system_libffi:
+ if sys.platform == 'darwin':
+ return self.configure_ctypes_darwin(ext)
+
(srcdir,) = sysconfig.get_config_vars('srcdir')
ffi_builddir = os.path.join(self.build_temp, 'libffi')
ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules',
@@ -1515,6 +1544,7 @@ class PyBuildExt(build_ext):
if sys.platform == 'darwin':
sources.append('_ctypes/darwin/dlfcn_simple.c')
+ extra_compile_args.append('-DMACOSX')
include_dirs.append('_ctypes/darwin')
# XXX Is this still needed?
## extra_link_args.extend(['-read_only_relocs', 'warning'])
@@ -1544,6 +1574,11 @@ class PyBuildExt(build_ext):
if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"):
return
+ if sys.platform == 'darwin':
+ # OS X 10.5 comes with libffi.dylib; the include files are
+ # in /usr/include/ffi
+ inc_dirs.append('/usr/include/ffi')
+
ffi_inc = find_file('ffi.h', [], inc_dirs)
if ffi_inc is not None:
ffi_h = ffi_inc[0] + '/ffi.h'