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 cat >$PSI_STDTYPES <<EOF
19 /* generated by configure */
20 static struct psi_std_type {
22 const char *type_name;
24 } psi_std_types@<:@@:>@ = {
25 {PSI_T_INT8, "int8_t", NULL},
26 {PSI_T_INT16, "int16_t", NULL},
27 {PSI_T_INT32, "int32_t", NULL},
28 {PSI_T_INT64, "int64_t", NULL},
29 {PSI_T_UINT8, "uint8_t", NULL},
30 {PSI_T_UINT16, "uint16_t", NULL},
31 {PSI_T_UINT32, "uint32_t", NULL},
32 {PSI_T_UINT64, "uint64_t", NULL},
35 /* generated by configure */
36 static struct psi_predef_type {
38 const char *type_name;
40 } psi_predef_types@<:@@:>@ = {
42 cat >$PSI_STRUCTS <<EOF
43 /* generated by configure */
44 static struct psi_predef_struct {
46 const char *type_name;
52 } psi_predef_structs@<:@@:>@ = {
54 cat >$PSI_UNIONS <<EOF
55 /* generated by configure */
56 static struct psi_predef_union {
58 const char *type_name;
64 } psi_predef_unions@<:@@:>@ = {
66 cat >$PSI_CONSTS <<EOF
67 /* generated by configure */
68 static struct psi_predef_const {
70 const char *type_name;
74 } psi_predef_consts@<:@@:>@ = {
76 cat >$PSI_REDIRS <<EOF
77 /* generated by configure */
78 typedef void (*psi_func_ptr)();
79 static struct psi_func_redir {
82 } psi_func_redirs@<:@@:>@ = {
84 cat >$PSI_MACROS </dev/null
86 /* generated by configure */
87 static struct psi_predef_decl {
89 const char *type_name;
93 } psi_predef_decls@<:@@:>@ = {
95 cat >$PSI_VA_DECLS <<EOF
96 /* generated by configure */
97 static struct psi_predef_decl psi_predef_vararg_decls@<:@@:>@ = {
101 dnl PSI_CONFIG_DONE()
102 dnl Finish the headers with the pre-defined types etc.
103 AC_DEFUN(PSI_CONFIG_DONE, [
104 cat >$PSI_STDINC <<EOF
105 /* generated by configure */
108 for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS; do
116 dnl PSI_SH_CONFIG_POSIX_ENABLED(section)
117 dnl Expand to $psi_config_posix_<section>
118 AC_DEFUN(PSI_SH_CONFIG_POSIX_ENABLED, [$AS_TR_SH([psi_config_posix_]$1)])
120 dnl PSI_CONFIG_POSIX_ENABLED(section, action-if-yes, action-if-not)
121 dnl Internal. Used to check if --enable-psi-posix=section was given.
122 AC_DEFUN(PSI_CONFIG_POSIX_ENABLED, [
123 AS_TR_SH([psi_config_posix_]$1)=false
124 case "$PHP_PSI_POSIX" in
126 AS_TR_SH([psi_config_posix_]$1)=true
129 if expr "$PHP_PSI_POSIX" : '\b$1\b' >/dev/null; then
130 AS_TR_SH([psi_config_posix_]$1)=true
134 if $AS_TR_SH([psi_config_posix_]$1); then
141 dnl PSI_TEST_POSIX_ENABLED(section, action-if-yes, action-if-not)
142 dnl Shell-if test if PSI POSIX section was configured.
143 AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [
144 if test "PSI_SH_CONFIG_POSIX_ENABLED([$1])" && $PSI_SH_CONFIG_POSIX_ENABLED([$1]); then
151 dnl PSI_CONFIG_POSIX(section, headers)
152 AC_DEFUN(PSI_CONFIG_POSIX, [
153 PSI_CONFIG_POSIX_ENABLED($1, [
154 PHP_CONFIGURE_PART(Configuring PSI POSIX: $1)
155 ifelse([$2],,,AC_CHECK_HEADERS($2))
161 AC_DEFUN(PSI_PTHREAD_ONCE, [
163 LIBS="$PTHREAD_LIBS $LIBS"
164 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
167 AC_DEFUN(PSI_PTHREAD, [
168 AC_REQUIRE([PSI_PTHREAD_ONCE])
172 dnl Expands to a complete list of include statements including
173 dnl AC_INCLUDES_DEFAULT().
174 AC_DEFUN(PSI_INCLUDES, [AC_INCLUDES_DEFAULT()
184 #ifdef HAVE_XLOCALE_H
185 # include <xlocale.h>
187 #ifdef HAVE_NETINET_IN_H
188 # include <netinet/in.h>
190 #ifdef HAVE_NETINET_TCP_H
191 # include <netinet/tcp.h>
193 #ifdef HAVE_ARPA_NAMESER_H
194 # include <arpa/nameser.h>
211 #ifdef HAVE_SYS_SELECT_H
212 # include <sys/select.h>
214 #ifdef HAVE_SYS_SOCKET_H
215 # include <sys/socket.h>
217 #ifdef HAVE_SYS_TIME_H
218 # include <sys/time.h>
220 #ifdef HAVE_SYS_TIMES_H
221 # include <sys/times.h>
223 #ifdef HAVE_SYS_UIO_H
224 # include <sys/uio.h>
226 #ifdef HAVE_SYS_UTSNAME_H
227 # include <sys/utsname.h>
247 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
248 AC_DEFUN(PSI_LEMON, [
249 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
250 AC_PATH_PROG(LEMON, lemon, ./lemon)
255 dnl Check for `pkg-config` and add possible libjit and libffi directories to
256 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
257 dnl arch-dependent locations.
258 AC_DEFUN([PSI_PKG_CONFIG], [
259 if test -z "$PKG_CONFIG"
261 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
263 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
266 dnl PSI_SH_SIZEOF(type)
267 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
268 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
270 dnl PSI_SH_OFFSETOF(type)
271 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
272 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
274 dnl PSI_SH_ALIGNOF(type)
275 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
276 AC_DEFUN([PSI_SH_ALIGNOF], [$AS_TR_SH([ac_cv_alignof_]$1)])
278 dnl PSI_SH_TEST_SIZEOF(type)
279 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
280 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])
282 dnl PSI_SH_TEST_ALIGNOF(type)
283 dnl `if` condition to test if $ac_cv_alignof_$1 is greater than 0.
284 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])
286 dnl PSI_CHECK_SIZEOF(type, special-includes)
287 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
288 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS.
289 AC_DEFUN(PSI_CHECK_SIZEOF, [
290 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
292 if PSI_SH_TEST_SIZEOF($1); then
293 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
297 dnl PSI_CHECK_ALIGNOF(type, special-includes)
298 dnl AC_CHECK_ALIGNOF wrapper with PSI_INCLUDES
299 dnl Defines psi\\ALIGNOF_<TYPE> pre-defined constant in $PSI_CONSTS.
300 AC_DEFUN(PSI_CHECK_ALIGNOF, [
301 AC_CHECK_ALIGNOF($1, PSI_INCLUDES
303 if PSI_SH_TEST_ALIGNOF($1); then
304 psi_add_int_const "AS_TR_CPP([ALIGNOF_]$1)" "$AS_TR_SH([ac_cv_alignof_]$1)"
308 dnl PSI_CHECK_OFFSETOF(struct, element)
309 dnl Check the offset of a struct element, implemented in the similar manner
310 dnl like AC_CHECK_SIZEOF.
311 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
312 AC_DEFUN(PSI_CHECK_OFFSETOF, [
314 [offset of $2 in $1],
315 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
316 [(long int) (offsetof ($1, $2))],
318 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
321 AS_TR_CPP(offsetof_$1_$2),
322 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
323 [The offset of `$2' in `$1', as computed by offsetof.]
328 dnl PSI_COMPUTE_STR(variable, string or expression)
329 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
330 AC_DEFUN(PSI_COMPUTE_STR, [
334 return EOF == fputs($2, fopen("conftest.out", "w"));
337 eval $1=\\\"`cat conftest.out`\\\"
341 dnl PSI_CHECK_LIBJIT()
342 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
343 dnl AC_DEFINEs HAVE_LIBJIT.
344 AC_DEFUN(PSI_CHECK_LIBJIT, [
345 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
346 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
348 if test -e $psi_cv_libjit_dir/include/jit/jit.h
355 if test -n "$psi_cv_libjit_dir"
357 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
358 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
359 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
361 AC_MSG_WARN([Could not find libjit, please provide the base install path])
365 dnl PSI_CHECK_LIBFFI()
366 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
367 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
368 dnl Checks for availability of recent closure API:
369 dnl \ffi_closure_alloc and \ffi_prep_closure.
370 dnl Checks for availability of recent vararg API:
371 dnl \ffi_prep_cif_var.
372 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
373 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
374 AC_DEFUN(PSI_CHECK_LIBFFI, [
375 AC_REQUIRE([PSI_PKG_CONFIG])dnl
377 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
378 if $PKG_CONFIG --exists libffi
387 AC_MSG_CHECKING(for libffi)
388 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
389 AC_MSG_RESULT($psi_cv_libffi_dir)
390 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
391 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
392 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
394 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
395 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
397 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
403 if test -n "$psi_cv_libffi_dir"
405 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
406 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
407 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
409 AC_MSG_WARN([Could not find libffi, please provide the base install path])
412 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
413 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
414 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
415 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
416 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
418 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
419 AC_CHECK_HEADERS(sys/mman.h)
421 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
423 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
424 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
425 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
426 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
428 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)