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