4 dnl This file contains local autoconf functions.
7 dnl -------------------------------------------------------------------------
8 dnl Output stylize macros for configure (help/runtime)
9 dnl -------------------------------------------------------------------------
12 dnl PHP_HELP_SEPARATOR(title)
14 dnl Adds separator title into the configure --help display.
16 AC_DEFUN([PHP_HELP_SEPARATOR],[
23 dnl PHP_CONFIGURE_PART(title)
25 dnl Adds separator title configure output (idea borrowed from mm)
27 AC_DEFUN([PHP_CONFIGURE_PART],[
29 AC_MSG_RESULT([${T_MD}$1${T_ME}])
32 dnl -------------------------------------------------------------------------
33 dnl Build system helper macros
34 dnl -------------------------------------------------------------------------
37 dnl PHP_DEF_HAVE(what)
39 dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'
41 AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])])
44 dnl PHP_RUN_ONCE(namespace, variable, code)
46 dnl execute code, if variable is not set in namespace
48 AC_DEFUN([PHP_RUN_ONCE],[
50 unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'`
52 cmd="echo $ac_n \"\$$1$unique$ac_c\""
53 if test -n "$unique" && test "`eval $cmd`" = "" ; then
60 dnl PHP_EXPAND_PATH(path, variable)
62 dnl expands path to an absolute path and assigns it to variable
64 AC_DEFUN([PHP_EXPAND_PATH],[
65 if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
69 ep_dir="`echo $1|$SED 's%/*[^/][^/]*/*$%%'`"
71 ep_realdir="`(cd \"$ep_dir\" && pwd)`"
72 $2="$ep_realdir/`basename \"$1\"`"
77 dnl PHP_DEFINE(WHAT [, value[, directory]])
79 dnl Creates builddir/include/what.h and in there #define WHAT value
81 AC_DEFUN([PHP_DEFINE],[
82 [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > ]ifelse([$3],,[include],[$3])[/php_]translit($1,A-Z,a-z)[.h]
86 dnl PHP_SUBST(varname)
88 dnl Adds variable with it's value into Makefile, e.g.:
91 AC_DEFUN([PHP_SUBST],[
92 PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
96 dnl PHP_SUBST_OLD(varname)
98 dnl Same as PHP_SUBST() but also substitutes all @VARNAME@
99 dnl instances in every file passed to AC_OUTPUT()
101 AC_DEFUN([PHP_SUBST_OLD],[
109 dnl Adds "file" to the list of files generated by AC_OUTPUT
110 dnl This macro can be used several times.
112 AC_DEFUN([PHP_OUTPUT],[
113 PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
117 dnl -------------------------------------------------------------------------
118 dnl Build system base macros
119 dnl -------------------------------------------------------------------------
122 dnl PHP_CANONICAL_HOST_TARGET
124 AC_DEFUN([PHP_CANONICAL_HOST_TARGET],[
125 AC_REQUIRE([AC_CANONICAL_HOST])dnl
126 AC_REQUIRE([AC_CANONICAL_TARGET])dnl
127 dnl Make sure we do not continue if host_alias is empty.
128 if test -z "$host_alias" && test -n "$host"; then
131 if test -z "$host_alias"; then
132 AC_MSG_ERROR([host_alias is not set!])
137 dnl PHP_INIT_BUILD_SYSTEM
139 AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[
140 AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
141 test -d include || $php_shtool mkdir include
144 dnl We need to play tricks here to avoid matching the grep line itself
146 $EGREP $pattern'.*include/php' $srcdir/configure|$SED 's/.*>//'|xargs touch 2>/dev/null
150 dnl PHP_GEN_GLOBAL_MAKEFILE
152 dnl Generates the global makefile.
154 AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[
157 builddir = $abs_builddir
158 top_srcdir = $abs_srcdir
159 top_builddir = $abs_builddir
161 for i in $PHP_VAR_SUBST; do
162 eval echo "$i = \$$i" >> Makefile
165 cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile
169 dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile [, ext_srcdir [, ext_builddir]]])
171 dnl Processes a file called Makefile.frag in the source directory
172 dnl of the most recently added extension. $(srcdir) and $(builddir)
173 dnl are substituted with the proper paths. Can be used to supply
174 dnl custom rules and/or additional targets.
176 AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[
177 ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1)
178 ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2)
179 ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3)
180 test -f "$src" && $SED -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
184 dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
186 dnl Adds sources which are located relative to source-path to the
187 dnl array of type type. Sources are processed with optional
188 dnl special-flags which are passed to the compiler. Sources
189 dnl can be either written in C or C++ (filenames shall end in .c
190 dnl or .cpp, respectively).
192 dnl Note: If source-path begins with a "/", the "/" is removed and
193 dnl the path is interpreted relative to the top build-directory.
195 dnl which array to append to?
196 AC_DEFUN([PHP_ADD_SOURCES],[
197 PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS))
201 dnl _PHP_ASSIGN_BUILD_VARS(type)
202 dnl internal, don't use
203 AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[
205 b_c_pre=$shared_c_pre
206 b_cxx_pre=$shared_cxx_pre
207 b_c_meta=$shared_c_meta
208 b_cxx_meta=$shared_cxx_meta
209 b_c_post=$shared_c_post
210 b_cxx_post=$shared_cxx_post
213 b_cxx_pre=$php_cxx_pre
215 b_cxx_meta=$php_cxx_meta
217 b_cxx_post=$php_cxx_post
223 dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
225 dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the
226 dnl name of the array target-var directly, as well as whether
227 dnl shared objects will be built from the sources.
229 dnl Should not be used directly.
231 AC_DEFUN([PHP_ADD_SOURCES_X],[
232 dnl relative to source- or build-directory?
233 dnl ac_srcdir/ac_bdir include trailing slash
235 ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;;
236 /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;;
237 *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;;
240 dnl how to build .. shared or static?
241 ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php))
243 dnl iterate over the sources
247 dnl remove the suffix
253 dnl append to the array which has been dynamically chosen at m4 time
254 $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
256 dnl choose the right compiler/flags/etc. for the source-file
258 *.c[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
259 *.s[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
260 *.S[)] ac_comp="$b_c_pre $3 $ac_inc $b_c_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_c_post" ;;
261 *.cpp|*.cc|*.cxx[)] ac_comp="$b_cxx_pre $3 $ac_inc $b_cxx_meta -c $ac_srcdir$ac_src -o $ac_bdir$ac_obj.$b_lo $6$b_cxx_post" ;;
264 dnl create a rule for the object/source combo
265 cat >>Makefile.objects<<EOF
266 $ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src
272 dnl -------------------------------------------------------------------------
273 dnl Compiler characteristics checks
274 dnl -------------------------------------------------------------------------
277 dnl PHP_TARGET_RDYNAMIC
279 dnl Checks whether -rdynamic is supported by the compiler. This
280 dnl is necessary for some targets to populate the global symbol
281 dnl table. Otherwise, dynamic modules would not be able to resolve
282 dnl PHP-related symbols.
284 dnl If successful, adds -rdynamic to PHP_LDFLAGS.
286 AC_DEFUN([PHP_TARGET_RDYNAMIC],[
287 if test -n "$GCC"; then
288 dnl we should use a PHP-specific macro here
289 PHP_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes)
290 if test "$gcc_rdynamic" = "yes"; then
291 PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic"
297 dnl PHP_RUNPATH_SWITCH
299 dnl Checks for -R, etc. switch
301 AC_DEFUN([PHP_RUNPATH_SWITCH],[
302 AC_MSG_CHECKING([if compiler supports -R])
303 AC_CACHE_VAL(php_cv_cc_dashr,[
305 LIBS="-R /usr/$PHP_LIBDIR $LIBS"
306 AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
308 AC_MSG_RESULT([$php_cv_cc_dashr])
309 if test $php_cv_cc_dashr = "yes"; then
312 AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
313 AC_CACHE_VAL(php_cv_cc_rpath,[
315 LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS"
316 AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
318 AC_MSG_RESULT([$php_cv_cc_rpath])
319 if test $php_cv_cc_rpath = "yes"; then
320 ld_runpath_switch=-Wl,-rpath,
322 dnl something innocuous
326 if test "$PHP_RPATH" = "no"; then
332 dnl PHP_CHECK_GCC_ARG(arg, action-if-found, action-if-not-found)
334 AC_DEFUN([PHP_CHECK_GCC_ARG],[
335 gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z-,a-z_)
336 AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z-,a-z_), [
337 echo 'void somefunc() { };' > conftest.c
338 cmd='$CC $1 -c conftest.c'
339 if eval $cmd 2>&1 | $EGREP -e $1 >/dev/null ; then
344 eval $gcc_arg_name=$ac_result
347 if eval test "\$$gcc_arg_name" = "yes"; then
356 dnl PHP_LIBGCC_LIBPATH(gcc)
358 dnl Stores the location of libgcc in libgcc_libpath
360 AC_DEFUN([PHP_LIBGCC_LIBPATH],[
362 libgcc_libpath=`$1 --print-libgcc-file-name|$SED 's%/*[^/][^/]*$%%'`
366 dnl -------------------------------------------------------------------------
367 dnl Macros to modify LIBS, INCLUDES, etc. variables
368 dnl -------------------------------------------------------------------------
371 dnl PHP_REMOVE_USR_LIB(NAME)
373 dnl Removes all -L/usr/$PHP_LIBDIR entries from variable NAME
375 AC_DEFUN([PHP_REMOVE_USR_LIB],[
379 -L/usr/$PHP_LIBDIR|-L/usr/$PHP_LIBDIR/[)] ;;
380 *[)] ac_new_flags="[$]ac_new_flags [$]i" ;;
387 dnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD)
389 dnl Use this macro, if you need to add libraries and or library search
390 dnl paths to the PHP build system which are only given in compiler
393 AC_DEFUN([PHP_EVAL_LIBLINE],[
397 if test "$ext_shared" = "yes"; then
400 PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"])
404 ac_ii=`echo $ac_i|cut -c 3-`
405 PHP_ADD_LIBRARY($ac_ii,1,$2)
408 ac_ii=`echo $ac_i|cut -c 3-`
409 PHP_ADD_LIBPATH($ac_ii,$2)
416 dnl PHP_EVAL_INCLINE(headerline)
418 dnl Use this macro, if you need to add header search paths to the PHP
419 dnl build system which are only given in compiler notation.
421 AC_DEFUN([PHP_EVAL_INCLINE],[
425 ac_ii=`echo $ac_i|cut -c 3-`
426 PHP_ADD_INCLUDE($ac_ii)
432 dnl internal, don't use
433 AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[
434 PHP_RUN_ONCE(LIBPATH, $1, [
435 test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1"
436 LDFLAGS="$LDFLAGS -L$1"
437 PHP_RPATHS="$PHP_RPATHS $1"
442 dnl PHP_ADD_LIBPATH(path [, SHARED-LIBADD])
444 dnl Adds a path to linkpath/runpath (LDFLAGS)
446 AC_DEFUN([PHP_ADD_LIBPATH],[
447 if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
448 PHP_EXPAND_PATH($1, ai_p)
450 _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
452 if test "$ext_shared" = "yes"; then
454 test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2"
456 _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
463 dnl PHP_UTILIZE_RPATHS()
465 dnl builds RPATHS/LDFLAGS from PHP_RPATHS
467 AC_DEFUN([PHP_UTILIZE_RPATHS],[
468 OLD_RPATHS=$PHP_RPATHS
471 for i in $OLD_RPATHS; do
472 dnl Can be passed to native cc/libtool
473 PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
475 PHP_RPATHS="$PHP_RPATHS -R $i"
477 NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
480 if test "$PHP_RPATH" = "no"; then
487 dnl PHP_ADD_INCLUDE(path [,before])
489 dnl add an include path.
490 dnl if before is 1, add in the beginning of INCLUDES.
492 AC_DEFUN([PHP_ADD_INCLUDE],[
493 if test "$1" != "/usr/include"; then
494 PHP_EXPAND_PATH($1, ai_p)
495 PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [
497 INCLUDES="-I$ai_p $INCLUDES"
499 INCLUDES="$INCLUDES -I$ai_p"
505 dnl internal, don't use
506 AC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl
507 ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl
510 dnl internal, don't use
511 AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[
515 _PHP_X_ADD_LIBRARY($1,$2,$5)
517 if test "$ext_shared" = "yes"; then
518 _PHP_X_ADD_LIBRARY($1,$2,$3)
527 dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
529 dnl add a library to the link line
531 AC_DEFUN([PHP_ADD_LIBRARY],[
532 _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS])
536 dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]])
538 dnl add a library to the link line (deferred, not used during configure)
540 AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[
541 _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS])
545 dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
547 dnl add a library to the link line and path to linkpath/runpath.
548 dnl if shared-libadd is not empty and $ext_shared is yes,
549 dnl shared-libadd will be assigned the library information
551 AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[
553 if test -n "$2"; then
558 if test "$ext_shared" = "yes"; then
560 if test -n "$2"; then
561 PHP_ADD_LIBPATH($2,$3)
564 PHP_ADD_LIBRARY_WITH_PATH($1,$2)
570 dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd])
572 dnl add a library to the link line (deferred)
573 dnl and path to linkpath/runpath (not deferred)
574 dnl if shared-libadd is not empty and $ext_shared is yes,
575 dnl shared-libadd will be assigned the library information
577 AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[
579 if test -n "$2"; then
582 PHP_ADD_LIBRARY_DEFER($1)
584 if test "$ext_shared" = "yes"; then
586 if test -n "$2"; then
587 PHP_ADD_LIBPATH($2,$3)
590 PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2)
596 dnl PHP_ADD_FRAMEWORK(framework [,before])
598 dnl add a (Darwin / Mac OS X) framework to the link
599 dnl line. if before is 1, the framework is added
600 dnl to the beginning of the line.
602 AC_DEFUN([PHP_ADD_FRAMEWORK], [
603 PHP_RUN_ONCE(FRAMEWORKS, $1, [
605 PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS"
607 PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1"
613 dnl PHP_ADD_FRAMEWORKPATH(path [,before])
615 dnl add a (Darwin / Mac OS X) framework path to the link
616 dnl and include lines. default paths include (but are
617 dnl not limited to) /Local/Library/Frameworks and
618 dnl /System/Library/Frameworks, so these don't need
619 dnl to be specifically added. if before is 1, the
620 dnl framework path is added to the beginning of the
623 AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [
624 PHP_EXPAND_PATH($1, ai_p)
625 PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [
627 PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH"
629 PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p"
635 dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path)
637 dnl Adds a (Darwin / Mac OS X) framework path and the
638 dnl framework itself to the link and include lines.
640 AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [
641 PHP_ADD_FRAMEWORKPATH($2)
642 PHP_ADD_FRAMEWORK($1)
646 dnl PHP_SET_LIBTOOL_VARIABLE(var)
648 dnl Set libtool variable
650 AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[
651 if test -z "$LIBTOOL"; then
652 LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
654 LIBTOOL="$LIBTOOL $1"
658 dnl -------------------------------------------------------------------------
659 dnl Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE
660 dnl -------------------------------------------------------------------------
662 dnl PHP_ARG_ANALYZE_EX
664 AC_DEFUN([PHP_ARG_ANALYZE_EX],[
665 ext_output="yes, shared"
669 $1=`echo "[$]$1"|$SED 's/^shared,//'`
684 PHP_ALWAYS_SHARED([$1])
689 AC_DEFUN([PHP_ARG_ANALYZE],[
690 ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)])
691 ifelse([$2],,,[AC_MSG_RESULT([$ext_output])])
695 dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]])
696 dnl Sets PHP_ARG_NAME either to the user value or to the default value.
697 dnl default-val defaults to no. This will also set the variable ext_shared,
698 dnl and will overwrite any previous variable of that name.
699 dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
700 dnl the PHP_ARG_ANALYZE_EX.
702 AC_DEFUN([PHP_ARG_WITH],[
703 php_with_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
704 PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
707 dnl PHP_REAL_ARG_WITH
709 AC_DEFUN([PHP_REAL_ARG_WITH],[
710 ifelse([$2],,,[AC_MSG_CHECKING([$2])])
711 AC_ARG_WITH($1,[$3],$5=[$]withval,
714 ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
716 PHP_ARG_ANALYZE($5,[$2],$6)
720 dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]])
721 dnl Sets PHP_ARG_NAME either to the user value or to the default value.
722 dnl default-val defaults to no. This will also set the variable ext_shared,
723 dnl and will overwrite any previous variable of that name.
724 dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
725 dnl the PHP_ARG_ANALYZE_EX.
727 AC_DEFUN([PHP_ARG_ENABLE],[
728 php_enable_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
729 PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
732 dnl PHP_REAL_ARG_ENABLE
734 AC_DEFUN([PHP_REAL_ARG_ENABLE],[
735 ifelse([$2],,,[AC_MSG_CHECKING([$2])])
736 AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
739 ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
741 PHP_ARG_ANALYZE($5,[$2],$6)
744 dnl -------------------------------------------------------------------------
746 dnl -------------------------------------------------------------------------
749 dnl PHP_BUILD_THREAD_SAFE
751 AC_DEFUN([PHP_BUILD_THREAD_SAFE],[
752 enable_maintainer_zts=yes
753 if test "$pthreads_working" != "yes"; then
754 AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.])
761 AC_DEFUN([PHP_REQUIRE_CXX],[
762 if test -z "$php_cxx_done"; then
765 PHP_ADD_LIBRARY(stdc++)
773 AC_DEFUN([PHP_BUILD_SHARED],[
775 OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
776 php_sapi_module=shared
778 php_c_pre=$shared_c_pre
779 php_c_meta=$shared_c_meta
780 php_c_post=$shared_c_post
781 php_cxx_pre=$shared_cxx_pre
782 php_cxx_meta=$shared_cxx_meta
783 php_cxx_post=$shared_cxx_post
790 AC_DEFUN([PHP_BUILD_STATIC],[
792 OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
793 php_sapi_module=static
799 AC_DEFUN([PHP_BUILD_BUNDLE],[
801 OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle]
802 php_sapi_module=static
806 dnl PHP_BUILD_PROGRAM
808 AC_DEFUN([PHP_BUILD_PROGRAM],[
809 php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
810 php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
812 php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
813 php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
818 yes) pic_setting='-prefer-pic';;
819 no) pic_setting='-prefer-non-pic';;
822 shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
823 shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting
825 shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
826 shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting
832 dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext)
834 dnl Basically sets up the link-stage for building module-name
835 dnl from object_var in build-dir.
837 AC_DEFUN([PHP_SHARED_MODULE],[
838 install_modules="install-modules"
843 link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -Wl,-G -o '$3'/$1.la -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) $(translit($1,a-z_-,A-Z__)_SHARED_LIBADD) && mv -f '$3'/.libs/$1.so '$3'/$1.so'
847 link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o [$]@ -shared -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) ifelse($1, php5lib, , -L$(top_builddir)/netware -lphp5lib) $(translit(ifelse($1, php5lib, $1, m4_substr($1, 3)),a-z_-,A-Z__)_SHARED_LIBADD)'
851 link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o [$]@ -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) $(translit($1,a-z_-,A-Z__)_SHARED_LIBADD)'
855 if test "x$5" = "xyes"; then
856 PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix"
858 PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix"
861 cat >>Makefile.objects<<EOF
862 \$(phplibdir)/$1.$suffix: $3/$1.$suffix
863 \$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir)
865 $3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
872 dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
874 dnl Selects the SAPI name and type (static, shared, bundle, program)
875 dnl and optionally also the source-files for the SAPI-specific
878 AC_DEFUN([PHP_SELECT_SAPI],[
879 if test "$2" = "program"; then
880 PHP_BINARIES="$PHP_BINARIES $1"
881 elif test "$PHP_SAPI" != "none"; then
883 +--------------------------------------------------------------------+
884 | *** ATTENTION *** |
886 | You've configured multiple SAPIs to be build. You can build only |
887 | one SAPI module plus CGI, CLI and FPM binaries at the same time. |
888 +--------------------------------------------------------------------+
894 PHP_ADD_BUILD_DIR([sapi/$1])
896 PHP_INSTALLED_SAPIS="$PHP_INSTALLED_SAPIS $1"
900 install_binaries="install-binaries"
901 install_binary_targets="$install_binary_targets install-$1"
902 PHP_SUBST(PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)
903 ifelse($3,,,[PHP_ADD_SOURCES_X([sapi/$1],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)])
906 static[)] PHP_BUILD_STATIC;;
907 shared[)] PHP_BUILD_SHARED;;
908 bundle[)] PHP_BUILD_BUNDLE;;
910 install_sapi="install-sapi"
911 ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
916 AC_DEFUN([PHP_EXTENSION],[
917 sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
919 PHP_NEW_EXTENSION($1, $sources, $2, $3)
921 if test -r "$ext_srcdir/Makefile.frag"; then
922 PHP_ADD_MAKEFILE_FRAGMENT
926 AC_DEFUN([PHP_ADD_BUILD_DIR],[
928 BUILD_DIR="$BUILD_DIR $1"
930 $php_shtool mkdir -p $1
934 AC_DEFUN([PHP_GEN_BUILD_DIRS],[
935 $php_shtool mkdir -p $BUILD_DIR
939 dnl PHP_NEW_EXTENSION(extname, sources [, shared [, sapi_class [, extra-cflags [, cxx [, zend_ext]]]]])
941 dnl Includes an extension in the build.
943 dnl "extname" is the name of the ext/ subdir where the extension resides.
944 dnl "sources" is a list of files relative to the subdir which are used
945 dnl to build the extension.
946 dnl "shared" can be set to "shared" or "yes" to build the extension as
947 dnl a dynamically loadable library. Optional parameter "sapi_class" can
948 dnl be set to "cli" to mark extension build only with CLI or CGI sapi's.
949 dnl "extra-cflags" are passed to the compiler, with
950 dnl @ext_srcdir@ and @ext_builddir@ being substituted.
951 dnl "cxx" can be used to indicate that a C++ shared module is desired.
952 dnl "zend_ext" indicates a zend extension.
953 AC_DEFUN([PHP_NEW_EXTENSION],[
954 ext_builddir=[]PHP_EXT_BUILDDIR($1)
955 ext_srcdir=[]PHP_EXT_SRCDIR($1)
957 ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`])
959 if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then
960 dnl ---------------------------------------------- Static module
961 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
962 PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
963 EXT_STATIC="$EXT_STATIC $1"
964 if test "$3" != "nocli"; then
965 EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
968 if test "$3" = "shared" || test "$3" = "yes"; then
969 dnl ---------------------------------------------- Shared module
970 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes
971 PHP_ADD_SOURCES_X(PHP_EXT_DIR($1),$2,$ac_extra,shared_objects_$1,yes)
974 PHP_SHARED_MODULE(php$1,shared_objects_$1, $ext_builddir, $6, $7)
977 PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7)
980 AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
984 if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then
985 dnl ---------------------------------------------- CLI static module
986 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
989 PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
990 EXT_STATIC="$EXT_STATIC $1"
993 PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cli)
996 EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
998 PHP_ADD_BUILD_DIR($ext_builddir)
1000 dnl Set for phpize builds only
1001 dnl ---------------------------
1002 if test "$ext_builddir" = "."; then
1003 PHP_PECL_EXTENSION=$1
1004 PHP_SUBST(PHP_PECL_EXTENSION)
1011 dnl Checks whether $withval is "shared" or starts with "shared,XXX"
1012 dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
1015 AC_DEFUN([PHP_WITH_SHARED],[
1016 PHP_ARG_ANALYZE_EX(withval)
1018 unset ext_shared ext_output
1022 dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf])
1024 dnl This macro is scanned by genif.sh when it builds the internal functions
1025 dnl list, so that modules can be init'd in the correct order
1026 dnl $1 = name of extension, $2 = extension upon which it depends
1027 dnl $3 = optional: if true, it's ok for $2 to have not been configured
1028 dnl default is false and should halt the build.
1029 dnl To be effective, this macro must be invoked *after* PHP_NEW_EXTENSION.
1030 dnl The extension on which it depends must also have been configured.
1031 dnl See ADD_EXTENSION_DEP in win32 build
1033 AC_DEFUN([PHP_ADD_EXTENSION_DEP], [
1034 am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]
1035 is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED]
1036 is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__)
1037 if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
1039 You've configured extension $1 to build statically, but it
1040 depends on extension $2, which you've configured to build shared.
1041 You either need to build $1 shared or build $2 statically for the
1042 build to be successful.
1045 if test "x$is_it_enabled" = "xno" && test "x$3" != "xtrue"; then
1047 You've configured extension $1, which depends on extension $2,
1048 but you've either not enabled $2, or have disabled it.
1051 dnl Some systems require that we link $2 to $1 when building
1054 dnl -------------------------------------------------------------------------
1055 dnl Checks for structures, typedefs, broken functions, etc.
1056 dnl -------------------------------------------------------------------------
1058 dnl Internal helper macros
1060 dnl _PHP_DEF_HAVE_FILE(what, filename)
1061 AC_DEFUN([_PHP_DEF_HAVE_FILE], [
1062 php_def_have_what=HAVE_[]`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_' `
1063 echo "#define $php_def_have_what 1" >> $2
1066 dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
1068 AC_DEFUN([_PHP_CHECK_SIZEOF], [
1069 php_cache_value=php_cv_sizeof_[]$1
1070 AC_CACHE_VAL(php_cv_sizeof_[]$1, [
1073 old_LDFLAGS=$LDFLAGS
1075 AC_TRY_RUN([#include <stdio.h>
1080 #ifdef HAVE_INTTYPES_H
1081 #include <inttypes.h>
1083 #ifdef HAVE_UNISTD_H
1090 FILE *fp = fopen("conftestval", "w");
1092 fprintf(fp, "%d\n", sizeof($1));
1096 eval $php_cache_value=`cat conftestval`
1098 eval $php_cache_value=0
1100 ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2])
1102 LDFLAGS=$old_LDFLAGS
1105 if eval test "\$$php_cache_value" != "0"; then
1106 ifelse([$4],[],:,[$4])
1107 ifelse([$5],[],,[else $5])
1112 dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
1114 AC_DEFUN([PHP_CHECK_SIZEOF], [
1115 AC_MSG_CHECKING([size of $1])
1116 _PHP_CHECK_SIZEOF($1, $2, $3, [
1117 AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1])
1118 AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available])
1120 AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)])
1124 dnl PHP_CHECK_TYPES(type-list, include-file [, extra-headers])
1126 AC_DEFUN([PHP_CHECK_TYPES], [
1127 for php_typename in $1; do
1128 AC_MSG_CHECKING([whether $php_typename exists])
1129 _PHP_CHECK_SIZEOF($php_typename, 0, $3, [
1130 _PHP_DEF_HAVE_FILE($php_typename, $2)
1131 AC_MSG_RESULT([yes])
1139 dnl PHP_CHECK_IN_ADDR_T
1141 AC_DEFUN([PHP_CHECK_IN_ADDR_T], [
1142 dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
1143 AC_MSG_CHECKING([for in_addr_t])
1144 AC_CACHE_VAL(ac_cv_type_in_addr_t,
1146 changequote(<<,>>)dnl
1147 <<in_addr_t[^a-zA-Z_0-9]>>dnl
1148 changequote([,]), [#include <sys/types.h>
1153 #ifdef HAVE_NETINET_IN_H
1154 #include <netinet/in.h>
1155 #endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
1156 AC_MSG_RESULT([$ac_cv_type_in_addr_t])
1157 if test $ac_cv_type_in_addr_t = no; then
1158 AC_DEFINE(in_addr_t, u_int, [ ])
1165 dnl Check type of reentrant time-related functions
1166 dnl Type can be: irix, hpux or POSIX
1168 AC_DEFUN([PHP_TIME_R_TYPE],[
1169 AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
1179 s = gmtime_r(&old, &t);
1180 r = (int) asctime_r(&t, buf, 26);
1181 if (r == s && s == 0) return (0);
1185 ac_cv_time_r_type=hpux
1194 s = gmtime_r(&old, &t);
1195 p = asctime_r(&t, buf, 26);
1196 if (p == buf && s == &t) return (0);
1200 ac_cv_time_r_type=irix
1202 ac_cv_time_r_type=POSIX
1204 ac_cv_time_r_type=POSIX
1207 ac_cv_time_r_type=POSIX
1210 case $ac_cv_time_r_type in
1211 hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
1212 irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
1217 dnl PHP_DOES_PWRITE_WORK
1219 AC_DEFUN([PHP_DOES_PWRITE_WORK],[
1221 #include <sys/types.h>
1222 #include <sys/stat.h>
1228 int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
1230 if (fd < 0) exit(1);
1231 if (pwrite(fd, "text", 4, 0) != 4) exit(1);
1232 /* Linux glibc breakage until 2.2.5 */
1233 if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1);
1246 dnl PHP_DOES_PREAD_WORK
1248 AC_DEFUN([PHP_DOES_PREAD_WORK],[
1249 echo test > conftest_in
1251 #include <sys/types.h>
1252 #include <sys/stat.h>
1259 int fd = open("conftest_in", O_RDONLY);
1260 if (fd < 0) exit(1);
1261 if (pread(fd, buf, 2, 0) != 2) exit(1);
1262 /* Linux glibc breakage until 2.2.5 */
1263 if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1);
1279 AC_DEFUN([PHP_PWRITE_TEST],[
1280 AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
1281 PHP_DOES_PWRITE_WORK
1282 if test "$ac_cv_pwrite" = "no"; then
1283 PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
1284 if test "$ac_cv_pwrite" = "yes"; then
1290 if test "$ac_cv_pwrite" != "no"; then
1291 AC_DEFINE(HAVE_PWRITE, 1, [ ])
1292 if test "$ac_cv_pwrite" = "64"; then
1293 AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
1301 AC_DEFUN([PHP_PREAD_TEST],[
1302 AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
1304 if test "$ac_cv_pread" = "no"; then
1305 PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
1306 if test "$ac_cv_pread" = "yes"; then
1312 if test "$ac_cv_pread" != "no"; then
1313 AC_DEFINE(HAVE_PREAD, 1, [ ])
1314 if test "$ac_cv_pread" = "64"; then
1315 AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
1321 dnl PHP_MISSING_TIME_R_DECL
1323 AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
1324 AC_MSG_CHECKING([for missing declarations of reentrant functions])
1325 AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
1328 AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
1330 AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
1333 AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
1335 AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
1338 AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
1340 AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
1343 AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
1345 AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
1348 AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
1350 AC_MSG_RESULT([done])
1354 dnl PHP_READDIR_R_TYPE
1356 AC_DEFUN([PHP_READDIR_R_TYPE],[
1357 dnl HAVE_READDIR_R is also defined by libmysql
1358 AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
1359 if test "$ac_cv_func_readdir_r" = "yes"; then
1360 AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
1363 #include <sys/types.h>
1367 #define PATH_MAX 1024
1372 char entry[sizeof(struct dirent)+PATH_MAX];
1373 struct dirent *pentry = (struct dirent *) &entry;
1378 if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
1383 ac_cv_what_readdir_r=POSIX
1387 #include <sys/types.h>
1389 int readdir_r(DIR *, struct dirent *);
1391 ac_cv_what_readdir_r=old-style
1393 ac_cv_what_readdir_r=none
1396 ac_cv_what_readdir_r=none
1399 case $ac_cv_what_readdir_r in
1401 AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
1403 AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
1411 AC_DEFUN([PHP_TM_GMTOFF],[
1412 AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
1413 [AC_TRY_COMPILE([#include <sys/types.h>
1414 #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
1415 ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
1417 if test "$ac_cv_struct_tm_gmtoff" = yes; then
1418 AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
1423 dnl PHP_STRUCT_FLOCK
1425 AC_DEFUN([PHP_STRUCT_FLOCK],[
1426 AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
1433 ac_cv_struct_flock=yes
1435 ac_cv_struct_flock=no
1438 if test "$ac_cv_struct_flock" = "yes" ; then
1439 AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
1446 AC_DEFUN([PHP_SOCKLEN_T],[
1447 AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
1449 #include <sys/types.h>
1450 #include <sys/socket.h>
1458 if test "$ac_cv_socklen_t" = "yes"; then
1459 AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
1464 dnl PHP_MISSING_FCLOSE_DECL
1466 dnl See if we have broken header files like SunOS has.
1468 AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
1469 AC_MSG_CHECKING([for fclose declaration])
1470 AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
1471 AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
1474 AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
1475 AC_MSG_RESULT([missing])
1480 dnl PHP_AC_BROKEN_SPRINTF
1482 dnl Check for broken sprintf(), C99 conformance
1484 AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[
1485 AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
1486 AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
1487 ac_cv_broken_sprintf=no
1489 ac_cv_broken_sprintf=yes
1491 ac_cv_broken_sprintf=no
1494 if test "$ac_cv_broken_sprintf" = "yes"; then
1495 AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform])
1497 AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform])
1502 dnl PHP_AC_BROKEN_SNPRINTF
1504 dnl Check for broken snprintf(), C99 conformance
1506 AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[
1507 AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[
1513 res = res || (snprintf(buf, 2, "marcus") != 6);
1514 res = res || (buf[1] != '\0');
1515 /* Implementations may consider this as an encoding error */
1516 snprintf(buf, 0, "boerger");
1517 /* However, they MUST ignore the pointer */
1518 res = res || (buf[0] != 'm');
1519 res = res || (snprintf(NULL, 0, "boerger") != 7);
1520 res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
1524 ac_cv_broken_snprintf=no
1526 ac_cv_broken_snprintf=yes
1528 ac_cv_broken_snprintf=no
1531 if test "$ac_cv_broken_snprintf" = "yes"; then
1532 AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform])
1534 AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform])
1539 dnl PHP_SOLARIS_PIC_WEIRDNESS
1541 dnl Solaris requires main code to be position independent in order
1542 dnl to let shared objects find symbols. Weird. Ugly.
1544 dnl Must be run after all --with-NN options that let the user
1545 dnl choose dynamic extensions, and after the gcc test.
1547 AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[
1548 AC_MSG_CHECKING([whether -fPIC is required])
1549 if test -n "$EXT_SHARED"; then
1550 os=`uname -sr 2>/dev/null`
1552 "SunOS 5.6"|"SunOS 5.7"[)]
1555 CFLAGS="$CFLAGS -fPIC";;
1557 CFLAGS="$CFLAGS -fpic";;
1559 AC_MSG_RESULT([yes]);;
1561 AC_MSG_RESULT([no]);;
1571 dnl The problem is that the default compilation flags in Solaris 2.6 won't
1572 dnl let programs access large files; you need to tell the compiler that
1573 dnl you actually want your programs to work on large files. For more
1574 dnl details about this brain damage please see:
1575 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
1577 dnl Written by Paul Eggert <eggert@twinsun.com>.
1579 AC_DEFUN([PHP_SYS_LFS],
1581 # If available, prefer support for large files unless the user specified
1582 # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
1583 AC_MSG_CHECKING([whether large file support needs explicit enabling])
1587 ac_shellvars='CPPFLAGS LDFLAGS LIBS'
1588 for ac_shellvar in $ac_shellvars; do
1589 case $ac_shellvar in
1590 CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;;
1591 *[)] ac_lfsvar=LFS_$ac_shellvar ;;
1593 eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
1594 (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
1595 ac_getconf=`getconf $ac_lfsvar`
1596 ac_getconfs=$ac_getconfs$ac_getconf
1597 eval ac_test_$ac_shellvar=\$ac_getconf
1599 case "$ac_result$ac_getconfs" in
1600 yes[)] ac_result=no ;;
1602 case "$ac_result$ac_set" in
1603 yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings"
1605 AC_MSG_RESULT([$ac_result])
1608 for ac_shellvar in $ac_shellvars; do
1609 eval $ac_shellvar=\$ac_test_$ac_shellvar
1615 dnl PHP_SOCKADDR_CHECKS
1617 AC_DEFUN([PHP_SOCKADDR_CHECKS], [
1618 dnl Check for struct sockaddr_storage exists
1619 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage,
1620 [AC_TRY_COMPILE([#include <sys/types.h>
1621 #include <sys/socket.h>],
1622 [struct sockaddr_storage s; s],
1623 [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no])
1625 if test "$ac_cv_sockaddr_storage" = "yes"; then
1626 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
1628 dnl Check if field sa_len exists in struct sockaddr
1629 AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
1630 AC_TRY_COMPILE([#include <sys/types.h>
1631 #include <sys/socket.h>],
1632 [static struct sockaddr sa; int n = (int) sa.sa_len; return n;],
1633 [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no])
1635 if test "$ac_cv_sockaddr_sa_len" = "yes"; then
1636 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len])
1641 dnl PHP_DECLARED_TIMEZONE
1643 AC_DEFUN([PHP_DECLARED_TIMEZONE],[
1644 AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
1646 #include <sys/types.h>
1648 #ifdef HAVE_SYS_TIME_H
1649 #include <sys/time.h>
1652 time_t foo = (time_t) timezone;
1654 ac_cv_declared_timezone=yes
1656 ac_cv_declared_timezone=no
1658 if test "$ac_cv_declared_timezone" = "yes"; then
1659 AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
1666 AC_DEFUN([PHP_EBCDIC], [
1667 AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
1670 return (unsigned char)'A' != (unsigned char)0xC1;
1679 if test "$ac_cv_ebcdic" = "yes"; then
1680 AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
1685 dnl PHP_BROKEN_GETCWD
1687 dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a
1688 dnl component of the path has execute but not read permissions
1690 AC_DEFUN([PHP_BROKEN_GETCWD],[
1691 AC_MSG_CHECKING([for broken getcwd])
1692 os=`uname -sr 2>/dev/null`
1695 AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd])
1696 AC_MSG_RESULT([yes]);;
1698 AC_MSG_RESULT([no]);;
1703 dnl PHP_BROKEN_GLIBC_FOPEN_APPEND
1705 AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
1706 AC_MSG_CHECKING([for broken libc stdio])
1707 AC_CACHE_VAL(_cv_have_broken_glibc_fopen_append,[
1710 int main(int argc, char *argv[])
1714 char *filename = "/tmp/phpglibccheck";
1716 fp = fopen(filename, "w");
1721 fputs("foobar", fp);
1724 fp = fopen(filename, "a+");
1725 position = ftell(fp);
1733 [_cv_have_broken_glibc_fopen_append=no],
1734 [_cv_have_broken_glibc_fopen_append=yes ],
1736 #include <features.h>
1738 #if !__GLIBC_PREREQ(2,2)
1742 [_cv_have_broken_glibc_fopen_append=yes],
1743 [_cv_have_broken_glibc_fopen_append=no ])
1746 if test "$_cv_have_broken_glibc_fopen_append" = "yes"; then
1748 AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
1757 AC_DEFUN([PHP_FOPENCOOKIE], [
1758 AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes])
1760 if test "$have_glibc_fopencookie" = "yes"; then
1761 dnl this comes in two flavors:
1762 dnl newer glibcs (since 2.1.2 ? )
1763 dnl have a type called cookie_io_functions_t
1767 ], [cookie_io_functions_t cookie;], [have_cookie_io_functions_t=yes], [])
1769 if test "$have_cookie_io_functions_t" = "yes"; then
1770 cookie_io_functions_t=cookie_io_functions_t
1771 have_fopen_cookie=yes
1773 dnl even newer glibcs have a different seeker definition...
1782 __ssize_t reader(void *cookie, char *buffer, size_t size)
1784 __ssize_t writer(void *cookie, const char *buffer, size_t size)
1786 int closer(void *cookie)
1788 int seeker(void *cookie, __off64_t *position, int whence)
1789 { ((struct cookiedata*)cookie)->pos = *position; return 0; }
1791 cookie_io_functions_t funcs = {reader, writer, seeker, closer};
1794 struct cookiedata g = { 0 };
1795 FILE *fp = fopencookie(&g, "r", funcs);
1797 if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
1803 cookie_io_functions_use_off64_t=yes
1805 cookie_io_functions_use_off64_t=no
1807 cookie_io_functions_use_off64_t=no
1812 dnl older glibc versions (up to 2.1.2 ?)
1813 dnl call it _IO_cookie_io_functions_t
1817 ], [ _IO_cookie_io_functions_t cookie; ], [have_IO_cookie_io_functions_t=yes], [])
1818 if test "$have_cookie_io_functions_t" = "yes" ; then
1819 cookie_io_functions_t=_IO_cookie_io_functions_t
1820 have_fopen_cookie=yes
1824 if test "$have_fopen_cookie" = "yes" ; then
1825 AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
1826 AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
1827 if test "$cookie_io_functions_use_off64_t" = "yes" ; then
1828 AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ])
1834 dnl -------------------------------------------------------------------------
1835 dnl Library/function existance and build sanity checks
1836 dnl -------------------------------------------------------------------------
1839 dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
1841 dnl Wrapper for AC_CHECK_LIB
1843 AC_DEFUN([PHP_CHECK_LIBRARY], [
1844 save_old_LDFLAGS=$LDFLAGS
1847 save_ext_shared=$ext_shared
1849 PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
1850 AC_CHECK_LIB([$1],[$2],[
1851 LDFLAGS=$save_old_LDFLAGS
1852 ext_shared=$save_ext_shared
1855 LDFLAGS=$save_old_LDFLAGS
1856 ext_shared=$save_ext_shared
1857 unset ac_cv_lib_$1[]_$2
1863 dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]])
1865 dnl El cheapo wrapper for AC_CHECK_LIB
1867 AC_DEFUN([PHP_CHECK_FRAMEWORK], [
1868 save_old_LDFLAGS=$LDFLAGS
1869 LDFLAGS="-framework $1 $LDFLAGS"
1870 dnl supplying "c" to AC_CHECK_LIB is technically cheating, but
1871 dnl rewriting AC_CHECK_LIB is overkill and this only affects
1872 dnl the "checking.." output anyway.
1873 AC_CHECK_LIB(c,[$2],[
1874 LDFLAGS=$save_old_LDFLAGS
1877 LDFLAGS=$save_old_LDFLAGS
1883 dnl PHP_CHECK_FUNC_LIB(func, libs)
1885 dnl This macro checks whether 'func' or '__func' exists
1886 dnl in the specified library.
1887 dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
1888 dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC
1891 dnl autoconf undefines the builtin "shift" :-(
1892 dnl If possible, we use the builtin shift anyway, otherwise we use
1893 dnl the ubercool definition I have tested so far with FreeBSD/GNU m4
1894 ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
1895 define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
1898 AC_DEFUN([PHP_CHECK_FUNC_LIB],[
1900 unset ac_cv_lib_$2[]_$1
1901 unset ac_cv_lib_$2[]___$1
1903 AC_CHECK_LIB($2, $1, [found=yes], [
1904 AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
1907 if test "$found" = "yes"; then
1910 AC_TRY_RUN([main() { return (0); }],[found=yes],[found=no],[found=no])
1914 if test "$found" = "yes"; then
1920 PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
1926 dnl PHP_CHECK_FUNC(func, ...)
1928 dnl This macro checks whether 'func' or '__func' exists
1929 dnl in the default libraries and as a fall back in the specified library.
1930 dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
1932 AC_DEFUN([PHP_CHECK_FUNC],[
1934 unset ac_cv_func___$1
1937 AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
1945 *[)] PHP_CHECK_FUNC_LIB($@) ;;
1951 dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]])
1953 dnl This macro checks whether build works and given function exists.
1955 AC_DEFUN([PHP_TEST_BUILD], [
1976 dnl -------------------------------------------------------------------------
1977 dnl Platform characteristics checks
1978 dnl -------------------------------------------------------------------------
1981 dnl PHP_SHLIB_SUFFIX_NAMES
1983 dnl Determines link library suffix SHLIB_SUFFIX_NAME
1984 dnl which can be: .so, .sl or .dylib
1986 dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME
1987 dnl suffix can be: .so or .sl
1989 AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[
1990 AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
1991 PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
1992 PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME)
1993 SHLIB_SUFFIX_NAME=so
1994 SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME
1997 SHLIB_SUFFIX_NAME=sl
1998 SHLIB_DL_SUFFIX_NAME=sl
2001 SHLIB_SUFFIX_NAME=dylib
2002 SHLIB_DL_SUFFIX_NAME=so
2008 dnl PHP_CHECK_64BIT([do if 32], [do if 64])
2010 dnl This macro is used to detect if we're at 64-bit platform or not.
2011 dnl It could be useful for those external libs, that have different precompiled
2012 dnl versions in different directories.
2014 AC_DEFUN([PHP_CHECK_64BIT],[
2015 AC_CHECK_SIZEOF(long int, 4)
2016 AC_MSG_CHECKING([checking if we're at 64-bit platform])
2017 if test "$ac_cv_sizeof_long_int" = "4" ; then
2021 AC_MSG_RESULT([yes])
2029 dnl Replacement macro for AC_C_BIGENDIAN
2031 AC_DEFUN([PHP_C_BIGENDIAN],
2032 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
2034 ac_cv_c_bigendian_php=unknown
2040 char *cp = (char *)&one;
2048 ], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
2050 if test $ac_cv_c_bigendian_php = yes; then
2051 AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word])
2055 dnl -------------------------------------------------------------------------
2056 dnl Checks for programs: PHP_PROG_<program>
2057 dnl -------------------------------------------------------------------------
2060 dnl PHP_PROG_SENDMAIL
2062 dnl Search for the sendmail binary
2064 AC_DEFUN([PHP_PROG_SENDMAIL], [
2065 PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
2066 AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH)
2067 PHP_SUBST(PROG_SENDMAIL)
2073 dnl Some vendors force mawk before gawk; mawk is broken so we don't like that
2075 AC_DEFUN([PHP_PROG_AWK], [
2076 AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
2079 AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
2084 AC_MSG_ERROR([Could not find awk; Install GNU awk])
2087 AC_MSG_CHECKING([if $AWK is broken])
2088 if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
2089 AC_MSG_RESULT([yes])
2090 AC_MSG_ERROR([You should install GNU awk])
2102 dnl Search for bison and check it's version
2104 AC_DEFUN([PHP_PROG_BISON], [
2113 dnl Search for (f)lex and check it's version
2115 AC_DEFUN([PHP_PROG_LEX], [
2116 dnl we only support certain flex versions
2117 flex_version_list="2.5.4"
2120 if test "$LEX" = "flex"; then
2121 dnl AC_DECL_YYTEXT is obsolete since autoconf 2.50 and merged into AC_PROG_LEX
2122 dnl this is what causes that annoying "PHP_PROG_LEX is expanded from" warning with autoconf 2.50+
2123 dnl it should be removed once we drop support of autoconf 2.13 (if ever)
2127 dnl ## Make flex scanners use const if they can, even if __STDC__ is not
2128 dnl ## true, for compilers like Sun's that only set __STDC__ true in
2129 dnl ## "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
2131 if test "$ac_cv_c_const" = "yes" ; then
2132 LEX_CFLAGS="-DYY_USE_CONST"
2135 if test "$LEX" = "flex"; then
2136 AC_CACHE_CHECK([for flex version], php_cv_flex_version, [
2137 flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'`
2138 php_cv_flex_version=invalid
2139 for flex_check_version in $flex_version_list; do
2140 if test "$flex_version" = "$flex_check_version"; then
2141 php_cv_flex_version="$flex_check_version (ok)"
2149 case $php_cv_flex_version in
2151 if test -f "$abs_srcdir/Zend/zend_language_scanner.c" && test -f "$abs_srcdir/Zend/zend_ini_scanner.c"; then
2152 AC_MSG_WARN([flex versions supported for regeneration of the Zend/PHP parsers: $flex_version_list (found: $flex_version)])
2154 flex_msg="Supported flex versions are: $flex_version_list"
2155 if test "$flex_version" = "none"; then
2156 flex_msg="flex not found. flex is required to generate the Zend/PHP parsers! $flex_msg"
2158 flex_msg="Found invalid flex version: $flex_version. $flex_msg"
2160 AC_MSG_ERROR([$flex_msg])
2171 dnl Search for the re2c binary and check the version
2173 AC_DEFUN([PHP_PROG_RE2C],[
2174 AC_CHECK_PROG(RE2C, re2c, re2c)
2175 if test -n "$RE2C"; then
2176 AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [
2177 re2c_vernum=`$RE2C --vernum 2>/dev/null`
2178 if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1304"; then
2179 php_cv_re2c_version=invalid
2181 php_cv_re2c_version="`$RE2C --version | cut -d ' ' -f 2 2>/dev/null` (ok)"
2185 case $php_cv_re2c_version in
2187 AC_MSG_WARN([You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.])
2194 dnl -------------------------------------------------------------------------
2195 dnl Common setup macros: PHP_SETUP_<what>
2196 dnl -------------------------------------------------------------------------
2199 dnl PHP_SETUP_ICU([shared-add])
2201 dnl Common setup macro for ICU
2203 AC_DEFUN([PHP_SETUP_ICU],[
2204 PHP_ARG_WITH(icu-dir,,
2205 [ --with-icu-dir=DIR Specify where ICU libraries and headers can be found], DEFAULT, no)
2207 if test "$PHP_ICU_DIR" = "no"; then
2211 if test "$PHP_ICU_DIR" = "DEFAULT"; then
2212 dnl Try to find icu-config
2213 AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
2215 ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
2218 AC_MSG_CHECKING([for location of ICU headers and libraries])
2220 dnl Trust icu-config to know better what the install prefix is..
2221 icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
2222 if test "$?" != "0" || test -z "$icu_install_prefix"; then
2223 AC_MSG_RESULT([not found])
2224 AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
2226 AC_MSG_RESULT([$icu_install_prefix])
2228 dnl Check ICU version
2229 AC_MSG_CHECKING([for ICU 3.4 or greater])
2230 icu_version_full=`$ICU_CONFIG --version`
2233 set $icu_version_full
2235 icu_version=`expr [$]1 \* 1000 + [$]2`
2236 AC_MSG_RESULT([found $icu_version_full])
2238 if test "$icu_version" -lt "3004"; then
2239 AC_MSG_ERROR([ICU version 3.4 or later is required])
2242 ICU_VERSION=$icu_version
2243 ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
2244 ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
2245 PHP_EVAL_INCLINE($ICU_INCS)
2246 PHP_EVAL_LIBLINE($ICU_LIBS, $1)
2251 dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]])
2253 dnl Common setup macro for kerberos
2255 AC_DEFUN([PHP_SETUP_KERBEROS],[
2257 unset KERBEROS_CFLAGS
2260 dnl First try to find krb5-config
2261 if test -z "$KRB5_CONFIG"; then
2262 AC_PATH_PROG(KRB5_CONFIG, krb5-config, no, [$PATH:/usr/kerberos/bin:/usr/local/bin])
2265 dnl If krb5-config is found try using it
2266 if test "$PHP_KERBEROS" = "yes" && test -x "$KRB5_CONFIG"; then
2267 KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi`
2268 KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi`
2270 if test -n "$KERBEROS_LIBS"; then
2272 PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1)
2273 PHP_EVAL_INCLINE($KERBEROS_CFLAGS)
2277 dnl If still not found use old skool method
2278 if test "$found_kerberos" = "no"; then
2280 if test "$PHP_KERBEROS" = "yes"; then
2281 PHP_KERBEROS="/usr/kerberos /usr/local /usr"
2284 for i in $PHP_KERBEROS; do
2285 if test -f $i/$PHP_LIBDIR/libkrb5.a || test -f $i/$PHP_LIBDIR/libkrb5.$SHLIB_SUFFIX_NAME; then
2291 if test "$PHP_KERBEROS_DIR"; then
2293 PHP_ADD_LIBPATH($PHP_KERBEROS_DIR/$PHP_LIBDIR, $1)
2294 PHP_ADD_LIBRARY(gssapi_krb5, 1, $1)
2295 PHP_ADD_LIBRARY(krb5, 1, $1)
2296 PHP_ADD_LIBRARY(k5crypto, 1, $1)
2297 PHP_ADD_LIBRARY(com_err, 1, $1)
2298 PHP_ADD_INCLUDE($PHP_KERBEROS_DIR/include)
2302 if test "$found_kerberos" = "yes"; then
2303 ifelse([$2],[],:,[$2])
2304 ifelse([$3],[],,[else $3])
2309 dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
2311 dnl Common setup macro for openssl
2313 AC_DEFUN([PHP_SETUP_OPENSSL],[
2315 unset OPENSSL_INCDIR
2316 unset OPENSSL_LIBDIR
2318 dnl Empty variable means 'no'
2319 test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
2320 test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
2322 dnl Fallbacks for different configure options
2323 if test "$PHP_OPENSSL" != "no"; then
2324 PHP_OPENSSL_DIR=$PHP_OPENSSL
2325 elif test "$PHP_IMAP_SSL" != "no"; then
2326 PHP_OPENSSL_DIR=$PHP_IMAP_SSL
2329 dnl First try to find pkg-config
2330 if test -z "$PKG_CONFIG"; then
2331 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2334 dnl If pkg-config is found try using it
2335 if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
2336 if $PKG_CONFIG --atleast-version=0.9.6 openssl; then
2338 OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
2339 OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
2340 OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
2342 AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
2345 if test -n "$OPENSSL_LIBS" && test -n "$OPENSSL_INCS"; then
2346 PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
2347 PHP_EVAL_INCLINE($OPENSSL_INCS)
2351 dnl If pkg-config fails for some reason, revert to the old method
2352 if test "$found_openssl" = "no"; then
2354 if test "$PHP_OPENSSL_DIR" = "yes"; then
2355 PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
2358 for i in $PHP_OPENSSL_DIR; do
2359 if test -r $i/include/openssl/evp.h; then
2360 OPENSSL_INCDIR=$i/include
2362 if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
2363 OPENSSL_LIBDIR=$i/$PHP_LIBDIR
2365 test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
2368 if test -z "$OPENSSL_INCDIR"; then
2369 AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
2372 if test -z "$OPENSSL_LIBDIR"; then
2373 AC_MSG_ERROR([Cannot find OpenSSL's libraries])
2376 old_CPPFLAGS=$CPPFLAGS
2377 CPPFLAGS=-I$OPENSSL_INCDIR
2378 AC_MSG_CHECKING([for OpenSSL version])
2380 #include <openssl/opensslv.h>
2381 #if OPENSSL_VERSION_NUMBER >= 0x0090600fL
2385 AC_MSG_RESULT([>= 0.9.6])
2387 AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
2389 CPPFLAGS=$old_CPPFLAGS
2391 PHP_ADD_INCLUDE($OPENSSL_INCDIR)
2393 PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
2394 PHP_ADD_LIBRARY(crypto,,$1)
2396 AC_MSG_ERROR([libcrypto not found!])
2402 LIBS="$LIBS -lcrypto"
2403 PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
2406 AC_MSG_ERROR([libssl not found!])
2411 PHP_ADD_LIBRARY(ssl,,$1)
2412 PHP_ADD_LIBRARY(crypto,,$1)
2414 PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1)
2417 if test "$found_openssl" = "yes"; then
2418 dnl For apache 1.3.x static build
2419 OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
2420 AC_SUBST(OPENSSL_INCDIR_OPT)
2422 ifelse([$2],[],:,[$2])
2423 ifelse([$3],[],,[else $3])
2428 dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
2430 dnl Common setup macro for iconv
2432 AC_DEFUN([PHP_SETUP_ICONV], [
2436 # Create the directories for a VPATH build:
2437 $php_shtool mkdir -p ext/iconv
2439 echo > ext/iconv/php_have_bsd_iconv.h
2440 echo > ext/iconv/php_have_ibm_iconv.h
2441 echo > ext/iconv/php_have_glibc_iconv.h
2442 echo > ext/iconv/php_have_libiconv.h
2443 echo > ext/iconv/php_have_iconv.h
2444 echo > ext/iconv/php_php_iconv_impl.h
2445 echo > ext/iconv/php_iconv_aliased_libiconv.h
2446 echo > ext/iconv/php_php_iconv_h_path.h
2447 echo > ext/iconv/php_iconv_supports_errno.h
2450 dnl Check libc first if no path is provided in --with-iconv
2453 if test "$PHP_ICONV" = "yes"; then
2454 dnl Reset LIBS temporarily as it may have already been included
2458 AC_CHECK_FUNC(iconv, [
2461 AC_CHECK_FUNC(libiconv,[
2462 PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
2463 AC_DEFINE(HAVE_LIBICONV, 1, [ ])
2471 dnl Check external libs for iconv funcs
2473 if test "$found_iconv" = "no"; then
2475 for i in $PHP_ICONV /usr/local /usr; do
2476 if test -r $i/include/giconv.h; then
2477 AC_DEFINE(HAVE_GICONV_H, 1, [ ])
2479 iconv_lib_name=giconv
2481 elif test -r $i/include/iconv.h; then
2483 iconv_lib_name=iconv
2488 if test -z "$ICONV_DIR"; then
2489 AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
2492 if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
2493 test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
2495 PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
2497 PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
2498 AC_DEFINE(HAVE_LIBICONV,1,[ ])
2499 PHP_DEFINE([ICONV_ALIASED_LIBICONV],1,[ext/iconv])
2500 AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv])
2502 PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
2505 -L$ICONV_DIR/$PHP_LIBDIR
2508 -L$ICONV_DIR/$PHP_LIBDIR
2513 if test "$found_iconv" = "yes"; then
2514 PHP_DEFINE(HAVE_ICONV,1,[ext/iconv])
2515 AC_DEFINE(HAVE_ICONV,1,[ ])
2516 if test -n "$ICONV_DIR"; then
2517 PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1)
2518 PHP_ADD_INCLUDE($ICONV_DIR/include)
2521 ifelse([$3],[],,[else $3])
2526 dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]])
2528 dnl Common setup macro for libxml
2530 AC_DEFUN([PHP_SETUP_LIBXML], [
2531 AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
2533 for i in $PHP_LIBXML_DIR /usr/local /usr; do
2534 if test -x "$i/bin/xml2-config"; then
2535 ac_cv_php_xml2_config_path="$i/bin/xml2-config"
2541 if test -x "$ac_cv_php_xml2_config_path"; then
2542 XML2_CONFIG="$ac_cv_php_xml2_config_path"
2543 libxml_full_version=`$XML2_CONFIG --version`
2546 set $libxml_full_version
2548 LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
2549 if test "$LIBXML_VERSION" -ge "2006011"; then
2550 LIBXML_LIBS=`$XML2_CONFIG --libs`
2551 LIBXML_INCS=`$XML2_CONFIG --cflags`
2552 PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
2553 PHP_EVAL_INCLINE($LIBXML_INCS)
2555 dnl Check that build works with given libs
2556 AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
2557 PHP_TEST_BUILD(xmlInitParser,
2559 php_cv_libxml_build_works=yes
2562 AC_MSG_ERROR([build test failed. Please check the config.log for details.])
2567 if test "$php_cv_libxml_build_works" = "yes"; then
2568 AC_DEFINE(HAVE_LIBXML, 1, [ ])
2572 AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
2574 ifelse([$3],[],,[else $3])
2578 dnl -------------------------------------------------------------------------
2580 dnl -------------------------------------------------------------------------
2583 dnl PHP_INSTALL_HEADERS(path [, file ...])
2585 dnl PHP header files to be installed
2587 AC_DEFUN([PHP_INSTALL_HEADERS],[
2589 for header_file in $1; do
2590 PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [
2591 INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
2596 for header_file in $2; do
2597 hp_hf="$header_path/$header_file"
2598 PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [
2599 INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf"
2606 dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
2608 dnl This macro is used to get a comparable
2609 dnl version for apache1/2.
2611 AC_DEFUN([PHP_AP_EXTRACT_VERSION],[
2612 ac_output=`$1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'`
2619 APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
2623 dnl PHP_DEBUG_MACRO(filename)
2625 AC_DEFUN([PHP_DEBUG_MACRO],[
2628 CONFIGURE: $CONFIGURE_COMMAND
2639 PHP_RPATHS: $PHP_RPATHS
2640 uname -a: `uname -a`
2643 cat >conftest.$ac_ext <<X
2649 (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
2654 dnl PHP_CONFIG_NICE(filename)
2656 dnl Generates the config.nice file
2658 AC_DEFUN([PHP_CONFIG_NICE],[
2659 AC_REQUIRE([AC_PROG_EGREP])
2660 AC_REQUIRE([LT_AC_PROG_SED])
2661 PHP_SUBST_OLD(EGREP)
2663 test -f $1 && mv $1 $1.old
2668 # Created by configure
2672 for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do
2674 if test -n "$val"; then
2675 echo "$var='$val' \\" >> $1
2679 echo "'[$]0' \\" >> $1
2680 if test `expr -- [$]0 : "'.*"` = 0; then
2681 CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'"
2683 CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0"
2685 for arg in $ac_configure_args; do
2686 if test `expr -- $arg : "'.*"` = 0; then
2687 if test `expr -- $arg : "--.*"` = 0; then
2690 echo "'[$]arg' \\" >> $1
2691 CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS '[$]arg'"
2693 if test `expr -- $arg : "'--.*"` = 0; then
2696 echo "[$]arg \\" >> $1
2697 CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS [$]arg"
2702 CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS"
2703 PHP_SUBST_OLD(CONFIGURE_COMMAND)
2704 PHP_SUBST_OLD(CONFIGURE_OPTIONS)
2708 dnl PHP_CHECK_CONFIGURE_OPTIONS
2710 AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
2711 for arg in $ac_configure_args; do
2714 arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
2717 arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
2720 arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
2723 arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
2730 # Allow --disable-all / --enable-all
2733 # Allow certain libtool options
2734 enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];;
2736 # Allow certain TSRM options
2737 with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads[)];;
2739 # Allow certain Zend options
2740 with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];;
2742 # All the rest must be set using the PHP_ARG_* macros
2743 # PHP_ARG_* macros set php_enable_<arg_name> or php_with_<arg_name>
2745 # Options that exist before PHP 6
2746 if test "$PHP_MAJOR_VERSION" -lt "6"; then
2748 enable-zend-multibyte[)] continue;;
2752 is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'`
2753 if eval test "x\$$is_arg_set" = "x"; then
2754 PHP_UNKNOWN_CONFIGURE_OPTIONS="$PHP_UNKNOWN_CONFIGURE_OPTIONS
2763 dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]])
2765 AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[
2766 AC_CACHE_CHECK([for PDO includes], pdo_cv_inc_path, [
2767 AC_MSG_CHECKING([for PDO includes])
2768 if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
2769 pdo_cv_inc_path=$abs_srcdir/ext
2770 elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
2771 pdo_cv_inc_path=$abs_srcdir/ext
2772 elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
2773 pdo_cv_inc_path=$prefix/include/php/ext
2776 if test -n "$pdo_cv_inc_path"; then
2777 ifelse([$1],[],:,[$1])
2779 ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2])
2785 dnl Detect Intel C++ Compiler and unset $GCC if ICC found
2786 AC_DEFUN([PHP_DETECT_ICC],
2789 AC_MSG_CHECKING([for icc])
2790 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
2792 AC_MSG_RESULT([no]),
2795 AC_MSG_RESULT([yes])
2799 dnl PHP_DETECT_SUNCC
2800 dnl Detect if the systems default compiler is suncc.
2801 dnl We also set some usefull CFLAGS if the user didn't set any
2802 AC_DEFUN([PHP_DETECT_SUNCC],[
2804 AC_MSG_CHECKING([for suncc])
2805 AC_EGREP_CPP([^__SUNPRO_C], [__SUNPRO_C],
2807 AC_MSG_RESULT([no]),
2810 test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload"
2812 AC_MSG_RESULT([yes])
2817 dnl PHP_CRYPT_R_STYLE
2818 dnl detect the style of crypt_r() is any is available
2819 dnl see APR_CHECK_CRYPT_R_STYLE() for original version
2821 AC_DEFUN([PHP_CRYPT_R_STYLE],
2823 AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[
2824 php_cv_crypt_r_style=none
2826 #define _REENTRANT 1
2830 crypt_r("passwd", "hash", &buffer);
2832 php_cv_crypt_r_style=cryptd)
2834 if test "$php_cv_crypt_r_style" = "none"; then
2836 #define _REENTRANT 1
2839 struct crypt_data buffer;
2840 crypt_r("passwd", "hash", &buffer);
2842 php_cv_crypt_r_style=struct_crypt_data)
2845 if test "$php_cv_crypt_r_style" = "none"; then
2847 #define _REENTRANT 1
2851 struct crypt_data buffer;
2852 crypt_r("passwd", "hash", &buffer);
2854 php_cv_crypt_r_style=struct_crypt_data_gnu_source)
2858 if test "$php_cv_crypt_r_style" = "cryptd"; then
2859 AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
2861 if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
2862 AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
2864 if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
2865 AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE])
2867 if test "$php_cv_crypt_r_style" = "none"; then
2868 AC_MSG_ERROR([Unable to detect data struct used by crypt_r])
2873 dnl PHP_TEST_WRITE_STDOUT
2875 AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
2876 AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
2878 #ifdef HAVE_UNISTD_H
2882 #define TEXT "This is the test message -- "
2888 n = write(1, TEXT, sizeof(TEXT)-1);
2889 return (!(n == sizeof(TEXT)-1));
2892 ac_cv_write_stdout=yes
2894 ac_cv_write_stdout=no
2896 ac_cv_write_stdout=no
2899 if test "$ac_cv_write_stdout" = "yes"; then
2900 AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])
2905 dnl PHP_INIT_DTRACE(providerdesc, header-file, sources [, module])
2907 AC_DEFUN([PHP_INIT_DTRACE],[
2908 dnl Set paths properly when called from extension
2910 ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir;;
2911 /*[)] ac_srcdir=`echo "$4"|cut -c 2-`"/"; ac_bdir=$ac_srcdir;;
2912 *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$4/";;
2926 dnl Add providerdesc.o into global objects when needed
2929 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.o"
2930 PHP_LDFLAGS="$PHP_LDFLAGS -lelf"
2933 PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.o"
2939 for ac_src in $3; do
2945 PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo"
2948 case [$]php_sapi_module in
2950 for ac_lo in $PHP_DTRACE_OBJS; do
2951 dtrace_objs="[$]dtrace_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`"
2955 dtrace_objs='$(PHP_DTRACE_OBJS:.lo=.o)'
2959 dnl Generate Makefile.objects entries
2960 cat>>Makefile.objects<<EOF
2962 $ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc
2963 dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@ && \$(SED) -ibak 's,PHP_,DTRACE_,g' \$[]@
2965 \$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj
2967 $ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS)
2968 dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs