Hi,

we have 2 solutions to use libffi (used by the standard ctypes library) with 
Python:
-use libffi included with Python (patched with same patches than devel/libffi)
-use devel/libffi in ports (concentrate patches/work on ffi here)

Nowadays, we use the first solution, but it could be usefull to switch to the 
second solution.

Attached file is the diff to permit this.

Are you ok?

Please tests on multiple archs.

Cheers,
Remi.
Index: Makefile.inc
===================================================================
RCS file: /cvs/ports/lang/python/Makefile.inc,v
retrieving revision 1.81
diff -u -p -r1.81 Makefile.inc
--- Makefile.inc        18 Jul 2011 15:32:18 -0000      1.81
+++ Makefile.inc        24 Aug 2011 09:29:01 -0000
@@ -58,8 +58,10 @@ RUN_DEPENDS-main =
 WANTLIB-main =         ssl panelw m crypto c util z readline pthread \
                        ncursesw stdc++ expat ossaudio bz2
 .if ${VERSION} == "2.5" || ${VERSION} == "2.6" || ${VERSION} == "2.7"
-LIB_DEPENDS-main +=    databases/sqlite3
-WANTLIB-main +=                sqlite3
+LIB_DEPENDS-main +=    databases/sqlite3 \
+                       devel/libffi
+WANTLIB-main +=                sqlite3 ffi
+CONFIGURE_ARGS +=      --with-system-ffi
 .endif
 
 LIB_DEPENDS-bsddb =    databases/db/v4 \
@@ -84,8 +86,7 @@ PKG_ARGS+=    -Dmm=0
 PKG_ARGS+=     -Dmm=1
 .endif
 
