xref: /PHP-5.4/configure.in (revision 51fca4b7)
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=4
122PHP_RELEASE_VERSION=46
123PHP_EXTRA_VERSION="-dev"
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  ltp_version_list="1.5 1.6 1.7 1.9 1.10"
788
789  AC_CHECK_PROG(LTP, lcov, lcov)
790  AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
791  PHP_SUBST(LTP)
792  PHP_SUBST(LTP_GENHTML)
793
794  if test "$LTP"; then
795    AC_CACHE_CHECK([for ltp version], php_cv_ltp_version, [
796      php_cv_ltp_version=invalid
797      ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
798      for ltp_check_version in $ltp_version_list; do
799        if test "$ltp_version" = "$ltp_check_version"; then
800          php_cv_ltp_version="$ltp_check_version (ok)"
801        fi
802      done
803    ])
804  else
805    ltp_msg="To enable code coverage reporting you must have one of the following LTP versions installed: $ltp_version_list"
806    AC_MSG_ERROR([$ltp_msg])
807  fi
808
809  case $php_cv_ltp_version in
810    ""|invalid[)]
811      ltp_msg="You must have one of the following versions of LTP: $ltp_version_list (found: $ltp_version)."
812      AC_MSG_ERROR([$ltp_msg])
813      LTP="exit 0;"
814      ;;
815  esac
816
817  if test -z "$LTP_GENHTML"; then
818    AC_MSG_ERROR([Could not find genhtml from the LTP package])
819  fi
820
821  AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov])
822  PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Makefile.gcov, $abs_srcdir)
823
824  dnl Remove all optimization flags from CFLAGS
825  changequote({,})
826  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
827  CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
828  changequote([,])
829
830  dnl Add the special gcc flags
831  CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
832  CXXFLAGS="$CXXFLAGS -O0 -fprofile-arcs -ftest-coverage"
833fi
834
835PHP_ARG_ENABLE(debug, whether to include debugging symbols,
836[  --enable-debug          Compile with debugging symbols], no, no)
837
838if test "$PHP_DEBUG" = "yes"; then
839  PHP_DEBUG=1
840  ZEND_DEBUG=yes
841  changequote({,})
842  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
843  CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
844  changequote([,])
845  dnl add -O0 only if GCC or ICC is used
846  if test "$GCC" = "yes" || test "$ICC" = "yes"; then
847    CFLAGS="$CFLAGS -O0"
848    CXXFLAGS="$CXXFLAGS -g -O0"
849  fi
850  if test "$SUNCC" = "yes"; then
851    if test -n "$auto_cflags"; then
852      CFLAGS="-g"
853      CXXFLAGS="-g"
854    else
855      CFLAGS="$CFLAGS -g"
856      CXXFLAGS="$CFLAGS -g"
857    fi
858  fi
859else
860  PHP_DEBUG=0
861  ZEND_DEBUG=no
862fi
863
864PHP_ARG_WITH(layout, layout of installed files,
865[  --with-layout=TYPE      Set how installed files will be laid out.  Type can
866                          be either PHP or GNU @<:@PHP@:>@], PHP, no)
867
868case $PHP_LAYOUT in
869  GNU)
870    oldstyleextdir=no
871    ;;
872  *)
873    oldstyleextdir=yes
874    ;;
875esac
876
877PHP_ARG_WITH(config-file-path, path to configuration file,
878[  --with-config-file-path=PATH
879                          Set the path in which to look for php.ini @<:@PREFIX/lib@:>@], DEFAULT, no)
880
881if test "$PHP_CONFIG_FILE_PATH" = "DEFAULT"; then
882  case $PHP_LAYOUT in
883    GNU)
884      PHP_CONFIG_FILE_PATH=$sysconfdir
885      ;;
886    *)
887      PHP_CONFIG_FILE_PATH=$libdir
888      ;;
889  esac
890fi
891
892AC_MSG_CHECKING([where to scan for configuration files])
893PHP_ARG_WITH(config-file-scan-dir,,
894[  --with-config-file-scan-dir=PATH
895                          Set the path where to scan for configuration files], DEFAULT, no)
896if test "$PHP_CONFIG_FILE_SCAN_DIR" = "DEFAULT"; then
897  PHP_CONFIG_FILE_SCAN_DIR=
898fi
899AC_MSG_RESULT([$PHP_CONFIG_FILE_SCAN_DIR])
900
901test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
902
903PHP_ARG_ENABLE(sigchild, whether to enable PHP's own SIGCHLD handler,
904[  --enable-sigchild       Enable PHP's own SIGCHLD handler], no, no)
905
906if test "$PHP_SIGCHILD" = "yes"; then
907  AC_DEFINE(PHP_SIGCHILD, 1, [ ])
908else
909  AC_DEFINE(PHP_SIGCHILD, 0, [ ])
910fi
911
912PHP_ARG_ENABLE(libgcc, whether to explicitly link against libgcc,
913[  --enable-libgcc         Enable explicitly linking against libgcc], no, no)
914
915if test "$PHP_LIBGCC" = "yes"; then
916  PHP_LIBGCC_LIBPATH(gcc)
917  if test -z "$libgcc_libpath"; then
918    AC_MSG_ERROR([Cannot locate libgcc. Make sure that gcc is in your path])
919  fi
920  PHP_ADD_LIBPATH($libgcc_libpath)
921  PHP_ADD_LIBRARY(gcc, yes)
922fi
923
924PHP_ARG_ENABLE(short-tags, whether to enable short tags by default,
925[  --disable-short-tags    Disable the short-form <? start tag by default], yes, no)
926
927if test "$PHP_SHORT_TAGS" = "yes"; then
928  AC_DEFINE(DEFAULT_SHORT_OPEN_TAG, "1", [ ])
929else
930  AC_DEFINE(DEFAULT_SHORT_OPEN_TAG, "0", [ ])
931fi
932
933PHP_ARG_ENABLE(dmalloc, whether to enable dmalloc,
934[  --enable-dmalloc        Enable dmalloc], no, no)
935
936if test "$PHP_DMALLOC" = "yes"; then
937  AC_CHECK_LIB(dmalloc, dmalloc_error, [
938    PHP_ADD_LIBRARY(dmalloc)
939    AC_DEFINE(HAVE_DMALLOC,1,[Whether you have dmalloc])
940    CPPFLAGS="$CPPFLAGS -DDMALLOC_FUNC_CHECK"
941  ], [
942    AC_MSG_ERROR([Problem with enabling dmalloc. Please check config.log for details.])
943  ])
944fi
945
946PHP_ARG_ENABLE(ipv6, whether to enable IPv6 support,
947[  --disable-ipv6          Disable IPv6 support], yes, no)
948
949if test "$PHP_IPV6" != "no" && test "$ac_cv_ipv6_support" = yes; then
950  AC_DEFINE(HAVE_IPV6, 1, [Whether to enable IPv6 support])
951fi
952
953dnl ##
954dnl ## DTRACE CHECKS
955dnl ## Note: this has to be done after SAPI configuration!
956dnl ##
957PHP_ARG_ENABLE(dtrace, whether to enable DTrace support,
958[  --enable-dtrace         Enable DTrace support], no, no)
959
960if test "$PHP_DTRACE" = "yes"; then
961  AC_CHECK_HEADERS([sys/sdt.h], [
962    PHP_INIT_DTRACE([Zend/zend_dtrace.d],[Zend/zend_dtrace_gen.h],[main/main.c Zend/zend_API.c \
963      Zend/zend_execute.c Zend/zend_exceptions.c \
964      Zend/zend_dtrace.c Zend/zend.c])
965    AC_DEFINE(HAVE_DTRACE, 1, [Whether to enable DTrace support])
966    PHP_SUBST(PHP_DTRACE_OBJS)
967  ], [
968    AC_MSG_ERROR([Cannot find sys/sdt.h which is required for DTrace support])
969  ])
970fi
971
972AC_MSG_CHECKING([how big to make fd sets])
973PHP_ARG_ENABLE(fd-setsize,,
974[  --enable-fd-setsize     Set size of descriptor sets], no, no)
975
976if test "$PHP_FD_SETSIZE" != "no"; then
977  if test "0$PHP_FD_SETSIZE" -gt 0 2>/dev/null; then
978    CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=$PHP_FD_SETSIZE"
979    AC_MSG_RESULT([using $PHP_FD_SETSIZE])
980  else
981    AC_MSG_ERROR([Invalid value passed to --enable-fd-setsize!])
982  fi
983else
984  AC_MSG_RESULT([using system default])
985fi
986
987dnl Extension configuration.
988dnl -------------------------------------------------------------------------
989
990PHP_HELP_SEPARATOR([Extensions:
991
992  --with-EXTENSION=[shared[,PATH]]
993
994    NOTE: Not all extensions can be build as 'shared'.
995
996    Example: --with-foobar=shared,/usr/local/foobar/
997
998      o Builds the foobar extension as shared extension.
999      o foobar package install prefix is /usr/local/foobar/
1000])
1001
1002PHP_CONFIGURE_PART(Configuring extensions)
1003
1004dnl
1005dnl Check if all enabled by default extensions should be disabled
1006dnl
1007
1008AC_ARG_ENABLE(all,
1009[ --disable-all   Disable all extensions which are enabled by default
1010], [
1011  PHP_ENABLE_ALL=$enableval
1012])
1013
1014# reading config stubs
1015esyscmd(./build/config-stubs ext)
1016
1017dnl Extensions post-config
1018dnl -------------------------------------------------------------------------
1019
1020enable_shared=yes
1021enable_static=yes
1022
1023case $php_sapi_module in
1024  shared[)]
1025    enable_static=no
1026    case $with_pic in
1027      yes)
1028        standard_libtool_flag='-prefer-pic'
1029        ;;
1030      no)
1031        standard_libtool_flag='-prefer-non-pic'
1032        ;;
1033    esac
1034    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -avoid-version -module"
1035    ;;
1036  *[)]
1037    standard_libtool_flag='-prefer-non-pic -static'
1038    if test -z "$PHP_MODULES" && test -z "$PHP_ZEND_EX"; then
1039      enable_shared=no
1040    fi
1041    ;;
1042esac
1043
1044EXTRA_LIBS="$EXTRA_LIBS $DLIBS $LIBS"
1045
1046dnl this has to be here to prevent the openssl crypt() from
1047dnl overriding the system provided crypt().
1048if test "$ac_cv_lib_crypt_crypt" = "yes"; then
1049  EXTRA_LIBS="-lcrypt $EXTRA_LIBS -lcrypt"
1050fi
1051
1052unset LIBS LDFLAGS
1053
1054dnl PEAR
1055dnl -------------------------------------------------------------------------
1056
1057PHP_HELP_SEPARATOR([PEAR:])
1058PHP_CONFIGURE_PART(Configuring PEAR)
1059
1060# compatibility
1061if test -z "$with_pear" && test "$enable_pear" = "no"; then
1062  with_pear=no
1063fi
1064
1065# If CLI is disabled -> disable PEAR
1066if test "$PHP_CLI" = "no"; then
1067  with_pear=no
1068fi
1069
1070PHP_ARG_WITH(pear, [whether to install PEAR],
1071[  --with-pear=DIR         Install PEAR in DIR @<:@PREFIX/lib/php@:>@
1072  --without-pear          Do not install PEAR], DEFAULT, yes)
1073
1074if test "$PHP_PEAR" != "no"; then
1075
1076  dnl
1077  dnl PEAR dependancies
1078  dnl
1079  if test "$PHP_XML" = "no"; then
1080    pear_error_msg="$pear_error_msg
1081                    PEAR requires XML to be enabled.     Add --enable-xml to the configure line. (or --without-pear)"
1082  fi
1083
1084dnl
1085dnl  if test "$PHP_XMLRPC" = "no"; then
1086dnl    pear_error_msg="$pear_error_msg
1087dnl                    PEAR requires XML-RPC to be enabled. Add --with-xmlrpc to the configure line. (or --without-pear)"
1088dnl  fi
1089dnl
1090
1091  if test "$pear_error_msg"; then
1092    AC_MSG_ERROR([$pear_error_msg])
1093  fi
1094
1095  install_pear="install-pear"
1096  PEAR_INSTALLDIR=$PHP_PEAR
1097
1098  if test "$PHP_PEAR" = "DEFAULT" || test "$PHP_PEAR" = "yes"; then
1099    case $PHP_LAYOUT in
1100      GNU) PEAR_INSTALLDIR=$datadir/pear;;
1101      *)   PEAR_INSTALLDIR=$libdir/php;;
1102    esac
1103  fi
1104
1105  PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/pear/Makefile.frag,$abs_srcdir/pear,pear)
1106fi
1107
1108
1109dnl Configuring Zend and TSRM.
1110dnl -------------------------------------------------------------------------
1111
1112PHP_HELP_SEPARATOR([Zend:])
1113PHP_CONFIGURE_PART(Configuring Zend)
1114
1115LIBZEND_BASIC_CHECKS
1116LIBZEND_DLSYM_CHECK
1117LIBZEND_OTHER_CHECKS
1118
1119if test "$ZEND_MAINTAINER_ZTS" = "yes"; then
1120  AC_DEFINE(ZTS,1,[ ])
1121  PHP_THREAD_SAFETY=yes
1122else
1123  PHP_THREAD_SAFETY=no
1124fi
1125
1126INCLUDES="$INCLUDES -I\$(top_builddir)/TSRM"
1127INCLUDES="$INCLUDES -I\$(top_builddir)/Zend"
1128
1129if test "$abs_srcdir" != "$abs_builddir"; then
1130  INCLUDES="$INCLUDES -I\$(top_srcdir)/main -I\$(top_srcdir)/Zend"
1131  INCLUDES="$INCLUDES -I\$(top_srcdir)/TSRM -I\$(top_builddir)/"
1132fi
1133
1134ZEND_EXTRA_LIBS="$LIBS"
1135unset LIBS LDFLAGS
1136
1137PHP_HELP_SEPARATOR([TSRM:])
1138PHP_CONFIGURE_PART(Configuring TSRM)
1139TSRM_BASIC_CHECKS
1140if test "$PHP_THREAD_SAFETY" = "yes"; then
1141  TSRM_THREADS_CHECKS
1142fi
1143
1144EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LDFLAGS"
1145EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $LDFLAGS"
1146EXTRA_LIBS="$EXTRA_LIBS $LIBS"
1147unset LIBS LDFLAGS
1148
1149test "$prefix" = "NONE" && prefix=/usr/local
1150test "$exec_prefix" = "NONE" && exec_prefix='${prefix}'
1151test "$program_prefix" = "NONE" && program_prefix=
1152test "$program_suffix" = "NONE" && program_suffix=
1153
1154case $libdir in
1155  '${exec_prefix}/lib')
1156    libdir=$libdir/php
1157    ;;
1158esac
1159case $datadir in
1160  '${prefix}/share')
1161    datadir=$datadir/php
1162    ;;
1163esac
1164
1165phplibdir=`pwd`/modules
1166$php_shtool mkdir -p $phplibdir
1167phptempdir=`pwd`/libs
1168
1169old_exec_prefix=$exec_prefix
1170old_libdir=$libdir
1171old_datadir=$datadir
1172exec_prefix=`eval echo $exec_prefix`
1173libdir=`eval echo $libdir`
1174datadir=`eval echo $datadir`
1175
1176dnl Build extension directory path
1177
1178ZEND_MODULE_API_NO=`$EGREP '#define ZEND_MODULE_API_NO ' $srcdir/Zend/zend_modules.h|$SED 's/#define ZEND_MODULE_API_NO //'`
1179
1180if test -z "$EXTENSION_DIR"; then
1181  extbasedir=$ZEND_MODULE_API_NO
1182  if test "$oldstyleextdir" = "yes"; then
1183    if test "$PHP_DEBUG" = "1"; then
1184      part1=debug
1185    else
1186      part1=no-debug
1187    fi
1188    if test "$enable_maintainer_zts" = "yes"; then
1189      part2=zts
1190    else
1191      part2=non-zts
1192    fi
1193    extbasedir=$part1-$part2-$extbasedir
1194    EXTENSION_DIR=$libdir/extensions/$extbasedir
1195  else
1196    if test "$enable_maintainer_zts" = "yes"; then
1197      extbasedir=$extbasedir-zts
1198    fi
1199
1200    if test "$PHP_DEBUG" = "1"; then
1201      extbasedir=$extbasedir-debug
1202    fi
1203    EXTENSION_DIR=$libdir/$extbasedir
1204  fi
1205fi
1206
1207case $PHP_LAYOUT in
1208  GNU)
1209    datarootdir=$prefix/share
1210    ;;
1211  *)
1212    datarootdir=$prefix/php
1213    ;;
1214esac
1215
1216dnl Expand all directory names for use in macros/constants
1217EXPANDED_PEAR_INSTALLDIR=`eval echo $PEAR_INSTALLDIR`
1218EXPANDED_EXTENSION_DIR=`eval echo $EXTENSION_DIR`
1219EXPANDED_LOCALSTATEDIR=`eval echo $localstatedir`
1220EXPANDED_BINDIR=`eval echo $bindir`
1221EXPANDED_SBINDIR=`eval echo $sbindir`
1222EXPANDED_MANDIR=`eval echo $mandir`
1223EXPANDED_LIBDIR=$libdir
1224EXPANDED_SYSCONFDIR=`eval echo $sysconfdir`
1225EXPANDED_DATADIR=$datadir
1226EXPANDED_PHP_CONFIG_FILE_PATH=`eval echo "$PHP_CONFIG_FILE_PATH"`
1227EXPANDED_PHP_CONFIG_FILE_SCAN_DIR=`eval echo "$PHP_CONFIG_FILE_SCAN_DIR"`
1228INCLUDE_PATH=.:$EXPANDED_PEAR_INSTALLDIR
1229
1230exec_prefix=$old_exec_prefix
1231libdir=$old_libdir
1232datadir=$old_datadir
1233
1234AC_SUBST(INCLUDE_PATH)
1235AC_SUBST(EXPANDED_PEAR_INSTALLDIR)
1236AC_SUBST(EXPANDED_EXTENSION_DIR)
1237AC_SUBST(EXPANDED_BINDIR)
1238AC_SUBST(EXPANDED_SBINDIR)
1239AC_SUBST(EXPANDED_MANDIR)
1240AC_SUBST(EXPANDED_LIBDIR)
1241AC_SUBST(EXPANDED_DATADIR)
1242AC_SUBST(EXPANDED_SYSCONFDIR)
1243AC_SUBST(EXPANDED_LOCALSTATEDIR)
1244AC_SUBST(EXPANDED_PHP_CONFIG_FILE_PATH)
1245AC_SUBST(EXPANDED_PHP_CONFIG_FILE_SCAN_DIR)
1246
1247if test -n "$php_ldflags_add_usr_lib"; then
1248  PHP_RPATHS="$PHP_RPATHS /usr/lib"
1249fi
1250
1251PHP_UTILIZE_RPATHS
1252
1253if test -z "$php_ldflags_add_usr_lib"; then
1254  PHP_REMOVE_USR_LIB(PHP_LDFLAGS)
1255  PHP_REMOVE_USR_LIB(LDFLAGS)
1256fi
1257
1258EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PHP_LDFLAGS"
1259EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM $PHP_LDFLAGS"
1260
1261PHP_BUILD_DATE=`date '+%Y-%m-%d'`
1262AC_DEFINE_UNQUOTED(PHP_BUILD_DATE,"$PHP_BUILD_DATE",[PHP build date])
1263
1264case $host_alias in
1265*netware*)
1266  PHP_OS="NetWare"
1267  PHP_UNAME="NetWare"
1268  AC_DEFINE_UNQUOTED(PHP_OS,"$PHP_OS",[hardcode for each of the cross compiler host])
1269  AC_DEFINE_UNQUOTED(PHP_UNAME,"$PHP_UNAME",[hardcode for each of the cross compiler host])
1270  ;;
1271*)
1272  PHP_UNAME=`uname -a | xargs`
1273  AC_DEFINE_UNQUOTED(PHP_UNAME,"$PHP_UNAME",[uname -a output])
1274  PHP_OS=`uname | xargs`
1275  AC_DEFINE_UNQUOTED(PHP_OS,"$PHP_OS",[uname output])
1276  ;;
1277esac
1278
1279PHP_SUBST_OLD(PHP_INSTALLED_SAPIS)
1280
1281PHP_SUBST(PHP_EXECUTABLE)
1282
1283PHP_SUBST(PHP_SAPI_OBJS)
1284PHP_SUBST(PHP_BINARY_OBJS)
1285PHP_SUBST(PHP_GLOBAL_OBJS)
1286
1287PHP_SUBST(PHP_BINARIES)
1288PHP_SUBST(PHP_MODULES)
1289PHP_SUBST(PHP_ZEND_EX)
1290
1291PHP_SUBST(EXT_LIBS)
1292
1293PHP_SUBST_OLD(abs_builddir)
1294PHP_SUBST_OLD(abs_srcdir)
1295PHP_SUBST_OLD(php_abs_top_builddir)
1296PHP_SUBST_OLD(php_abs_top_srcdir)
1297
1298PHP_SUBST(bindir)
1299PHP_SUBST(sbindir)
1300PHP_SUBST(exec_prefix)
1301PHP_SUBST_OLD(program_prefix)
1302PHP_SUBST_OLD(program_suffix)
1303PHP_SUBST(includedir)
1304PHP_SUBST(libdir)
1305PHP_SUBST(mandir)
1306PHP_SUBST(phplibdir)
1307PHP_SUBST(phptempdir)
1308PHP_SUBST(prefix)
1309PHP_SUBST(localstatedir)
1310PHP_SUBST(datadir)
1311PHP_SUBST(datarootdir)
1312PHP_SUBST(sysconfdir)
1313
1314PHP_SUBST(EXEEXT)
1315PHP_SUBST(CC)
1316PHP_SUBST(CFLAGS)
1317PHP_SUBST(CFLAGS_CLEAN)
1318PHP_SUBST(CPP)
1319PHP_SUBST(CPPFLAGS)
1320PHP_SUBST(CXX)
1321PHP_SUBST(CXXFLAGS)
1322PHP_SUBST(CXXFLAGS_CLEAN)
1323PHP_SUBST_OLD(DEBUG_CFLAGS)
1324PHP_SUBST_OLD(EXTENSION_DIR)
1325PHP_SUBST_OLD(EXTRA_LDFLAGS)
1326PHP_SUBST_OLD(EXTRA_LDFLAGS_PROGRAM)
1327PHP_SUBST_OLD(EXTRA_LIBS)
1328PHP_SUBST_OLD(ZEND_EXTRA_LIBS)
1329PHP_SUBST_OLD(INCLUDES)
1330PHP_SUBST_OLD(EXTRA_INCLUDES)
1331PHP_SUBST_OLD(INCLUDE_PATH)
1332PHP_SUBST_OLD(INSTALL_IT)
1333PHP_SUBST(LFLAGS)
1334PHP_SUBST(LIBTOOL)
1335PHP_SUBST(LN_S)
1336PHP_SUBST_OLD(NATIVE_RPATHS)
1337PHP_SUBST_OLD(PEAR_INSTALLDIR)
1338PHP_SUBST(PHP_BUILD_DATE)
1339PHP_SUBST_OLD(PHP_LDFLAGS)
1340PHP_SUBST_OLD(PHP_LIBS)
1341PHP_SUBST(OVERALL_TARGET)
1342PHP_SUBST(PHP_RPATHS)
1343PHP_SUBST(PHP_SAPI)
1344PHP_SUBST_OLD(PHP_VERSION)
1345PHP_SUBST_OLD(PHP_VERSION_ID)
1346PHP_SUBST(SHELL)
1347PHP_SUBST(SHARED_LIBTOOL)
1348PHP_SUBST(WARNING_LEVEL)
1349PHP_SUBST(PHP_FRAMEWORKS)
1350PHP_SUBST(PHP_FRAMEWORKPATH)
1351PHP_SUBST(INSTALL_HEADERS)
1352
1353old_CC=$CC
1354
1355if test "$PHP_THREAD_SAFETY" = "yes" && test -n "$ac_cv_pthreads_cflags"; then
1356  CXXFLAGS="$CXXFLAGS $ac_cv_pthreads_cflags"
1357  INLINE_CFLAGS="$INLINE_CFLAGS $ac_cv_pthreads_cflags"
1358  cat >meta_ccld<<EOF
1359#! /bin/sh
1360exec $CC $ac_cv_pthreads_cflags \$@
1361EOF
1362  CC="$abs_builddir/meta_ccld"
1363  chmod +x meta_ccld
1364fi
1365
1366dnl This will go away, if we have a facility to run per-extension code
1367dnl after the thread_safety decision was done
1368if test "$PHP_THREAD_SAFETY" = "yes" && test "$PHP_MYSQL" = "yes"; then
1369  CPPFLAGS="$CPPFLAGS -DTHREAD=1"
1370fi
1371
1372ZEND_EXT_TYPE="zend_extension"
1373PHP_SUBST(ZEND_EXT_TYPE)
1374
1375dnl
1376dnl Libtool creation
1377dnl
1378
1379PHP_HELP_SEPARATOR([Libtool:])
1380PHP_CONFIGURE_PART(Configuring libtool)
1381
1382LDFLAGS="$LDFLAGS $PHP_AIX_LDFLAGS"
1383
1384dnl Autoconf 2.13's libtool checks go slightly nuts on Mac OS X 10.5 and 10.6.
1385dnl This hack works around it. Ugly.
1386case $host_alias in
1387*darwin9*|*darwin10*)
1388  ac_cv_exeext=
1389  ;;
1390esac
1391
1392dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by PHP_REQUIRE_CXX).
1393dnl Otherwise AC_PROG_LIBTOOL fails if there is no working C++ compiler.
1394AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [
1395  undefine([AC_PROG_CXX])
1396  AC_DEFUN([AC_PROG_CXX], [])
1397  undefine([AC_PROG_CXXCPP])
1398  AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled])
1399])
1400AC_PROG_LIBTOOL
1401
1402if test "$enable_debug" != "yes"; then
1403  PHP_SET_LIBTOOL_VARIABLE([--silent])
1404fi
1405
1406dnl libtool 1.4.3 needs this.
1407PHP_SET_LIBTOOL_VARIABLE([--preserve-dup-deps])
1408
1409test -z "$PHP_COMPILE" && PHP_COMPILE='$(LIBTOOL) --mode=compile $(COMPILE) -c $<'
1410test -z "$CXX_PHP_COMPILE" && CXX_PHP_COMPILE='$(LIBTOOL) --mode=compile $(CXX_COMPILE) -c $<'
1411SHARED_LIBTOOL='$(LIBTOOL)'
1412
1413CC=$old_CC
1414
1415PHP_CONFIGURE_PART(Generating files)
1416
1417CXXFLAGS_CLEAN=$CXXFLAGS
1418CFLAGS_CLEAN=$CFLAGS
1419CFLAGS="\$(CFLAGS_CLEAN) $standard_libtool_flag"
1420INLINE_CFLAGS="$INLINE_CFLAGS $standard_libtool_flag"
1421CXXFLAGS="$CXXFLAGS $standard_libtool_flag"
1422
1423if test "$PHP_PHAR" != "no" && test "$PHP_CLI" != "no"; then
1424  pharcmd=pharcmd
1425  pharcmd_install=install-pharcmd
1426else
1427  pharcmd=
1428  pharcmd_install=
1429fi;
1430
1431all_targets="$lcov_target \$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_ZEND_EX) \$(PHP_BINARIES) $pharcmd"
1432install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install"
1433
1434PHP_SUBST(all_targets)
1435PHP_SUBST(install_targets)
1436PHP_SUBST(install_binary_targets)
1437
1438PHP_INSTALL_HEADERS([Zend/ TSRM/ include/ main/ main/streams/])
1439
1440PHP_ADD_SOURCES(TSRM, TSRM.c tsrm_strtok_r.c tsrm_virtual_cwd.c)
1441
1442PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c php_sprintf.c \
1443       fopen_wrappers.c alloca.c  php_scandir.c \
1444       php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
1445       strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \
1446       network.c php_open_temporary_file.c php_logos.c \
1447       output.c getopt.c)
1448
1449PHP_ADD_SOURCES(main/streams, streams.c cast.c memory.c filter.c \
1450       plain_wrapper.c userspace.c transports.c xp_socket.c mmap.c \
1451       glob_wrapper.c)
1452
1453PHP_ADD_SOURCES(/main, internal_functions.c,, sapi)
1454
1455case $host_alias in
1456  *netware*)
1457    PHP_ADD_BUILD_DIR(win32)
1458    PHP_ADD_BUILD_DIR(netware)
1459    ;;
1460  *)
1461    PHP_ADD_SOURCES_X(/main, internal_functions_cli.c,, PHP_BINARY_OBJS)
1462    ;;
1463esac
1464
1465PHP_ADD_SOURCES(Zend, \
1466    zend_language_parser.c zend_language_scanner.c \
1467    zend_ini_parser.c zend_ini_scanner.c \
1468    zend_alloc.c zend_compile.c zend_constants.c zend_dynamic_array.c zend_dtrace.c \
1469    zend_execute_API.c zend_highlight.c zend_llist.c \
1470    zend_vm_opcodes.c zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \
1471    zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
1472    zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
1473    zend_ini.c zend_qsort.c zend_multibyte.c zend_ts_hash.c zend_stream.c \
1474    zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_gc.c \
1475    zend_closures.c zend_float.c zend_string.c zend_signal.c)
1476
1477if test -r "$abs_srcdir/Zend/zend_objects.c"; then
1478  PHP_ADD_SOURCES(Zend, zend_objects.c zend_object_handlers.c zend_objects_API.c zend_default_classes.c)
1479fi
1480
1481dnl Selectively disable optimization due to high RAM usage during
1482dnl compiling the executor.
1483if test -n "$GCC" && test "$ZEND_INLINE_OPTIMIZATION" != "yes"; then
1484  flag=-O0
1485else
1486  flag=
1487fi
1488
1489PHP_ADD_SOURCES_X(Zend, zend_execute.c,,PHP_GLOBAL_OBJS,,$flag)
1490
1491PHP_ADD_BUILD_DIR(main main/streams)
1492PHP_ADD_BUILD_DIR(TSRM)
1493PHP_ADD_BUILD_DIR(Zend)
1494
1495PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/scripts/Makefile.frag,$abs_srcdir/scripts,scripts)
1496PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Makefile.frag,$abs_srcdir/Zend,Zend)
1497PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Zend/Makefile.frag,$abs_srcdir/Zend,Zend)
1498
1499PHP_GEN_BUILD_DIRS
1500PHP_GEN_GLOBAL_MAKEFILE
1501
1502AC_DEFINE([HAVE_BUILD_DEFS_H], 1, [ ])
1503
1504$php_shtool mkdir -p pear/scripts
1505$php_shtool mkdir -p scripts
1506$php_shtool mkdir -p scripts/man1
1507
1508ALL_OUTPUT_FILES="php5.spec main/build-defs.h \
1509scripts/phpize scripts/man1/phpize.1 \
1510scripts/php-config scripts/man1/php-config.1 \
1511$PHP_OUTPUT_FILES"
1512
1513dnl
1514dnl Check for unknown configure options
1515dnl
1516PHP_CHECK_CONFIGURE_OPTIONS
1517
1518dnl
1519dnl Generate build files
1520dnl
1521AC_OUTPUT($ALL_OUTPUT_FILES, [], [
1522
1523if test "\$CONFIG_FILES" = "$ALL_OUTPUT_FILES" || test "\$CONFIG_FILES" = " $ALL_OUTPUT_FILES" || test -z "\$CONFIG_FILES"; then
1524  REDO_ALL=yes
1525fi
1526
1527################################################################
1528# Create configuration headers
1529#
1530
1531test -d TSRM || $php_shtool mkdir TSRM
1532echo '#include <../main/php_config.h>' > TSRM/tsrm_config.h
1533
1534test -d Zend || $php_shtool mkdir Zend
1535
1536cat >Zend/zend_config.h <<FEO
1537#include <../main/php_config.h>
1538#if defined(APACHE) && defined(PHP_API_VERSION)
1539#undef HAVE_DLFCN_H
1540#endif
1541FEO
1542
1543# run this only when generating all the files?
1544if test -n "\$REDO_ALL"; then
1545  # Hacking while airborne considered harmful.
1546  #
1547  echo "creating main/internal_functions.c"
1548  extensions="$EXT_STATIC"
1549dnl mv -f main/internal_functions.c main/internal_functions.c.old 2>/dev/null
1550  sh $srcdir/build/genif.sh $srcdir/main/internal_functions.c.in $srcdir "$EXTRA_MODULE_PTRS" $AWK \$extensions > main/internal_functions.c
1551
1552  echo "creating main/internal_functions_cli.c"
1553  cli_extensions="$EXT_CLI_STATIC"
1554  sh $srcdir/build/genif.sh $srcdir/main/internal_functions.c.in $srcdir "$EXTRA_MODULE_PTRS" $AWK \$cli_extensions > main/internal_functions_cli.c
1555
1556  if test "$UNAME" = "FreeBSD" && test "$PHP_SAPI" = "apache2filter" && test "$TSRM_PTH" != "pth-config" ; then
1557    echo "+--------------------------------------------------------------------+"
1558    echo "|                        *** WARNING ***                             |"
1559    echo "|                                                                    |"
1560    echo "| In order to build PHP as a Apache2 module on FreeBSD, you have to  |"
1561    echo "| add  --with-tsrm-pth to your ./configure line. Therefore you need  |"
1562    echo "| to install gnu-pth from /usr/ports/devel/pth.                      |"
1563  fi
1564
1565  if test -n "$PHP_APXS_BROKEN"; then
1566    echo "+--------------------------------------------------------------------+"
1567    echo "| WARNING: Your $APXS script is most likely broken."
1568    echo "|                                                                    |"
1569    echo "| Please go read http://www.php.net/faq.build#faq.build.apxs         |"
1570    echo "| and make the changes described there and try again.                |"
1571  fi
1572
1573  if test -n "$DEBUG_LOG"; then
1574    rm -f config.cache
1575cat <<X
1576+--------------------------------------------------------------------+
1577|                       *** ATTENTION ***                            |
1578|                                                                    |
1579| Something is likely to be messed up here, because the configure    |
1580| script was not able to detect a simple feature on your platform.   |
1581| This is often caused by incorrect configuration parameters. Please |
1582| see the file debug.log for error messages.                         |
1583|                                                                    |
1584| If you are unable to fix this, send the file debug.log to the      |
1585| php-install@lists.php.net mailing list and include appropriate      |
1586| information about your setup.                                      |
1587X
1588  fi
1589
1590  if test "$PHP_SAPI" = "apache2handler" || test "$PHP_SAPI" = "apache2filter"; then
1591    if test "$APACHE_VERSION" -ge 2004001; then
1592      if test -z "$APACHE_THREADED_MPM"; then
1593cat <<X
1594+--------------------------------------------------------------------+
1595|                        *** WARNING ***                             |
1596|                                                                    |
1597| You have built PHP for Apache's current non-threaded MPM.          |
1598| If you change Apache to use a threaded MPM you must reconfigure    |
1599| PHP with --enable-maintainer-zts                                   |
1600X
1601      fi
1602    fi
1603  fi
1604
1605  # Warn about linking Apache with libpthread if oci8 extension is enabled on linux.
1606  if test "$PHP_OCI8" != "no"; then
1607    if test "$PHP_SAPI" = "apache"; then
1608      if test `uname` = "Linux"; then
1609cat <<X
1610+--------------------------------------------------------------------+
1611|                        *** WARNING ***                             |
1612|                                                                    |
1613| Please check that your Apache (httpd) is linked with libpthread.   |
1614| If not, you have to recompile Apache with pthread. For more        |
1615| details, see this page: http://www.php.net/manual/ref.oci8.php     |
1616X
1617      fi
1618    fi
1619
1620    if test "$PHP_SIGCHILD" != "yes"; then
1621      if test "$PHP_OCI8_INSTANT_CLIENT" = "no"; then
1622cat <<X
1623+--------------------------------------------------------------------+
1624| Notice:                                                            |
1625| If you encounter <defunc> processes when using a local Oracle      |
1626| database, set the value BEQUEATH_DETACH=YES in Oracle Net's        |
1627| sqlnet.ora file on the PHP host, or set the environment variable   |
1628| BEQUEATH_DETACH to YES before starting Apache.  If the problem     |
1629| still occurs, then recompile PHP and specify --enable-sigchild     |
1630| when configuring.                                                  |
1631X
1632      fi
1633    fi
1634  fi
1635
1636cat <<X
1637+--------------------------------------------------------------------+
1638| License:                                                           |
1639| This software is subject to the PHP License, available in this     |
1640| distribution in the file LICENSE.  By continuing this installation |
1641| process, you are bound by the terms of this license agreement.     |
1642| If you do not agree with the terms of this license, you must abort |
1643| the installation process at this point.                            |
1644+--------------------------------------------------------------------+
1645
1646Thank you for using PHP.
1647
1648X
1649
1650  # Output unknown configure options
1651  if test "$PHP_UNKNOWN_CONFIGURE_OPTIONS"; then
1652    echo "Notice: Following unknown configure options were used:
1653$PHP_UNKNOWN_CONFIGURE_OPTIONS
1654
1655Check '[$]0 --help' for available options
1656"
1657  fi
1658
1659fi
1660])
1661
1662dnl ## Local Variables:
1663dnl ## tab-width: 4
1664dnl ## End:
1665