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)
21 if test "$PHP_DEBUG" = "1"; then
24 PSI_EXTRA_REDIRS=false
37 [$PHP_PSI_BUILDDIR/php_psi_stdinc.h:$PHP_PSI_SRCDIR/php_psi_stdinc.h.in]
38 [$PHP_PSI_BUILDDIR/php_psi_posix.h:$PHP_PSI_SRCDIR/php_psi_posix.h.in]
44 dnl Finish the headers with the pre-defined types etc.
45 AC_DEFUN(PSI_CONFIG_DONE, [
46 if $PSI_FAST_CONFIG; then
48 for conf_env in $PSI_CONFIG_TMP/*/conf.env; do
55 PHP_EVAL_LIBLINE($psi_eval_LIBS, PSI_SHARED_LIBADD)
57 [PSI_INCLUDES]="PSI_INCLUDES"
58 AC_SUBST([PSI_INCLUDES])
59 AC_SUBST([PSI_STDTYPES])
61 AC_SUBST([PSI_COMPOSITES])
62 AC_SUBST([PSI_CONSTS])
63 AC_SUBST([PSI_REDIRS])
64 AC_SUBST([PSI_MACROS])
68 dnl PSI_SH_CONFIG_POSIX_ENABLED(section)
69 dnl Expand to $psi_config_posix_<section>
70 AC_DEFUN(PSI_SH_CONFIG_POSIX_ENABLED, [$AS_TR_SH([psi_config_posix_]$1)])
72 dnl PSI_CONFIG_POSIX_ENABLED(section, action-if-yes, action-if-not)
73 dnl Internal. Used to check if --enable-psi-posix=section was given.
74 AC_DEFUN(PSI_CONFIG_POSIX_ENABLED, [
75 AS_TR_SH([psi_config_posix_]$1)=false
76 case "$PHP_PSI_POSIX" in
78 AS_TR_SH([psi_config_posix_]$1)=true
81 if expr "$PHP_PSI_POSIX" : '\b$1\b' >/dev/null; then
82 AS_TR_SH([psi_config_posix_]$1)=true
86 if $AS_TR_SH([psi_config_posix_]$1); then
93 dnl PSI_TEST_POSIX_ENABLED(section, action-if-yes, action-if-not)
94 dnl Shell-if test if PSI POSIX section was configured.
95 AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [
96 if test "PSI_SH_CONFIG_POSIX_ENABLED([$1])" && $PSI_SH_CONFIG_POSIX_ENABLED([$1]); then
103 dnl PSI_CONFIG_POSIX(section, headers)
104 AC_DEFUN(PSI_CONFIG_POSIX, [
105 PSI_CONFIG_POSIX_ENABLED($1, [
106 if $PSI_FAST_CONFIG; then
107 PSI_CONFIG_POSIX_PARALLEL($1, $2)
109 ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
110 AS_TR_CPP([PSI_CHECK_$1])
115 AC_DEFUN([PSI_CONFIG_POSIX_PARALLEL], [
118 mkdir $PSI_CONFIG_TMP/AS_TR_SH([$1])
119 ln -s $(pwd)/confdefs.h $PSI_CONFIG_TMP/AS_TR_SH([$1])/confdefs.h
122 exec 66>&AS_MESSAGE_FD
123 exec AS_MESSAGE_FD>$PSI_CONFIG_TMP/AS_TR_SH([$1])/stdout.log
124 exec 2>$PSI_CONFIG_TMP/AS_TR_SH([$1])/stderr.log
126 dnl check for headers?
127 ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
130 cd $PSI_CONFIG_TMP/AS_TR_SH([$1])
139 AS_TR_CPP([PSI_CHECK_$1])
142 cat >$PSI_CONFIG_TMP/AS_TR_SH([$1])/conf.env <<EOF
145 for env in TYPES CONSTS COMPOSITES MACROS REDIRS DECLS; do
147 if test -n "$var"; then
148 cat >>$PSI_CONFIG_TMP/AS_TR_SH([$1])/conf.env <<EOF
156 printf "%s " "$1" >&66
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, [dnl
181 AC_INCLUDES_DEFAULT()
182 #ifdef HAVE_STDBOOL_H
183 # include <stdbool.h>
189 # define _Bool signed char
195 # define __bool_true_false_are_defined 1
206 #ifdef HAVE_XLOCALE_H
207 # include <xlocale.h>
209 #ifdef HAVE_NETINET_IN_H
210 # include <netinet/in.h>
212 #ifdef HAVE_NETINET_TCP_H
213 # include <netinet/tcp.h>
215 #ifdef HAVE_ARPA_NAMESER_H
216 # include <arpa/nameser.h>
225 #elif HAVE_GDBM_NDBM_H
226 # include <gdbm-ndbm.h>
237 #ifdef HAVE_SYS_SELECT_H
238 # include <sys/select.h>
240 #ifdef HAVE_SYS_SOCKET_H
241 # include <sys/socket.h>
243 #ifdef HAVE_SYS_TIME_H
244 # include <sys/time.h>
246 #ifdef HAVE_SYS_TIMES_H
247 # include <sys/times.h>
249 #ifdef HAVE_SYS_UIO_H
250 # include <sys/uio.h>
252 #ifdef HAVE_SYS_UTSNAME_H
253 # include <sys/utsname.h>
273 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
274 AC_DEFUN(PSI_LEMON, [
275 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
278 AC_PATH_PROG(LEMON, lemon, ./lemon)
284 dnl Check for `pkg-config` and add possible libjit and libffi directories to
285 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
286 dnl arch-dependent locations.
287 AC_DEFUN([PSI_PKG_CONFIG], [
288 if test -z "$PKG_CONFIG"
290 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
292 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
295 dnl PSI_SH_SIZEOF(type)
296 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
297 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
299 dnl PSI_SH_OFFSETOF(type)
300 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
301 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
303 dnl PSI_SH_ALIGNOF(type)
304 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
305 AC_DEFUN([PSI_SH_ALIGNOF], [$AS_TR_SH([ac_cv_alignof_]$1)])
307 dnl PSI_SH_TEST_SIZEOF(type)
308 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
309 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])
311 dnl PSI_SH_TEST_ALIGNOF(type)
312 dnl `if` condition to test if $ac_cv_alignof_$1 is greater than 0.
313 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])
315 dnl PSI_CHECK_SIZEOF(type, special-includes)
316 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
317 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS_H.
318 AC_DEFUN(PSI_CHECK_SIZEOF, [
319 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
321 if PSI_SH_TEST_SIZEOF($1); then
322 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
326 dnl PSI_CHECK_ALIGNOF(type, special-includes)
327 dnl AC_CHECK_ALIGNOF wrapper with PSI_INCLUDES
328 dnl Defines psi\\ALIGNOF_<TYPE> pre-defined constant in $PSI_CONSTS_H.
329 AC_DEFUN(PSI_CHECK_ALIGNOF, [
330 AC_CHECK_ALIGNOF($1, PSI_INCLUDES
332 if PSI_SH_TEST_ALIGNOF($1); then
333 psi_add_int_const "AS_TR_CPP([ALIGNOF_]$1)" "$AS_TR_SH([ac_cv_alignof_]$1)"
337 dnl PSI_CHECK_OFFSETOF(struct, element)
338 dnl Check the offset of a struct element, implemented in the similar manner
339 dnl like AC_CHECK_SIZEOF.
340 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
341 AC_DEFUN(PSI_CHECK_OFFSETOF, [
343 [offset of $2 in $1],
344 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
345 [(long int) (offsetof ($1, $2))],
347 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
350 AS_TR_CPP(offsetof_$1_$2),
351 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
352 [The offset of `$2' in `$1', as computed by offsetof.]
357 dnl PSI_COMPUTE_STR(variable, string or expression)
358 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
359 AC_DEFUN(PSI_COMPUTE_STR, [
363 return EOF == fputs($2, fopen("conftest.out", "w"));
366 eval $1=\\\"`cat conftest.out`\\\"
370 dnl PSI_CHECK_LIBJIT()
371 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
372 dnl AC_DEFINEs HAVE_LIBJIT.
373 AC_DEFUN(PSI_CHECK_LIBJIT, [
374 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
375 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
377 if test -e $psi_cv_libjit_dir/include/jit/jit.h
384 if test -n "$psi_cv_libjit_dir"
386 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
387 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
388 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
390 AC_MSG_WARN([Could not find libjit, please provide the base install path])
394 dnl PSI_CHECK_LIBFFI()
395 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
396 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
397 dnl Checks for availability of recent closure API:
398 dnl \ffi_closure_alloc and \ffi_prep_closure.
399 dnl Checks for availability of recent vararg API:
400 dnl \ffi_prep_cif_var.
401 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
402 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
403 AC_DEFUN(PSI_CHECK_LIBFFI, [
404 AC_REQUIRE([PSI_PKG_CONFIG])dnl
406 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
407 if $PKG_CONFIG --exists libffi
416 AC_MSG_CHECKING(for libffi)
417 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
418 AC_MSG_RESULT($psi_cv_libffi_dir)
419 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
420 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
421 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
422 AC_DEFINE_UNQUOTED([PHP_PSI_LIBFFI_VERSION], ["`$PKG_CONFIG --modversion libffi`"], [libffi version])
424 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
425 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
427 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
433 if test -n "$psi_cv_libffi_dir"
435 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
436 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
437 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
439 AC_MSG_WARN([Could not find libffi, please provide the base install path])
442 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
443 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
444 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
445 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
446 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
448 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
449 AC_CHECK_HEADERS(sys/mman.h)
451 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
453 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
454 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
455 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
456 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
458 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)