xref: /php-src/configure.ac (revision 413f2cd4)
1dnl Process this file with autoconf to produce a configure script.
2
3dnl Include external macro definitions before the AC_INIT to also remove
4dnl comments starting with # and empty newlines from the included files.
5dnl ----------------------------------------------------------------------------
6m4_include([build/ax_check_compile_flag.m4])
7m4_include([build/ax_func_which_gethostbyname_r.m4])
8m4_include([build/ax_gcc_func_attribute.m4])
9m4_include([build/libtool.m4])
10m4_include([build/php_cxx_compile_stdcxx.m4])
11m4_include([build/php.m4])
12m4_include([build/pkg.m4])
13m4_include([TSRM/threads.m4])
14m4_include([TSRM/tsrm.m4])
15
16dnl Basic autoconf initialization, generation of config.nice.
17dnl ----------------------------------------------------------------------------
18
19AC_PREREQ([2.68])
20AC_INIT([PHP],[8.4.0-dev],[https://github.com/php/php-src/issues],[php],[https://www.php.net])
21AC_CONFIG_SRCDIR([main/php_version.h])
22AC_CONFIG_AUX_DIR([build])
23AC_PRESERVE_HELP_ORDER
24
25PHP_CONFIG_NICE(config.nice)
26
27PHP_CANONICAL_HOST_TARGET
28
29AC_CONFIG_HEADERS([main/php_config.h])
30
31AH_TOP([
32#ifndef PHP_CONFIG_H
33#define PHP_CONFIG_H
34
35#if defined(__GNUC__) && __GNUC__ >= 4
36# define ZEND_API __attribute__ ((visibility("default")))
37# define ZEND_DLEXPORT __attribute__ ((visibility("default")))
38#else
39# define ZEND_API
40# define ZEND_DLEXPORT
41#endif
42
43#define ZEND_DLIMPORT
44])
45AH_BOTTOM([
46#include <stdlib.h>
47
48#ifdef HAVE_SYS_TYPES_H
49# include <sys/types.h>
50#endif
51
52#ifdef HAVE_SYS_SELECT_H
53#include <sys/select.h>
54#endif
55
56#include <string.h>
57
58#endif /* PHP_CONFIG_H */
59])
60
61ac_IFS=$IFS; IFS="."
62set $(echo AC_PACKAGE_VERSION | "${SED}" 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/')
63IFS=$ac_IFS
64PHP_MAJOR_VERSION=[$]1
65PHP_MINOR_VERSION=[$]2
66PHP_RELEASE_VERSION=[$]3
67dnl Allow overriding PHP_EXTRA_VERSION through the homonymous env var
68AC_ARG_VAR([PHP_EXTRA_VERSION],[Extra PHP version label suffix, e.g. '-dev', 'rc1', '-acme'])dnl
69AS_IF([test -z "$PHP_EXTRA_VERSION"],[PHP_EXTRA_VERSION=[$]4])
70PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
71PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
72
73dnl Allow version values to be used in Makefile.
74PHP_SUBST(PHP_MAJOR_VERSION)
75PHP_SUBST(PHP_MINOR_VERSION)
76PHP_SUBST(PHP_RELEASE_VERSION)
77PHP_SUBST(PHP_EXTRA_VERSION)
78
79dnl Define where extension directories are located in the configure context.
80AC_DEFUN([PHP_EXT_BUILDDIR],[$config_m4_dir])dnl
81AC_DEFUN([PHP_EXT_DIR],[$config_m4_dir])dnl
82AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir/$config_m4_dir])dnl
83AC_DEFUN([PHP_ALWAYS_SHARED],[])dnl
84
85dnl Setting up the PHP version based on the information above.
86dnl ----------------------------------------------------------------------------
87
88echo "/* automatically generated by configure */" > php_version.h.new
89echo "/* edit configure.ac to change version number */" >> php_version.h.new
90echo "#define PHP_MAJOR_VERSION $PHP_MAJOR_VERSION" >> php_version.h.new
91echo "#define PHP_MINOR_VERSION $PHP_MINOR_VERSION" >> php_version.h.new
92echo "#define PHP_RELEASE_VERSION $PHP_RELEASE_VERSION" >> php_version.h.new
93echo "#define PHP_EXTRA_VERSION \"$PHP_EXTRA_VERSION\"" >> php_version.h.new
94echo "#define PHP_VERSION \"$PHP_VERSION\"" >> php_version.h.new
95echo "#define PHP_VERSION_ID $PHP_VERSION_ID" >> php_version.h.new
96cmp php_version.h.new $srcdir/main/php_version.h >/dev/null 2>&1
97if test $? -ne 0 ; then
98  rm -f $srcdir/main/php_version.h && mv php_version.h.new $srcdir/main/php_version.h && \
99  echo 'Updated main/php_version.h'
100else
101  rm -f php_version.h.new
102fi
103
104dnl Settings we want to make before the checks.
105dnl ----------------------------------------------------------------------------
106
107php_shtool=$srcdir/build/shtool
108T_MD=`$php_shtool echo -n -e %B`
109T_ME=`$php_shtool echo -n -e %b`
110
111PHP_INIT_BUILD_SYSTEM
112
113dnl We want this one before the checks, so the checks can modify CFLAGS.
114test -z "$CFLAGS" && auto_cflags=1
115
116abs_srcdir=`(cd $srcdir; pwd)`
117abs_builddir=`pwd`
118
119dnl Because `make install` is often performed by the superuser, we create the
120dnl libs subdirectory as the user who configures PHP. Otherwise, the current
121dnl user will not be able to delete libs or the contents of libs.
122
123$php_shtool mkdir -p libs
124rm -f libs/*
125
126dnl Checks for programs.
127dnl ----------------------------------------------------------------------------
128
129PKG_PROG_PKG_CONFIG
130AC_PROG_CC([cc gcc])
131PHP_DETECT_ICC
132PHP_DETECT_SUNCC
133
134dnl AC_PROG_CC_C99 is obsolete with autoconf >= 2.70 yet necessary for <= 2.69.
135m4_version_prereq([2.70],,[AC_PROG_CC_C99])
136AC_PROG_CPP
137AC_USE_SYSTEM_EXTENSIONS
138AC_PROG_LN_S
139
140if test "$cross_compiling" = yes ; then
141  AC_MSG_CHECKING(for native build C compiler)
142  AC_CHECK_PROGS(BUILD_CC, [gcc clang c99 c89 cc cl],none)
143  AC_MSG_RESULT($BUILD_CC)
144else
145  BUILD_CC=$CC
146fi
147
148dnl Support systems with system libraries in e.g. /usr/lib64.
149PHP_ARG_WITH([libdir],
150  [for system library directory],
151  [AS_HELP_STRING([--with-libdir=NAME],
152    [Look for libraries in .../NAME rather than .../lib])],
153  [lib],
154  [no])
155
156PHP_ARG_ENABLE([rpath],
157  [whether to enable runpaths],
158  [AS_HELP_STRING([--disable-rpath],
159    [Disable passing additional runtime library search paths])],
160  [yes],
161  [no])
162
163dnl Check for -R, etc. switch.
164PHP_RUNPATH_SWITCH
165
166dnl Checks for some support/generator progs.
167PHP_PROG_AWK
168PHP_PROG_BISON([3.0.0])
169PHP_PROG_RE2C([1.0.3])
170PHP_PROG_PHP()
171
172PHP_ARG_ENABLE([re2c-cgoto],
173  [whether to enable computed goto gcc extension with re2c],
174  [AS_HELP_STRING([--enable-re2c-cgoto],
175    [Enable -g flag to re2c to use computed goto gcc extension])],
176  [no],
177  [no])
178
179if test "$PHP_RE2C_CGOTO" = "no"; then
180  RE2C_FLAGS=""
181else
182  AC_MSG_CHECKING([whether re2c -g works])
183  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
184int main(int argc, const char **argv)
185{
186  argc = argc;
187  argv = argv;
188label1:
189label2:
190  static void *adr[] = { &&label1, &&label2};
191  goto *adr[0];
192  return 0;
193}
194  ]])],[
195    RE2C_FLAGS=""
196    AC_MSG_RESULT([no])
197  ],[
198    RE2C_FLAGS="-g"
199    AC_MSG_RESULT([yes])
200  ])
201fi
202PHP_SUBST(RE2C_FLAGS)
203
204dnl Platform-specific compile settings.
205dnl ----------------------------------------------------------------------------
206
207dnl See bug #28605
208case $host_cpu in
209  alpha*)
210    if test "$GCC" = "yes"; then
211      CFLAGS="$CFLAGS -mieee"
212    else
213      CFLAGS="$CFLAGS -ieee"
214    fi
215    ;;
216  sparc*)
217    if test "$SUNCC" = "yes"; then
218      CFLAGS="$CFLAGS -xmemalign=8s"
219    fi
220    ;;
221esac
222
223dnl Mark symbols hidden by default if the compiler (for example, gcc >= 4)
224dnl supports it. This can help reduce the binary size and startup time.
225AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],
226                       [CFLAGS="$CFLAGS -fvisibility=hidden"])
227
228case $host_alias in
229  *solaris*)
230    CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
231    ;;
232  *hpux*)
233    if test "$GCC" = "yes"; then
234      CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
235    fi
236    ;;
237esac
238
239dnl Disable PIC mode by default where it is known to be safe to do so, to avoid
240dnl the performance hit from the lost register.
241AC_MSG_CHECKING([whether to force non-PIC code in shared modules])
242case $host_alias in
243  i?86-*-linux*|i?86-*-freebsd*)
244    if test "${with_pic+set}" != "set" || test "$with_pic" = "no"; then
245      with_pic=no
246      AC_MSG_RESULT(yes)
247    else
248      AC_MSG_RESULT(no)
249    fi
250    ;;
251  *)
252    AC_MSG_RESULT(no)
253    ;;
254esac
255
256dnl Detect musl libc
257AC_MSG_CHECKING([whether we are using musl libc])
258if command -v ldd >/dev/null && ldd --version 2>&1 | grep -q ^musl
259then
260  AC_MSG_RESULT(yes)
261  AC_DEFINE([__MUSL__], [1], [Define when using musl libc])
262else
263  AC_MSG_RESULT(no)
264fi
265
266dnl The effect of _GNU_SOURCE defined in config.h depeds on includes order
267if test "$ac_cv_safe_to_define___extensions__" = yes ; then
268  AC_MSG_CHECKING(whether to use -D_GNU_SOURCE cflag)
269  CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
270  AC_MSG_RESULT(yes)
271fi
272
273dnl Include Zend configurations.
274dnl ----------------------------------------------------------------------------
275
276sinclude(Zend/Zend.m4)
277
278dnl ----------------------------------------------------------------------------
279
280PTHREADS_CHECK
281PHP_HELP_SEPARATOR([SAPI modules:])
282PHP_SHLIB_SUFFIX_NAMES
283PHP_BUILD_PROGRAM
284PHP_SAPI=none
285
286dnl SAPI configuration.
287dnl ----------------------------------------------------------------------------
288
289dnl Paths to the targets are relative to the build directory.
290SAPI_LIBNAME=libphp
291SAPI_LIBNAME_SHARED=$SAPI_LIBNAME.[]$SHLIB_DL_SUFFIX_NAME
292SAPI_LIBNAME_STATIC=$SAPI_LIBNAME.a
293SAPI_SHARED=libs/$SAPI_LIBNAME_SHARED
294SAPI_STATIC=libs/$SAPI_LIBNAME_STATIC
295SAPI_LIBTOOL=libphp.la
296
297PHP_CONFIGURE_PART(Configuring SAPI modules)
298
299esyscmd(./build/config-stubs sapi)
300
301dnl Show which main SAPI was selected.
302AC_MSG_CHECKING([for chosen SAPI module])
303AC_MSG_RESULT([$PHP_SAPI])
304
305dnl Show which binaries were selected.
306AC_MSG_CHECKING([for executable SAPI binaries])
307if test "$PHP_BINARIES"; then
308  AC_MSG_RESULT([$PHP_BINARIES])
309else
310  AC_MSG_RESULT([none])
311fi
312
313dnl Exit early.
314if test -z "$PHP_INSTALLED_SAPIS"; then
315  AC_MSG_ERROR([Nothing to build.])
316fi
317
318dnl Force ZTS.
319if test "$enable_zts" = "yes"; then
320  dnl Add pthreads linker and compiler flags.
321  if test -n "$ac_cv_pthreads_lib"; then
322    LIBS="$LIBS -l$ac_cv_pthreads_lib"
323  fi
324  if test -n "$ac_cv_pthreads_cflags"; then
325    CFLAGS="$CFLAGS $ac_cv_pthreads_cflags"
326  fi
327
328  PTHREADS_FLAGS
329fi
330
331dnl Starting system checks.
332dnl ----------------------------------------------------------------------------
333
334PHP_CONFIGURE_PART(Running system checks)
335
336dnl Find sendmail binary.
337PHP_PROG_SENDMAIL
338
339dnl Check whether the system uses EBCDIC (not ASCII) as its native codeset.
340PHP_EBCDIC
341
342dnl Check whether the system byte ordering is bigendian.
343PHP_C_BIGENDIAN
344
345dnl Check whether writing to stdout works.
346PHP_TEST_WRITE_STDOUT
347
348dnl Check for /usr/pkg/{lib,include} which is where NetBSD puts binary and
349dnl source packages. This should be harmless on other OSs.
350if test -d /usr/pkg/include && test -d /usr/pkg/lib; then
351   CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
352   LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
353fi
354test -d /usr/ucblib && PHP_ADD_LIBPATH(/usr/ucblib)
355
356dnl First, library checks.
357dnl ----------------------------------------------------------------------------
358
359dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try to avoid -lnsl
360dnl checks, if we already have the functions which are usually in libnsl. Also,
361dnl uClibc will bark at linking with glibc's libnsl.
362
363AC_SEARCH_LIBS([socket], [socket network])
364PHP_CHECK_FUNC(socketpair, socket, network)
365PHP_CHECK_FUNC(gethostname, nsl, network)
366PHP_CHECK_FUNC(gethostbyaddr, nsl, network)
367AC_SEARCH_LIBS([dlopen], [dl],
368  [AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if the dl library is available.])])
369AC_SEARCH_LIBS([sin], [m])
370
371case $host_alias in
372  riscv64*)
373    PHP_CHECK_FUNC(__atomic_exchange_1, atomic)
374    ;;
375esac
376
377dnl Solaris/Illumos for process mapping.
378AC_SEARCH_LIBS([Pgrab], [proc])
379
380dnl Haiku does not have network api in libc.
381AC_SEARCH_LIBS([setsockopt], [network])
382
383dnl Then headers.
384dnl ----------------------------------------------------------------------------
385
386dnl QNX requires unix.h to allow functions in libunix to work properly.
387AC_CHECK_HEADERS([ \
388dirent.h \
389sys/param.h \
390sys/types.h \
391sys/time.h \
392netinet/in.h \
393alloca.h \
394arpa/inet.h \
395arpa/nameser.h \
396dns.h \
397fcntl.h \
398grp.h \
399ieeefp.h \
400langinfo.h \
401linux/sock_diag.h \
402os/signpost.h \
403poll.h \
404pty.h \
405pwd.h \
406resolv.h \
407strings.h \
408syslog.h \
409sysexits.h \
410sys/ioctl.h \
411sys/file.h \
412sys/mman.h \
413sys/mount.h \
414sys/poll.h \
415sys/resource.h \
416sys/select.h \
417sys/socket.h \
418sys/stat.h \
419sys/statfs.h \
420sys/statvfs.h \
421sys/vfs.h \
422sys/sysexits.h \
423sys/uio.h \
424sys/wait.h \
425sys/loadavg.h \
426unistd.h \
427unix.h \
428utime.h \
429sys/utsname.h \
430sys/ipc.h \
431dlfcn.h \
432tmmintrin.h \
433nmmintrin.h \
434wmmintrin.h \
435immintrin.h
436],[],[],[
437#ifdef HAVE_SYS_PARAM_H
438#include <sys/param.h>
439#endif
440#ifdef HAVE_SYS_TYPES_H
441#include <sys/types.h>
442#endif
443#ifdef HAVE_SYS_TIME_H
444#include <sys/time.h>
445#endif
446#ifdef HAVE_NETINET_IN_H
447#include <netinet/in.h>
448#endif
449#ifdef HAVE_ARPA_NAMESER_H
450#include <arpa/nameser.h>
451#endif
452])
453
454PHP_FOPENCOOKIE
455PHP_BROKEN_GETCWD
456if test "$GCC" = "yes"; then
457  PHP_BROKEN_GCC_STRLEN_OPT
458fi
459
460dnl Detect the headers required to use makedev, major, and minor.
461dnl Autoconf <= 2.69 didn't check glibc 2.25 deprecated macros in sys/types.h.
462m4_version_prereq([2.70],,[ac_cv_header_sys_types_h_makedev=no])
463AC_HEADER_MAJOR
464
465dnl Checks for typedefs, structures, and compiler characteristics.
466dnl ----------------------------------------------------------------------------
467
468AC_STRUCT_TIMEZONE
469
470PHP_MISSING_TIME_R_DECL
471
472AC_CHECK_TYPES([struct flock],,,[#include <fcntl.h>])
473AC_CHECK_TYPES(socklen_t, [], [], [
474  #ifdef HAVE_SYS_TYPES_H
475  # include <sys/types.h>
476  #endif
477  #ifdef HAVE_SYS_SOCKET_H
478  # include <sys/socket.h>
479  #endif
480])
481
482dnl These are defined elsewhere than stdio.h.
483PHP_CHECK_SIZEOF(intmax_t, 0)
484PHP_CHECK_SIZEOF(ssize_t, 8)
485PHP_CHECK_SIZEOF(ptrdiff_t, 8)
486
487dnl Check stdint types (must be after header check).
488PHP_CHECK_STDINT_TYPES
489
490dnl Check __builtin_expect
491PHP_CHECK_BUILTIN_EXPECT
492dnl Check __builtin_unreachable
493PHP_CHECK_BUILTIN_UNREACHABLE
494dnl Check __builtin_clz
495PHP_CHECK_BUILTIN_CLZ
496dnl Check __builtin_clzl
497PHP_CHECK_BUILTIN_CLZL
498dnl Check __builtin_clzll
499PHP_CHECK_BUILTIN_CLZLL
500dnl Check __builtin_ctzl
501PHP_CHECK_BUILTIN_CTZL
502dnl Check __builtin_ctzll
503PHP_CHECK_BUILTIN_CTZLL
504dnl Check __builtin_smull_overflow
505PHP_CHECK_BUILTIN_SMULL_OVERFLOW
506dnl Check __builtin_smulll_overflow
507PHP_CHECK_BUILTIN_SMULLL_OVERFLOW
508dnl Check __builtin_saddl_overflow
509PHP_CHECK_BUILTIN_SADDL_OVERFLOW
510dnl Check __builtin_saddll_overflow
511PHP_CHECK_BUILTIN_SADDLL_OVERFLOW
512dnl Check __builtin_usub_overflow
513PHP_CHECK_BUILTIN_USUB_OVERFLOW
514dnl Check __builtin_ssubl_overflow
515PHP_CHECK_BUILTIN_SSUBL_OVERFLOW
516dnl Check __builtin_ssubll_overflow
517PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW
518dnl Check __builtin_cpu_init
519PHP_CHECK_BUILTIN_CPU_INIT
520dnl Check __builtin_cpu_supports
521PHP_CHECK_BUILTIN_CPU_SUPPORTS
522dnl Check __builtin_frame_address
523PHP_CHECK_BUILTIN_FRAME_ADDRESS
524dnl Check AVX512
525PHP_CHECK_AVX512_SUPPORTS
526dnl Check AVX512 VBMI
527PHP_CHECK_AVX512_VBMI_SUPPORTS
528
529dnl Check for __alignof__ support in the compiler
530AC_CACHE_CHECK(whether the compiler supports __alignof__, ac_cv_alignof_exists,[
531AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
532]],[[
533  int align = __alignof__(int);
534]])],[
535  ac_cv_alignof_exists=yes
536],[
537  ac_cv_alignof_exists=no
538])])
539if test "$ac_cv_alignof_exists" = "yes"; then
540  AC_DEFINE([HAVE_ALIGNOF], 1, [whether the compiler supports __alignof__])
541fi
542
543dnl Check for structure members.
544AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
545AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev])
546dnl AC_STRUCT_ST_BLOCKS will screw QNX because fileblocks.o does not exist.
547if test "`uname -s 2>/dev/null`" != "QNX"; then
548  AC_STRUCT_ST_BLOCKS
549fi
550
551dnl Checks for types.
552AC_TYPE_UID_T
553
554dnl Checks for sockaddr_storage and sockaddr.sa_len.
555AC_CHECK_TYPES([struct sockaddr_storage],,,[#include <sys/socket.h>])
556AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[#include <sys/socket.h>])
557
558dnl Checks for GCC function attributes on all systems except ones without glibc
559dnl Fix for these systems is already included in GCC 7, but not on GCC 6.
560dnl
561dnl At least some versions of FreeBSD seem to have buggy ifunc support, see
562dnl bug #77284. Conservatively don't use ifuncs on FreeBSD prior to version 12.
563AS_CASE([$host_alias], [*-*-*android*|*-*-*uclibc*|*-*-*musl*|*openbsd*], [true], [
564  if test "`uname -s 2>/dev/null`" != "FreeBSD" || test "`uname -U 2>/dev/null`" -ge 1200000; then
565    AX_GCC_FUNC_ATTRIBUTE([ifunc])
566    AX_GCC_FUNC_ATTRIBUTE([target])
567  fi
568])
569
570dnl Check for IPv6 support.
571AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support,
572[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
573#include <sys/socket.h>
574#include <netinet/in.h>]], [[struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;]])],
575  [ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])])
576
577dnl Checks for library functions.
578dnl ----------------------------------------------------------------------------
579
580AC_CHECK_FUNCS(
581alphasort \
582asctime_r \
583chroot \
584ctime_r \
585explicit_memset \
586fdatasync \
587flock \
588ftok \
589funopen \
590gai_strerror \
591getcwd \
592getloadavg \
593getlogin \
594getprotobyname \
595getprotobynumber \
596getservbyname \
597getservbyport \
598getrusage \
599gettimeofday \
600gmtime_r \
601getpwnam_r \
602getgrnam_r \
603getpwuid_r \
604getwd \
605glob \
606localtime_r \
607lchown \
608memcntl \
609memfd_create \
610mkstemp \
611mmap \
612nice \
613nl_langinfo \
614poll \
615pthread_jit_write_protect_np \
616putenv \
617scandir \
618setitimer \
619setenv \
620shutdown \
621sigprocmask \
622statfs \
623statvfs \
624std_syslog \
625strcasecmp \
626strnlen \
627strptime \
628strtok_r \
629symlink \
630tzset \
631unsetenv \
632usleep \
633utime \
634vasprintf \
635asprintf \
636memmem \
637memrchr \
638mempcpy \
639)
640
641AC_CHECK_FUNC([inet_ntop],,[AC_MSG_ERROR([Required inet_ntop not found.])])
642AC_CHECK_FUNC([inet_pton],,[AC_MSG_ERROR([Required inet_pton not found.])])
643
644dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version.
645AC_FUNC_STRERROR_R
646
647dnl Check for functions inside their belonging headers.
648AC_CHECK_HEADER([sys/prctl.h], [AC_CHECK_FUNCS([prctl])])
649AC_CHECK_HEADER([sys/procctl.h], [AC_CHECK_FUNCS([procctl])])
650
651AX_FUNC_WHICH_GETHOSTBYNAME_R
652
653dnl Some systems (Solaris 10) do not have nanosleep in libc.
654AC_CHECK_FUNCS([nanosleep],,
655  [AC_SEARCH_LIBS([nanosleep], [rt], [AC_DEFINE([HAVE_NANOSLEEP], [1])])])
656
657dnl Check for getaddrinfo, should be a better way, but... Also check for working
658dnl getaddrinfo.
659AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo,
660[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
661  [[struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);]])],[AC_RUN_IFELSE([AC_LANG_SOURCE([[
662#include <netdb.h>
663#include <sys/types.h>
664#include <string.h>
665#include <stdlib.h>
666#ifndef AF_INET
667# include <sys/socket.h>
668#endif
669int main(void) {
670  struct addrinfo *ai, *pai, hints;
671
672  memset(&hints, 0, sizeof(hints));
673  hints.ai_flags = AI_NUMERICHOST;
674
675  if (getaddrinfo("127.0.0.1", 0, &hints, &ai) < 0) {
676    return 1;
677  }
678
679  if (ai == 0) {
680    return 1;
681  }
682
683  pai = ai;
684
685  while (pai) {
686    if (pai->ai_family != AF_INET) {
687      /* 127.0.0.1/NUMERICHOST should only resolve ONE way */
688      return 1;
689    }
690    if (pai->ai_addr->sa_family != AF_INET) {
691      /* 127.0.0.1/NUMERICHOST should only resolve ONE way */
692      return 1;
693    }
694    pai = pai->ai_next;
695  }
696  freeaddrinfo(ai);
697  return 0;
698}
699  ]])],[ac_cv_func_getaddrinfo=yes], [ac_cv_func_getaddrinfo=no], [
700    dnl Cross compilation.
701    case $host_alias in
702      *linux*)
703        ac_cv_func_getaddrinfo=yes
704        ;;
705      *)
706        ac_cv_func_getaddrinfo=no
707        ;;
708    esac
709  ])],
710[ac_cv_func_getaddrinfo=no])])
711if test "$ac_cv_func_getaddrinfo" = yes; then
712  AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
713fi
714
715dnl on FreeBSD, copy_file_range() works only with the undocumented flag 0x01000000;
716dnl until the problem is fixed properly, copy_file_range() is used only on Linux
717AC_CACHE_CHECK([for copy_file_range], ac_cv_copy_file_range,
718[AC_RUN_IFELSE([AC_LANG_SOURCE([[
719#ifdef __linux__
720#ifndef _GNU_SOURCE
721#define _GNU_SOURCE
722#endif
723#include <linux/version.h>
724#include <unistd.h>
725
726int main(void) {
727(void)copy_file_range(-1, 0, -1, 0, 0, 0);
728#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
729#error "kernel too old"
730#else
731return 0;
732#endif
733}
734#else
735#error "unsupported platform"
736#endif
737]])], [ac_cv_copy_file_range=yes], [ac_cv_copy_file_range=no], [ac_cv_copy_file_range=no])
738])
739
740if test "$ac_cv_copy_file_range" = yes; then
741  AC_DEFINE(HAVE_COPY_FILE_RANGE,1,[Define if copy_file_range support])
742fi
743
744AC_REPLACE_FUNCS(strlcat strlcpy explicit_bzero getopt)
745AC_FUNC_ALLOCA
746PHP_TIME_R_TYPE
747
748AC_CACHE_CHECK([for aarch64 CRC32 API], ac_cv_func___crc32d,
749[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <arm_acle.h>]],[[__crc32d(0, 0);]])],[ac_cv_func___crc32d=yes],[ac_cv_func___crc32d="no"])])
750if test "$ac_cv_func___crc32d" = "yes"; then
751  AC_DEFINE([HAVE_AARCH64_CRC32], [1], [Define when aarch64 CRC32 API is available.])
752fi
753
754dnl Check for asm goto support.
755AC_CACHE_CHECK([for asm goto], [ac_cv__asm_goto],
756[AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[
757#if defined(__x86_64__) || defined(__i386__)
758    __asm__ goto("jmp %l0\n" :::: end);
759#elif defined(__aarch64__)
760    __asm__ goto("b %l0\n" :::: end);
761#endif
762end:
763    return 0;
764]])], [ac_cv__asm_goto=yes], [ac_cv__asm_goto=no])])
765if test "$ac_cv__asm_goto" = yes; then
766  AC_DEFINE([HAVE_ASM_GOTO], [1], [Define if asm goto support is available.])
767fi
768
769dnl Check valgrind support.
770PHP_ARG_WITH([valgrind],
771  [whether to enable valgrind support],
772  [AS_HELP_STRING([--with-valgrind],
773    [Enable valgrind support])],
774  [no],
775  [no])
776
777if test "$PHP_VALGRIND" != "no"; then
778  PKG_CHECK_MODULES([VALGRIND], [valgrind], [have_valgrind="yes"], [have_valgrind="no"])
779
780  if test "$have_valgrind" = "yes"; then
781    PHP_EVAL_INCLINE($VALGRIND_CFLAGS)
782    AC_DEFINE(HAVE_VALGRIND, 1, [ ])
783  else
784    if test "$with_valgrind" = "yes"; then
785      AC_MSG_ERROR([Valgrind not found. Please install Valgrind.])
786    fi
787  fi
788fi
789
790dnl Check for openpty. It may require linking against libutil or libbsd.
791AC_CHECK_FUNCS([openpty],,
792  [AC_SEARCH_LIBS([openpty], [util bsd], [AC_DEFINE([HAVE_OPENPTY], [1])])])
793
794dnl General settings.
795dnl ----------------------------------------------------------------------------
796PHP_CONFIGURE_PART(General settings)
797
798PHP_HELP_SEPARATOR([General settings:])
799
800PHP_ARG_ENABLE([gcov],
801  [whether to include gcov symbols],
802  [AS_HELP_STRING([--enable-gcov],
803    [Enable GCOV code coverage - FOR DEVELOPERS ONLY!!])],
804  [no],
805  [no])
806
807if test "$PHP_GCOV" = "yes"; then
808
809  if test "$GCC" != "yes"; then
810    AC_MSG_ERROR([GCC is required for --enable-gcov])
811  fi
812
813  dnl Check if ccache is being used.
814  case `$php_shtool path $CC` in
815    *ccache*[)] gcc_ccache=yes;;
816    *[)] gcc_ccache=no;;
817  esac
818
819  if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
820    AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
821  fi
822
823  AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov])
824  PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/build/Makefile.gcov, $abs_srcdir)
825
826  dnl Remove all optimization flags from CFLAGS.
827  changequote({,})
828  CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
829  CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
830  changequote([,])
831
832  dnl Add the special gcc flags.
833  CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
834  CXXFLAGS="$CXXFLAGS -O0 -fprofile-arcs -ftest-coverage"
835fi
836
837PHP_ARG_ENABLE([debug],
838  [whether to include debugging symbols],
839  [AS_HELP_STRING([--enable-debug],
840    [Compile with debugging symbols])],
841  [no],
842  [no])
843
844if test "$PHP_DEBUG" = "yes"; then
845  PHP_DEBUG=1
846  ZEND_DEBUG=yes
847  changequote({,})
848  CFLAGS=`echo "$CFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
849  CXXFLAGS=`echo "$CXXFLAGS" | "${SED}" -e 's/-O[0-9s]*//g'`
850  changequote([,])
851  dnl Add -O0 only if GCC or ICC is used.
852  if test "$GCC" = "yes" || test "$ICC" = "yes"; then
853    CFLAGS="$CFLAGS -O0"
854    CXXFLAGS="$CXXFLAGS -g -O0"
855  fi
856  if test "$SUNCC" = "yes"; then
857    if test -n "$auto_cflags"; then
858      CFLAGS="-g"
859      CXXFLAGS="-g"
860    else
861      CFLAGS="$CFLAGS -g"
862      CXXFLAGS="$CFLAGS -g"
863    fi
864  fi
865else
866  PHP_DEBUG=0
867  ZEND_DEBUG=no
868fi
869
870PHP_ARG_ENABLE([debug-assertions],
871  [whether to enable debug assertions in release mode],
872  [AS_HELP_STRING([--enable-debug-assertions],
873    [Compile with debug assertions even in release mode])],
874  [no],
875  [no])
876
877if test "$PHP_DEBUG_ASSERTIONS" = "yes"; then
878  PHP_DEBUG=1
879  ZEND_DEBUG=yes
880fi
881
882AC_ARG_ENABLE([zts],
883  [AS_HELP_STRING([--enable-zts],
884    [Enable thread safety])],
885  [ZEND_ZTS=$enableval],
886  [ZEND_ZTS=no])
887
888if test "$ZEND_ZTS" = "yes"; then
889  AC_DEFINE(ZTS, 1,[ ])
890  PHP_THREAD_SAFETY=yes
891else
892  PHP_THREAD_SAFETY=no
893fi
894
895PHP_ARG_ENABLE([rtld-now],
896  [whether to dlopen extensions with RTLD_NOW instead of RTLD_LAZY],
897  [AS_HELP_STRING([--enable-rtld-now],
898    [Use dlopen with RTLD_NOW instead of RTLD_LAZY])],
899  [no],
900  [no])
901
902if test "$PHP_RTLD_NOW" = "yes"; then
903  AC_DEFINE(PHP_USE_RTLD_NOW, 1, [ Use dlopen with RTLD_NOW instead of RTLD_LAZY ])
904fi
905
906PHP_ARG_WITH([layout],
907  [layout of installed files],
908  [AS_HELP_STRING([--with-layout=TYPE],
909    [Set how installed files will be laid out. Type can be either PHP or GNU [PHP]])],
910  [PHP],
911  [no])
912
913case $PHP_LAYOUT in
914  GNU)
915    oldstyleextdir=no
916    ;;
917  *)
918    oldstyleextdir=yes
919    ;;
920esac
921
922PHP_ARG_WITH([config-file-path],
923  [path to configuration file],
924  [AS_HELP_STRING([--with-config-file-path=PATH],
925    [Set the path in which to look for php.ini [PREFIX/lib]])],
926  [DEFAULT],
927  [no])
928
929if test "$PHP_CONFIG_FILE_PATH" = "DEFAULT"; then
930  case $PHP_LAYOUT in
931    GNU)
932      PHP_CONFIG_FILE_PATH=$sysconfdir
933      ;;
934    *)
935      PHP_CONFIG_FILE_PATH=$libdir
936      ;;
937  esac
938fi
939
940AC_MSG_CHECKING([where to scan for configuration files])
941PHP_ARG_WITH([config-file-scan-dir],,
942  [AS_HELP_STRING([--with-config-file-scan-dir=PATH],
943    [Set the path where to scan for configuration files])],
944  [DEFAULT],
945  [no])
946
947if test "$PHP_CONFIG_FILE_SCAN_DIR" = "DEFAULT"; then
948  PHP_CONFIG_FILE_SCAN_DIR=
949fi
950AC_MSG_RESULT([$PHP_CONFIG_FILE_SCAN_DIR])
951
952test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
953
954PHP_ARG_ENABLE([sigchild],
955  [whether to enable PHP's own SIGCHLD handler],
956  [AS_HELP_STRING([--enable-sigchild],
957    [Enable PHP's own SIGCHLD handler])],
958  [no],
959  [no])
960
961if test "$PHP_SIGCHILD" = "yes"; then
962  AC_DEFINE(PHP_SIGCHILD, 1, [ ])
963else
964  AC_DEFINE(PHP_SIGCHILD, 0, [ ])
965fi
966
967PHP_ARG_ENABLE([libgcc],
968  [whether to explicitly link against libgcc],
969  [AS_HELP_STRING([--enable-libgcc],
970    [Enable explicitly linking against libgcc])],
971  [no],
972  [no])
973
974if test "$PHP_LIBGCC" = "yes"; then
975  PHP_LIBGCC_LIBPATH(gcc)
976  if test -z "$libgcc_libpath"; then
977    AC_MSG_ERROR([Cannot locate libgcc. Make sure that gcc is in your path])
978  fi
979  PHP_ADD_LIBPATH($libgcc_libpath)
980  PHP_ADD_LIBRARY(gcc, yes)
981fi
982
983PHP_ARG_ENABLE([short-tags],
984  [whether to enable short tags by default],
985  [AS_HELP_STRING([--disable-short-tags],
986    [Disable the short-form <? start tag by default])],
987  [yes],
988  [no])
989
990if test "$PHP_SHORT_TAGS" = "yes"; then
991  AC_DEFINE(DEFAULT_SHORT_OPEN_TAG, "1", [ ])
992else
993  AC_DEFINE(DEFAULT_SHORT_OPEN_TAG, "0", [ ])
994fi
995
996PHP_ARG_ENABLE([dmalloc],
997  [whether to enable dmalloc],
998  [AS_HELP_STRING([--enable-dmalloc],
999    [Enable dmalloc])],
1000  [no],
1001  [no])
1002
1003if test "$PHP_DMALLOC" = "yes"; then
1004  AC_CHECK_LIB(dmalloc, dmalloc_error, [
1005    PHP_ADD_LIBRARY(dmalloc)
1006    AC_DEFINE(HAVE_DMALLOC,1,[Whether you have dmalloc])
1007    CPPFLAGS="$CPPFLAGS -DDMALLOC_FUNC_CHECK"
1008  ], [
1009    AC_MSG_ERROR([Problem with enabling dmalloc. Please check config.log for details.])
1010  ])
1011fi
1012
1013PHP_ARG_ENABLE([ipv6],
1014  [whether to enable IPv6 support],
1015  [AS_HELP_STRING([--disable-ipv6],
1016    [Disable IPv6 support])],
1017  [yes],
1018  [no])
1019
1020if test "$PHP_IPV6" != "no" && test "$ac_cv_ipv6_support" = yes; then
1021  AC_DEFINE(HAVE_IPV6, 1, [Whether to enable IPv6 support])
1022fi
1023
1024dnl DTRACE checks. Note: this has to be done after SAPI configuration.
1025PHP_ARG_ENABLE([dtrace],
1026  [whether to enable DTrace support],
1027  [AS_HELP_STRING([--enable-dtrace],
1028    [Enable DTrace support])],
1029  [no],
1030  [no])
1031
1032if test "$PHP_DTRACE" = "yes"; then
1033  AC_CHECK_HEADER([sys/sdt.h], [
1034    PHP_INIT_DTRACE([Zend/zend_dtrace.d],[Zend/zend_dtrace_gen.h],[main/main.c Zend/zend_API.c \
1035      Zend/zend_execute.c Zend/zend_exceptions.c \
1036      Zend/zend_dtrace.c Zend/zend.c])
1037    AC_DEFINE(HAVE_DTRACE, 1, [Whether to enable DTrace support])
1038    PHP_SUBST(PHP_DTRACE_OBJS)
1039  ], [
1040    AC_MSG_ERROR([Cannot find sys/sdt.h which is required for DTrace support])
1041  ])
1042fi
1043
1044AC_MSG_CHECKING([how big to make fd sets])
1045PHP_ARG_ENABLE([fd-setsize],,
1046  [AS_HELP_STRING([--enable-fd-setsize],
1047    [Set size of descriptor sets])],
1048  [no],
1049  [no])
1050
1051if test "$PHP_FD_SETSIZE" != "no"; then
1052  if test "0$PHP_FD_SETSIZE" -gt 0 2>/dev/null; then
1053    CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=$PHP_FD_SETSIZE"
1054    AC_MSG_RESULT([using $PHP_FD_SETSIZE])
1055  else
1056    AC_MSG_ERROR([Invalid value passed to --enable-fd-setsize!])
1057  fi
1058else
1059  AC_MSG_RESULT([using system default])
1060fi
1061
1062PHP_ARG_ENABLE([werror],,
1063  [AS_HELP_STRING([--enable-werror],
1064    [Enable -Werror])],
1065  [no],
1066  [no])
1067PHP_ARG_ENABLE([memory-sanitizer],,
1068  [AS_HELP_STRING([--enable-memory-sanitizer],
1069    [Enable memory sanitizer (clang only)])],
1070  [no],
1071  [no])
1072PHP_ARG_ENABLE([address-sanitizer],,
1073  [AS_HELP_STRING([--enable-address-sanitizer],
1074    [Enable address sanitizer])],
1075  [no],
1076  [no])
1077PHP_ARG_ENABLE([undefined-sanitizer],,
1078  [AS_HELP_STRING([--enable-undefined-sanitizer],
1079    [Enable undefined sanitizer])],
1080  [no],
1081  [no])
1082
1083dnl Extension configuration.
1084dnl ----------------------------------------------------------------------------
1085
1086PHP_HELP_SEPARATOR([Extensions:
1087
1088  --with-EXTENSION=[shared[,PATH]]
1089
1090    NOTE: Not all extensions can be built as 'shared'.
1091
1092    Example: --with-foobar=shared,/usr/local/foobar/
1093
1094      o Builds the foobar extension as shared extension.
1095      o foobar package install prefix is /usr/local/foobar/
1096])
1097
1098PHP_CONFIGURE_PART(Configuring extensions)
1099
1100dnl Check if all enabled by default extensions should be disabled.
1101AC_ARG_ENABLE([all],
1102  [AS_HELP_STRING([--disable-all],
1103    [Disable all extensions which are enabled by default])],
1104  [PHP_ENABLE_ALL=$enableval])
1105
1106dnl Reading config stubs.
1107esyscmd(./build/config-stubs ext)
1108
1109dnl Extensions post-config.
1110dnl ----------------------------------------------------------------------------
1111
1112dnl Align segments on huge page boundary
1113case $host_alias in
1114  i[[3456]]86-*-linux-* | x86_64-*-linux-*)
1115	AC_MSG_CHECKING(linker support for -zcommon-page-size=2097152)
1116    save_LDFLAGS=$LDFLAGS
1117    LDFLAGS="$LDFLAGS -Wl,-zcommon-page-size=2097152 -Wl,-zmax-page-size=2097152"
1118    AC_RUN_IFELSE(
1119        [AC_LANG_PROGRAM()],
1120        [ac_cv_common_page_size=yes],
1121        [ac_cv_common_page_size=no],
1122        [ac_cv_common_page_size=no])
1123    LDFLAGS=$save_LDFLAGS
1124    if test "$ac_cv_common_page_size" = "yes"; then
1125        AC_MSG_RESULT([yes])
1126        EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM -Wl,-zcommon-page-size=2097152 -Wl,-zmax-page-size=2097152"
1127    else
1128        AC_MSG_RESULT([no])
1129        AC_MSG_CHECKING(linker support for -zmax-page-size=2097152)
1130        save_LDFLAGS=$LDFLAGS
1131        LDFLAGS="$LDFLAGS -Wl,-zmax-page-size=2097152"
1132        AC_RUN_IFELSE(
1133            [AC_LANG_PROGRAM()],
1134            [ac_cv_max_page_size=yes],
1135            [ac_cv_max_page_size=no],
1136            [ac_cv_max_page_size=no])
1137        LDFLAGS=$save_LDFLAGS
1138        if test "$ac_cv_max_page_size" = "yes"; then
1139            AC_MSG_RESULT([yes])
1140            EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM -Wl,-zmax-page-size=2097152"
1141        else
1142            AC_MSG_RESULT([no])
1143        fi
1144    fi
1145    ;;
1146esac
1147
1148enable_shared=yes
1149enable_static=yes
1150
1151case $php_sapi_module in
1152  shared[)]
1153    if test "$PHP_CGI" = "no" && test "$PHP_CLI" = "no" && test "$PHP_FPM" = "no" && test "$PHP_LITESPEED" = "no" && test "$PHP_PHPDBG" = "no"; then
1154      enable_static=no
1155    fi
1156    case $with_pic in
1157      yes)
1158        standard_libtool_flag='-prefer-pic'
1159        ;;
1160      no)
1161        standard_libtool_flag='-prefer-non-pic'
1162        ;;
1163    esac
1164    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -avoid-version -module"
1165    ;;
1166  *[)]
1167    standard_libtool_flag='-prefer-non-pic -static'
1168    if test -z "$PHP_MODULES" && test -z "$PHP_ZEND_EX"; then
1169      enable_shared=no
1170    fi
1171    ;;
1172esac
1173
1174EXTRA_LIBS="$EXTRA_LIBS $DLIBS $LIBS"
1175
1176dnl This has to be here to prevent the openssl crypt() from overriding the
1177dnl system provided crypt().
1178if test "$ac_cv_lib_crypt_crypt" = "yes"; then
1179  EXTRA_LIBS="-lcrypt $EXTRA_LIBS -lcrypt"
1180fi
1181
1182unset LIBS
1183
1184dnl PEAR
1185dnl ----------------------------------------------------------------------------
1186
1187PHP_HELP_SEPARATOR([PEAR:])
1188PHP_CONFIGURE_PART(Configuring PEAR)
1189
1190dnl Compatibility
1191if test -z "$with_pear" && test "$enable_pear" = "no"; then
1192  with_pear=no
1193fi
1194
1195dnl If CLI is disabled disable PEAR.
1196if test "$PHP_CLI" = "no"; then
1197  with_pear=no
1198fi
1199
1200PHP_ARG_WITH([pear],
1201  [whether to install PEAR],
1202  [AS_HELP_STRING([[--with-pear[=DIR]]],
1203    [Install PEAR in DIR [PREFIX/lib/php]])],
1204  [no],
1205  [yes])
1206
1207if test "$PHP_PEAR" != "no"; then
1208
1209  dnl PEAR dependencies.
1210  if test "$PHP_XML" = "no"; then
1211    pear_error_msg="$pear_error_msg
1212                    PEAR requires XML to be enabled.     Add --enable-xml to the configure line. (or --without-pear)"
1213  fi
1214
1215  if test "$pear_error_msg"; then
1216    AC_MSG_ERROR([$pear_error_msg])
1217  fi
1218
1219  AC_MSG_WARN([The --with-pear option is deprecated])
1220
1221  install_pear="install-pear"
1222  PEAR_INSTALLDIR=$PHP_PEAR
1223
1224  if test "$PHP_PEAR" = "yes"; then
1225    case $PHP_LAYOUT in
1226      GNU) PEAR_INSTALLDIR=$datadir/pear;;
1227      *)   PEAR_INSTALLDIR=$libdir/php;;
1228    esac
1229  fi
1230
1231  PHP_ADD_BUILD_DIR([pear])
1232  PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/pear/Makefile.frag,$abs_srcdir/pear,pear)
1233fi
1234
1235dnl Configuring Zend and TSRM.
1236dnl ----------------------------------------------------------------------------
1237
1238PHP_HELP_SEPARATOR([Zend:])
1239PHP_CONFIGURE_PART(Configuring Zend)
1240
1241AC_ARG_ENABLE([fiber-asm],
1242  [AS_HELP_STRING([--disable-fiber-asm],
1243    [Disable the use of boost fiber assembly files])],
1244  [fiber_asm=$enableval], [fiber_asm='yes'])
1245
1246AS_CASE([$host_cpu],
1247  [x86_64*|amd64*], [fiber_cpu="x86_64"],
1248  [x86*|amd*|i?86*|pentium], [fiber_cpu="i386"],
1249  [aarch64*|arm64*], [fiber_cpu="arm64"],
1250  [arm*], [fiber_cpu="arm32"],
1251  [ppc64*|powerpc64*], [fiber_cpu="ppc64"],
1252  [ppc*|powerpc*], [fiber_cpu="ppc32"],
1253  [riscv64*], [fiber_cpu="riscv64"],
1254  [sparc64], [fiber_cpu="sparc64"],
1255  [s390x*], [fiber_cpu="s390x"],
1256  [mips64*], [fiber_cpu="mips64"],
1257  [mips*], [fiber_cpu="mips32"],
1258  [fiber_cpu="unknown"]
1259)
1260
1261AS_CASE([$host_os],
1262  [darwin*], [fiber_os="mac"],
1263  [aix*|os400*], [fiber_os="aix"],
1264  [freebsd*], [fiber_os="freebsd"],
1265  [fiber_os="other"]
1266)
1267
1268AS_CASE([$fiber_cpu],
1269  [x86_64], [fiber_asm_file_prefix="x86_64_sysv"],
1270  [i386], [fiber_asm_file_prefix="i386_sysv"],
1271  [arm64], [fiber_asm_file_prefix="arm64_aapcs"],
1272  [arm32], [fiber_asm_file_prefix="arm_aapcs"],
1273  [ppc64], [fiber_asm_file_prefix="ppc64_sysv"],
1274  [ppc32], [fiber_asm_file_prefix="ppc32_sysv"],
1275  [riscv64], [fiber_asm_file_prefix="riscv64_sysv"],
1276  [sparc64], [fiber_asm_file_prefix="sparc64_sysv"],
1277  [s390x], [fiber_asm_file_prefix="s390x_sysv"],
1278  [mips64], [fiber_asm_file_prefix="mips64_n64"],
1279  [mips32], [fiber_asm_file_prefix="mips32_o32"],
1280  [fiber_asm_file_prefix="unknown"]
1281)
1282
1283if test "$fiber_os" = 'mac'; then
1284  fiber_asm_file="combined_sysv_macho_gas"
1285elif test "$fiber_os" = 'aix'; then
1286  # AIX uses a different calling convention (shared with non-_CALL_ELF Linux).
1287  # The AIX assembler isn't GNU, but the file is compatible.
1288  fiber_asm_file="${fiber_asm_file_prefix}_xcoff_gas"
1289elif test "$fiber_os" = 'freebsd'; then
1290  case $fiber_cpu in
1291    i386*)
1292      fiber_asm="no"
1293      ;;
1294    *)
1295      fiber_asm_file="${fiber_asm_file_prefix}_elf_gas"
1296      ;;
1297  esac
1298elif test "$fiber_asm_file_prefix" != 'unknown'; then
1299  fiber_asm_file="${fiber_asm_file_prefix}_elf_gas"
1300else
1301  fiber_asm="no"
1302fi
1303
1304dnl Check whether syscall to create shadow stack exists, should be a better way, but...
1305AC_CACHE_CHECK([whether syscall to create shadow stack exists], ac_cv_syscall_shadow_stack_exists,
1306[AC_RUN_IFELSE([AC_LANG_SOURCE([[
1307#include <unistd.h>
1308#include <sys/mman.h>
1309int main(void) {
1310  /* test if syscall 451, i.e., map_shadow_stack is available */
1311  void* base = (void *)syscall(451, 0, 0x20000, 0x1);
1312  if (base != (void*)-1) {
1313    munmap(base, 0x20000);
1314    return 0;
1315  }
1316  else
1317    return 1;
1318}
1319  ]])], [ac_cv_syscall_shadow_stack_exists=yes], [ac_cv_syscall_shadow_stack_exists=no], [ac_cv_syscall_shadow_stack_exists=no])
1320])
1321if test "$ac_cv_syscall_shadow_stack_exists" = yes; then
1322  AC_DEFINE([SHADOW_STACK_SYSCALL], 1, [ ])
1323  # asm file can't see macro from AC_DEFINE, workaround this via cflag
1324  fiber_asm_cflag="-DSHADOW_STACK_SYSCALL=1"
1325  # if the syscall doesn't exist, we may block the final ELF from __PROPERTY_SHSTK
1326  # via redefine macro as "-D__CET__=1"
1327fi
1328
1329if test "$fiber_asm" = 'yes'; then
1330  AC_MSG_CHECKING([for fiber switching context])
1331  PHP_ADD_SOURCES(Zend/asm, make_${fiber_asm_file}.S jump_${fiber_asm_file}.S, "$fiber_asm_cflag")
1332  AC_MSG_RESULT([$fiber_asm_file])
1333else
1334  if test "$fiber_os" = 'mac'; then
1335    AC_DEFINE([_XOPEN_SOURCE], 1, [ ])
1336  fi
1337  AC_CHECK_HEADER(ucontext.h, [
1338    AC_DEFINE([ZEND_FIBER_UCONTEXT], 1, [ ])
1339  ], [
1340       AC_MSG_ERROR([fibers not available on this platform])
1341  ])
1342fi
1343
1344LIBZEND_BASIC_CHECKS
1345LIBZEND_DLSYM_CHECK
1346LIBZEND_OTHER_CHECKS
1347
1348INCLUDES="$INCLUDES -I\$(top_builddir)/TSRM"
1349INCLUDES="$INCLUDES -I\$(top_builddir)/Zend"
1350
1351if test "$abs_srcdir" != "$abs_builddir"; then
1352  INCLUDES="$INCLUDES -I\$(top_srcdir)/main -I\$(top_srcdir)/Zend"
1353  INCLUDES="$INCLUDES -I\$(top_srcdir)/TSRM -I\$(top_builddir)/"
1354fi
1355
1356ZEND_EXTRA_LIBS="$LIBS"
1357unset LIBS
1358
1359PHP_CONFIGURE_PART(Configuring TSRM)
1360if test "$PHP_THREAD_SAFETY" = "yes"; then
1361  TSRM_CHECK_PTHREADS
1362fi
1363
1364EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LDFLAGS"
1365EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $LDFLAGS"
1366EXTRA_LIBS="$EXTRA_LIBS $LIBS"
1367unset LIBS LDFLAGS
1368
1369AC_ARG_PROGRAM
1370
1371test "$prefix" = "NONE" && prefix=/usr/local
1372test "$exec_prefix" = "NONE" && exec_prefix='${prefix}'
1373test "$program_prefix" = "NONE" && program_prefix=
1374test "$program_suffix" = "NONE" && program_suffix=
1375
1376orig_libdir=$libdir
1377case $libdir in
1378  '${exec_prefix}/lib')
1379    libdir=$libdir/php
1380    ;;
1381esac
1382case `eval echo $datadir` in
1383  '${prefix}/share')
1384    datadir=$datadir/php
1385    ;;
1386esac
1387
1388phptempdir=`pwd`/libs
1389
1390old_exec_prefix=$exec_prefix
1391old_libdir=$libdir
1392old_datadir=$datadir
1393exec_prefix=`eval echo $exec_prefix`
1394libdir=`eval echo $libdir`
1395datadir=`eval eval echo $datadir`
1396
1397dnl Build extension directory path.
1398ZEND_MODULE_API_NO=`$EGREP '#define ZEND_MODULE_API_NO ' $srcdir/Zend/zend_modules.h|"${SED}" 's/#define ZEND_MODULE_API_NO //'`
1399
1400if test -z "$EXTENSION_DIR"; then
1401  extbasedir=$ZEND_MODULE_API_NO
1402  if test "$oldstyleextdir" = "yes"; then
1403    if test "$PHP_DEBUG" = "1"; then
1404      part1=debug
1405    else
1406      part1=no-debug
1407    fi
1408    if test "$enable_zts" = "yes"; then
1409      part2=zts
1410    else
1411      part2=non-zts
1412    fi
1413    extbasedir=$part1-$part2-$extbasedir
1414    EXTENSION_DIR=$libdir/extensions/$extbasedir
1415  else
1416    if test "$enable_zts" = "yes"; then
1417      extbasedir=$extbasedir-zts
1418    fi
1419
1420    if test "$PHP_DEBUG" = "1"; then
1421      extbasedir=$extbasedir-debug
1422    fi
1423    EXTENSION_DIR=$libdir/$extbasedir
1424  fi
1425fi
1426
1427case $PHP_LAYOUT in
1428  GNU)
1429    datarootdir=$prefix/share
1430    ;;
1431  *)
1432    datarootdir=$prefix/php
1433    ;;
1434esac
1435
1436dnl Expand all directory names for use in macros/constants.
1437EXPANDED_PEAR_INSTALLDIR=`eval echo $PEAR_INSTALLDIR`
1438EXPANDED_EXTENSION_DIR=`eval echo $EXTENSION_DIR`
1439EXPANDED_LOCALSTATEDIR=`eval echo $localstatedir`
1440EXPANDED_BINDIR=`eval echo $bindir`
1441EXPANDED_SBINDIR=`eval echo $sbindir`
1442EXPANDED_MANDIR=`eval echo $mandir`
1443EXPANDED_LIBDIR=$libdir
1444EXPANDED_SYSCONFDIR=`eval echo $sysconfdir`
1445EXPANDED_DATADIR=$datadir
1446EXPANDED_PHP_CONFIG_FILE_PATH=`eval echo "$PHP_CONFIG_FILE_PATH"`
1447EXPANDED_PHP_CONFIG_FILE_SCAN_DIR=`eval echo "$PHP_CONFIG_FILE_SCAN_DIR"`
1448INCLUDE_PATH=.:$EXPANDED_PEAR_INSTALLDIR
1449
1450exec_prefix=$old_exec_prefix
1451libdir=$old_libdir
1452datadir=$old_datadir
1453
1454AC_SUBST(INCLUDE_PATH)
1455AC_SUBST(EXPANDED_PEAR_INSTALLDIR)
1456AC_SUBST(EXPANDED_EXTENSION_DIR)
1457AC_SUBST(EXPANDED_BINDIR)
1458AC_SUBST(EXPANDED_SBINDIR)
1459AC_SUBST(EXPANDED_MANDIR)
1460AC_SUBST(EXPANDED_LIBDIR)
1461AC_SUBST(EXPANDED_DATADIR)
1462AC_SUBST(EXPANDED_SYSCONFDIR)
1463AC_SUBST(EXPANDED_LOCALSTATEDIR)
1464AC_SUBST(EXPANDED_PHP_CONFIG_FILE_PATH)
1465AC_SUBST(EXPANDED_PHP_CONFIG_FILE_SCAN_DIR)
1466
1467PHP_UTILIZE_RPATHS
1468
1469PHP_REMOVE_USR_LIB(PHP_LDFLAGS)
1470PHP_REMOVE_USR_LIB(LDFLAGS)
1471
1472EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PHP_LDFLAGS"
1473EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $PHP_LDFLAGS"
1474
1475UNAME=`uname -a | xargs`
1476PHP_UNAME=${PHP_UNAME:-$UNAME}
1477AC_DEFINE_UNQUOTED(PHP_UNAME,"$PHP_UNAME",[uname -a output])
1478PHP_OS=`uname | xargs`
1479AC_DEFINE_UNQUOTED(PHP_OS,"$PHP_OS",[uname output])
1480PHP_BUILD_SYSTEM=${PHP_BUILD_SYSTEM:-$PHP_UNAME}
1481AC_DEFINE_UNQUOTED(PHP_BUILD_SYSTEM,"$PHP_BUILD_SYSTEM",[builder uname output])
1482if test -n "${PHP_BUILD_PROVIDER}"; then
1483  AC_DEFINE_UNQUOTED(PHP_BUILD_PROVIDER,"$PHP_BUILD_PROVIDER",[build provider])
1484fi
1485if test -n "${PHP_BUILD_COMPILER}"; then
1486  AC_DEFINE_UNQUOTED(PHP_BUILD_COMPILER,"$PHP_BUILD_COMPILER",[used compiler for build])
1487fi
1488if test -n "${PHP_BUILD_ARCH}"; then
1489  AC_DEFINE_UNQUOTED(PHP_BUILD_ARCH,"$PHP_BUILD_ARCH",[build architecture])
1490fi
1491
1492PHP_SUBST_OLD(PHP_INSTALLED_SAPIS)
1493
1494PHP_SUBST(PHP_FASTCGI_OBJS)
1495PHP_SUBST(PHP_SAPI_OBJS)
1496PHP_SUBST(PHP_BINARY_OBJS)
1497PHP_SUBST(PHP_GLOBAL_OBJS)
1498
1499PHP_SUBST(PHP_BINARIES)
1500PHP_SUBST(PHP_MODULES)
1501PHP_SUBST(PHP_ZEND_EX)
1502
1503PHP_SUBST_OLD(abs_builddir)
1504PHP_SUBST_OLD(abs_srcdir)
1505
1506PHP_SUBST(bindir)
1507PHP_SUBST(sbindir)
1508PHP_SUBST(exec_prefix)
1509PHP_SUBST_OLD(program_prefix)
1510PHP_SUBST_OLD(program_suffix)
1511PHP_SUBST(includedir)
1512PHP_SUBST_OLD(orig_libdir)
1513PHP_SUBST(libdir)
1514PHP_SUBST(mandir)
1515PHP_SUBST(phptempdir)
1516PHP_SUBST(prefix)
1517PHP_SUBST(localstatedir)
1518PHP_SUBST(datadir)
1519PHP_SUBST(datarootdir)
1520PHP_SUBST(sysconfdir)
1521
1522PHP_SUBST(EXEEXT)
1523PHP_SUBST(CC)
1524PHP_SUBST(BUILD_CC)
1525PHP_SUBST(CFLAGS)
1526PHP_SUBST(CFLAGS_CLEAN)
1527PHP_SUBST(CPP)
1528PHP_SUBST(CPPFLAGS)
1529PHP_SUBST(CXX)
1530PHP_SUBST(CXXFLAGS)
1531PHP_SUBST(CXXFLAGS_CLEAN)
1532PHP_SUBST_OLD(DEBUG_CFLAGS)
1533PHP_SUBST_OLD(EXTENSION_DIR)
1534PHP_SUBST_OLD(EXTRA_LDFLAGS)
1535PHP_SUBST_OLD(EXTRA_LDFLAGS_PROGRAM)
1536PHP_SUBST_OLD(EXTRA_LIBS)
1537PHP_SUBST_OLD(ZEND_EXTRA_LIBS)
1538PHP_SUBST_OLD(INCLUDES)
1539PHP_SUBST_OLD(EXTRA_INCLUDES)
1540PHP_SUBST_OLD(INSTALL_IT)
1541PHP_SUBST(LIBTOOL)
1542PHP_SUBST(LN_S)
1543PHP_SUBST_OLD(NATIVE_RPATHS)
1544PHP_SUBST_OLD(PEAR_INSTALLDIR)
1545PHP_SUBST_OLD(PHP_LDFLAGS)
1546PHP_SUBST(OVERALL_TARGET)
1547PHP_SUBST(PHP_RPATHS)
1548PHP_SUBST(PHP_SAPI)
1549PHP_SUBST_OLD(PHP_VERSION)
1550PHP_SUBST_OLD(PHP_VERSION_ID)
1551PHP_SUBST(SHELL)
1552PHP_SUBST(PHP_FRAMEWORKS)
1553PHP_SUBST(PHP_FRAMEWORKPATH)
1554PHP_SUBST(INSTALL_HEADERS)
1555PHP_SUBST_OLD(SAPI_LIBNAME_SHARED)
1556PHP_SUBST_OLD(SAPI_LIBNAME_STATIC)
1557
1558old_CC=$CC
1559
1560if test "$PHP_THREAD_SAFETY" = "yes" && test -n "$ac_cv_pthreads_cflags"; then
1561  CXXFLAGS="$CXXFLAGS $ac_cv_pthreads_cflags"
1562  CPPFLAGS="$CPPFLAGS $ac_cv_pthreads_cflags"
1563fi
1564
1565dnl Enable -Werror late, because it may break configure checks throwing warnings.
1566if test "$PHP_WERROR" = "yes"; then
1567  CFLAGS="$CFLAGS -Werror"
1568  CXXFLAGS="$CXXFLAGS -Werror"
1569fi
1570
1571if test "$PHP_MEMORY_SANITIZER" = "yes" &&
1572   test "$PHP_ADDRESS_SANITIZER" = "yes"; then
1573   AC_MSG_ERROR([MemorySanitizer and AddressSanitizer are mutually exclusive])
1574fi
1575
1576dnl Enable -fsanitize=memory late, because interceptors may break linking detection.
1577if test "$PHP_MEMORY_SANITIZER" = "yes"; then
1578  AX_CHECK_COMPILE_FLAG([-fsanitize=memory -fsanitize-memory-track-origins], [
1579    CFLAGS="$CFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
1580    CXXFLAGS="$CXXFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
1581  ], [AC_MSG_ERROR([MemorySanitizer is not available])])
1582fi
1583
1584if test "$PHP_ADDRESS_SANITIZER" = "yes"; then
1585  AX_CHECK_COMPILE_FLAG([-fsanitize=address], [
1586    CFLAGS="$CFLAGS -fsanitize=address -DZEND_TRACK_ARENA_ALLOC"
1587    CXXFLAGS="$CXXFLAGS -fsanitize=address -DZEND_TRACK_ARENA_ALLOC"
1588  ], [AC_MSG_ERROR([AddressSanitizer is not available])])
1589fi
1590
1591if test "$PHP_UNDEFINED_SANITIZER" = "yes"; then
1592  AX_CHECK_COMPILE_FLAG([-fsanitize=undefined], [
1593    CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined"
1594    CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined"
1595    AX_CHECK_COMPILE_FLAG([-fno-sanitize=object-size], [
1596      dnl Disable object-size sanitizer, because it is incompatible with our zend_function
1597      dnl union, and this can't be easily fixed.
1598      CFLAGS="$CFLAGS -fno-sanitize=object-size"
1599      CXXFLAGS="$CFLAGS -fno-sanitize=object-size"
1600    ])
1601
1602    dnl Clang 17 adds stricter function pointer compatibility checks where pointer args cannot be
1603    dnl cast to void*. In that case, set -fno-sanitize=function.
1604    OLD_CFLAGS="$CFLAGS"
1605    CFLAGS="$CFLAGS -fno-sanitize-recover=undefined"
1606    AC_CACHE_CHECK([whether to add -fno-sanitize=function],[php_cv_ubsan_no_function],[
1607    AC_RUN_IFELSE([AC_LANG_SOURCE([[
1608void foo(char *string) {}
1609int main(void) {
1610  void (*f)(void *) = (void (*)(void *))foo;
1611  f("foo");
1612}
1613    ]])],[php_cv_ubsan_no_function=no],[php_cv_ubsan_no_function=yes],[php_cv_ubsan_no_function=no])])
1614    CFLAGS="$OLD_CFLAGS"
1615    if test "$php_cv_ubsan_no_function" = yes; then
1616      CFLAGS="$CFLAGS -fno-sanitize=function"
1617      CXXFLAGS="$CFLAGS -fno-sanitize=function"
1618    fi
1619  ], [AC_MSG_ERROR([UndefinedBehaviorSanitizer is not available])])
1620fi
1621
1622if test "$PHP_MEMORY_SANITIZER" = "yes" ||
1623   test "$PHP_ADDRESS_SANITIZER" = "yes" ||
1624   test "$PHP_UNDEFINED_SANITIZER" = "yes"; then
1625    CFLAGS="$CFLAGS -fno-omit-frame-pointer"
1626    CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer"
1627fi
1628
1629dnl
1630dnl Libtool creation.
1631dnl
1632
1633PHP_HELP_SEPARATOR([Libtool:])
1634PHP_CONFIGURE_PART(Configuring libtool)
1635
1636dnl Silence warning: `ar: 'u' modifier ignored since 'D' is the default`
1637dnl See https://github.com/php/php-src/pull/3017
1638AC_SUBST(AR_FLAGS, [cr])
1639
1640dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by
1641dnl PHP_REQUIRE_CXX). Otherwise AC_PROG_LIBTOOL fails if there is no working C++
1642dnl compiler.
1643AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [
1644  undefine([AC_PROG_CXX])
1645  AC_DEFUN([AC_PROG_CXX], [])
1646  undefine([AC_PROG_CXXCPP])
1647  AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled])
1648])
1649AC_PROG_LIBTOOL
1650
1651PHP_SET_LIBTOOL_VARIABLE([--silent])
1652
1653dnl libtool 1.4.3 needs this.
1654PHP_SET_LIBTOOL_VARIABLE([--preserve-dup-deps])
1655
1656CC=$old_CC
1657
1658PHP_CONFIGURE_PART(Generating files)
1659
1660CXXFLAGS_CLEAN=$CXXFLAGS
1661CFLAGS_CLEAN="$CFLAGS \$(PROF_FLAGS)"
1662CFLAGS="\$(CFLAGS_CLEAN) $standard_libtool_flag"
1663CXXFLAGS="$CXXFLAGS $standard_libtool_flag \$(PROF_FLAGS)"
1664
1665if test "$PHP_PHAR" != "no" && test "$PHP_CLI" != "no"; then
1666  pharcmd=pharcmd
1667  pharcmd_install=install-pharcmd
1668else
1669  pharcmd=
1670  pharcmd_install=
1671fi;
1672
1673all_targets="\$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_ZEND_EX) \$(PHP_BINARIES) $pharcmd"
1674install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install"
1675
1676PHP_SUBST(all_targets)
1677PHP_SUBST(install_targets)
1678PHP_SUBST(install_binary_targets)
1679
1680PHP_INSTALL_HEADERS([Zend/ TSRM/ main/ main/streams/])
1681PHP_INSTALL_HEADERS([Zend/Optimizer], [ \
1682    zend_call_graph.h \
1683    zend_cfg.h \
1684    zend_dfg.h \
1685    zend_dump.h \
1686    zend_func_info.h \
1687    zend_inference.h \
1688    zend_optimizer.h \
1689    zend_ssa.h \
1690    zend_worklist.h])
1691
1692PHP_ADD_SOURCES(TSRM, TSRM.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
1693
1694PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c \
1695       fopen_wrappers.c php_scandir.c \
1696       php_ini_builder.c \
1697       php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
1698       strlcat.c explicit_bzero.c reentrancy.c php_variables.c php_ticks.c \
1699       network.c php_open_temporary_file.c php_odbc_utils.c safe_bcmp.c \
1700       output.c getopt.c php_syslog.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
1701
1702PHP_ADD_SOURCES_X(main, fastcgi.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, PHP_FASTCGI_OBJS, no)
1703
1704PHP_ADD_SOURCES(main/streams, streams.c cast.c memory.c filter.c \
1705       plain_wrapper.c userspace.c transports.c xp_socket.c mmap.c \
1706       glob_wrapper.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
1707
1708PHP_ADD_SOURCES(/main, internal_functions.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, sapi)
1709PHP_ADD_SOURCES_X(/main, internal_functions_cli.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, PHP_BINARY_OBJS)
1710
1711PHP_ADD_SOURCES(Zend, \
1712    zend_language_parser.c zend_language_scanner.c \
1713    zend_ini_parser.c zend_ini_scanner.c \
1714    zend_alloc.c zend_call_stack.c zend_compile.c zend_constants.c zend_dtrace.c \
1715    zend_execute_API.c zend_highlight.c zend_llist.c \
1716    zend_vm_opcodes.c zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \
1717    zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
1718    zend_list.c zend_builtin_functions.c zend_attributes.c zend_execute.c \
1719    zend_ini.c zend_sort.c zend_multibyte.c zend_stream.c \
1720    zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_gc.c \
1721    zend_closures.c zend_weakrefs.c zend_float.c zend_string.c zend_signal.c zend_generators.c \
1722    zend_virtual_cwd.c zend_ast.c zend_objects.c zend_object_handlers.c zend_objects_API.c \
1723    zend_default_classes.c zend_inheritance.c zend_smart_str.c zend_cpuinfo.c zend_gdb.c \
1724    zend_observer.c zend_system_id.c zend_enum.c zend_fibers.c zend_atomic.c \
1725    zend_max_execution_timer.c \
1726    zend_hrtime.c \
1727    zend_frameless_function.c \
1728	Optimizer/zend_optimizer.c \
1729	Optimizer/pass1.c \
1730	Optimizer/pass3.c \
1731	Optimizer/optimize_func_calls.c \
1732	Optimizer/block_pass.c \
1733	Optimizer/optimize_temp_vars_5.c \
1734	Optimizer/nop_removal.c \
1735	Optimizer/compact_literals.c \
1736	Optimizer/zend_cfg.c \
1737	Optimizer/zend_dfg.c \
1738	Optimizer/dfa_pass.c \
1739	Optimizer/zend_ssa.c \
1740	Optimizer/zend_inference.c \
1741	Optimizer/zend_func_info.c \
1742	Optimizer/zend_call_graph.c \
1743	Optimizer/sccp.c \
1744	Optimizer/scdf.c \
1745	Optimizer/dce.c \
1746	Optimizer/escape_analysis.c \
1747	Optimizer/compact_vars.c \
1748	Optimizer/zend_dump.c \
1749    , -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
1750
1751PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/scripts/Makefile.frag,$abs_srcdir/scripts,scripts)
1752PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Zend/Makefile.frag,$abs_srcdir/Zend,Zend)
1753
1754AC_DEFINE([HAVE_BUILD_DEFS_H], 1, [ ])
1755
1756PHP_ADD_BUILD_DIR([m4_normalize([
1757  main
1758  main/streams
1759  scripts
1760  scripts/man1
1761  TSRM
1762  Zend
1763  Zend/asm
1764  Zend/Optimizer
1765])])
1766
1767ALL_OUTPUT_FILES="main/build-defs.h \
1768scripts/phpize scripts/man1/phpize.1 \
1769scripts/php-config scripts/man1/php-config.1 \
1770$PHP_OUTPUT_FILES"
1771
1772dnl Generate build files.
1773AC_CONFIG_FILES([$ALL_OUTPUT_FILES])
1774
1775AC_CONFIG_COMMANDS_PRE([PHP_PATCH_CONFIG_HEADERS([main/php_config.h.in])])
1776
1777AC_CONFIG_COMMANDS([default],[
1778cat <<X
1779
1780+--------------------------------------------------------------------+
1781| License:                                                           |
1782| This software is subject to the PHP License, available in this     |
1783| distribution in the file LICENSE. By continuing this installation  |
1784| process, you are bound by the terms of this license agreement.     |
1785| If you do not agree with the terms of this license, you must abort |
1786| the installation process at this point.                            |
1787+--------------------------------------------------------------------+
1788
1789Thank you for using PHP.
1790
1791X
1792],[
1793
1794if test "\$CONFIG_FILES" = "$ALL_OUTPUT_FILES" || test "\$CONFIG_FILES" = " $ALL_OUTPUT_FILES" || test -z "\$CONFIG_FILES"; then
1795  REDO_ALL=yes
1796fi
1797
1798dnl Create configuration headers.
1799dnl ----------------------------------------------------------------------------
1800cat >Zend/zend_config.h <<FEO
1801#include <../main/php_config.h>
1802FEO
1803
1804dnl Run this only when generating all the files.
1805if test -n "\$REDO_ALL"; then
1806  echo "creating main/internal_functions.c"
1807  AWK="$AWK" sh $srcdir/build/genif.sh $srcdir/main/internal_functions.c.in "$EXT_STATIC" > main/internal_functions.c
1808
1809  echo "creating main/internal_functions_cli.c"
1810  AWK="$AWK" sh $srcdir/build/genif.sh $srcdir/main/internal_functions.c.in "$EXT_CLI_STATIC" > main/internal_functions_cli.c
1811
1812    if test "$PHP_SAPI" = "apache2handler"; then
1813      if test "$APACHE_VERSION" -ge 2004001; then
1814        if test -z "$APACHE_THREADED_MPM"; then
1815cat <<X
1816+--------------------------------------------------------------------+
1817|                        *** WARNING ***                             |
1818|                                                                    |
1819| You have built PHP for Apache's current non-threaded MPM.          |
1820| If you change Apache to use a threaded MPM you must reconfigure    |
1821| PHP with --enable-zts                                              |
1822X
1823        fi
1824      fi
1825    fi
1826
1827fi
1828])
1829AC_OUTPUT
1830