summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-12-04 10:21:43 (GMT)
committerGitHub <noreply@github.com>2021-12-04 10:21:43 (GMT)
commit4045392e0e3446362841b3336497cb6eeccfcd23 (patch)
treead93651b416d5fb070044047f26a64bcc816226e /configure.ac
parentcee07b162843694e8166ad8715162d4d5886b50f (diff)
downloadcpython-4045392e0e3446362841b3336497cb6eeccfcd23.zip
cpython-4045392e0e3446362841b3336497cb6eeccfcd23.tar.gz
cpython-4045392e0e3446362841b3336497cb6eeccfcd23.tar.bz2
bpo-45847: Port _ctypes partly to PY_STDLIB_MOD (GH-29747)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac61
1 files changed, 60 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index b35c92a..40dc6f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3175,6 +3175,60 @@ else
with_system_ffi="yes"
fi
+dnl detect libffi
+have_libffi=missing
+AS_VAR_IF([with_system_ffi], [yes], [
+ PKG_CHECK_MODULES([LIBFFI], [libffi], [have_libffi=yes], [
+ AC_CHECK_HEADER([ffi.h], [
+ WITH_SAVE_ENV([
+ AC_CHECK_LIB([ffi], [ffi_call], [have_libffi=yes], [have_libffi=no])
+ ])
+ ])
+ ])
+], [
+ dnl private ffi copy
+ have_libffi=yes
+ LIBFFI_CFLAGS="-I\$(srcdir)/Modules/_ctypes/darwin -DUSING_MALLOC_CLOSURE_DOT_C=1 -DMACOSX"
+ LIBFFI_LIBS=
+])
+
+dnl _ctypes needs -ldl for dlopen
+AS_CASE([$LIBS],
+ [*-ldl*], [LIBFFI_LIBS="$LIBFFI_LIBS -ldl"]
+)
+
+if test "$with_system_ffi" = yes -a "$have_libffi" = yes; then
+ WITH_SAVE_ENV([
+ CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
+ LIBS="$LIBFFI_LIBS $LIBS"
+
+ AC_CACHE_CHECK([for ffi_prep_cif_var in ffi.h], [ac_cv_ffi_prep_cif_var], [
+ AC_EGREP_HEADER([ffi_prep_cif_var], [ffi.h], [ac_cv_ffi_prep_cif_var=yes], [ac_cv_ffi_prep_cif_var=no])
+ ])
+ AS_VAR_IF([ac_cv_ffi_prep_cif_var], [yes], [
+ AC_DEFINE([HAVE_FFI_PREP_CIF_VAR], [1],
+ [Define to 1 if you have the ffi_prep_cif_var function in <ffi.h> header file.])
+ ])
+
+ AC_CACHE_CHECK([for ffi_prep_closure_loc in ffi.h], [ac_cv_ffi_prep_closure_loc], [
+ AC_EGREP_HEADER([ffi_prep_closure_loc], [ffi.h], [ac_cv_ffi_prep_closure_loc=yes], [ac_cv_ffi_prep_closure_loc=no])
+ ])
+ AS_VAR_IF([ac_cv_ffi_prep_closure_loc], [yes], [
+ AC_DEFINE([HAVE_FFI_PREP_CLOSURE_LOC], [1],
+ [Define to 1 if you have the ffi_prep_closure_loc function in <ffi.h> header file.])
+ ])
+
+ AC_CACHE_CHECK([for ffi_closure_alloc in ffi.h], [ac_cv_ffi_closure_alloc], [
+ AC_EGREP_HEADER([ffi_closure_alloc], [ffi.h], [ac_cv_ffi_closure_alloc=yes], [ac_cv_ffi_closure_alloc=no])
+ ])
+ AS_VAR_IF([ac_cv_ffi_closure_alloc], [yes], [
+ AC_DEFINE([HAVE_FFI_CLOSURE_ALLOC], [1],
+ [Define to 1 if you have the ffi_closure_alloc function in <ffi.h> header file.])
+ ])
+ ])
+fi
+
+
if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
else
@@ -6423,6 +6477,9 @@ PY_STDLIB_MOD([_blake2], [test "$with_builtin_blake2" = yes])
PY_STDLIB_MOD([_crypt],
[], [test "$ac_cv_crypt_crypt" = yes],
[$LIBCRYPT_CFLAGS], [$LIBCRYPT_LIBS])
+PY_STDLIB_MOD([_ctypes],
+ [], [test "$have_libffi" = yes],
+ [$LIBFFI_CFLAGS], [$LIBFFI_LIBS])
PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LDFLAGS])
PY_STDLIB_MOD([_gdbm],
[test "$have_gdbm_dbmliborder" = yes], [test "$have_gdbm" = yes],
@@ -6461,7 +6518,9 @@ PY_STDLIB_MOD([_testbuffer], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes])
-PY_STDLIB_MOD([_ctypes_test], [test "$TEST_MODULES" = yes], [], [], [-lm])
+PY_STDLIB_MOD([_ctypes_test],
+ [test "$TEST_MODULES" = yes], [test "$have_libffi" = yes],
+ [], [$LIBM])
dnl Limited API template modules.
dnl The limited C API is not compatible with the Py_TRACE_REFS macro.