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_MSG_CHECKING(for preprocessor defaults)
15 psi_cpp_predef=`$CPP -Wp,-dM $CPPFLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -U__BLOCKS__ - </dev/null`
16 psi_cpp_search=`$CPP -Wp,-v $CPPFLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 - </dev/null 2>&1 >/dev/null \
18 /include.*search.*start/ {
22 /@<:@Ee@:>@nd.*search/ {
31 psi_cpp_predef_count=`printf %s "$psi_cpp_predef" | wc -l`
32 psi_cpp_search_count=`printf %s "$psi_cpp_search" | wc -l`
33 AC_MSG_RESULT([$psi_cpp_predef_count predefined macros, and $psi_cpp_search_count search paths])
34 PSI_CPP_PREDEF=`printf "%s\n" "$psi_cpp_predef" | \
37 printf "\"%s\\\n\"\n", $[]0
40 PSI_CPP_SEARCH=`printf %s "$psi_cpp_search" | \
43 gsub(/^@<:@@<:@:space:@:>@@:>@+/,"");
44 gsub(/@<:@@<:@:space:@:>@@:>@+$/,"");
50 if test "$PHP_PSI_MAINTAINER_MODE" = "yes"; then
53 EXTRA_CFLAGS="-Wall -Wextra $EXTRA_CFLAGS"
62 [$PHP_PSI_BUILDDIR/php_psi_stdinc.h:$PHP_PSI_SRCDIR/php_psi_stdinc.h.in]
63 [$PHP_PSI_BUILDDIR/php_psi_posix.h:$PHP_PSI_SRCDIR/php_psi_posix.h.in]
64 [$PHP_PSI_BUILDDIR/php_psi_cpp.h:$PHP_PSI_SRCDIR/php_psi_cpp.h.in]
70 dnl Finish the headers with the pre-defined types etc.
71 AC_DEFUN(PSI_CONFIG_DONE, [
74 PHP_EVAL_LIBLINE($psi_eval_LIBS, PSI_SHARED_LIBADD)
76 [PSI_INCLUDES]="PSI_INCLUDES"
77 AC_SUBST([PSI_INCLUDES])
78 AC_SUBST([PSI_STDTYPES])
79 AC_SUBST([PSI_CONSTS])
80 AC_SUBST([PSI_CPP_SEARCH])
81 AC_SUBST([PSI_CPP_PREDEF])
84 AC_DEFUN(PSI_PTHREAD_ONCE, [
86 LIBS="$PTHREAD_LIBS $LIBS"
87 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
90 AC_DEFUN(PSI_PTHREAD, [
91 AC_REQUIRE([PSI_PTHREAD_ONCE])
95 dnl Expands to a complete list of include statements including
96 dnl autoconf's defaults.
97 AC_DEFUN(PSI_INCLUDES, [
105 #ifdef HAVE_STDBOOL_H
106 # include <stdbool.h>
112 # define _Bool signed char
118 # define __bool_true_false_are_defined 1
129 #ifdef HAVE_XLOCALE_H
130 # include <xlocale.h>
132 #ifdef HAVE_NETINET_IN_H
133 # include <netinet/in.h>
135 #ifdef HAVE_NETINET_TCP_H
136 # include <netinet/tcp.h>
138 #ifdef HAVE_ARPA_NAMESER_H
139 # include <arpa/nameser.h>
141 #ifdef HAVE_ARPA_INET_H
142 # include <arpa/inet.h>
151 #elif HAVE_GDBM_NDBM_H
152 # include <gdbm-ndbm.h>
163 #ifdef HAVE_SYS_SELECT_H
164 # include <sys/select.h>
166 #ifdef HAVE_SYS_SOCKET_H
167 # include <sys/socket.h>
169 #ifdef HAVE_SYS_TIME_H
170 # include <sys/time.h>
172 #ifdef HAVE_SYS_TIMES_H
173 # include <sys/times.h>
175 #ifdef HAVE_SYS_UIO_H
176 # include <sys/uio.h>
178 #ifdef HAVE_SYS_UTSNAME_H
179 # include <sys/utsname.h>
199 dnl Check for `pkg-config` and add possible libjit and libffi directories to
200 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
201 dnl arch-dependent locations.
202 AC_DEFUN([PSI_PKG_CONFIG], [
203 if test -z "$PKG_CONFIG"
205 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
207 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
210 dnl PSI_SH_SIZEOF(type)
211 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
212 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
214 dnl PSI_SH_OFFSETOF(type)
215 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
216 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
218 dnl PSI_SH_ALIGNOF(type)
219 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
220 AC_DEFUN([PSI_SH_ALIGNOF], [$AS_TR_SH([ac_cv_alignof_]$1)])
222 dnl PSI_SH_TEST_SIZEOF(type)
223 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
224 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])
226 dnl PSI_SH_TEST_ALIGNOF(type)
227 dnl `if` condition to test if $ac_cv_alignof_$1 is greater than 0.
228 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])
230 dnl PSI_CHECK_SIZEOF(type, special-includes)
231 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
232 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS_H.
233 AC_DEFUN(PSI_CHECK_SIZEOF, [
234 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
236 if PSI_SH_TEST_SIZEOF($1); then
237 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
241 dnl PSI_CHECK_ALIGNOF(type, special-includes)
242 dnl AC_CHECK_ALIGNOF wrapper with PSI_INCLUDES
243 dnl Defines psi\\ALIGNOF_<TYPE> pre-defined constant in $PSI_CONSTS_H.
244 AC_DEFUN(PSI_CHECK_ALIGNOF, [
245 AC_CHECK_ALIGNOF($1, PSI_INCLUDES
247 if PSI_SH_TEST_ALIGNOF($1); then
248 psi_add_int_const "AS_TR_CPP([ALIGNOF_]$1)" "$AS_TR_SH([ac_cv_alignof_]$1)"
252 dnl PSI_CHECK_OFFSETOF(struct, element)
253 dnl Check the offset of a struct element, implemented in the similar manner
254 dnl like AC_CHECK_SIZEOF.
255 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
256 AC_DEFUN(PSI_CHECK_OFFSETOF, [
258 [offset of $2 in $1],
259 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
260 [(long int) (offsetof ($1, $2))],
262 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
265 AS_TR_CPP(offsetof_$1_$2),
266 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
267 [The offset of `$2' in `$1', as computed by offsetof.]
272 dnl PSI_COMPUTE_STR(variable, string or expression)
273 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
274 AC_DEFUN(PSI_COMPUTE_STR, [
278 return EOF == fputs($2, fopen("conftest.out", "w"));
281 eval $1=\\\"`cat conftest.out`\\\"
285 dnl PSI_CHECK_LIBJIT()
286 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
287 dnl AC_DEFINEs HAVE_LIBJIT.
288 AC_DEFUN(PSI_CHECK_LIBJIT, [
289 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
290 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
292 if test -e $psi_cv_libjit_dir/include/jit/jit.h
299 if test -n "$psi_cv_libjit_dir"
301 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
302 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
303 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
305 AC_MSG_WARN([Could not find libjit, please provide the base install path])
309 dnl PSI_CHECK_LIBFFI()
310 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
311 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
312 dnl Checks for availability of recent closure API:
313 dnl \ffi_closure_alloc and \ffi_prep_closure.
314 dnl Checks for availability of recent vararg API:
315 dnl \ffi_prep_cif_var.
316 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
317 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
318 AC_DEFUN(PSI_CHECK_LIBFFI, [
319 AC_REQUIRE([PSI_PKG_CONFIG])dnl
321 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
322 if $PKG_CONFIG --exists libffi
331 AC_MSG_CHECKING(for libffi)
332 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
333 AC_MSG_RESULT($psi_cv_libffi_dir)
334 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
335 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
336 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
337 AC_DEFINE_UNQUOTED([PHP_PSI_LIBFFI_VERSION], ["`$PKG_CONFIG --modversion libffi`"], [libffi version])
339 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
340 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
342 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
348 if test -n "$psi_cv_libffi_dir"
350 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
351 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
352 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
354 AC_MSG_WARN([Could not find libffi, please provide the base install path])
359 CFLAGS="$CFLAGS $INCLUDES"
360 AC_CHECK_DECL(FFI_STDCALL,[AC_DEFINE([HAVE_FFI_STDCALL],[1],[ ])],,[#include "ffi.h"])
361 AC_CHECK_DECL(FFI_FASTCALL,[AC_DEFINE([HAVE_FFI_FASTCALL],[1],[ ])],,[#include "ffi.h"])
364 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
365 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
366 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
367 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
368 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
370 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
371 AC_CHECK_HEADERS(sys/mman.h)
373 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
375 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
376 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
377 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
378 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
380 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)