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