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