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 static struct psi_func_redir {
81 } psi_func_redirs@<:@@:>@ = {
83 cat >$PSI_MACROS </dev/null
85 /* generated by configure */
86 static struct psi_predef_decl {
88 const char *type_name;
92 } psi_predef_decls@<:@@:>@ = {
94 cat >$PSI_VA_DECLS <<EOF
95 /* generated by configure */
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 */
107 for i in $PSI_STDTYPES $PSI_TYPES $PSI_STRUCTS $PSI_UNIONS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS; do
115 dnl PSI_SH_CONFIG_POSIX_ENABLED(section)
116 dnl Expand to $psi_config_posix_<section>
117 AC_DEFUN(PSI_SH_CONFIG_POSIX_ENABLED, [$AS_TR_SH([psi_config_posix_]$1)])
119 dnl PSI_CONFIG_POSIX_ENABLED(section, action-if-yes, action-if-not)
120 dnl Internal. Used to check if --enable-psi-posix=section was given.
121 AC_DEFUN(PSI_CONFIG_POSIX_ENABLED, [
122 AS_TR_SH([psi_config_posix_]$1)=false
123 case "$PHP_PSI_POSIX" in
125 AS_TR_SH([psi_config_posix_]$1)=true
128 if expr "$PHP_PSI_POSIX" : '\b$1\b' >/dev/null; then
129 AS_TR_SH([psi_config_posix_]$1)=true
133 if $AS_TR_SH([psi_config_posix_]$1); then
140 dnl PSI_TEST_POSIX_ENABLED(section, action-if-yes, action-if-not)
141 dnl Shell-if test if PSI POSIX section was configured.
142 AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [
143 if test "PSI_SH_CONFIG_POSIX_ENABLED([$1])" && $PSI_SH_CONFIG_POSIX_ENABLED([$1]); then
150 dnl PSI_CONFIG_POSIX(section, headers)
151 AC_DEFUN(PSI_CONFIG_POSIX, [
152 PSI_CONFIG_POSIX_ENABLED($1, [
153 PHP_CONFIGURE_PART(Configuring PSI POSIX: $1)
154 ifelse([$2],,,AC_CHECK_HEADERS($2))
160 AC_DEFUN(PSI_PTHREAD_ONCE, [
162 LIBS="$PTHREAD_LIBS $LIBS"
163 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
166 AC_DEFUN(PSI_PTHREAD, [
167 AC_REQUIRE([PSI_PTHREAD_ONCE])
171 dnl Expands to a complete list of include statements including
172 dnl AC_INCLUDES_DEFAULT().
173 AC_DEFUN(PSI_INCLUDES, [AC_INCLUDES_DEFAULT()
183 #ifdef HAVE_XLOCALE_H
184 # include <xlocale.h>
186 #ifdef HAVE_NETINET_IN_H
187 # include <netinet/in.h>
189 #ifdef HAVE_NETINET_TCP_H
190 # include <netinet/tcp.h>
192 #ifdef HAVE_ARPA_NAMESER_H
193 # include <arpa/nameser.h>
210 #ifdef HAVE_SYS_SELECT_H
211 # include <sys/select.h>
213 #ifdef HAVE_SYS_SOCKET_H
214 # include <sys/socket.h>
216 #ifdef HAVE_SYS_TIME_H
217 # include <sys/time.h>
219 #ifdef HAVE_SYS_TIMES_H
220 # include <sys/times.h>
222 #ifdef HAVE_SYS_UIO_H
223 # include <sys/uio.h>
225 #ifdef HAVE_SYS_UTSNAME_H
226 # include <sys/utsname.h>
246 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
247 AC_DEFUN(PSI_LEMON, [
248 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
249 AC_PATH_PROG(LEMON, lemon, ./lemon)
254 dnl Check for `pkg-config` and add possible libjit and libffi directories to
255 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
256 dnl arch-dependent locations.
257 AC_DEFUN([PSI_PKG_CONFIG], [
258 if test -z "$PKG_CONFIG"
260 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
262 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
265 dnl PSI_SH_SIZEOF(type)
266 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
267 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
269 dnl PSI_SH_OFFSETOF(type)
270 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
271 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
273 dnl PSI_SH_ALIGNOF(type)
274 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
275 AC_DEFUN([PSI_SH_ALIGNOF], [$AS_TR_SH([ac_cv_alignof_]$1)])
277 dnl PSI_SH_TEST_SIZEOF(type)
278 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
279 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])
281 dnl PSI_SH_TEST_ALIGNOF(type)
282 dnl `if` condition to test if $ac_cv_alignof_$1 is greater than 0.
283 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])
285 dnl PSI_CHECK_SIZEOF(type, special-includes)
286 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
287 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS.
288 AC_DEFUN(PSI_CHECK_SIZEOF, [
289 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
291 if PSI_SH_TEST_SIZEOF($1); then
292 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
296 dnl PSI_CHECK_ALIGNOF(type, special-includes)
297 dnl AC_CHECK_ALIGNOF wrapper with PSI_INCLUDES
298 dnl Defines psi\\ALIGNOF_<TYPE> pre-defined constant in $PSI_CONSTS.
299 AC_DEFUN(PSI_CHECK_ALIGNOF, [
300 AC_CHECK_ALIGNOF($1, PSI_INCLUDES
302 if PSI_SH_TEST_ALIGNOF($1); then
303 psi_add_int_const "AS_TR_CPP([ALIGNOF_]$1)" "$AS_TR_SH([ac_cv_alignof_]$1)"
307 dnl PSI_CHECK_OFFSETOF(struct, element)
308 dnl Check the offset of a struct element, implemented in the similar manner
309 dnl like AC_CHECK_SIZEOF.
310 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
311 AC_DEFUN(PSI_CHECK_OFFSETOF, [
313 [offset of $2 in $1],
314 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
315 [(long int) (offsetof ($1, $2))],
317 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
320 AS_TR_CPP(offsetof_$1_$2),
321 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
322 [The offset of `$2' in `$1', as computed by offsetof.]
327 dnl PSI_COMPUTE_STR(variable, string or expression)
328 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
329 AC_DEFUN(PSI_COMPUTE_STR, [
333 return EOF == fputs($2, fopen("conftest.out", "w"));
336 eval $1=\\\"`cat conftest.out`\\\"
340 dnl PSI_CHECK_LIBJIT()
341 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
342 dnl AC_DEFINEs HAVE_LIBJIT.
343 AC_DEFUN(PSI_CHECK_LIBJIT, [
344 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
345 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
347 if test -e $psi_cv_libjit_dir/include/jit/jit.h
354 if test -n "$psi_cv_libjit_dir"
356 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
357 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
358 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
360 AC_MSG_WARN([Could not find libjit, please provide the base install path])
364 dnl PSI_CHECK_LIBFFI()
365 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
366 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
367 dnl Checks for availability of recent closure API:
368 dnl \ffi_closure_alloc and \ffi_prep_closure.
369 dnl Checks for availability of recent vararg API:
370 dnl \ffi_prep_cif_var.
371 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
372 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
373 AC_DEFUN(PSI_CHECK_LIBFFI, [
374 AC_REQUIRE([PSI_PKG_CONFIG])dnl
376 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
377 if $PKG_CONFIG --exists libffi
386 AC_MSG_CHECKING(for libffi)
387 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
388 AC_MSG_RESULT($psi_cv_libffi_dir)
389 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
390 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
391 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
393 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
394 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
396 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
402 if test -n "$psi_cv_libffi_dir"
404 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
405 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
406 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
408 AC_MSG_WARN([Could not find libffi, please provide the base install path])
411 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
412 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
413 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
414 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
415 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
417 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
418 AC_CHECK_HEADERS(sys/mman.h)
420 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
422 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
423 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
424 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
425 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
427 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)