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