1 dnl Generated headers with pre-defined types, structs, consts and decls.
2 PSI_STDINC=$PHP_PSI_SRCDIR/php_psi_stdinc.h
3 PSI_STDTYPES=$PHP_PSI_SRCDIR/php_psi_stdtypes.h
4 PSI_TYPES=$PHP_PSI_SRCDIR/php_psi_types.h
5 PSI_STRUCTS=$PHP_PSI_SRCDIR/php_psi_structs.h
6 PSI_CONSTS=$PHP_PSI_SRCDIR/php_psi_consts.h
7 PSI_REDIRS=$PHP_PSI_SRCDIR/php_psi_redirs.h
8 PSI_MACROS=$PHP_PSI_SRCDIR/php_psi_macros.h
9 PSI_DECLS=$PHP_PSI_SRCDIR/php_psi_decls.h
10 PSI_VA_DECLS=$PHP_PSI_SRCDIR/php_psi_va_decls.h
13 dnl Creates stubs of the headers with pre-defined types etc.
14 dnl These headers are included by src/context.c.
15 dnl This macro must be called prior any checks for a type, struct, decl etc.
16 AC_DEFUN(PSI_CONFIG_INIT, [
17 cat >$PSI_STDTYPES <<EOF
18 /* generated by configure */
19 static struct psi_std_type {
21 const char *type_name;
23 } psi_std_types@<:@@:>@ = {
24 {PSI_T_INT8, "int8_t", NULL},
25 {PSI_T_INT16, "int16_t", NULL},
26 {PSI_T_INT32, "int32_t", NULL},
27 {PSI_T_INT64, "int64_t", NULL},
28 {PSI_T_UINT8, "uint8_t", NULL},
29 {PSI_T_UINT16, "uint16_t", NULL},
30 {PSI_T_UINT32, "uint32_t", NULL},
31 {PSI_T_UINT64, "uint64_t", NULL},
34 /* generated by configure */
35 static struct psi_predef_type {
37 const char *type_name;
39 } psi_predef_types@<:@@:>@ = {
41 cat >$PSI_STRUCTS <<EOF
42 /* generated by configure */
43 static struct psi_predef_struct {
45 const char *type_name;
51 } psi_predef_structs@<:@@:>@ = {
53 cat >$PSI_CONSTS <<EOF
54 /* generated by configure */
55 static struct psi_predef_const {
57 const char *type_name;
61 } psi_predef_consts@<:@@:>@ = {
63 cat >$PSI_REDIRS <<EOF
64 /* generated by configure */
65 static struct psi_func_redir {
68 } psi_func_redirs@<:@@:>@ = {
70 cat >$PSI_MACROS </dev/null
72 /* generated by configure */
73 static struct psi_predef_decl {
75 const char *type_name;
79 } psi_predef_decls@<:@@:>@ = {
81 cat >$PSI_VA_DECLS <<EOF
82 /* generated by configure */
83 static struct psi_predef_decl psi_predef_vararg_decls@<:@@:>@ = {
88 dnl Finish the headers with the pre-defined types etc.
89 AC_DEFUN(PSI_CONFIG_DONE, [
90 cat >$PSI_STDINC <<EOF
91 /* generated by configure */
94 for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS; do
102 dnl PSI_CONFIG_POSIX(section, headers)
103 AC_DEFUN(PSI_CONFIG_POSIX, [
104 case "$PHP_PSI_POSIX" in
106 *) expr "$PHP_PSI_POSIX" : '\b$1\b' >/dev/null || return 0 ;;
108 ifelse($2,,,AC_CHECK_HEADERS($2))
112 dnl Expands to a complete list of include statements including
113 dnl AC_INCLUDES_DEFAULT().
114 AC_DEFUN(PSI_INCLUDES, [AC_INCLUDES_DEFAULT()
124 #ifdef HAVE_XLOCALE_H
125 # include <xlocale.h>
127 #ifdef HAVE_NETINET_IN_H
128 # include <netinet/in.h>
130 #ifdef HAVE_NETINET_TCP_H
131 # include <netinet/tcp.h>
133 #ifdef HAVE_ARPA_NAMESER_H
134 # include <arpa/nameser.h>
151 #ifdef HAVE_SYS_SELECT_H
152 # include <sys/select.h>
154 #ifdef HAVE_SYS_SOCKET_H
155 # include <sys/socket.h>
157 #ifdef HAVE_SYS_TIME_H
158 # include <sys/time.h>
160 #ifdef HAVE_SYS_TIMES_H
161 # include <sys/times.h>
163 #ifdef HAVE_SYS_UIO_H
164 # include <sys/uio.h>
166 #ifdef HAVE_SYS_UTSNAME_H
167 # include <sys/utsname.h>
184 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
185 AC_DEFUN(PSI_LEMON, [
186 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
187 AC_PATH_PROG(LEMON, lemon, ./lemon)
192 dnl Check for `pkg-config` and add possible libjit and libffi directories to
193 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
194 dnl arch-dependent locations.
195 AC_DEFUN([PSI_PKG_CONFIG], [
196 if test -z "$PKG_CONFIG"
198 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
200 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
203 dnl PSI_SH_SIZEOF(type)
204 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
205 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
207 dnl PSI_SH_TEST_SIZEOF(type)
208 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
209 AC_DEFUN([PSI_SH_TEST_SIZEOF], [test -n "$AS_TR_SH([ac_cv_sizeof_]$1)" && test "$AS_TR_SH([ac_cv_sizeof_]$1)" -gt 0])
211 dnl PSI_CHECK_SIZEOF(type, special-includes)
212 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
213 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS.
214 AC_DEFUN(PSI_CHECK_SIZEOF, [
215 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
217 if PSI_SH_TEST_SIZEOF($1); then
218 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
222 dnl PSI_CHECK_OFFSETOF(struct, element)
223 dnl Check the offset of a struct element, implemented in the similar manner
224 dnl like AC_CHECK_SIZEOF.
225 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
226 AC_DEFUN(PSI_CHECK_OFFSETOF, [
228 [offset of $2 in $1],
229 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
230 [(long int) (offsetof ($1, $2))],
232 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
235 AS_TR_CPP(offsetof_$1_$2),
236 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
237 [The offset of `$2' in `$1', as computed by offsetof.]
241 dnl PSI_SH_OFFSETOF(type)
242 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
243 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
246 dnl PSI_COMPUTE_STR(variable, string or expression)
247 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
248 AC_DEFUN(PSI_COMPUTE_STR, [
252 return EOF == fputs($2, fopen("conftest.out", "w"));
255 eval $1=\\\"`cat conftest.out`\\\"
259 dnl PSI_CHECK_LIBJIT()
260 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
261 dnl AC_DEFINEs HAVE_LIBJIT.
262 AC_DEFUN(PSI_CHECK_LIBJIT, [
263 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
264 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
266 if test -e $psi_cv_libjit_dir/include/jit/jit.h
273 if test -n "$psi_cv_libjit_dir"
275 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
276 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
277 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
279 AC_MSG_WARN([Could not find libjit, please provide the base install path])
283 dnl PSI_CHECK_LIBFFI()
284 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
285 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
286 dnl Checks for availability of recent closure API:
287 dnl \ffi_closure_alloc and \ffi_prep_closure.
288 dnl Checks for availability of recent vararg API:
289 dnl \ffi_prep_cif_var.
290 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
291 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
292 AC_DEFUN(PSI_CHECK_LIBFFI, [
293 AC_REQUIRE([PSI_PKG_CONFIG])dnl
295 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
296 if $PKG_CONFIG --exists libffi
305 AC_MSG_CHECKING(for libffi)
306 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
307 AC_MSG_RESULT($psi_cv_libffi_dir)
308 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
309 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
310 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
312 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
313 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
315 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
321 if test -n "$psi_cv_libffi_dir"
323 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
324 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
325 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
327 AC_MSG_WARN([Could not find libffi, please provide the base install path])
330 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
331 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
332 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
333 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
334 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
336 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
337 AC_CHECK_HEADERS(sys/mman.h)
339 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
341 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
342 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
343 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
344 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
346 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)