1 dnl Generated headers with pre-defined types, structs, consts and decls.
2 PSI_STDINC=$PHP_PSI_SRCDIR/php_psi_stdinc.h
3 PSI_TYPES=$PHP_PSI_SRCDIR/php_psi_types.h
4 PSI_STRUCTS=$PHP_PSI_SRCDIR/php_psi_structs.h
5 PSI_CONSTS=$PHP_PSI_SRCDIR/php_psi_consts.h
6 PSI_REDIRS=$PHP_PSI_SRCDIR/php_psi_redirs.h
7 PSI_MACROS=$PHP_PSI_SRCDIR/php_psi_macros.h
8 PSI_DECLS=$PHP_PSI_SRCDIR/php_psi_decls.h
9 PSI_VA_DECLS=$PHP_PSI_SRCDIR/php_psi_va_decls.h
12 dnl Creates stubs of the headers with pre-defined types etc.
13 dnl These headers are included by src/context.c.
14 dnl This macro must be called prior any checks for a type, struct, decl etc.
15 AC_DEFUN(PSI_CONFIG_INIT, [
17 /* generated by configure */
18 static struct psi_predef_type {
20 const char *type_name;
22 } psi_predef_types@<:@@:>@ = {
24 cat >$PSI_STRUCTS <<EOF
25 /* generated by configure */
26 static struct psi_predef_struct {
28 const char *type_name;
34 } psi_predef_structs@<:@@:>@ = {
36 cat >$PSI_CONSTS <<EOF
37 /* generated by configure */
38 static struct psi_predef_const {
40 const char *type_name;
44 } psi_predef_consts@<:@@:>@ = {
46 cat >$PSI_REDIRS <<EOF
47 /* generated by configure */
48 static struct psi_func_redir {
51 } psi_func_redirs@<:@@:>@ = {
53 cat >$PSI_MACROS </dev/null
55 /* generated by configure */
56 static struct psi_predef_decl {
58 const char *type_name;
62 } psi_predef_decls@<:@@:>@ = {
64 cat >$PSI_VA_DECLS <<EOF
65 /* generated by configure */
66 static struct psi_predef_decl psi_predef_vararg_decls@<:@@:>@ = {
71 dnl Finish the headers with the pre-defined types etc.
72 AC_DEFUN(PSI_CONFIG_DONE, [
73 cat >$PSI_STDINC <<EOF
74 /* generated by configure */
77 for i in $PSI_TYPES $PSI_STRUCTS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS; do
86 dnl Expands to a complete list of include statements including
87 dnl AC_INCLUDES_DEFAULT().
88 AC_DEFUN(PSI_INCLUDES, [AC_INCLUDES_DEFAULT()
101 #ifdef HAVE_NETINET_IN_H
102 # include <netinet/in.h>
104 #ifdef HAVE_NETINET_TCP_H
105 # include <netinet/tcp.h>
107 #ifdef HAVE_ARPA_NAMESER_H
108 # include <arpa/nameser.h>
125 #ifdef HAVE_SYS_SELECT_H
126 # include <sys/select.h>
128 #ifdef HAVE_SYS_SOCKET_H
129 # include <sys/socket.h>
131 #ifdef HAVE_SYS_TIME_H
132 # include <sys/time.h>
134 #ifdef HAVE_SYS_TIMES_H
135 # include <sys/times.h>
137 #ifdef HAVE_SYS_UIO_H
138 # include <sys/uio.h>
140 #ifdef HAVE_SYS_UTSNAME_H
141 # include <sys/utsname.h>
158 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
159 AC_DEFUN(PSI_LEMON, [
160 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
161 AC_PATH_PROG(LEMON, lemon, ./lemon)
166 dnl Check for `pkg-config` and add possible libjit and libffi directories to
167 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
168 dnl arch-dependent locations.
169 AC_DEFUN([PSI_PKG_CONFIG], [
170 if test -z "$PKG_CONFIG"
172 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
174 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
177 dnl PSI_SH_SIZEOF(type)
178 dnl expand to shell variable $ac_cv_sizeof_<TYPE>
179 AC_DEFUN([PSI_SH_SIZEOF], [$AS_TR_SH([ac_cv_sizeof_]$1)])
181 dnl PSI_SH_TEST_SIZEOF(type)
182 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
183 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])
185 dnl PSI_CHECK_SIZEOF(type, special-includes)
186 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
187 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS.
188 AC_DEFUN(PSI_CHECK_SIZEOF, [
189 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
191 if PSI_SH_TEST_SIZEOF($1); then
192 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
196 dnl PSI_CHECK_OFFSETOF(struct, element)
197 dnl Check the offset of a struct element, implemented in the similar manner
198 dnl like AC_CHECK_SIZEOF.
199 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
200 AC_DEFUN(PSI_CHECK_OFFSETOF, [
202 [offset of $2 in $1],
203 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
204 [(long int) (offsetof ($1, $2))],
206 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
209 AS_TR_CPP(offsetof_$1_$2),
210 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
211 [The offset of `$2' in `$1', as computed by offsetof.]
215 dnl PSI_SH_OFFSETOF(type)
216 dnl Expand to shell variable $ac_cv_offsetof_<TYPE>
217 AC_DEFUN([PSI_SH_OFFSETOF], [$AS_TR_SH([ac_cv_offsetof_]$1)])
220 dnl PSI_COMPUTE_STR(variable, string or expression)
221 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
222 AC_DEFUN(PSI_COMPUTE_STR, [
226 return EOF == fputs($2, fopen("conftest.out", "w"));
229 eval $1=\\\"`cat conftest.out`\\\"
233 dnl PSI_CHECK_LIBJIT()
234 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
235 dnl AC_DEFINEs HAVE_LIBJIT.
236 AC_DEFUN(PSI_CHECK_LIBJIT, [
237 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
238 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
240 if test -e $psi_cv_libjit_dir/include/jit/jit.h
247 if test -n "$psi_cv_libjit_dir"
249 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
250 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
251 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
253 AC_MSG_WARN([Could not find libjit, please provide the base install path])
257 dnl PSI_CHECK_LIBFFI()
258 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
259 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
260 dnl Checks for availability of recent closure API:
261 dnl \ffi_closure_alloc and \ffi_prep_closure.
262 dnl Checks for availability of recent vararg API:
263 dnl \ffi_prep_cif_var.
264 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
265 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
266 AC_DEFUN(PSI_CHECK_LIBFFI, [
267 AC_REQUIRE([PSI_PKG_CONFIG])dnl
269 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
270 if $PKG_CONFIG --exists libffi
279 AC_MSG_CHECKING(for libffi)
280 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
281 AC_MSG_RESULT($psi_cv_libffi_dir)
282 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
283 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
284 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
286 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
287 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
289 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
295 if test -n "$psi_cv_libffi_dir"
297 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
298 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
299 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
301 AC_MSG_WARN([Could not find libffi, please provide the base install path])
304 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
305 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
306 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
307 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
308 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
310 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
311 AC_CHECK_HEADERS(sys/mman.h)
313 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
315 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
316 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
317 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
318 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
320 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)