-# XXX fix ctypes on powerpc for python2.6
-# The ctypes module is not supported on all platforms (in particular, ARM)
+# The ctypes module depends of devel/libffi, not supported on all platforms
 .if ${VERSION} == "2.5" || ${VERSION} == "2.6" || ${VERSION} == "2.7"
 .  if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || \
       ${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64" || \
Index: 2.5/Makefile
===================================================================
RCS file: /cvs/ports/lang/python/2.5/Makefile,v
retrieving revision 1.50
diff -u -p -r1.50 Makefile
--- 2.5/Makefile        18 Jul 2011 15:32:18 -0000      1.50
+++ 2.5/Makefile        24 Aug 2011 09:29:01 -0000
@@ -2,7 +2,7 @@
 
 VERSION=               2.5
 PATCHLEVEL=            .4
-REVISION=              13
+REVISION=              14
 SHARED_LIBS=           python2.5 1.0
 
 AUTOCONF_VERSION=      2.61
Index: 2.5/patches/patch-Modules__ctypes_libffi_configure
===================================================================
RCS file: 2.5/patches/patch-Modules__ctypes_libffi_configure
diff -N 2.5/patches/patch-Modules__ctypes_libffi_configure
--- 2.5/patches/patch-Modules__ctypes_libffi_configure  28 Feb 2010 15:27:37 
-0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
-$OpenBSD: patch-Modules__ctypes_libffi_configure,v 1.3 2010/02/28 15:27:37 
phessler Exp $
---- Modules/_ctypes/libffi/configure.orig      Wed Sep  5 01:47:16 2007
-+++ Modules/_ctypes/libffi/configure   Sun Feb 28 13:56:32 2010
-@@ -3471,7 +3471,8 @@ fi
- TARGETDIR="unknown"
- case "$host" in
- x86_64-*-openbsd*) TARGET=X86_64; TARGETDIR=x86;;
--mips*-*-openbsd*) TARGET=MIPS; TARGETDIR=mips;;
-+mips*-*-openbsd*) TARGET=MIPS_LINUX; TARGETDIR=mips;;
-+loongson-*-openbsd*) TARGET=MIPS_LINUX; TARGETDIR=mips;;
- sparc-*-openbsd*) TARGET=SPARC; TARGETDIR=sparc;;
- sparc64-*-openbsd*) TARGET=SPARC; TARGETDIR=sparc;;
- alpha*-*-openbsd*) TARGET=ALPHA; TARGETDIR=alpha;;
Index: 2.5/patches/patch-Modules__ctypes_libffi_src_mips_ffi_c
===================================================================
RCS file: 2.5/patches/patch-Modules__ctypes_libffi_src_mips_ffi_c
diff -N 2.5/patches/patch-Modules__ctypes_libffi_src_mips_ffi_c
--- 2.5/patches/patch-Modules__ctypes_libffi_src_mips_ffi_c     25 Feb 2010 
11:02:39 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-$OpenBSD: patch-Modules__ctypes_libffi_src_mips_ffi_c,v 1.1 2010/02/25 
11:02:39 phessler Exp $
-
-Allow building this on OpenBSD, where we don't provide the ICACHE related
-defines in cachectl.h, but in sysarch.h
-
---- Modules/_ctypes/libffi/src/mips/ffi.c.orig Sat Feb 20 16:32:04 2010
-+++ Modules/_ctypes/libffi/src/mips/ffi.c      Sat Feb 20 16:33:13 2010
-@@ -27,7 +27,11 @@
- #include <ffi_common.h>
- 
- #include <stdlib.h>
--#include <sys/cachectl.h>
-+#if defined(__OpenBSD__)
-+#  include <mips64/sysarch.h>
-+#else
-+#  include <sys/cachectl.h>
-+#endif
- 
- #if _MIPS_SIM == _ABIN32
- #define FIX_ARGP \
Index: 2.5/patches/patch-Modules__ctypes_libffi_src_mips_ffitarget_h
===================================================================
RCS file: 2.5/patches/patch-Modules__ctypes_libffi_src_mips_ffitarget_h
diff -N 2.5/patches/patch-Modules__ctypes_libffi_src_mips_ffitarget_h
--- 2.5/patches/patch-Modules__ctypes_libffi_src_mips_ffitarget_h       25 Feb 
2010 11:02:39 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,17 +0,0 @@
-$OpenBSD: patch-Modules__ctypes_libffi_src_mips_ffitarget_h,v 1.1 2010/02/25 
11:02:39 phessler Exp $
-
-Allow _ctypes to build on mips64*
-
---- Modules/_ctypes/libffi/src/mips/ffitarget.h.orig   Thu Mar  9 02:35:32 2006
-+++ Modules/_ctypes/libffi/src/mips/ffitarget.h        Tue Feb 23 21:32:09 2010
-@@ -158,8 +158,8 @@ typedef enum ffi_abi {
- #define FFI_CLOSURES 1
- #define FFI_TRAMPOLINE_SIZE 20
- #else
--/* N32/N64 not implemented yet. */
--#define FFI_CLOSURES 0
-+#define FFI_CLOSURES 1
-+#define FFI_TRAMPOLINE_SIZE 52
- #endif /* FFI_MIPS_O32 */
- #define FFI_NATIVE_RAW_API 0
- 
Index: 2.7/Makefile
===================================================================
RCS file: /cvs/ports/lang/python/2.7/Makefile,v
retrieving revision 1.12
diff -u -p -r1.12 Makefile
--- 2.7/Makefile        23 Aug 2011 07:08:23 -0000      1.12
+++ 2.7/Makefile        24 Aug 2011 09:29:01 -0000
@@ -2,7 +2,7 @@
 
 VERSION =              2.7
 PATCHLEVEL =           .1
-REVISION =             10
+REVISION =             11
 SHARED_LIBS =          python2.7 0.0
 
 AUTOCONF_VERSION =     2.65
Index: 2.7/patches/patch-Modules__ctypes_libffi_configure
===================================================================
RCS file: 2.7/patches/patch-Modules__ctypes_libffi_configure
diff -N 2.7/patches/patch-Modules__ctypes_libffi_configure
--- 2.7/patches/patch-Modules__ctypes_libffi_configure  6 Jul 2011 12:05:56 
-0000       1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-$OpenBSD: patch-Modules__ctypes_libffi_configure,v 1.2 2011/07/06 12:05:56 
jasper Exp $
---- Modules/_ctypes/libffi/configure.orig      Fri Mar 19 19:59:20 2010
-+++ Modules/_ctypes/libffi/configure   Wed Jul  6 14:05:41 2011
-@@ -11254,7 +11254,7 @@ case "$host" in
-   mips-sgi-irix5.* | mips-sgi-irix6.*)
-       TARGET=MIPS_IRIX; TARGETDIR=mips
-       ;;
--  mips*-*-linux*)
-+  mips*-*-linux* | mips*-*-openbsd*)
-       # Support 128-bit long double for NewABI.
-       HAVE_LONG_DOUBLE='defined(__mips64)'
-       TARGET=MIPS_IRIX; TARGETDIR=mips
Index: 2.7/patches/patch-Modules__ctypes_libffi_src_mips_ffi_c
===================================================================
RCS file: 2.7/patches/patch-Modules__ctypes_libffi_src_mips_ffi_c
diff -N 2.7/patches/patch-Modules__ctypes_libffi_src_mips_ffi_c
--- 2.7/patches/patch-Modules__ctypes_libffi_src_mips_ffi_c     24 Apr 2011 
09:31:44 -0000      1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-$OpenBSD: patch-Modules__ctypes_libffi_src_mips_ffi_c,v 1.1.1.1 2011/04/24 
09:31:44 rpointel Exp $
-
-Allow building this on OpenBSD, where we don't provide the ICACHE related
-defines in cachectl.h, but in sysarch.h
-
---- Modules/_ctypes/libffi/src/mips/ffi.c.orig Tue Feb 23 20:12:37 2010
-+++ Modules/_ctypes/libffi/src/mips/ffi.c      Tue Feb 23 20:13:38 2010
-@@ -37,7 +37,11 @@
- #endif
- 
- #ifndef USE__BUILTIN___CLEAR_CACHE
--#include <sys/cachectl.h>
-+#if defined(__OpenBSD__)
-+#  include <mips64/sysarch.h>
-+#else
-+#  include <sys/cachectl.h>
-+#endif
- #endif
- 
- #ifdef FFI_DEBUG
Index: 2.7/patches/patch-Modules__ctypes_libffi_src_mips_ffitarget_h
===================================================================
RCS file: 2.7/patches/patch-Modules__ctypes_libffi_src_mips_ffitarget_h
diff -N 2.7/patches/patch-Modules__ctypes_libffi_src_mips_ffitarget_h
--- 2.7/patches/patch-Modules__ctypes_libffi_src_mips_ffitarget_h       13 Jun 
2011 19:43:59 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,20 +0,0 @@
-$OpenBSD: patch-Modules__ctypes_libffi_src_mips_ffitarget_h,v 1.1 2011/06/13 
19:43:59 rpointel Exp $
---- Modules/_ctypes/libffi/src/mips/ffitarget.h.orig   Mon Jun 13 14:31:24 2011
-+++ Modules/_ctypes/libffi/src/mips/ffitarget.h        Mon Jun 13 14:36:33 2011
-@@ -27,10 +27,12 @@
- #ifndef LIBFFI_TARGET_H
- #define LIBFFI_TARGET_H
- 
--#ifdef linux
--# include <asm/sgidefs.h>
--#else
--# include <sgidefs.h>
-+#if !defined(__OpenBSD__)
-+#  ifdef linux
-+#    include <asm/sgidefs.h>
-+#  else
-+#    include <sgidefs.h>
-+#  endif
- #endif
- #  ifndef _ABIN32
- #    define _ABIN32 _MIPS_SIM_NABI32

Reply via email to