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