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_UNIONS=$PHP_PSI_SRCDIR/php_psi_unions.h
7 PSI_CONSTS=$PHP_PSI_SRCDIR/php_psi_consts.h
8 PSI_REDIRS=$PHP_PSI_SRCDIR/php_psi_redirs.h
9 PSI_MACROS=$PHP_PSI_SRCDIR/php_psi_macros.h
10 PSI_DECLS=$PHP_PSI_SRCDIR/php_psi_decls.h
11 PSI_VA_DECLS=$PHP_PSI_SRCDIR/php_psi_va_decls.h
14 dnl Creates stubs of the headers with pre-defined types etc.
15 dnl These headers are included by src/context.c.
16 dnl This macro must be called prior any checks for a type, struct, decl etc.
17 AC_DEFUN(PSI_CONFIG_INIT, [
18 for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_MACROS $PSI_DECLS $PSI_VA_DECLS; do
20 /* generated by configure */
21 #include "php_psi_stdinc.h"
24 cat >>$PSI_STDTYPES <<EOF
25 static struct psi_std_type {
27 const char *type_name;
29 } psi_std_types@<:@@:>@ = {
30 {PSI_T_INT8, "int8_t", NULL},
31 {PSI_T_INT16, "int16_t", NULL},
32 {PSI_T_INT32, "int32_t", NULL},
33 {PSI_T_INT64, "int64_t", NULL},
34 {PSI_T_UINT8, "uint8_t", NULL},
35 {PSI_T_UINT16, "uint16_t", NULL},
36 {PSI_T_UINT32, "uint32_t", NULL},
37 {PSI_T_UINT64, "uint64_t", NULL},
39 cat >>$PSI_TYPES <<EOF
40 static struct psi_predef_type {
42 const char *type_name;
44 } psi_predef_types@<:@@:>@ = {
46 cat >>$PSI_STRUCTS <<EOF
47 static struct psi_predef_struct {
49 const char *type_name;
55 } psi_predef_structs@<:@@:>@ = {
57 cat >>$PSI_UNIONS <<EOF
58 static struct psi_predef_union {
60 const char *type_name;
66 } psi_predef_unions@<:@@:>@ = {
68 cat >>$PSI_CONSTS <<EOF
69 static struct psi_predef_const {
71 const char *type_name;
75 } psi_predef_consts@<:@@:>@ = {
77 cat >>$PSI_REDIRS <<EOF
78 typedef void (*psi_func_ptr)();
79 static struct psi_func_redir {
82 } psi_func_redirs@<:@@:>@ = {
84 cat >>$PSI_MACROS <<EOF
86 cat >>$PSI_DECLS <<EOF
87 static struct psi_predef_decl {
89 const char *type_name;
93 } psi_predef_decls@<:@@:>@ = {
95 cat >>$PSI_VA_DECLS <<EOF
96 static struct psi_predef_decl psi_predef_vararg_decls@<:@@:>@ = {
100 dnl PSI_CONFIG_DONE()
101 dnl Finish the headers with the pre-defined types etc.
102 AC_DEFUN(PSI_CONFIG_DONE, [
103 cat >$PSI_STDINC <<EOF
104 /* generated by configure */
110 #ifndef _XOPEN_SOURCE
111 #define _XOPEN_SOURCE
116 for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS; do
124 dnl PSI_SH_CONFIG_POSIX_ENABLED(section)
125 dnl Expand to $psi_config_posix_<section>
126 AC_DEFUN(PSI_SH_CONFIG_POSIX_ENABLED, [$AS_TR_SH([psi_config_posix_]$1)])
128 dnl PSI_CONFIG_POSIX_ENABLED(section, action-if-yes, action-if-not)
129 dnl Internal. Used to check if --enable-psi-posix=section was given.
130 AC_DEFUN(PSI_CONFIG_POSIX_ENABLED, [
131 AS_TR_SH([psi_config_posix_]$1)=false
132 case "$PHP_PSI_POSIX" in
134 AS_TR_SH([psi_config_posix_]$1)=true
137 if expr "$PHP_PSI_POSIX" : '\b$1\b' >/dev/null; then
138 AS_TR_SH([psi_config_posix_]$1)=true
142 if $AS_TR_SH([psi_config_posix_]$1); then
149 dnl PSI_TEST_POSIX_ENABLED(section, action-if-yes, action-if-not)
150 dnl Shell-if test if PSI POSIX section was configured.
151 AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [
152 if test "PSI_SH_CONFIG_POSIX_ENABLED([$1])" && $PSI_SH_CONFIG_POSIX_ENABLED([$1]); then
159 dnl PSI_CONFIG_POSIX(section, headers)
160 AC_DEFUN(PSI_CONFIG_POSIX, [
161 PSI_CONFIG_POSIX_ENABLED($1, [
162 PHP_CONFIGURE_PART(Configuring PSI POSIX: $1)
163 ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
169 AC_DEFUN(PSI_PTHREAD_ONCE, [
171 LIBS="$PTHREAD_LIBS $LIBS"
172 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
175 AC_DEFUN(PSI_PTHREAD, [
176 AC_REQUIRE([PSI_PTHREAD_ONCE])
180 dnl Expands to a complete list of include statements including
181 dnl AC_INCLUDES_DEFAULT().
182 AC_DEFUN(PSI_INCLUDES, [AC_INCLUDES_DEFAULT()
192 #ifdef HAVE_XLOCALE_H
193 # include <xlocale.h>
195 #ifdef HAVE_NETINET_IN_H
196 # include <netinet/in.h>
198 #ifdef HAVE_NETINET_TCP_H
199 # include <netinet/tcp.h>
201 #ifdef HAVE_ARPA_NAMESER_H
202 # include <arpa/nameser.h>
219 #ifdef HAVE_SYS_SELECT_H
220 # include <sys/select.h>
222 #ifdef HAVE_SYS_SOCKET_H
223 # include <sys/socket.h>
225 #ifdef HAVE_SYS_TIME_H
226 # include <sys/time.h>
228 #ifdef HAVE_SYS_TIMES_H
229 # include <sys/times.h>
231 #ifdef HAVE_SYS_UIO_H
232 # include <sys/uio.h>
234 #ifdef HAVE_SYS_UTSNAME_H
235 # include <sys/utsname.h>
255 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
256 AC_DEFUN(PSI_LEMON, [
257 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
258 AC_PATH_PROG(LEMON, lemon, ./lemon)
263 dnl Check for `pkg-config` and add possible libjit and libffi directories to
264 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
265 dnl arch-dependent locations.
266 AC_DEFUN([PSI_PKG_CONFIG], [
267 if test -z "$PKG_CONFIG"
269 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
271 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
274 dnl PSI_SH_SIZEOF(type)
275 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
276 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
278 dnl PSI_SH_OFFSETOF(type)
279 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
280 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
282 dnl PSI_SH_ALIGNOF(type)
283 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
284 AC_DEFUN([PSI_SH_ALIGNOF], [$AS_TR_SH([ac_cv_alignof_]$1)])
286 dnl PSI_SH_TEST_SIZEOF(type)
287 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
288 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])
290 dnl PSI_SH_TEST_ALIGNOF(type)
291 dnl `if` condition to test if $ac_cv_alignof_$1 is greater than 0.
292 AC_DEFUN([PSI_SH_TEST_ALIGNOF], [test -n "$AS_TR_SH([ac_cv_alignof_]$1)" && test "$AS_TR_SH([ac_cv_alignof_]$1)" -gt 0])
294 dnl PSI_CHECK_SIZEOF(type, special-includes)
295 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
296 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS.
297 AC_DEFUN(PSI_CHECK_SIZEOF, [
298 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
300 if PSI_SH_TEST_SIZEOF($1); then
301 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
305 dnl PSI_CHECK_ALIGNOF(type, special-includes)
306 dnl AC_CHECK_ALIGNOF wrapper with PSI_INCLUDES
307 dnl Defines psi\\ALIGNOF_<TYPE> pre-defined constant in $PSI_CONSTS.
308 AC_DEFUN(PSI_CHECK_ALIGNOF, [
309 AC_CHECK_ALIGNOF($1, PSI_INCLUDES
311 if PSI_SH_TEST_ALIGNOF($1); then
312 psi_add_int_const "AS_TR_CPP([ALIGNOF_]$1)" "$AS_TR_SH([ac_cv_alignof_]$1)"
316 dnl PSI_CHECK_OFFSETOF(struct, element)
317 dnl Check the offset of a struct element, implemented in the similar manner
318 dnl like AC_CHECK_SIZEOF.
319 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
320 AC_DEFUN(PSI_CHECK_OFFSETOF, [
322 [offset of $2 in $1],
323 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
324 [(long int) (offsetof ($1, $2))],
326 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
329 AS_TR_CPP(offsetof_$1_$2),
330 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
331 [The offset of `$2' in `$1', as computed by offsetof.]
336 dnl PSI_COMPUTE_STR(variable, string or expression)
337 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
338 AC_DEFUN(PSI_COMPUTE_STR, [
342 return EOF == fputs($2, fopen("conftest.out", "w"));
345 eval $1=\\\"`cat conftest.out`\\\"
349 dnl PSI_CHECK_LIBJIT()
350 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
351 dnl AC_DEFINEs HAVE_LIBJIT.
352 AC_DEFUN(PSI_CHECK_LIBJIT, [
353 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
354 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
356 if test -e $psi_cv_libjit_dir/include/jit/jit.h
363 if test -n "$psi_cv_libjit_dir"
365 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
366 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
367 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
369 AC_MSG_WARN([Could not find libjit, please provide the base install path])
373 dnl PSI_CHECK_LIBFFI()
374 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
375 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
376 dnl Checks for availability of recent closure API:
377 dnl \ffi_closure_alloc and \ffi_prep_closure.
378 dnl Checks for availability of recent vararg API:
379 dnl \ffi_prep_cif_var.
380 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
381 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
382 AC_DEFUN(PSI_CHECK_LIBFFI, [
383 AC_REQUIRE([PSI_PKG_CONFIG])dnl
385 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
386 if $PKG_CONFIG --exists libffi
395 AC_MSG_CHECKING(for libffi)
396 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
397 AC_MSG_RESULT($psi_cv_libffi_dir)
398 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
399 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
400 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
402 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
403 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
405 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
411 if test -n "$psi_cv_libffi_dir"
413 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
414 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
415 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
417 AC_MSG_WARN([Could not find libffi, please provide the base install path])
420 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
421 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
422 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
423 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
424 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
426 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
427 AC_CHECK_HEADERS(sys/mman.h)
429 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
431 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
432 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
433 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
434 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
436 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)