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 ac_includes_default="AC_INCLUDES_DEFAULT"
14 AC_CACHE_CHECK(for libc start main symbol, psi_cv_libc_main, [
16 AC_TRY_LINK(PSI_INCLUDES, [(void)0;], [
17 psi_libc_main=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'`
19 psi_cv_libc_main=$psi_libc_main
22 if test "$PHP_PSI_MAINTAINER_MODE" = "yes"; then
29 PSI_CONFIG_TMP=$(mktemp -d)
33 if test "$PHP_DEBUG" = "1"; then
36 PSI_EXTRA_REDIRS=false
49 [$PHP_PSI_BUILDDIR/php_psi_stdinc.h:$PHP_PSI_SRCDIR/php_psi_stdinc.h.in]
50 [$PHP_PSI_BUILDDIR/php_psi_posix.h:$PHP_PSI_SRCDIR/php_psi_posix.h.in]
56 dnl Internal: waits for sub configures in maintainer mode
57 AC_DEFUN(PSI_CONFIG_WAIT, [
59 if test $? -gt 0; then
60 cat $PSI_CONFIG_TMP/*/stderr.log >&2
66 dnl Finish the headers with the pre-defined types etc.
67 AC_DEFUN(PSI_CONFIG_DONE, [
70 if $PSI_FAST_CONFIG; then
71 for conf_env in $PSI_CONFIG_TMP/*/conf.env; do
78 PHP_EVAL_LIBLINE($psi_eval_LIBS, PSI_SHARED_LIBADD)
80 [PSI_INCLUDES]="PSI_INCLUDES"
81 AC_SUBST([PSI_INCLUDES])
82 AC_SUBST([PSI_STDTYPES])
84 AC_SUBST([PSI_COMPOSITES])
85 AC_SUBST([PSI_CONSTS])
86 AC_SUBST([PSI_REDIRS])
87 AC_SUBST([PSI_MACROS])
91 dnl PSI_SH_CONFIG_POSIX_ENABLED(section)
92 dnl Expand to $psi_config_posix_<section>
93 AC_DEFUN(PSI_SH_CONFIG_POSIX_ENABLED, [$AS_TR_SH([psi_config_posix_]$1)])
95 dnl PSI_CONFIG_POSIX_ENABLED(section, action-if-yes, action-if-not)
96 dnl Internal. Used to check if --enable-psi-posix=section was given.
97 AC_DEFUN(PSI_CONFIG_POSIX_ENABLED, [
98 AS_TR_SH([psi_config_posix_]$1)=false
99 case "$PHP_PSI_POSIX" in
101 AS_TR_SH([psi_config_posix_]$1)=true
104 if expr "$PHP_PSI_POSIX" : '.*\b$1\b' >/dev/null; then
105 AS_TR_SH([psi_config_posix_]$1)=true
109 if $AS_TR_SH([psi_config_posix_]$1); then
116 dnl PSI_TEST_POSIX_ENABLED(section, action-if-yes, action-if-not)
117 dnl Shell-if test if PSI POSIX section was configured.
118 AC_DEFUN(PSI_SH_TEST_POSIX_ENABLED, [
119 if test "PSI_SH_CONFIG_POSIX_ENABLED([$1])" && $PSI_SH_CONFIG_POSIX_ENABLED([$1]); then
126 dnl PSI_CONFIG_POSIX(section, headers, dependents)
127 AC_DEFUN(PSI_CONFIG_POSIX, [
128 PSI_CONFIG_POSIX_ENABLED($1, [
129 if $PSI_FAST_CONFIG; then
130 PSI_CONFIG_POSIX_PARALLEL($1, $2, [$3])
132 ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
133 AS_TR_CPP([PSI_CHECK_$1])
139 AC_DEFUN([PSI_CONFIG_POSIX_PARALLEL], [
142 mkdir $PSI_CONFIG_TMP/AS_TR_SH([$1])
143 cd $PSI_CONFIG_TMP/AS_TR_SH([$1])
146 ln -s $abs_builddir/confdefs.h confdefs.h
149 exec {PSI_MESSAGE_FD}>&AS_MESSAGE_FD {PSI_ERROR_FD}>&2
150 exec AS_MESSAGE_FD>stdout.log 2>stderr.log
152 dnl check for headers?
153 ifelse([$2],,:,[AC_CHECK_HEADERS($2)])
162 AS_TR_CPP([PSI_CHECK_$1])
168 for env in TYPES CONSTS COMPOSITES MACROS REDIRS DECLS; do
170 if test -n "$var"; then
178 _AC_CACHE_DUMP >>conf.env
179 dnl restore STDOUT,STDERR
180 exec AS_MESSAGE_FD>&$PSI_MESSAGE_FD 2>&$PSI_ERROR_FD
193 AC_DEFUN(PSI_PTHREAD_ONCE, [
195 LIBS="$PTHREAD_LIBS $LIBS"
196 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
199 AC_DEFUN(PSI_PTHREAD, [
200 AC_REQUIRE([PSI_PTHREAD_ONCE])
204 dnl Expands to a complete list of include statements including
205 dnl autoconf's defaults.
206 AC_DEFUN(PSI_INCLUDES, [
214 #ifdef HAVE_STDBOOL_H
215 # include <stdbool.h>
221 # define _Bool signed char
227 # define __bool_true_false_are_defined 1
238 #ifdef HAVE_XLOCALE_H
239 # include <xlocale.h>
241 #ifdef HAVE_NETINET_IN_H
242 # include <netinet/in.h>
244 #ifdef HAVE_NETINET_TCP_H
245 # include <netinet/tcp.h>
247 #ifdef HAVE_ARPA_NAMESER_H
248 # include <arpa/nameser.h>
250 #ifdef HAVE_ARPA_INET_H
251 # include <arpa/inet.h>
260 #elif HAVE_GDBM_NDBM_H
261 # include <gdbm-ndbm.h>
272 #ifdef HAVE_SYS_SELECT_H
273 # include <sys/select.h>
275 #ifdef HAVE_SYS_SOCKET_H
276 # include <sys/socket.h>
278 #ifdef HAVE_SYS_TIME_H
279 # include <sys/time.h>
281 #ifdef HAVE_SYS_TIMES_H
282 # include <sys/times.h>
284 #ifdef HAVE_SYS_UIO_H
285 # include <sys/uio.h>
287 #ifdef HAVE_SYS_UTSNAME_H
288 # include <sys/utsname.h>
308 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
309 AC_DEFUN(PSI_LEMON, [
310 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
313 AC_PATH_PROG(LEMON, lemon, $PHP_PSI_BUILDDIR/lemon)
314 if expr + "$LEMON" : "/" >/dev/null; then
317 LEMON_PATH=$abs_builddir/
320 PHP_SUBST(LEMON_PATH)
325 dnl Check for `pkg-config` and add possible libjit and libffi directories to
326 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
327 dnl arch-dependent locations.
328 AC_DEFUN([PSI_PKG_CONFIG], [
329 if test -z "$PKG_CONFIG"
331 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
333 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
336 dnl PSI_SH_SIZEOF(type)
337 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
338 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
340 dnl PSI_SH_OFFSETOF(type)
341 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
342 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
344 dnl PSI_SH_ALIGNOF(type)
345 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
346 AC_DEFUN([PSI_SH_ALIGNOF], [$AS_TR_SH([ac_cv_alignof_]$1)])
348 dnl PSI_SH_TEST_SIZEOF(type)
349 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
350 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])
352 dnl PSI_SH_TEST_ALIGNOF(type)
353 dnl `if` condition to test if $ac_cv_alignof_$1 is greater than 0.
354 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])
356 dnl PSI_CHECK_SIZEOF(type, special-includes)
357 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
358 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS_H.
359 AC_DEFUN(PSI_CHECK_SIZEOF, [
360 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
362 if PSI_SH_TEST_SIZEOF($1); then
363 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
367 dnl PSI_CHECK_ALIGNOF(type, special-includes)
368 dnl AC_CHECK_ALIGNOF wrapper with PSI_INCLUDES
369 dnl Defines psi\\ALIGNOF_<TYPE> pre-defined constant in $PSI_CONSTS_H.
370 AC_DEFUN(PSI_CHECK_ALIGNOF, [
371 AC_CHECK_ALIGNOF($1, PSI_INCLUDES
373 if PSI_SH_TEST_ALIGNOF($1); then
374 psi_add_int_const "AS_TR_CPP([ALIGNOF_]$1)" "$AS_TR_SH([ac_cv_alignof_]$1)"
378 dnl PSI_CHECK_OFFSETOF(struct, element)
379 dnl Check the offset of a struct element, implemented in the similar manner
380 dnl like AC_CHECK_SIZEOF.
381 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
382 AC_DEFUN(PSI_CHECK_OFFSETOF, [
384 [offset of $2 in $1],
385 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
386 [(long int) (offsetof ($1, $2))],
388 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
391 AS_TR_CPP(offsetof_$1_$2),
392 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
393 [The offset of `$2' in `$1', as computed by offsetof.]
398 dnl PSI_COMPUTE_STR(variable, string or expression)
399 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
400 AC_DEFUN(PSI_COMPUTE_STR, [
404 return EOF == fputs($2, fopen("conftest.out", "w"));
407 eval $1=\\\"`cat conftest.out`\\\"
411 dnl PSI_CHECK_LIBJIT()
412 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
413 dnl AC_DEFINEs HAVE_LIBJIT.
414 AC_DEFUN(PSI_CHECK_LIBJIT, [
415 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
416 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
418 if test -e $psi_cv_libjit_dir/include/jit/jit.h
425 if test -n "$psi_cv_libjit_dir"
427 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
428 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
429 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
431 AC_MSG_WARN([Could not find libjit, please provide the base install path])
435 dnl PSI_CHECK_LIBFFI()
436 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
437 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
438 dnl Checks for availability of recent closure API:
439 dnl \ffi_closure_alloc and \ffi_prep_closure.
440 dnl Checks for availability of recent vararg API:
441 dnl \ffi_prep_cif_var.
442 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
443 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
444 AC_DEFUN(PSI_CHECK_LIBFFI, [
445 AC_REQUIRE([PSI_PKG_CONFIG])dnl
447 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
448 if $PKG_CONFIG --exists libffi
457 AC_MSG_CHECKING(for libffi)
458 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
459 AC_MSG_RESULT($psi_cv_libffi_dir)
460 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
461 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
462 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
463 AC_DEFINE_UNQUOTED([PHP_PSI_LIBFFI_VERSION], ["`$PKG_CONFIG --modversion libffi`"], [libffi version])
465 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
466 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
468 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
474 if test -n "$psi_cv_libffi_dir"
476 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
477 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
478 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
480 AC_MSG_WARN([Could not find libffi, please provide the base install path])
485 CFLAGS="$CFLAGS $INCLUDES"
486 AC_CHECK_DECL(FFI_STDCALL,[AC_DEFINE([HAVE_FFI_STDCALL],[1],[ ])],,[#include "ffi.h"])
487 AC_CHECK_DECL(FFI_FASTCALL,[AC_DEFINE([HAVE_FFI_FASTCALL],[1],[ ])],,[#include "ffi.h"])
490 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
491 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
492 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
493 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
494 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
496 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
497 AC_CHECK_HEADERS(sys/mman.h)
499 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
501 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
502 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
503 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
504 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
506 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)