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