3 dnl Creates stubs of the headers with pre-defined types etc.
4 dnl These headers are included by src/context.c.
5 dnl This macro must be called prior any checks for a type, struct, decl etc.
6 AC_DEFUN(PSI_CONFIG_INIT, [
10 if test "$PHP_PSI_MAINTAINER_MODE" = "yes"; then
17 PSI_CONFIG_TMP=$(mktemp -d)
22 if test "$PHP_DEBUG" = "1"; then
25 PSI_EXTRA_REDIRS=false
38 [$PHP_PSI_BUILDDIR/php_psi_stdinc.h:$PHP_PSI_SRCDIR/php_psi_stdinc.h.in]
39 [$PHP_PSI_BUILDDIR/php_psi_posix.h:$PHP_PSI_SRCDIR/php_psi_posix.h.in]
45 dnl Internal: waits for sub configures in maintainer mode
46 AC_DEFUN(PSI_CONFIG_WAIT, [
48 if test $? -gt 0; then
49 cat $PSI_CONFIG_TMP/*/stderr.log >&2
55 dnl Finish the headers with the pre-defined types etc.
56 AC_DEFUN(PSI_CONFIG_DONE, [
59 if $PSI_FAST_CONFIG; then
60 for conf_env in $PSI_CONFIG_TMP/*/conf.env; do
67 PHP_EVAL_LIBLINE($psi_eval_LIBS, PSI_SHARED_LIBADD)
69 [PSI_INCLUDES]="PSI_INCLUDES"
70 AC_SUBST([PSI_INCLUDES])
71 AC_SUBST([PSI_STDTYPES])
73 AC_SUBST([PSI_COMPOSITES])
74 AC_SUBST([PSI_CONSTS])
75 AC_SUBST([PSI_REDIRS])
76 AC_SUBST([PSI_MACROS])
80 dnl PSI_SH_CONFIG_POSIX_ENABLED(section)
81 dnl Expand to $psi_config_posix_<section>
82 AC_DEFUN(PSI_SH_CONFIG_POSIX_ENABLED, [$AS_TR_SH([psi_config_posix_]$1)])
84 dnl PSI_CONFIG_POSIX_ENABLED(section, action-if-yes, action-if-not)
85 dnl Internal. Used to check if --enable-psi-posix=section was given.
86 AC_DEFUN(PSI_CONFIG_POSIX_ENABLED, [
87 AS_TR_SH([psi_config_posix_]$1)=false
88 case "$PHP_PSI_POSIX" in
90 AS_TR_SH([psi_config_posix_]$1)=true
93 if expr "$PHP_PSI_POSIX" : '.*\b$1\b' >/dev/null; then
94 AS_TR_SH([psi_config_posix_]$1)=true
98 if $AS_TR_SH([psi_config_posix_]$1); then
105 dnl PSI_TEST_POSIX_ENABLED(section, action-if-yes, action-if-not)
106 dnl Shell-if test if PSI POSIX section was configured.
107 AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [
108 if test "PSI_SH_CONFIG_POSIX_ENABLED([$1])" && $PSI_SH_CONFIG_POSIX_ENABLED([$1]); then
115 dnl PSI_CONFIG_POSIX(section, headers, dependents)
116 AC_DEFUN(PSI_CONFIG_POSIX, [
117 PSI_CONFIG_POSIX_ENABLED($1, [
118 if $PSI_FAST_CONFIG; then
119 PSI_CONFIG_POSIX_PARALLEL($1, $2, [$3])
121 ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
122 AS_TR_CPP([PSI_CHECK_$1])
128 AC_DEFUN([PSI_CONFIG_POSIX_PARALLEL], [
131 mkdir $PSI_CONFIG_TMP/AS_TR_SH([$1])
132 cd $PSI_CONFIG_TMP/AS_TR_SH([$1])
135 ln -s $abs_builddir/confdefs.h confdefs.h
138 exec {PSI_MESSAGE_FD}>&AS_MESSAGE_FD {PSI_ERROR_FD}>&2
139 exec AS_MESSAGE_FD>stdout.log 2>stderr.log
141 dnl check for headers?
142 ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
151 AS_TR_CPP([PSI_CHECK_$1])
157 for env in TYPES CONSTS COMPOSITES MACROS REDIRS DECLS; do
159 if test -n "$var"; then
167 _AC_CACHE_DUMP >>conf.env
168 dnl restore STDOUT,STDERR
169 exec >&$PSI_MESSAGE_FD 2>&$PSI_ERROR_FD
182 AC_DEFUN(PSI_PTHREAD_ONCE, [
184 LIBS="$PTHREAD_LIBS $LIBS"
185 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
188 AC_DEFUN(PSI_PTHREAD, [
189 AC_REQUIRE([PSI_PTHREAD_ONCE])
193 dnl Expands to a complete list of include statements including
194 dnl AC_INCLUDES_DEFAULT().
195 AC_DEFUN(PSI_INCLUDES, [dnl
203 AC_INCLUDES_DEFAULT()
204 #ifdef HAVE_STDBOOL_H
205 # include <stdbool.h>
211 # define _Bool signed char
217 # define __bool_true_false_are_defined 1
228 #ifdef HAVE_XLOCALE_H
229 # include <xlocale.h>
231 #ifdef HAVE_NETINET_IN_H
232 # include <netinet/in.h>
234 #ifdef HAVE_NETINET_TCP_H
235 # include <netinet/tcp.h>
237 #ifdef HAVE_ARPA_NAMESER_H
238 # include <arpa/nameser.h>
247 #elif HAVE_GDBM_NDBM_H
248 # include <gdbm-ndbm.h>
259 #ifdef HAVE_SYS_SELECT_H
260 # include <sys/select.h>
262 #ifdef HAVE_SYS_SOCKET_H
263 # include <sys/socket.h>
265 #ifdef HAVE_SYS_TIME_H
266 # include <sys/time.h>
268 #ifdef HAVE_SYS_TIMES_H
269 # include <sys/times.h>
271 #ifdef HAVE_SYS_UIO_H
272 # include <sys/uio.h>
274 #ifdef HAVE_SYS_UTSNAME_H
275 # include <sys/utsname.h>
295 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
296 AC_DEFUN(PSI_LEMON, [
297 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
300 AC_PATH_PROG(LEMON, lemon, $PHP_PSI_BUILDDIR/lemon)
301 if expr + "$LEMON" : "/" >/dev/null; then
304 LEMON_PATH=$abs_builddir/
307 PHP_SUBST(LEMON_PATH)
312 dnl Check for `pkg-config` and add possible libjit and libffi directories to
313 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
314 dnl arch-dependent locations.
315 AC_DEFUN([PSI_PKG_CONFIG], [
316 if test -z "$PKG_CONFIG"
318 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
320 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
323 dnl PSI_SH_SIZEOF(type)
324 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
325 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
327 dnl PSI_SH_OFFSETOF(type)
328 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
329 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
331 dnl PSI_SH_ALIGNOF(type)
332 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
333 AC_DEFUN([PSI_SH_ALIGNOF], [$AS_TR_SH([ac_cv_alignof_]$1)])
335 dnl PSI_SH_TEST_SIZEOF(type)
336 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
337 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])
339 dnl PSI_SH_TEST_ALIGNOF(type)
340 dnl `if` condition to test if $ac_cv_alignof_$1 is greater than 0.
341 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])
343 dnl PSI_CHECK_SIZEOF(type, special-includes)
344 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
345 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS_H.
346 AC_DEFUN(PSI_CHECK_SIZEOF, [
347 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
349 if PSI_SH_TEST_SIZEOF($1); then
350 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
354 dnl PSI_CHECK_ALIGNOF(type, special-includes)
355 dnl AC_CHECK_ALIGNOF wrapper with PSI_INCLUDES
356 dnl Defines psi\\ALIGNOF_<TYPE> pre-defined constant in $PSI_CONSTS_H.
357 AC_DEFUN(PSI_CHECK_ALIGNOF, [
358 AC_CHECK_ALIGNOF($1, PSI_INCLUDES
360 if PSI_SH_TEST_ALIGNOF($1); then
361 psi_add_int_const "AS_TR_CPP([ALIGNOF_]$1)" "$AS_TR_SH([ac_cv_alignof_]$1)"
365 dnl PSI_CHECK_OFFSETOF(struct, element)
366 dnl Check the offset of a struct element, implemented in the similar manner
367 dnl like AC_CHECK_SIZEOF.
368 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
369 AC_DEFUN(PSI_CHECK_OFFSETOF, [
371 [offset of $2 in $1],
372 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
373 [(long int) (offsetof ($1, $2))],
375 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
378 AS_TR_CPP(offsetof_$1_$2),
379 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
380 [The offset of `$2' in `$1', as computed by offsetof.]
385 dnl PSI_COMPUTE_STR(variable, string or expression)
386 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
387 AC_DEFUN(PSI_COMPUTE_STR, [
391 return EOF == fputs($2, fopen("conftest.out", "w"));
394 eval $1=\\\"`cat conftest.out`\\\"
398 dnl PSI_CHECK_LIBJIT()
399 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
400 dnl AC_DEFINEs HAVE_LIBJIT.
401 AC_DEFUN(PSI_CHECK_LIBJIT, [
402 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
403 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
405 if test -e $psi_cv_libjit_dir/include/jit/jit.h
412 if test -n "$psi_cv_libjit_dir"
414 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
415 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
416 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
418 AC_MSG_WARN([Could not find libjit, please provide the base install path])
422 dnl PSI_CHECK_LIBFFI()
423 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
424 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
425 dnl Checks for availability of recent closure API:
426 dnl \ffi_closure_alloc and \ffi_prep_closure.
427 dnl Checks for availability of recent vararg API:
428 dnl \ffi_prep_cif_var.
429 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
430 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
431 AC_DEFUN(PSI_CHECK_LIBFFI, [
432 AC_REQUIRE([PSI_PKG_CONFIG])dnl
434 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
435 if $PKG_CONFIG --exists libffi
444 AC_MSG_CHECKING(for libffi)
445 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
446 AC_MSG_RESULT($psi_cv_libffi_dir)
447 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
448 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
449 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
450 AC_DEFINE_UNQUOTED([PHP_PSI_LIBFFI_VERSION], ["`$PKG_CONFIG --modversion libffi`"], [libffi version])
452 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
453 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
455 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
461 if test -n "$psi_cv_libffi_dir"
463 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
464 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
465 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
467 AC_MSG_WARN([Could not find libffi, please provide the base install path])
470 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
471 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
472 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
473 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
474 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
476 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
477 AC_CHECK_HEADERS(sys/mman.h)
479 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
481 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
482 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
483 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
484 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
486 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)