xref: /PHP-8.0/ext/ffi/config.m4 (revision 7ec50c24)
1PHP_ARG_WITH([ffi],
2  [for FFI support],
3  [AS_HELP_STRING([--with-ffi],
4    [Include FFI support])])
5
6if test "$PHP_FFI" != "no"; then
7  PKG_CHECK_MODULES([FFI], [libffi >= 3.0.11])
8
9  PHP_EVAL_INCLINE($FFI_CFLAGS)
10  PHP_EVAL_LIBLINE($FFI_LIBS, FFI_SHARED_LIBADD)
11
12  AC_DEFINE(HAVE_FFI, 1, [Have ffi support])
13
14  AC_CHECK_TYPES(long double)
15
16  AC_CACHE_CHECK([for fastcall calling convention], ac_cv_ffi_fastcall,
17    [
18      AC_COMPILE_IFELSE(
19        [AC_LANG_PROGRAM([[#include <ffi.h>]],
20        [[return FFI_FASTCALL]])
21    ],
22    [ac_cv_ffi_fastcall=yes], [ac_cv_ffi_fastcall=no])
23  ])
24
25  if test "$ac_cv_ffi_fastcall" = yes; then
26    AC_DEFINE(HAVE_FFI_FASTCALL,1,[Whether libffi supports fastcall calling convention])
27  fi
28
29  AC_CACHE_CHECK([for thiscall calling convention], ac_cv_ffi_thiscall,
30    [
31      AC_COMPILE_IFELSE(
32        [AC_LANG_PROGRAM([[#include <ffi.h>]],
33        [[return FFI_THISCALL]])
34    ],
35    [ac_cv_ffi_thiscall=yes], [ac_cv_ffi_thiscall=no])
36  ])
37
38  if test "$ac_cv_ffi_thiscall" = yes; then
39    AC_DEFINE(HAVE_FFI_THISCALL,1,[Whether libffi supports thiscall calling convention])
40  fi
41
42  AC_CACHE_CHECK([for stdcall calling convention], ac_cv_ffi_stdcall,
43    [
44      AC_COMPILE_IFELSE(
45        [AC_LANG_PROGRAM([[#include <ffi.h>]],
46        [[return FFI_STDCALL]])
47    ],
48    [ac_cv_ffi_stdcall=yes], [ac_cv_ffi_stdcall=no])
49  ])
50
51  if test "$ac_cv_ffi_stdcall" = yes; then
52    AC_DEFINE(HAVE_FFI_STDCALL,1,[Whether libffi supports stdcall calling convention])
53  fi
54
55  AC_CACHE_CHECK([for pascal calling convention], ac_cv_ffi_pascal,
56    [
57      AC_COMPILE_IFELSE(
58        [AC_LANG_PROGRAM([[#include <ffi.h>]],
59        [[return FFI_PASCAL]])
60    ],
61    [ac_cv_ffi_pascal=yes], [ac_cv_ffi_pascal=no])
62  ])
63
64  if test "$ac_cv_ffi_pascal" = yes; then
65    AC_DEFINE(HAVE_FFI_PASCAL,1,[Whether libffi supports pascal calling convention])
66  fi
67
68  AC_CACHE_CHECK([for register calling convention], ac_cv_ffi_register,
69    [
70      AC_COMPILE_IFELSE(
71        [AC_LANG_PROGRAM([[#include <ffi.h>]],
72        [[return FFI_REGISTER]])
73    ],
74    [ac_cv_ffi_register=yes], [ac_cv_ffi_register=no])
75  ])
76
77  if test "$ac_cv_ffi_register" = yes; then
78    AC_DEFINE(HAVE_FFI_REGISTER,1,[Whether libffi supports register calling convention])
79  fi
80
81  AC_CACHE_CHECK([for ms_cdecl calling convention], ac_cv_ffi_ms_cdecl,
82    [
83      AC_COMPILE_IFELSE(
84        [AC_LANG_PROGRAM([[#include <ffi.h>]],
85        [[return FFI_MS_CDECL]])
86    ],
87    [ac_cv_ffi_ms_cdecl=yes], [ac_cv_ffi_ms_cdecl=no])
88  ])
89
90  if test "$ac_cv_ffi_ms_cdecl" = yes; then
91    AC_DEFINE(HAVE_FFI_MS_CDECL,1,[Whether libffi supports ms_cdecl calling convention])
92  fi
93
94  AC_CACHE_CHECK([for sysv calling convention], ac_cv_ffi_sysv,
95    [
96      AC_COMPILE_IFELSE(
97        [AC_LANG_PROGRAM([[#include <ffi.h>]],
98        [[return FFI_SYSV]])
99    ],
100    [ac_cv_ffi_sysv=yes], [ac_cv_ffi_sysv=no])
101  ])
102
103  if test "$ac_cv_ffi_sysv" = yes; then
104    AC_DEFINE(HAVE_FFI_SYSV,1,[Whether libffi supports sysv calling convention])
105  fi
106
107  PHP_NEW_EXTENSION(ffi, ffi.c ffi_parser.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
108  PHP_SUBST(FFI_SHARED_LIBADD)
109fi
110