2 dnl $Id: acinclude.m4,v 1.332.2.14.2.26 2007/08/20 14:28:45 jani Exp $
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,cli,PHP_CLI_OBJS,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" && test "$1" != "/usr/lib64"; 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,
715 if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
719 PHP_ARG_ANALYZE($5,[$2],$6)
723 dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]])
724 dnl Sets PHP_ARG_NAME either to the user value or to the default value.
725 dnl default-val defaults to no. This will also set the variable ext_shared,
726 dnl and will overwrite any previous variable of that name.
727 dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
728 dnl the PHP_ARG_ANALYZE_EX.
730 AC_DEFUN([PHP_ARG_ENABLE],[
731 php_enable_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
732 PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
735 dnl PHP_REAL_ARG_ENABLE
737 AC_DEFUN([PHP_REAL_ARG_ENABLE],[
738 ifelse([$2],,,[AC_MSG_CHECKING([$2])])
739 AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
743 if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
747 PHP_ARG_ANALYZE($5,[$2],$6)
750 dnl -------------------------------------------------------------------------
752 dnl -------------------------------------------------------------------------
755 dnl PHP_BUILD_THREAD_SAFE
757 AC_DEFUN([PHP_BUILD_THREAD_SAFE],[
758 enable_maintainer_zts=yes
759 if test "$pthreads_working" != "yes"; then
760 AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.])
767 AC_DEFUN([PHP_REQUIRE_CXX],[
768 if test -z "$php_cxx_done"; then
778 AC_DEFUN([PHP_BUILD_SHARED],[
780 OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
781 php_build_target=shared
783 php_c_pre=$shared_c_pre
784 php_c_meta=$shared_c_meta
785 php_c_post=$shared_c_post
786 php_cxx_pre=$shared_cxx_pre
787 php_cxx_meta=$shared_cxx_meta
788 php_cxx_post=$shared_cxx_post
795 AC_DEFUN([PHP_BUILD_STATIC],[
797 OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
798 php_build_target=static
804 AC_DEFUN([PHP_BUILD_BUNDLE],[
806 OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle]
807 php_build_target=static
811 dnl PHP_BUILD_PROGRAM
813 AC_DEFUN([PHP_BUILD_PROGRAM],[
814 OVERALL_TARGET=[]ifelse($1,,php,$1)
815 php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
816 php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
818 php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
819 php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
824 yes) pic_setting='-prefer-pic';;
825 no) pic_setting='-prefer-non-pic';;
828 shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
829 shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting
831 shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
832 shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting
836 php_build_target=program
840 dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx)
842 dnl Basically sets up the link-stage for building module-name
843 dnl from object_var in build-dir.
845 AC_DEFUN([PHP_SHARED_MODULE],[
846 install_modules="install-modules"
851 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'
855 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)'
859 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)'
863 PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix"
865 cat >>Makefile.objects<<EOF
866 \$(phplibdir)/$1.$suffix: $3/$1.$suffix
867 \$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir)
869 $3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
876 dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
878 dnl Selects the SAPI name and type (static, shared, programm)
879 dnl and optionally also the source-files for the SAPI-specific
882 AC_DEFUN([PHP_SELECT_SAPI],[
886 static[)] PHP_BUILD_STATIC;;
887 shared[)] PHP_BUILD_SHARED;;
888 bundle[)] PHP_BUILD_BUNDLE;;
889 program[)] PHP_BUILD_PROGRAM($5);;
892 ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
896 AC_DEFUN([PHP_EXTENSION],[
897 sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
899 PHP_NEW_EXTENSION($1, $sources, $2, $3)
901 if test -r "$ext_srcdir/Makefile.frag"; then
902 PHP_ADD_MAKEFILE_FRAGMENT
906 AC_DEFUN([PHP_ADD_BUILD_DIR],[
908 BUILD_DIR="$BUILD_DIR $1"
910 $php_shtool mkdir -p $1
914 AC_DEFUN([PHP_GEN_BUILD_DIRS],[
915 $php_shtool mkdir -p $BUILD_DIR
919 dnl PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags[, cxx]]]])
921 dnl Includes an extension in the build.
923 dnl "extname" is the name of the ext/ subdir where the extension resides.
924 dnl "sources" is a list of files relative to the subdir which are used
925 dnl to build the extension.
926 dnl "shared" can be set to "shared" or "yes" to build the extension as
927 dnl a dynamically loadable library. Optional parameter "sapi_class" can
928 dnl be set to "cli" to mark extension build only with CLI or CGI sapi's.
929 dnl "extra-cflags" are passed to the compiler, with
930 dnl @ext_srcdir@ and @ext_builddir@ being substituted.
931 AC_DEFUN([PHP_NEW_EXTENSION],[
932 ext_builddir=[]PHP_EXT_BUILDDIR($1)
933 ext_srcdir=[]PHP_EXT_SRCDIR($1)
935 ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`])
937 if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then
938 dnl ---------------------------------------------- Static module
939 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
940 PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
941 EXT_STATIC="$EXT_STATIC $1"
942 if test "$3" != "nocli"; then
943 EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
946 if test "$3" = "shared" || test "$3" = "yes"; then
947 dnl ---------------------------------------------- Shared module
948 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes
949 PHP_ADD_SOURCES_X(PHP_EXT_DIR($1),$2,$ac_extra,shared_objects_$1,yes)
952 PHP_SHARED_MODULE(php$1,shared_objects_$1, $ext_builddir, $6)
955 PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6)
958 AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
962 if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then
963 dnl ---------------------------------------------- CLI static module
964 [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
965 if test "$PHP_SAPI" = "cgi"; then
966 PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
967 EXT_STATIC="$EXT_STATIC $1"
969 PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cli)
971 EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
973 PHP_ADD_BUILD_DIR($ext_builddir)
975 dnl Set for phpize builds only
976 dnl ---------------------------
977 if test "$ext_builddir" = "."; then
978 PHP_PECL_EXTENSION=$1
979 PHP_SUBST(PHP_PECL_EXTENSION)
986 dnl Checks whether $withval is "shared" or starts with "shared,XXX"
987 dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
990 AC_DEFUN([PHP_WITH_SHARED],[
991 PHP_ARG_ANALYZE_EX(withval)
993 unset ext_shared ext_output
997 dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf])
999 dnl This macro is scanned by genif.sh when it builds the internal functions
1000 dnl list, so that modules can be init'd in the correct order
1001 dnl $1 = name of extension, $2 = extension upon which it depends
1002 dnl $3 = optional: if true, it's ok for $2 to have not been configured
1003 dnl default is false and should halt the build.
1004 dnl To be effective, this macro must be invoked *after* PHP_NEW_EXTENSION.
1005 dnl The extension on which it depends must also have been configured.
1006 dnl See ADD_EXTENSION_DEP in win32 build
1008 AC_DEFUN([PHP_ADD_EXTENSION_DEP], [
1009 am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]
1010 is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED]
1011 is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__)
1012 if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
1014 You've configured extension $1 to build statically, but it
1015 depends on extension $2, which you've configured to build shared.
1016 You either need to build $1 shared or build $2 statically for the
1017 build to be successful.
1020 if test "x$is_it_enabled" = "xno" && test "x$3" != "xtrue"; then
1022 You've configured extension $1, which depends on extension $2,
1023 but you've either not enabled $2, or have disabled it.
1026 dnl Some systems require that we link $2 to $1 when building
1029 dnl -------------------------------------------------------------------------
1030 dnl Checks for structures, typedefs, broken functions, etc.
1031 dnl -------------------------------------------------------------------------
1033 dnl Internal helper macros
1035 dnl _PHP_DEF_HAVE_FILE(what, filename)
1036 AC_DEFUN([_PHP_DEF_HAVE_FILE], [
1037 php_def_have_what=HAVE_[]`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_' `
1038 echo "#define $php_def_have_what 1" >> $2
1041 dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
1043 AC_DEFUN([_PHP_CHECK_SIZEOF], [
1044 php_cache_value=php_cv_sizeof_[]$1
1045 AC_CACHE_VAL(php_cv_sizeof_[]$1, [
1048 old_LDFLAGS=$LDFLAGS
1050 AC_TRY_RUN([#include <stdio.h>
1055 #ifdef HAVE_INTTYPES_H
1056 #include <inttypes.h>
1058 #ifdef HAVE_UNISTD_H
1065 FILE *fp = fopen("conftestval", "w");
1067 fprintf(fp, "%d\n", sizeof($1));
1071 eval $php_cache_value=`cat conftestval`
1073 eval $php_cache_value=0
1075 ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2])
1077 LDFLAGS=$old_LDFLAGS
1080 if eval test "\$$php_cache_value" != "0"; then
1081 ifelse([$4],[],:,[$4])
1082 ifelse([$5],[],,[else $5])
1087 dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
1089 AC_DEFUN(PHP_CHECK_SIZEOF, [
1090 AC_MSG_CHECKING([size of $1])
1091 _PHP_CHECK_SIZEOF($1, $2, $3, [
1092 AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1])
1093 AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available])
1095 AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)])
1099 dnl PHP_CHECK_TYPES(type-list, include-file [, extra-headers])
1101 AC_DEFUN([PHP_CHECK_TYPES], [
1102 for php_typename in $1; do
1103 AC_MSG_CHECKING([whether $php_typename exists])
1104 _PHP_CHECK_SIZEOF($php_typename, 0, $3, [
1105 _PHP_DEF_HAVE_FILE($php_typename, $2)
1106 AC_MSG_RESULT([yes])
1114 dnl PHP_CHECK_IN_ADDR_T
1116 AC_DEFUN([PHP_CHECK_IN_ADDR_T], [
1117 dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
1118 AC_MSG_CHECKING([for in_addr_t])
1119 AC_CACHE_VAL(ac_cv_type_in_addr_t,
1121 changequote(<<,>>)dnl
1122 <<in_addr_t[^a-zA-Z_0-9]>>dnl
1123 changequote([,]), [#include <sys/types.h>
1128 #ifdef HAVE_NETINET_IN_H
1129 #include <netinet/in.h>
1130 #endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
1131 AC_MSG_RESULT([$ac_cv_type_in_addr_t])
1132 if test $ac_cv_type_in_addr_t = no; then
1133 AC_DEFINE(in_addr_t, u_int, [ ])
1140 dnl Check type of reentrant time-related functions
1141 dnl Type can be: irix, hpux or POSIX
1143 AC_DEFUN([PHP_TIME_R_TYPE],[
1144 AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
1154 s = gmtime_r(&old, &t);
1155 r = (int) asctime_r(&t, buf, 26);
1156 if (r == s && s == 0) return (0);
1160 ac_cv_time_r_type=hpux
1169 s = gmtime_r(&old, &t);
1170 p = asctime_r(&t, buf, 26);
1171 if (p == buf && s == &t) return (0);
1175 ac_cv_time_r_type=irix
1177 ac_cv_time_r_type=POSIX
1179 ac_cv_time_r_type=POSIX
1182 ac_cv_time_r_type=POSIX
1185 case $ac_cv_time_r_type in
1186 hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
1187 irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
1192 dnl PHP_DOES_PWRITE_WORK
1194 AC_DEFUN([PHP_DOES_PWRITE_WORK],[
1196 #include <sys/types.h>
1197 #include <sys/stat.h>
1203 int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
1205 if (fd < 0) exit(1);
1206 if (pwrite(fd, "text", 4, 0) != 4) exit(1);
1207 /* Linux glibc breakage until 2.2.5 */
1208 if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1);
1221 dnl PHP_DOES_PREAD_WORK
1223 AC_DEFUN([PHP_DOES_PREAD_WORK],[
1224 echo test > conftest_in
1226 #include <sys/types.h>
1227 #include <sys/stat.h>
1234 int fd = open("conftest_in", O_RDONLY);
1235 if (fd < 0) exit(1);
1236 if (pread(fd, buf, 2, 0) != 2) exit(1);
1237 /* Linux glibc breakage until 2.2.5 */
1238 if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1);
1254 AC_DEFUN([PHP_PWRITE_TEST],[
1255 AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
1256 PHP_DOES_PWRITE_WORK
1257 if test "$ac_cv_pwrite" = "no"; then
1258 PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
1259 if test "$ac_cv_pwrite" = "yes"; then
1265 if test "$ac_cv_pwrite" != "no"; then
1266 AC_DEFINE(HAVE_PWRITE, 1, [ ])
1267 if test "$ac_cv_pwrite" = "64"; then
1268 AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
1276 AC_DEFUN([PHP_PREAD_TEST],[
1277 AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
1279 if test "$ac_cv_pread" = "no"; then
1280 PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
1281 if test "$ac_cv_pread" = "yes"; then
1287 if test "$ac_cv_pread" != "no"; then
1288 AC_DEFINE(HAVE_PREAD, 1, [ ])
1289 if test "$ac_cv_pread" = "64"; then
1290 AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
1296 dnl PHP_MISSING_TIME_R_DECL
1298 AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
1299 AC_MSG_CHECKING([for missing declarations of reentrant functions])
1300 AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
1303 AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
1305 AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
1308 AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
1310 AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
1313 AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
1315 AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
1318 AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
1320 AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
1323 AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
1325 AC_MSG_RESULT([done])
1329 dnl PHP_READDIR_R_TYPE
1331 AC_DEFUN([PHP_READDIR_R_TYPE],[
1332 dnl HAVE_READDIR_R is also defined by libmysql
1333 AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
1334 if test "$ac_cv_func_readdir_r" = "yes"; then
1335 AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
1338 #include <sys/types.h>
1342 #define PATH_MAX 1024
1347 char entry[sizeof(struct dirent)+PATH_MAX];
1348 struct dirent *pentry = (struct dirent *) &entry;
1353 if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
1358 ac_cv_what_readdir_r=POSIX
1362 #include <sys/types.h>
1364 int readdir_r(DIR *, struct dirent *);
1366 ac_cv_what_readdir_r=old-style
1368 ac_cv_what_readdir_r=none
1371 ac_cv_what_readdir_r=none
1374 case $ac_cv_what_readdir_r in
1376 AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
1378 AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
1386 AC_DEFUN([PHP_TM_GMTOFF],[
1387 AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
1388 [AC_TRY_COMPILE([#include <sys/types.h>
1389 #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
1390 ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
1392 if test "$ac_cv_struct_tm_gmtoff" = yes; then
1393 AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
1398 dnl PHP_STRUCT_FLOCK
1400 AC_DEFUN([PHP_STRUCT_FLOCK],[
1401 AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
1408 ac_cv_struct_flock=yes
1410 ac_cv_struct_flock=no
1413 if test "$ac_cv_struct_flock" = "yes" ; then
1414 AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
1421 AC_DEFUN([PHP_SOCKLEN_T],[
1422 AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
1424 #include <sys/types.h>
1425 #include <sys/socket.h>
1433 if test "$ac_cv_socklen_t" = "yes"; then
1434 AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
1439 dnl PHP_MISSING_FCLOSE_DECL
1441 dnl See if we have broken header files like SunOS has.
1443 AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
1444 AC_MSG_CHECKING([for fclose declaration])
1445 AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
1446 AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
1449 AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
1450 AC_MSG_RESULT([missing])
1455 dnl PHP_AC_BROKEN_SPRINTF
1457 dnl Check for broken sprintf(), C99 conformance
1459 AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[
1460 AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
1461 AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
1462 ac_cv_broken_sprintf=no
1464 ac_cv_broken_sprintf=yes
1466 ac_cv_broken_sprintf=no
1469 if test "$ac_cv_broken_sprintf" = "yes"; then
1470 AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform])
1472 AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform])
1477 dnl PHP_AC_BROKEN_SNPRINTF
1479 dnl Check for broken snprintf(), C99 conformance
1481 AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[
1482 AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[
1488 res = res || (snprintf(buf, 2, "marcus") != 6);
1489 res = res || (buf[1] != '\0');
1490 /* Implementations may consider this as an encoding error */
1491 snprintf(buf, 0, "boerger");
1492 /* However, they MUST ignore the pointer */
1493 res = res || (buf[0] != 'm');
1494 res = res || (snprintf(NULL, 0, "boerger") != 7);
1495 res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
1499 ac_cv_broken_snprintf=no
1501 ac_cv_broken_snprintf=yes
1503 ac_cv_broken_snprintf=no
1506 if test "$ac_cv_broken_snprintf" = "yes"; then
1507 AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform])
1509 AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform])
1514 dnl PHP_SOLARIS_PIC_WEIRDNESS
1516 dnl Solaris requires main code to be position independent in order
1517 dnl to let shared objects find symbols. Weird. Ugly.
1519 dnl Must be run after all --with-NN options that let the user
1520 dnl choose dynamic extensions, and after the gcc test.
1522 AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[
1523 AC_MSG_CHECKING([whether -fPIC is required])
1524 if test -n "$EXT_SHARED"; then
1525 os=`uname -sr 2>/dev/null`
1527 "SunOS 5.6"|"SunOS 5.7"[)]
1530 CFLAGS="$CFLAGS -fPIC";;
1532 CFLAGS="$CFLAGS -fpic";;
1534 AC_MSG_RESULT([yes]);;
1536 AC_MSG_RESULT([no]);;
1546 dnl The problem is that the default compilation flags in Solaris 2.6 won't
1547 dnl let programs access large files; you need to tell the compiler that
1548 dnl you actually want your programs to work on large files. For more
1549 dnl details about this brain damage please see:
1550 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
1552 dnl Written by Paul Eggert <eggert@twinsun.com>.
1554 AC_DEFUN([PHP_SYS_LFS],
1556 # If available, prefer support for large files unless the user specified
1557 # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
1558 AC_MSG_CHECKING([whether large file support needs explicit enabling])
1562 ac_shellvars='CPPFLAGS LDFLAGS LIBS'
1563 for ac_shellvar in $ac_shellvars; do
1564 case $ac_shellvar in
1565 CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;;
1566 *[)] ac_lfsvar=LFS_$ac_shellvar ;;
1568 eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
1569 (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
1570 ac_getconf=`getconf $ac_lfsvar`
1571 ac_getconfs=$ac_getconfs$ac_getconf
1572 eval ac_test_$ac_shellvar=\$ac_getconf
1574 case "$ac_result$ac_getconfs" in
1575 yes[)] ac_result=no ;;
1577 case "$ac_result$ac_set" in
1578 yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings"
1580 AC_MSG_RESULT([$ac_result])
1583 for ac_shellvar in $ac_shellvars; do
1584 eval $ac_shellvar=\$ac_test_$ac_shellvar
1590 dnl PHP_SOCKADDR_CHECKS
1592 AC_DEFUN([PHP_SOCKADDR_CHECKS], [
1593 dnl Check for struct sockaddr_storage exists
1594 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage,
1595 [AC_TRY_COMPILE([#include <sys/types.h>
1596 #include <sys/socket.h>],
1597 [struct sockaddr_storage s; s],
1598 [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no])
1600 if test "$ac_cv_sockaddr_storage" = "yes"; then
1601 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
1603 dnl Check if field sa_len exists in struct sockaddr
1604 AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
1605 AC_TRY_COMPILE([#include <sys/types.h>
1606 #include <sys/socket.h>],
1607 [static struct sockaddr sa; int n = (int) sa.sa_len; return n;],
1608 [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no])
1610 if test "$ac_cv_sockaddr_sa_len" = "yes"; then
1611 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len])
1616 dnl PHP_DECLARED_TIMEZONE
1618 AC_DEFUN([PHP_DECLARED_TIMEZONE],[
1619 AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
1621 #include <sys/types.h>
1623 #ifdef HAVE_SYS_TIME_H
1624 #include <sys/time.h>
1627 time_t foo = (time_t) timezone;
1629 ac_cv_declared_timezone=yes
1631 ac_cv_declared_timezone=no
1633 if test "$ac_cv_declared_timezone" = "yes"; then
1634 AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
1641 AC_DEFUN([PHP_EBCDIC], [
1642 AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
1645 return (unsigned char)'A' != (unsigned char)0xC1;
1654 if test "$ac_cv_ebcdic" = "yes"; then
1655 AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
1660 dnl PHP_BROKEN_GETCWD
1662 dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a
1663 dnl component of the path has execute but not read permissions
1665 AC_DEFUN([PHP_BROKEN_GETCWD],[
1666 AC_MSG_CHECKING([for broken getcwd])
1667 os=`uname -sr 2>/dev/null`
1670 AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd])
1671 AC_MSG_RESULT([yes]);;
1673 AC_MSG_RESULT([no]);;
1678 dnl PHP_BROKEN_GLIBC_FOPEN_APPEND
1680 AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
1681 AC_MSG_CHECKING([for broken libc stdio])
1682 AC_CACHE_VAL(have_broken_glibc_fopen_append,[
1685 int main(int argc, char *argv[])
1689 char *filename = "/tmp/phpglibccheck";
1691 fp = fopen(filename, "w");
1696 fputs("foobar", fp);
1699 fp = fopen(filename, "a+");
1700 position = ftell(fp);
1708 [have_broken_glibc_fopen_append=no],
1709 [have_broken_glibc_fopen_append=yes ],
1711 #include <features.h>
1713 #if !__GLIBC_PREREQ(2,2)
1717 [have_broken_glibc_fopen_append=yes],
1718 [have_broken_glibc_fopen_append=no ])
1721 if test "$have_broken_glibc_fopen_append" = "yes"; then
1723 AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
1732 AC_DEFUN([PHP_FOPENCOOKIE], [
1733 AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes])
1735 if test "$have_glibc_fopencookie" = "yes"; then
1736 dnl this comes in two flavors:
1737 dnl newer glibcs (since 2.1.2 ? )
1738 dnl have a type called cookie_io_functions_t
1742 ], [cookie_io_functions_t cookie;], [have_cookie_io_functions_t=yes], [])
1744 if test "$have_cookie_io_functions_t" = "yes"; then
1745 cookie_io_functions_t=cookie_io_functions_t
1746 have_fopen_cookie=yes
1748 dnl even newer glibcs have a different seeker definition...
1757 __ssize_t reader(void *cookie, char *buffer, size_t size)
1759 __ssize_t writer(void *cookie, const char *buffer, size_t size)
1761 int closer(void *cookie)
1763 int seeker(void *cookie, __off64_t *position, int whence)
1764 { ((struct cookiedata*)cookie)->pos = *position; return 0; }
1766 cookie_io_functions_t funcs = {reader, writer, seeker, closer};
1769 struct cookiedata g = { 0 };
1770 FILE *fp = fopencookie(&g, "r", funcs);
1772 if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
1778 cookie_io_functions_use_off64_t=yes
1780 cookie_io_functions_use_off64_t=no
1782 cookie_io_functions_use_off64_t=no
1787 dnl older glibc versions (up to 2.1.2 ?)
1788 dnl call it _IO_cookie_io_functions_t
1792 ], [ _IO_cookie_io_functions_t cookie; ], [have_IO_cookie_io_functions_t=yes], [])
1793 if test "$have_cookie_io_functions_t" = "yes" ; then
1794 cookie_io_functions_t=_IO_cookie_io_functions_t
1795 have_fopen_cookie=yes
1799 if test "$have_fopen_cookie" = "yes" ; then
1800 AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
1801 AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
1802 if test "$cookie_io_functions_use_off64_t" = "yes" ; then
1803 AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ])
1809 dnl -------------------------------------------------------------------------
1810 dnl Library/function existance and build sanity checks
1811 dnl -------------------------------------------------------------------------
1814 dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
1816 dnl Wrapper for AC_CHECK_LIB
1818 AC_DEFUN([PHP_CHECK_LIBRARY], [
1819 save_old_LDFLAGS=$LDFLAGS
1822 save_ext_shared=$ext_shared
1824 PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
1825 AC_CHECK_LIB([$1],[$2],[
1826 LDFLAGS=$save_old_LDFLAGS
1827 ext_shared=$save_ext_shared
1830 LDFLAGS=$save_old_LDFLAGS
1831 ext_shared=$save_ext_shared
1832 unset ac_cv_lib_$1[]_$2
1838 dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]])
1840 dnl El cheapo wrapper for AC_CHECK_LIB
1842 AC_DEFUN([PHP_CHECK_FRAMEWORK], [
1843 save_old_LDFLAGS=$LDFLAGS
1844 LDFLAGS="-framework $1 $LDFLAGS"
1845 dnl supplying "c" to AC_CHECK_LIB is technically cheating, but
1846 dnl rewriting AC_CHECK_LIB is overkill and this only affects
1847 dnl the "checking.." output anyway.
1848 AC_CHECK_LIB(c,[$2],[
1849 LDFLAGS=$save_old_LDFLAGS
1852 LDFLAGS=$save_old_LDFLAGS
1858 dnl PHP_CHECK_FUNC_LIB(func, libs)
1860 dnl This macro checks whether 'func' or '__func' exists
1861 dnl in the specified library.
1862 dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
1863 dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC
1866 dnl autoconf undefines the builtin "shift" :-(
1867 dnl If possible, we use the builtin shift anyway, otherwise we use
1868 dnl the ubercool definition I have tested so far with FreeBSD/GNU m4
1869 ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
1870 define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
1873 AC_DEFUN([PHP_CHECK_FUNC_LIB],[
1875 unset ac_cv_lib_$2[]_$1
1876 unset ac_cv_lib_$2[]___$1
1878 AC_CHECK_LIB($2, $1, [found=yes], [
1879 AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
1882 if test "$found" = "yes"; then
1885 AC_TRY_RUN([main() { return (0); }],[found=yes],[found=no],[found=no])
1889 if test "$found" = "yes"; then
1895 PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
1901 dnl PHP_CHECK_FUNC(func, ...)
1903 dnl This macro checks whether 'func' or '__func' exists
1904 dnl in the default libraries and as a fall back in the specified library.
1905 dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
1907 AC_DEFUN([PHP_CHECK_FUNC],[
1909 unset ac_cv_func___$1
1912 AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
1920 *[)] PHP_CHECK_FUNC_LIB($@) ;;
1926 dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]])
1928 dnl This macro checks whether build works and given function exists.
1930 AC_DEFUN([PHP_TEST_BUILD], [
1951 dnl -------------------------------------------------------------------------
1952 dnl Platform characteristics checks
1953 dnl -------------------------------------------------------------------------
1956 dnl PHP_SHLIB_SUFFIX_NAMES
1958 dnl Determines link library suffix SHLIB_SUFFIX_NAME
1959 dnl which can be: .so, .sl or .dylib
1961 dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME
1962 dnl suffix can be: .so or .sl
1964 AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[
1965 AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
1966 PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
1967 PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME)
1968 SHLIB_SUFFIX_NAME=so
1969 SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME
1972 SHLIB_SUFFIX_NAME=sl
1973 SHLIB_DL_SUFFIX_NAME=sl
1976 SHLIB_SUFFIX_NAME=dylib
1977 SHLIB_DL_SUFFIX_NAME=so
1983 dnl PHP_CHECK_64BIT([do if 32], [do if 64])
1985 dnl This macro is used to detect if we're at 64-bit platform or not.
1986 dnl It could be useful for those external libs, that have different precompiled
1987 dnl versions in different directories.
1989 AC_DEFUN([PHP_CHECK_64BIT],[
1990 AC_CHECK_SIZEOF(long int, 4)
1991 AC_MSG_CHECKING([checking if we're at 64-bit platform])
1992 if test "$ac_cv_sizeof_long_int" = "4" ; then
1996 AC_MSG_RESULT([yes])
2004 dnl Replacement macro for AC_C_BIGENDIAN
2006 AC_DEFUN([PHP_C_BIGENDIAN],
2007 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
2009 ac_cv_c_bigendian_php=unknown
2015 char *cp = (char *)&one;
2023 ], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
2025 if test $ac_cv_c_bigendian_php = yes; then
2026 AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word])
2030 dnl -------------------------------------------------------------------------
2031 dnl Checks for programs: PHP_PROG_<program>
2032 dnl -------------------------------------------------------------------------
2035 dnl PHP_PROG_SENDMAIL
2037 dnl Search for the sendmail binary
2039 AC_DEFUN([PHP_PROG_SENDMAIL], [
2040 PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib:/usr/lib64
2041 AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH)
2042 PHP_SUBST(PROG_SENDMAIL)
2048 dnl Some vendors force mawk before gawk; mawk is broken so we don't like that
2050 AC_DEFUN([PHP_PROG_AWK], [
2051 AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
2054 AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
2059 AC_MSG_ERROR([Could not find awk; Install GNU awk])
2062 AC_MSG_CHECKING([if $AWK is broken])
2063 if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
2064 AC_MSG_RESULT([yes])
2065 AC_MSG_ERROR([You should install GNU awk])
2077 dnl Search for bison and check it's version
2079 AC_DEFUN([PHP_PROG_BISON], [
2088 dnl Search for (f)lex and check it's version
2090 AC_DEFUN([PHP_PROG_LEX], [
2091 dnl we only support certain flex versions
2092 flex_version_list="2.5.4"
2095 if test "$LEX" = "flex"; then
2096 dnl AC_DECL_YYTEXT is obsolete since autoconf 2.50 and merged into AC_PROG_LEX
2097 dnl this is what causes that annoying "PHP_PROG_LEX is expanded from" warning with autoconf 2.50+
2098 dnl it should be removed once we drop support of autoconf 2.13 (if ever)
2102 dnl ## Make flex scanners use const if they can, even if __STDC__ is not
2103 dnl ## true, for compilers like Sun's that only set __STDC__ true in
2104 dnl ## "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
2106 if test "$ac_cv_c_const" = "yes" ; then
2107 LEX_CFLAGS="-DYY_USE_CONST"
2110 if test "$LEX" = "flex"; then
2111 AC_CACHE_CHECK([for flex version], php_cv_flex_version, [
2112 flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'`
2113 php_cv_flex_version=invalid
2114 for flex_check_version in $flex_version_list; do
2115 if test "$flex_version" = "$flex_check_version"; then
2116 php_cv_flex_version="$flex_check_version (ok)"
2124 case $php_cv_flex_version in
2126 if test -f "$abs_srcdir/Zend/zend_language_scanner.c" && test -f "$abs_srcdir/Zend/zend_ini_scanner.c"; then
2127 AC_MSG_WARN([flex versions supported for regeneration of the Zend/PHP parsers: $flex_version_list (found: $flex_version)])
2129 flex_msg="Supported flex versions are: $flex_version_list"
2130 if test "$flex_version" = "none"; then
2131 flex_msg="flex not found. flex is required to generate the Zend/PHP parsers! $flex_msg"
2133 flex_msg="Found invalid flex version: $flex_version. $flex_msg"
2135 AC_MSG_ERROR([$flex_msg])
2146 dnl Search for the re2c binary and check the version
2148 AC_DEFUN([PHP_PROG_RE2C],[
2149 AC_CHECK_PROG(RE2C, re2c, re2c)
2150 if test -n "$RE2C"; then
2151 AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [
2152 re2c_vernum=`re2c --vernum 2>/dev/null`
2153 if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1200"; then
2154 php_cv_re2c_version=invalid
2156 php_cv_re2c_version="`re2c --version | cut -d ' ' -f 2 2>/dev/null` (ok)"
2160 case $php_cv_re2c_version in
2162 AC_MSG_WARN([You will need re2c 0.12.0 or later if you want to regenerate PHP parsers.])
2169 dnl -------------------------------------------------------------------------
2170 dnl Common setup macros: PHP_SETUP_<what>
2171 dnl -------------------------------------------------------------------------
2174 dnl PHP_SETUP_ICU([shared-add])
2176 dnl Common setup macro for ICU
2178 AC_DEFUN([PHP_SETUP_ICU],[
2179 PHP_ARG_WITH(icu-dir,,
2180 [ --with-icu-dir=DIR Specify where ICU libraries and headers can be found], DEFAULT, no)
2182 if test "$PHP_ICU_DIR" = "no"; then
2186 if test "$PHP_ICU_DIR" = "DEFAULT"; then
2187 dnl Try to find icu-config
2188 AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
2190 ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
2193 AC_MSG_CHECKING([for location of ICU headers and libraries])
2195 dnl Trust icu-config to know better what the install prefix is..
2196 icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
2197 if test "$?" != "0" || test -z "$icu_install_prefix"; then
2198 AC_MSG_RESULT([not found])
2199 AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
2201 AC_MSG_RESULT([$icu_install_prefix])
2203 dnl Check ICU version
2204 AC_MSG_CHECKING([for ICU 3.4 or greater])
2205 icu_version_full=`$ICU_CONFIG --version`
2208 set $icu_version_full
2210 icu_version=`expr [$]1 \* 1000 + [$]2`
2211 AC_MSG_RESULT([found $icu_version_full])
2213 if test "$icu_version" -lt "3004"; then
2214 AC_MSG_ERROR([ICU version 3.4 or later is required])
2217 ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
2218 ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
2219 PHP_EVAL_INCLINE($ICU_INCS)
2220 PHP_EVAL_LIBLINE($ICU_LIBS, $1)
2225 dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]])
2227 dnl Common setup macro for kerberos
2229 AC_DEFUN([PHP_SETUP_KERBEROS],[
2231 unset KERBEROS_CFLAGS
2234 dnl First try to find krb5-config
2235 if test -z "$KRB5_CONFIG"; then
2236 AC_PATH_PROG(KRB5_CONFIG, krb5-config, no, [$PATH:/usr/kerberos/bin:/usr/local/bin])
2239 dnl If krb5-config is found try using it
2240 if test "$PHP_KERBEROS" = "yes" && test -x "$KRB5_CONFIG"; then
2241 KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi`
2242 KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi`
2244 if test -n "$KERBEROS_LIBS" && test -n "$KERBEROS_CFLAGS"; then
2246 PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1)
2247 PHP_EVAL_INCLINE($KERBEROS_CFLAGS)
2251 dnl If still not found use old skool method
2252 if test "$found_kerberos" = "no"; then
2254 if test "$PHP_KERBEROS" = "yes"; then
2255 PHP_KERBEROS="/usr/kerberos /usr/local /usr"
2258 for i in $PHP_KERBEROS; do
2259 if test -f $i/$PHP_LIBDIR/libkrb5.a || test -f $i/$PHP_LIBDIR/libkrb5.$SHLIB_SUFFIX_NAME; then
2265 if test "$PHP_KERBEROS_DIR"; then
2267 PHP_ADD_LIBPATH($PHP_KERBEROS_DIR/$PHP_LIBDIR, $1)
2268 PHP_ADD_LIBRARY(gssapi_krb5, 1, $1)
2269 PHP_ADD_LIBRARY(krb5, 1, $1)
2270 PHP_ADD_LIBRARY(k5crypto, 1, $1)
2271 PHP_ADD_LIBRARY(com_err, 1, $1)
2272 PHP_ADD_INCLUDE($PHP_KERBEROS_DIR/include)
2276 if test "$found_kerberos" = "yes"; then
2277 ifelse([$2],[],:,[$2])
2278 ifelse([$3],[],,[else $3])
2283 dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
2285 dnl Common setup macro for openssl
2287 AC_DEFUN([PHP_SETUP_OPENSSL],[
2289 unset OPENSSL_INCDIR
2290 unset OPENSSL_LIBDIR
2292 dnl Empty variable means 'no'
2293 test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
2294 test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
2296 dnl Fallbacks for different configure options
2297 if test "$PHP_OPENSSL" != "no"; then
2298 PHP_OPENSSL_DIR=$PHP_OPENSSL
2299 elif test "$PHP_IMAP_SSL" != "no"; then
2300 PHP_OPENSSL_DIR=$PHP_IMAP_SSL
2303 dnl First try to find pkg-config
2304 if test -z "$PKG_CONFIG"; then
2305 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2308 dnl If pkg-config is found try using it
2309 if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
2310 if $PKG_CONFIG --atleast-version=0.9.6 openssl; then
2312 OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
2313 OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
2314 OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
2316 AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
2319 if test -n "$OPENSSL_LIBS" && test -n "$OPENSSL_INCS"; then
2320 PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
2321 PHP_EVAL_INCLINE($OPENSSL_INCS)
2325 dnl If pkg-config fails for some reason, revert to the old method
2326 if test "$found_openssl" = "no"; then
2328 if test "$PHP_OPENSSL_DIR" = "yes"; then
2329 PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
2332 for i in $PHP_OPENSSL_DIR; do
2333 if test -r $i/include/openssl/evp.h; then
2334 OPENSSL_INCDIR=$i/include
2336 if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
2337 OPENSSL_LIBDIR=$i/$PHP_LIBDIR
2339 test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
2342 if test -z "$OPENSSL_INCDIR"; then
2343 AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
2346 if test -z "$OPENSSL_LIBDIR"; then
2347 AC_MSG_ERROR([Cannot find OpenSSL's libraries])
2350 old_CPPFLAGS=$CPPFLAGS
2351 CPPFLAGS=-I$OPENSSL_INCDIR
2352 AC_MSG_CHECKING([for OpenSSL version])
2354 #include <openssl/opensslv.h>
2355 #if OPENSSL_VERSION_NUMBER >= 0x0090600fL
2359 AC_MSG_RESULT([>= 0.9.6])
2361 AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
2363 CPPFLAGS=$old_CPPFLAGS
2365 PHP_ADD_INCLUDE($OPENSSL_INCDIR)
2367 PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
2368 PHP_ADD_LIBRARY(crypto,,$1)
2370 AC_MSG_ERROR([libcrypto not found!])
2376 LIBS="$LIBS -lcrypto"
2377 PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
2380 AC_MSG_ERROR([libssl not found!])
2385 PHP_ADD_LIBRARY(ssl,,$1)
2387 PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1)
2390 if test "$found_openssl" = "yes"; then
2391 dnl For apache 1.3.x static build
2392 OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
2393 AC_SUBST(OPENSSL_INCDIR_OPT)
2395 ifelse([$2],[],:,[$2])
2396 ifelse([$3],[],,[else $3])
2401 dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
2403 dnl Common setup macro for iconv
2405 AC_DEFUN([PHP_SETUP_ICONV], [
2409 # Create the directories for a VPATH build:
2410 $php_shtool mkdir -p ext/iconv
2412 echo > ext/iconv/php_have_bsd_iconv.h
2413 echo > ext/iconv/php_have_glibc_iconv.h
2414 echo > ext/iconv/php_have_libiconv.h
2415 echo > ext/iconv/php_have_iconv.h
2416 echo > ext/iconv/php_php_iconv_impl.h
2417 echo > ext/iconv/php_php_iconv_h_path.h
2418 echo > ext/iconv/php_iconv_supports_errno.h
2421 dnl Check libc first if no path is provided in --with-iconv
2423 if test "$PHP_ICONV" = "yes"; then
2424 AC_CHECK_FUNC(iconv, [
2427 AC_CHECK_FUNC(libiconv,[
2428 PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
2429 AC_DEFINE(HAVE_LIBICONV, 1, [ ])
2436 dnl Check external libs for iconv funcs
2438 if test "$found_iconv" = "no"; then
2440 for i in $PHP_ICONV /usr/local /usr; do
2441 if test -r $i/include/giconv.h; then
2442 AC_DEFINE(HAVE_GICONV_H, 1, [ ])
2444 iconv_lib_name=giconv
2446 elif test -r $i/include/iconv.h; then
2448 iconv_lib_name=iconv
2453 if test -z "$ICONV_DIR"; then
2454 AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
2457 if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
2458 test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
2460 PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
2462 PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
2463 AC_DEFINE(HAVE_LIBICONV,1,[ ])
2465 PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
2468 -L$ICONV_DIR/$PHP_LIBDIR
2471 -L$ICONV_DIR/$PHP_LIBDIR
2476 if test "$found_iconv" = "yes"; then
2477 PHP_DEFINE(HAVE_ICONV,1,[ext/iconv])
2478 AC_DEFINE(HAVE_ICONV,1,[ ])
2479 if test -n "$ICONV_DIR"; then
2480 PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1)
2481 PHP_ADD_INCLUDE($ICONV_DIR/include)
2484 ifelse([$3],[],,[else $3])
2489 dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]])
2491 dnl Common setup macro for libxml
2493 AC_DEFUN([PHP_SETUP_LIBXML], [
2494 AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
2496 for i in $PHP_LIBXML_DIR /usr/local /usr; do
2497 if test -x "$i/bin/xml2-config"; then
2498 ac_cv_php_xml2_config_path="$i/bin/xml2-config"
2504 if test -x "$ac_cv_php_xml2_config_path"; then
2505 XML2_CONFIG="$ac_cv_php_xml2_config_path"
2506 libxml_full_version=`$XML2_CONFIG --version`
2509 set $libxml_full_version
2511 LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
2512 if test "$LIBXML_VERSION" -ge "2006011"; then
2513 LIBXML_LIBS=`$XML2_CONFIG --libs`
2514 LIBXML_INCS=`$XML2_CONFIG --cflags`
2515 PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
2516 PHP_EVAL_INCLINE($LIBXML_INCS)
2518 dnl Check that build works with given libs
2519 AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
2520 PHP_TEST_BUILD(xmlInitParser,
2522 php_cv_libxml_build_works=yes
2525 AC_MSG_ERROR([build test failed. Please check the config.log for details.])
2530 if test "$php_cv_libxml_build_works" = "yes"; then
2531 AC_DEFINE(HAVE_LIBXML, 1, [ ])
2535 AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
2537 ifelse([$3],[],,[else $3])
2541 dnl -------------------------------------------------------------------------
2543 dnl -------------------------------------------------------------------------
2546 dnl PHP_INSTALL_HEADERS(path [, file ...])
2548 dnl PHP header files to be installed
2550 AC_DEFUN([PHP_INSTALL_HEADERS],[
2552 for header_file in $1; do
2553 PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [
2554 INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
2559 for header_file in $2; do
2560 hp_hf="$header_path/$header_file"
2561 PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [
2562 INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf"
2569 dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
2571 dnl This macro is used to get a comparable
2572 dnl version for apache1/2.
2574 AC_DEFUN([PHP_AP_EXTRACT_VERSION],[
2575 ac_output=`$1 -v 2>&1 | grep version`
2582 APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
2586 dnl PHP_DEBUG_MACRO(filename)
2588 AC_DEFUN([PHP_DEBUG_MACRO],[
2591 CONFIGURE: $CONFIGURE_COMMAND
2602 PHP_RPATHS: $PHP_RPATHS
2603 uname -a: `uname -a`
2606 cat >conftest.$ac_ext <<X
2612 (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
2617 dnl PHP_CONFIG_NICE(filename)
2619 dnl Generates the config.nice file
2621 AC_DEFUN([PHP_CONFIG_NICE],[
2622 AC_REQUIRE([AC_PROG_EGREP])
2623 AC_REQUIRE([LT_AC_PROG_SED])
2624 PHP_SUBST_OLD(EGREP)
2626 test -f $1 && mv $1 $1.old
2631 # Created by configure
2635 for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do
2637 if test -n "$val"; then
2638 echo "$var='$val' \\" >> $1
2642 echo "'[$]0' \\" >> $1
2643 if test `expr -- [$]0 : "'.*"` = 0; then
2644 CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'"
2646 CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0"
2648 for arg in $ac_configure_args; do
2649 if test `expr -- $arg : "'.*"` = 0; then
2650 if test `expr -- $arg : "--.*"` = 0; then
2653 echo "'[$]arg' \\" >> $1
2654 CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS '[$]arg'"
2656 if test `expr -- $arg : "'--.*"` = 0; then
2659 echo "[$]arg \\" >> $1
2660 CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS [$]arg"
2665 CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS"
2666 PHP_SUBST_OLD(CONFIGURE_COMMAND)
2667 PHP_SUBST_OLD(CONFIGURE_OPTIONS)
2671 dnl PHP_CHECK_CONFIGURE_OPTIONS
2673 AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
2674 for arg in $ac_configure_args; do
2677 arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
2680 arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
2683 arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
2686 arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
2693 # Allow --disable-all / --enable-all
2696 # Allow certain libtool options
2697 enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];;
2699 # Allow certain TSRM options
2700 with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads[)];;
2702 # Allow certain Zend options
2703 with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];;
2705 # All the rest must be set using the PHP_ARG_* macros
2706 # PHP_ARG_* macros set php_enable_<arg_name> or php_with_<arg_name>
2708 # Options that exist before PHP 6
2709 if test "$PHP_MAJOR_VERSION" -lt "6"; then
2711 enable-zend-multibyte[)] continue;;
2714 is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'`
2715 if eval test "x\$$is_arg_set" = "x"; then
2716 PHP_UNKNOWN_CONFIGURE_OPTIONS="$PHP_UNKNOWN_CONFIGURE_OPTIONS
2725 dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]])
2727 AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[
2728 AC_CACHE_CHECK([for PDO includes], pdo_inc_path, [
2729 AC_MSG_CHECKING([for PDO includes])
2730 if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
2731 pdo_inc_path=$abs_srcdir/ext
2732 elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
2733 pdo_inc_path=$abs_srcdir/ext
2734 elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
2735 pdo_inc_path=$prefix/include/php/ext
2738 if test -n "$pdo_inc_path"; then
2739 ifelse([$1],[],:,[$1])
2741 ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2])
2748 AC_DEFUN([PHP_DETECT_ICC],
2751 AC_MSG_CHECKING([for icc])
2752 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
2754 AC_MSG_RESULT([no]),
2756 AC_MSG_RESULT([yes])
2761 dnl PHP_CRYPT_R_STYLE
2762 dnl detect the style of crypt_r() is any is available
2763 dnl see APR_CHECK_CRYPT_R_STYLE() for original version
2765 AC_DEFUN([PHP_CRYPT_R_STYLE],
2767 AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[
2768 php_cv_crypt_r_style=none
2770 #define _REENTRANT 1
2774 crypt_r("passwd", "hash", &buffer);
2776 php_cv_crypt_r_style=cryptd)
2778 if test "$php_cv_crypt_r_style" = "none"; then
2780 #define _REENTRANT 1
2783 struct crypt_data buffer;
2784 crypt_r("passwd", "hash", &buffer);
2786 php_cv_crypt_r_style=struct_crypt_data)
2789 if test "$php_cv_crypt_r_style" = "none"; then
2791 #define _REENTRANT 1
2795 struct crypt_data buffer;
2796 crypt_r("passwd", "hash", &buffer);
2798 php_cv_crypt_r_style=struct_crypt_data_gnu_source)
2802 if test "$php_cv_crypt_r_style" = "cryptd"; then
2803 AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
2805 if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
2806 AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
2808 if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
2809 AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE])
2811 if test "$php_cv_crypt_r_style" = "none"; then
2812 AC_MSG_ERROR([Unable to detect data struct used by crypt_r])
2817 dnl PHP_TEST_WRITE_STDOUT
2819 AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
2820 AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
2822 #ifdef HAVE_UNISTD_H
2826 #define TEXT "This is the test message -- "
2832 n = write(1, TEXT, sizeof(TEXT)-1);
2833 return (!(n == sizeof(TEXT)-1));
2836 ac_cv_write_stdout=yes
2838 ac_cv_write_stdout=no
2840 ac_cv_write_stdout=no
2843 if test "$ac_cv_write_stdout" = "yes"; then
2844 AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])