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 static struct psi_predef_type {
19 const char *type_name;
21 } psi_predef_types@<:@@:>@ = {
23 cat >$PSI_STRUCTS <<EOF
24 static struct psi_predef_struct {
26 const char *type_name;
32 } psi_predef_structs@<:@@:>@ = {
34 cat >$PSI_CONSTS <<EOF
35 static struct psi_predef_const {
37 const char *type_name;
41 } psi_predef_consts@<:@@:>@ = {
43 cat >$PSI_REDIRS <<EOF
44 static struct psi_func_redir {
47 } psi_func_redirs@<:@@:>@ = {
49 cat >$PSI_MACROS </dev/null
51 static struct psi_predef_decl {
53 const char *type_name;
57 } psi_predef_decls@<:@@:>@ = {
59 cat >$PSI_VA_DECLS <<EOF
60 static struct psi_predef_decl psi_predef_vararg_decls@<:@@:>@ = {
65 dnl Finish the headers with the pre-defined types etc.
66 AC_DEFUN(PSI_CONFIG_DONE, [
67 cat >$PSI_STDINC <<EOF
70 for i in $PSI_TYPES $PSI_STRUCTS $PSI_CONSTS $PSI_REDIRS $PSI_DECLS $PSI_VA_DECLS; do
79 dnl Expands to a complete list of include statements including
80 dnl AC_INCLUDES_DEFAULT().
81 AC_DEFUN(PSI_INCLUDES, [AC_INCLUDES_DEFAULT()
94 #ifdef HAVE_NETINET_IN_H
95 # include <netinet/in.h>
97 #ifdef HAVE_NETINET_TCP_H
98 # include <netinet/tcp.h>
100 #ifdef HAVE_ARPA_NAMESER_H
101 # include <arpa/nameser.h>
112 #ifdef HAVE_SYS_SELECT_H
113 # include <sys/select.h>
115 #ifdef HAVE_SYS_SOCKET_H
116 # include <sys/socket.h>
118 #ifdef HAVE_SYS_TIME_H
119 # include <sys/time.h>
121 #ifdef HAVE_SYS_TIMES_H
122 # include <sys/times.h>
124 #ifdef HAVE_SYS_UIO_H
125 # include <sys/uio.h>
127 #ifdef HAVE_SYS_UTSNAME_H
128 # include <sys/utsname.h>
145 dnl Declare $LEMON precious, and check for a `lemon` in $PATH.
146 AC_DEFUN(PSI_LEMON, [
147 AC_ARG_VAR(LEMON, The lemon parser generator of the SQLite project)
148 AC_PATH_PROG(LEMON, lemon, ./lemon)
153 dnl Check for `pkg-config` and add possible libjit and libffi directories to
154 dnl $PKG_CONFIG_PATH, because those libs often ship with headers etc. in
155 dnl arch-dependent locations.
156 AC_DEFUN([PSI_PKG_CONFIG], [
157 if test -z "$PKG_CONFIG"
159 AC_PATH_PROG(PKG_CONFIG, pkg-config, false)
161 export PKG_CONFIG_PATH="$PHP_PSI_LIBFFI/lib/pkgconfig:$PHP_PSI_LIBJIT/lib/pkgconfig:$PKG_CONFIG_PATH"
164 dnl PSI_SH_TEST_SIZEOF(type)
165 dnl `if` condition to test if $ac_cv_sizeof_$1 is greater than 0.
166 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])
168 dnl PSI_CHECK_SIZEOF(type, special-includes)
169 dnl AC_CHECK_SIZEOF wrapper with PSI_INCLUDES
170 dnl Defines psi\\SIZEOF_<TYPE> pre-defined constant in $PSI_CONSTS.
171 AC_DEFUN(PSI_CHECK_SIZEOF, [
172 AC_CHECK_SIZEOF($1, [], PSI_INCLUDES
174 if PSI_SH_TEST_SIZEOF($1); then
175 psi_add_int_const "AS_TR_CPP([SIZEOF_]$1)" "$AS_TR_SH([ac_cv_sizeof_]$1)"
179 dnl PSI_CHECK_OFFSETOF(struct, element)
180 dnl Check the offset of a struct element, implemented in the similar manner
181 dnl like AC_CHECK_SIZEOF.
182 dnl AC_DEFINEs OFFSETOF_<STRUCT>_<ELEMENT>.
183 AC_DEFUN(PSI_CHECK_OFFSETOF, [
185 [offset of $2 in $1],
186 [AS_TR_SH([ac_cv_offsetof_$1_$2])],
187 [(long int) (offsetof ($1, $2))],
189 [AC_MSG_FAILURE([cannot compute offsetof ($1, $2)])]
192 AS_TR_CPP(offsetof_$1_$2),
193 $AS_TR_SH([ac_cv_offsetof_$1_$2]),
194 [The offset of `$2' in `$1', as computed by offsetof.]
198 dnl PSI_COMPUTE_STR(variable, string or expression)
199 dnl Compute a string constant value in a similar manner like AC_COMPUTE_INT.
200 AC_DEFUN(PSI_COMPUTE_STR, [
204 return EOF == fputs($2, fopen("conftest.out", "w"));
207 eval $1=\\\"`cat conftest.out`\\\"
211 dnl PSI_CHECK_LIBJIT()
212 dnl Check for libjit in $PHP_PSI_LIBJIT or standard locations
213 dnl AC_DEFINEs HAVE_LIBJIT.
214 AC_DEFUN(PSI_CHECK_LIBJIT, [
215 AC_CACHE_CHECK(for libjit, psi_cv_libjit_dir, [
216 for psi_cv_libjit_dir in $PHP_PSI_LIBJIT {/usr{,/local},/opt}{,/libjit}
218 if test -e $psi_cv_libjit_dir/include/jit/jit.h
225 if test -n "$psi_cv_libjit_dir"
227 PHP_ADD_INCLUDE($psi_cv_libjit_dir/include)
228 PHP_ADD_LIBRARY_WITH_PATH(jit, $psi_cv_libjit_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
229 AC_DEFINE(HAVE_LIBJIT, 1, Have libjit)
231 AC_MSG_WARN([Could not find libjit, please provide the base install path])
235 dnl PSI_CHECK_LIBFFI()
236 dnl Check for libffi with `pkg-config`. If that fails, `configure` looks into
237 dnl $PHP_PSI_LIBFFI or standard locations to find libjit deps.
238 dnl Checks for availability of recent closure API:
239 dnl \ffi_closure_alloc and \ffi_prep_closure.
240 dnl Checks for availability of recent vararg API:
241 dnl \ffi_prep_cif_var.
242 dnl AC_DEFINEs HAVE_LIBFFI, PSI_HAVE_FFI_CLOSURE_ALLOC,
243 dnl PSI_HAVE_FFI_PREP_CLOSURE and PSI_HAVE_FFO_PREP_VIF_VAR.
244 AC_DEFUN(PSI_CHECK_LIBFFI, [
245 AC_REQUIRE([PSI_PKG_CONFIG])dnl
247 AC_CACHE_CHECK(for libffi through pkg-config, psi_cv_libffi, [
248 if $PKG_CONFIG --exists libffi
257 AC_MSG_CHECKING(for libffi)
258 psi_cv_libffi_dir=`$PKG_CONFIG --variable=prefix libffi`
259 AC_MSG_RESULT($psi_cv_libffi_dir)
260 PHP_EVAL_INCLINE(`$PKG_CONFIG --cflags libffi`)
261 PHP_EVAL_LIBLINE(`$PKG_CONFIG --libs libffi`, PSI_SHARED_LIBADD)
262 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
264 AC_CACHE_CHECK(for libffi, psi_cv_libffi_dir, [
265 for psi_cv_libffi_dir in $PHP_PSI_LIBFFI {/usr{,/local},/opt}{,/libffi}
267 if test -e $psi_cv_libffi_dir/include/ffi/ffi.h
273 if test -n "$psi_cv_libffi_dir"
275 PHP_ADD_INCLUDE($psi_cv_libffi_dir/include/ffi)
276 PHP_ADD_LIBRARY_WITH_PATH(ffi, $psi_cv_libffi_dir/$PHP_LIBDIR, PSI_SHARED_LIBADD)
277 AC_DEFINE(HAVE_LIBFFI, 1, Have libffi)
279 AC_MSG_WARN([Could not find libffi, please provide the base install path])
282 PHP_CHECK_LIBRARY(ffi, ffi_closure_alloc, [
283 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure_loc, [
284 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE_LOC, 1, [ ])
285 ], [], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
286 AC_DEFINE(PSI_HAVE_FFI_CLOSURE_ALLOC, 1, [ ])
288 PHP_CHECK_LIBRARY(ffi, ffi_prep_closure, [
289 AC_CHECK_HEADERS(sys/mman.h)
291 AC_DEFINE(PSI_HAVE_FFI_PREP_CLOSURE, 1, [ ])
293 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
294 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)
295 PHP_CHECK_LIBRARY(ffi, ffi_prep_cif_var, [
296 AC_DEFINE(PSI_HAVE_FFI_PREP_CIF_VAR, 1, [ ])
298 ], -L$psi_cv_libffi_dir/$PHP_LIBDIR)