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
12 PSI_FN_DECLS=$PHP_PSI_SRCDIR/php_psi_fn_decls.h
15 dnl Creates stubs of the headers with pre-defined types etc.
16 dnl These headers are included by src/context.c.
17 dnl This macro must be called prior any checks for a type, struct, decl etc.
18 AC_DEFUN(PSI_CONFIG_INIT, [
19 for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_MACROS $PSI_DECLS $PSI_VA_DECLS $PSI_FN_DECLS; do
21 /* generated by configure */
22 #include "php_psi_stdinc.h"
25 cat >>$PSI_STDTYPES <<EOF
26 static struct psi_std_type {
28 const char *type_name;
30 } psi_std_types@<:@@:>@ = {
31 {PSI_T_INT8, "int8_t", NULL},
32 {PSI_T_INT16, "int16_t", NULL},
33 {PSI_T_INT32, "int32_t", NULL},
34 {PSI_T_INT64, "int64_t", NULL},
35 {PSI_T_UINT8, "uint8_t", NULL},
36 {PSI_T_UINT16, "uint16_t", NULL},
37 {PSI_T_UINT32, "uint32_t", NULL},
38 {PSI_T_UINT64, "uint64_t", NULL},
40 cat >>$PSI_TYPES <<EOF
41 static struct psi_predef_type {
43 const char *type_name;
45 } psi_predef_types@<:@@:>@ = {
47 cat >>$PSI_STRUCTS <<EOF
48 static struct psi_predef_struct {
50 const char *type_name;
56 } psi_predef_structs@<:@@:>@ = {
58 cat >>$PSI_UNIONS <<EOF
59 static struct psi_predef_union {
61 const char *type_name;
67 } psi_predef_unions@<:@@:>@ = {
69 cat >>$PSI_CONSTS <<EOF
70 static struct psi_predef_const {
72 const char *type_name;
76 } psi_predef_consts@<:@@:>@ = {
78 cat >>$PSI_REDIRS <<EOF
79 typedef void (*psi_func_ptr)();
80 static struct psi_func_redir {
83 } psi_func_redirs@<:@@:>@ = {
85 cat >>$PSI_MACROS <<EOF
87 cat >>$PSI_DECLS <<EOF
88 static struct psi_predef_decl {
90 const char *type_name;
94 } psi_predef_decls@<:@@:>@ = {
96 cat >>$PSI_VA_DECLS <<EOF
97 static struct psi_predef_decl psi_predef_vararg_decls@<:@@:>@ = {
99 cat >>$PSI_FN_DECLS <<EOF
100 static struct psi_predef_decl psi_predef_functor_decls@<:@@:>@ = {
104 dnl PSI_CONFIG_DONE()
105 dnl Finish the headers with the pre-defined types etc.
106 AC_DEFUN(PSI_CONFIG_DONE, [
107 cat >$PSI_STDINC <<EOF
108 /* generated by configure */
115 # include "php_config.h"
128 for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS $PSI_FN_DECLS; do
136 dnl PSI_SH_CONFIG_POSIX_ENABLED(section)
137 dnl Expand to $psi_config_posix_<section>
138 AC_DEFUN(PSI_SH_CONFIG_POSIX_ENABLED, [$AS_TR_SH([psi_config_posix_]$1)])
140 dnl PSI_CONFIG_POSIX_ENABLED(section, action-if-yes, action-if-not)
141 dnl Internal. Used to check if --enable-psi-posix=section was given.
142 AC_DEFUN(PSI_CONFIG_POSIX_ENABLED, [
143 AS_TR_SH([psi_config_posix_]$1)=false
144 case "$PHP_PSI_POSIX" in
146 AS_TR_SH([psi_config_posix_]$1)=true
149 if expr "$PHP_PSI_POSIX" : '\b$1\b' >/dev/null; then
150 AS_TR_SH([psi_config_posix_]$1)=true
154 if $AS_TR_SH([psi_config_posix_]$1); then
161 dnl PSI_TEST_POSIX_ENABLED(section, action-if-yes, action-if-not)
162 dnl Shell-if test if PSI POSIX section was configured.
163 AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [
164 if test "PSI_SH_CONFIG_POSIX_ENABLED([$1])" && $PSI_SH_CONFIG_POSIX_ENABLED([$1]); then
171 dnl PSI_CONFIG_POSIX(section, headers)
172 AC_DEFUN(PSI_CONFIG_POSIX, [
173 PSI_CONFIG_POSIX_ENABLED($1, [
174 PHP_CONFIGURE_PART(Configuring PSI POSIX: $1)
175 ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
181 AC_DEFUN(PSI_PTHREAD_ONCE, [
183 LIBS="$PTHREAD_LIBS $LIBS"
184 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
187 AC_DEFUN(PSI_PTHREAD, [
188 AC_REQUIRE([PSI_PTHREAD_ONCE])
192 dnl Expands to a complete list of include statements including
193 dnl AC_INCLUDES_DEFAULT().
194 AC_DEFUN(PSI_INCLUDES, [#define PSI_INCLUDES
201 AC_INCLUDES_DEFAULT()
202 #ifdef HAVE_STDBOOL_H
203 # include <stdbool.h>
209 # define _Bool signed char
215 # define __bool_true_false_are_defined 1
226 #ifdef HAVE_XLOCALE_H
227 # include <xlocale.h>
229 #ifdef HAVE_NETINET_IN_H
230 # include <netinet/in.h>
232 #ifdef HAVE_NETINET_TCP_H
233 # include <netinet/tcp.h>
235 #ifdef HAVE_ARPA_NAMESER_H
236 # include <arpa/nameser.h>
245 #elif HAVE_GDBM_NDBM_H
246 # include <gdbm-ndbm.h>
257 #ifdef HAVE_SYS_SELECT_H
258 # include <sys/select.h>
260 #ifdef HAVE_SYS_SOCKET_H
261 # include <sys/socket.h>
263 #ifdef HAVE_SYS_TIME_H
264 # include <sys/time.h>
266 #ifdef HAVE_SYS_TIMES_H
267 # include <sys/times.h>
269 #ifdef HAVE_SYS_UIO_H
270 # include <sys/uio.h>
272 #ifdef HAVE_SYS_UTSNAME_H
273 # include <sys/utsname.h>
293 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
294 AC_DEFUN(PSI_LEMON, [
295 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
296 AC_PATH_PROG(LEMON, lemon, ./lemon)
301 dnl Check for `pkg-config` and add possible libjit and libffi directories to
302 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
303 dnl arch-dependent locations.
304 AC_DEFUN([PSI_PKG_CONFIG], [
305 if test -z "$PKG_CONFIG"
307 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
309 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
312 dnl PSI_SH_SIZEOF(type)
313 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
314 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
316 dnl PSI_SH_OFFSETOF(type)
317 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
318 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
320 dnl PSI_SH_ALIGNOF(type)
321 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
322 AC_DEFUN([PSI_SH_ALIGNOF], [$AS_TR_SH([ac_cv_alignof_]$1)])
324 dnl PSI_SH_TEST_SIZEOF(type)
325 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
326 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])
328 dnl PSI_SH_TEST_ALIGNOF(type)
329 dnl `if` condition to test if $ac_cv_alignof_$1 is greater than 0.
330 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])
332 dnl PSI_CHECK_SIZEOF(type, special-includes)
333 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
334 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS.
335 AC_DEFUN(PSI_CHECK_SIZEOF, [
336 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
338 if PSI_SH_TEST_SIZEOF($1); then
339 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
343 dnl PSI_CHECK_ALIGNOF(type, special-includes)
344 dnl AC_CHECK_ALIGNOF wrapper with PSI_INCLUDES
345 dnl Defines psi\\ALIGNOF_<TYPE> pre-defined constant in $PSI_CONSTS.
346 AC_DEFUN(PSI_CHECK_ALIGNOF, [
347 AC_CHECK_ALIGNOF($1, PSI_INCLUDES
349 if PSI_SH_TEST_ALIGNOF($1); then
350 psi_add_int_const "AS_TR_CPP([ALIGNOF_]$1)" "$AS_TR_SH([ac_cv_alignof_]$1)"
354 dnl PSI_CHECK_OFFSETOF(struct, element)
355 dnl Check the offset of a struct element, implemented in the similar manner
356 dnl like AC_CHECK_SIZEOF.
357 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
358 AC_DEFUN(PSI_CHECK_OFFSETOF, [
360 [offset of $2 in $1],
361 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
362 [(long int) (offsetof ($1, $2))],
364 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
367 AS_TR_CPP(offsetof_$1_$2),
368 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
369 [The offset of `$2' in `$1', as computed by offsetof.]
374 dnl PSI_COMPUTE_STR(variable, string or expression)
375 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
376 AC_DEFUN(PSI_COMPUTE_STR, [
380 return EOF == fputs($2, fopen("conftest.out", "w"));
383 eval $1=\\\"`cat conftest.out`\\\"
387 dnl PSI_CHECK_LIBJIT()
388 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
389 dnl AC_DEFINEs HAVE_LIBJIT.
390 AC_DEFUN(PSI_CHECK_LIBJIT, [
391 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
392 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
394 if test -e $psi_cv_libjit_dir/include/jit/jit.h
401 if test -n "$psi_cv_libjit_dir"
403 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
404 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
405 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
407 AC_MSG_WARN([Could not find libjit, please provide the base install path])
411 dnl PSI_CHECK_LIBFFI()
412 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
413 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
414 dnl Checks for availability of recent closure API:
415 dnl \ffi_closure_alloc and \ffi_prep_closure.
416 dnl Checks for availability of recent vararg API:
417 dnl \ffi_prep_cif_var.
418 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
419 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
420 AC_DEFUN(PSI_CHECK_LIBFFI, [
421 AC_REQUIRE([PSI_PKG_CONFIG])dnl
423 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
424 if $PKG_CONFIG --exists libffi
433 AC_MSG_CHECKING(for libffi)
434 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
435 AC_MSG_RESULT($psi_cv_libffi_dir)
436 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
437 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
438 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
439 AC_DEFINE_UNQUOTED([PHP_PSI_LIBFFI_VERSION], ["`$PKG_CONFIG --modversion libffi`"], [libffi version])
441 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
442 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
444 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
450 if test -n "$psi_cv_libffi_dir"
452 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
453 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
454 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
456 AC_MSG_WARN([Could not find libffi, please provide the base install path])
459 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
460 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
461 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
462 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
463 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
465 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
466 AC_CHECK_HEADERS(sys/mman.h)
468 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
470 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
471 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
472 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
473 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
475 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)