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