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