File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / acinclude.m4
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:34 2012 UTC (12 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_17p0, HEAD
php 5.4.3+patches

    1: dnl
    2: dnl $Id: acinclude.m4,v 1.1.1.2 2012/05/29 12:34:34 misho Exp $
    3: dnl
    4: dnl This file contains local autoconf functions.
    5: dnl
    6: 
    7: dnl -------------------------------------------------------------------------
    8: dnl Output stylize macros for configure (help/runtime)
    9: dnl -------------------------------------------------------------------------
   10: 
   11: dnl
   12: dnl PHP_HELP_SEPARATOR(title)
   13: dnl
   14: dnl Adds separator title into the configure --help display.
   15: dnl 
   16: AC_DEFUN([PHP_HELP_SEPARATOR],[
   17: AC_ARG_ENABLE([],[
   18: $1
   19: ],[])
   20: ])
   21: 
   22: dnl
   23: dnl PHP_CONFIGURE_PART(title)
   24: dnl
   25: dnl Adds separator title configure output (idea borrowed from mm)
   26: dnl
   27: AC_DEFUN([PHP_CONFIGURE_PART],[
   28:   AC_MSG_RESULT()
   29:   AC_MSG_RESULT([${T_MD}$1${T_ME}])
   30: ])
   31: 
   32: dnl -------------------------------------------------------------------------
   33: dnl Build system helper macros
   34: dnl -------------------------------------------------------------------------
   35: 
   36: dnl
   37: dnl PHP_DEF_HAVE(what)
   38: dnl
   39: dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'
   40: dnl
   41: AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])])
   42: 
   43: dnl
   44: dnl PHP_RUN_ONCE(namespace, variable, code)
   45: dnl
   46: dnl execute code, if variable is not set in namespace
   47: dnl
   48: AC_DEFUN([PHP_RUN_ONCE],[
   49:   changequote({,})
   50:   unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'`
   51:   changequote([,])
   52:   cmd="echo $ac_n \"\$$1$unique$ac_c\""
   53:   if test -n "$unique" && test "`eval $cmd`" = "" ; then
   54:     eval "$1$unique=set"
   55:     $3
   56:   fi
   57: ])
   58: 
   59: dnl
   60: dnl PHP_EXPAND_PATH(path, variable)
   61: dnl
   62: dnl expands path to an absolute path and assigns it to variable
   63: dnl
   64: AC_DEFUN([PHP_EXPAND_PATH],[
   65:   if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
   66:     $2=$1
   67:   else
   68:     changequote({,})
   69:     ep_dir="`echo $1|$SED 's%/*[^/][^/]*/*$%%'`"
   70:     changequote([,])
   71:     ep_realdir="`(cd \"$ep_dir\" && pwd)`"
   72:     $2="$ep_realdir/`basename \"$1\"`"
   73:   fi
   74: ])
   75: 
   76: dnl
   77: dnl PHP_DEFINE(WHAT [, value[, directory]])
   78: dnl
   79: dnl Creates builddir/include/what.h and in there #define WHAT value
   80: dnl
   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]
   83: ])
   84: 
   85: dnl
   86: dnl PHP_SUBST(varname)
   87: dnl
   88: dnl Adds variable with it's value into Makefile, e.g.:
   89: dnl CC = gcc
   90: dnl
   91: AC_DEFUN([PHP_SUBST],[
   92:   PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
   93: ])
   94: 
   95: dnl
   96: dnl PHP_SUBST_OLD(varname)
   97: dnl
   98: dnl Same as PHP_SUBST() but also substitutes all @VARNAME@
   99: dnl instances in every file passed to AC_OUTPUT()
  100: dnl
  101: AC_DEFUN([PHP_SUBST_OLD],[
  102:   PHP_SUBST($1)
  103:   AC_SUBST($1)
  104: ])
  105: 
  106: dnl
  107: dnl PHP_OUTPUT(file)
  108: dnl
  109: dnl Adds "file" to the list of files generated by AC_OUTPUT
  110: dnl This macro can be used several times.
  111: dnl
  112: AC_DEFUN([PHP_OUTPUT],[
  113:   PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  114: ])
  115: 
  116: 
  117: dnl -------------------------------------------------------------------------
  118: dnl Build system base macros
  119: dnl -------------------------------------------------------------------------
  120: 
  121: dnl
  122: dnl PHP_CANONICAL_HOST_TARGET
  123: dnl
  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
  129:     host_alias=$host
  130:   fi
  131:   if test -z "$host_alias"; then
  132:     AC_MSG_ERROR([host_alias is not set!])
  133:   fi
  134: ])
  135: 
  136: dnl
  137: dnl PHP_INIT_BUILD_SYSTEM
  138: dnl
  139: AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[
  140: AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
  141: test -d include || $php_shtool mkdir include
  142: > Makefile.objects
  143: > Makefile.fragments
  144: dnl We need to play tricks here to avoid matching the grep line itself
  145: pattern=define
  146: $EGREP $pattern'.*include/php' $srcdir/configure|$SED 's/.*>//'|xargs touch 2>/dev/null
  147: ])
  148: 
  149: dnl
  150: dnl PHP_GEN_GLOBAL_MAKEFILE
  151: dnl 
  152: dnl Generates the global makefile.
  153: dnl
  154: AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[
  155:   cat >Makefile <<EOF
  156: srcdir = $abs_srcdir
  157: builddir = $abs_builddir
  158: top_srcdir = $abs_srcdir
  159: top_builddir = $abs_builddir
  160: EOF
  161:   for i in $PHP_VAR_SUBST; do
  162:     eval echo "$i = \$$i" >> Makefile
  163:   done
  164: 
  165:   cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile
  166: ])
  167: 
  168: dnl
  169: dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile [, ext_srcdir [, ext_builddir]]])
  170: dnl
  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.
  175: dnl
  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
  181: ])
  182: 
  183: dnl
  184: dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
  185: dnl
  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).
  191: dnl
  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.
  194: dnl
  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))
  198: ])
  199: 
  200: dnl
  201: dnl _PHP_ASSIGN_BUILD_VARS(type)
  202: dnl internal, don't use
  203: AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[
  204: ifelse($1,shared,[
  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
  211: ],[
  212:   b_c_pre=$php_c_pre
  213:   b_cxx_pre=$php_cxx_pre
  214:   b_c_meta=$php_c_meta
  215:   b_cxx_meta=$php_cxx_meta
  216:   b_c_post=$php_c_post
  217:   b_cxx_post=$php_cxx_post
  218: ])dnl
  219:   b_lo=[$]$1_lo
  220: ])
  221: 
  222: dnl
  223: dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
  224: dnl
  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.
  228: dnl
  229: dnl Should not be used directly.
  230: dnl 
  231: AC_DEFUN([PHP_ADD_SOURCES_X],[
  232: dnl relative to source- or build-directory?
  233: dnl ac_srcdir/ac_bdir include trailing slash
  234:   case $1 in
  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" ;;
  238:   esac
  239:   
  240: dnl how to build .. shared or static?
  241:   ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php))
  242: 
  243: dnl iterate over the sources
  244:   old_IFS=[$]IFS
  245:   for ac_src in $2; do
  246:   
  247: dnl remove the suffix
  248:       IFS=.
  249:       set $ac_src
  250:       ac_obj=[$]1
  251:       IFS=$old_IFS
  252:       
  253: dnl append to the array which has been dynamically chosen at m4 time
  254:       $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
  255: 
  256: dnl choose the right compiler/flags/etc. for the source-file
  257:       case $ac_src in
  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" ;;
  262:       esac
  263: 
  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
  267: 	$ac_comp
  268: EOF
  269:   done
  270: ])
  271: 
  272: dnl -------------------------------------------------------------------------
  273: dnl Compiler characteristics checks
  274: dnl -------------------------------------------------------------------------
  275: 
  276: dnl
  277: dnl PHP_TARGET_RDYNAMIC
  278: dnl
  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.
  283: dnl
  284: dnl If successful, adds -rdynamic to PHP_LDFLAGS.
  285: dnl
  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"
  292:     fi
  293:   fi
  294: ])
  295: 
  296: dnl
  297: dnl PHP_RUNPATH_SWITCH
  298: dnl
  299: dnl Checks for -R, etc. switch
  300: dnl
  301: AC_DEFUN([PHP_RUNPATH_SWITCH],[
  302: AC_MSG_CHECKING([if compiler supports -R])
  303: AC_CACHE_VAL(php_cv_cc_dashr,[
  304:   SAVE_LIBS=$LIBS
  305:   LIBS="-R /usr/$PHP_LIBDIR $LIBS"
  306:   AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
  307:   LIBS=$SAVE_LIBS])
  308: AC_MSG_RESULT([$php_cv_cc_dashr])
  309: if test $php_cv_cc_dashr = "yes"; then
  310:   ld_runpath_switch=-R
  311: else
  312:   AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
  313:   AC_CACHE_VAL(php_cv_cc_rpath,[
  314:     SAVE_LIBS=$LIBS
  315:     LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS"
  316:     AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
  317:     LIBS=$SAVE_LIBS])
  318:   AC_MSG_RESULT([$php_cv_cc_rpath])
  319:   if test $php_cv_cc_rpath = "yes"; then
  320:     ld_runpath_switch=-Wl,-rpath,
  321:   else
  322:     dnl something innocuous
  323:     ld_runpath_switch=-L
  324:   fi
  325: fi
  326: if test "$PHP_RPATH" = "no"; then
  327:   ld_runpath_switch=
  328: fi
  329: ])
  330: 
  331: dnl
  332: dnl PHP_CHECK_GCC_ARG(arg, action-if-found, action-if-not-found)
  333: dnl
  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
  340:     ac_result=no
  341:   else
  342:     ac_result=yes
  343:   fi
  344:   eval $gcc_arg_name=$ac_result
  345:   rm -f conftest.*
  346:   ])
  347:   if eval test "\$$gcc_arg_name" = "yes"; then
  348:     $2
  349:   else
  350:     :
  351:     $3
  352:   fi
  353: ])
  354: 
  355: dnl
  356: dnl PHP_LIBGCC_LIBPATH(gcc)
  357: dnl
  358: dnl Stores the location of libgcc in libgcc_libpath
  359: dnl
  360: AC_DEFUN([PHP_LIBGCC_LIBPATH],[
  361:   changequote({,})
  362:   libgcc_libpath=`$1 --print-libgcc-file-name|$SED 's%/*[^/][^/]*$%%'`
  363:   changequote([,])
  364: ])
  365: 
  366: dnl -------------------------------------------------------------------------
  367: dnl Macros to modify LIBS, INCLUDES, etc. variables 
  368: dnl -------------------------------------------------------------------------
  369: 
  370: dnl
  371: dnl PHP_REMOVE_USR_LIB(NAME)
  372: dnl
  373: dnl Removes all -L/usr/$PHP_LIBDIR entries from variable NAME
  374: dnl
  375: AC_DEFUN([PHP_REMOVE_USR_LIB],[
  376:   unset ac_new_flags
  377:   for i in [$]$1; do
  378:     case [$]i in
  379:     -L/usr/$PHP_LIBDIR|-L/usr/$PHP_LIBDIR/[)] ;;
  380:     *[)] ac_new_flags="[$]ac_new_flags [$]i" ;;
  381:     esac
  382:   done
  383:   $1=[$]ac_new_flags
  384: ])
  385: 
  386: dnl
  387: dnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD)
  388: dnl
  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
  391: dnl notation.
  392: dnl
  393: AC_DEFUN([PHP_EVAL_LIBLINE],[
  394:   for ac_i in $1; do
  395:     case $ac_i in
  396:     -pthread[)]
  397:       if test "$ext_shared" = "yes"; then
  398:         $2="[$]$2 -pthread"
  399:       else
  400:         PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"])
  401:       fi
  402:     ;;
  403:     -l*[)]
  404:       ac_ii=`echo $ac_i|cut -c 3-`
  405:       PHP_ADD_LIBRARY($ac_ii,1,$2)
  406:     ;;
  407:     -L*[)]
  408:       ac_ii=`echo $ac_i|cut -c 3-`
  409:       PHP_ADD_LIBPATH($ac_ii,$2)
  410:     ;;
  411:     esac
  412:   done
  413: ])
  414: 
  415: dnl
  416: dnl PHP_EVAL_INCLINE(headerline)
  417: dnl
  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.
  420: dnl
  421: AC_DEFUN([PHP_EVAL_INCLINE],[
  422:   for ac_i in $1; do
  423:     case $ac_i in
  424:     -I*[)]
  425:       ac_ii=`echo $ac_i|cut -c 3-`
  426:       PHP_ADD_INCLUDE($ac_ii)
  427:     ;;
  428:     esac
  429:   done
  430: ])
  431: 
  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"
  438:   ])
  439: ])dnl
  440: dnl
  441: dnl
  442: dnl PHP_ADD_LIBPATH(path [, SHARED-LIBADD])
  443: dnl
  444: dnl Adds a path to linkpath/runpath (LDFLAGS)
  445: dnl
  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)
  449:     ifelse([$2],,[
  450:       _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  451:     ],[
  452:       if test "$ext_shared" = "yes"; then
  453:         $2="-L$ai_p [$]$2"
  454:         test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2"
  455:       else
  456:         _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  457:       fi
  458:     ])
  459:   fi
  460: ])
  461: 
  462: dnl
  463: dnl PHP_UTILIZE_RPATHS()
  464: dnl
  465: dnl builds RPATHS/LDFLAGS from PHP_RPATHS
  466: dnl
  467: AC_DEFUN([PHP_UTILIZE_RPATHS],[
  468:   OLD_RPATHS=$PHP_RPATHS
  469:   unset PHP_RPATHS
  470: 
  471:   for i in $OLD_RPATHS; do
  472: dnl Can be passed to native cc/libtool
  473:     PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
  474: dnl Libtool-specific
  475:     PHP_RPATHS="$PHP_RPATHS -R $i"
  476: dnl cc-specific
  477:     NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
  478:   done
  479: 
  480:   if test "$PHP_RPATH" = "no"; then
  481:     unset PHP_RPATHS
  482:     unset NATIVE_RPATHS
  483:   fi
  484: ])
  485: 
  486: dnl
  487: dnl PHP_ADD_INCLUDE(path [,before])
  488: dnl
  489: dnl add an include path. 
  490: dnl if before is 1, add in the beginning of INCLUDES.
  491: dnl
  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, [
  496:       if test "$2"; then
  497:         INCLUDES="-I$ai_p $INCLUDES"
  498:       else
  499:         INCLUDES="$INCLUDES -I$ai_p"
  500:       fi
  501:     ])
  502:   fi
  503: ])
  504: 
  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
  508: ])dnl
  509: dnl
  510: dnl internal, don't use
  511: AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[
  512:   case $1 in
  513:   c|c_r|pthread*[)] ;;
  514:   *[)] ifelse($3,,[
  515:     _PHP_X_ADD_LIBRARY($1,$2,$5)
  516:   ],[
  517:     if test "$ext_shared" = "yes"; then
  518:       _PHP_X_ADD_LIBRARY($1,$2,$3)
  519:     else
  520:       $4($1,$2)
  521:     fi
  522:   ]) ;;
  523:   esac
  524: ])dnl
  525: dnl
  526: dnl
  527: dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
  528: dnl
  529: dnl add a library to the link line
  530: dnl
  531: AC_DEFUN([PHP_ADD_LIBRARY],[
  532:   _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS])
  533: ])
  534: 
  535: dnl
  536: dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]])
  537: dnl
  538: dnl add a library to the link line (deferred, not used during configure)
  539: dnl
  540: AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[
  541:   _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS])
  542: ])
  543: 
  544: dnl
  545: dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
  546: dnl
  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
  550: dnl
  551: AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[
  552: ifelse($3,,[
  553:   if test -n "$2"; then
  554:     PHP_ADD_LIBPATH($2)
  555:   fi
  556:   PHP_ADD_LIBRARY($1)
  557: ],[
  558:   if test "$ext_shared" = "yes"; then
  559:     $3="-l$1 [$]$3"
  560:     if test -n "$2"; then
  561:       PHP_ADD_LIBPATH($2,$3)
  562:     fi
  563:   else
  564:     PHP_ADD_LIBRARY_WITH_PATH($1,$2)
  565:   fi
  566: ])
  567: ])
  568: 
  569: dnl
  570: dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd])
  571: dnl
  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
  576: dnl
  577: AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[
  578: ifelse($3,,[
  579:   if test -n "$2"; then
  580:     PHP_ADD_LIBPATH($2)
  581:   fi
  582:   PHP_ADD_LIBRARY_DEFER($1)
  583: ],[
  584:   if test "$ext_shared" = "yes"; then
  585:     $3="-l$1 [$]$3"
  586:     if test -n "$2"; then
  587:       PHP_ADD_LIBPATH($2,$3)
  588:     fi
  589:   else
  590:     PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2)
  591:   fi
  592: ])
  593: ])
  594: 
  595: dnl
  596: dnl PHP_ADD_FRAMEWORK(framework [,before])
  597: dnl
  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.
  601: dnl
  602: AC_DEFUN([PHP_ADD_FRAMEWORK], [
  603:   PHP_RUN_ONCE(FRAMEWORKS, $1, [
  604:     if test "$2"; then
  605:       PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS"
  606:     else
  607:       PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1"
  608:     fi
  609:   ])
  610: ])
  611: 
  612: dnl
  613: dnl PHP_ADD_FRAMEWORKPATH(path [,before])
  614: dnl
  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
  621: dnl relevant lines.
  622: dnl
  623: AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [
  624:   PHP_EXPAND_PATH($1, ai_p)
  625:   PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [
  626:     if test "$2"; then
  627:       PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH"
  628:     else
  629:       PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p"
  630:     fi
  631:   ])
  632: ])
  633: 
  634: dnl
  635: dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path)
  636: dnl
  637: dnl Adds a (Darwin / Mac OS X) framework path and the
  638: dnl framework itself to the link and include lines.
  639: dnl
  640: AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [
  641:   PHP_ADD_FRAMEWORKPATH($2)
  642:   PHP_ADD_FRAMEWORK($1)
  643: ])
  644: 
  645: dnl
  646: dnl PHP_SET_LIBTOOL_VARIABLE(var)
  647: dnl
  648: dnl Set libtool variable
  649: dnl
  650: AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[
  651:   if test -z "$LIBTOOL"; then
  652:     LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
  653:   else
  654:     LIBTOOL="$LIBTOOL $1"
  655:   fi
  656: ])
  657: 
  658: dnl -------------------------------------------------------------------------
  659: dnl Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE
  660: dnl -------------------------------------------------------------------------
  661: 
  662: dnl PHP_ARG_ANALYZE_EX
  663: dnl internal
  664: AC_DEFUN([PHP_ARG_ANALYZE_EX],[
  665: ext_output="yes, shared"
  666: ext_shared=yes
  667: case [$]$1 in
  668: shared,*[)]
  669:   $1=`echo "[$]$1"|$SED 's/^shared,//'`
  670:   ;;
  671: shared[)]
  672:   $1=yes
  673:   ;;
  674: no[)]
  675:   ext_output=no
  676:   ext_shared=no
  677:   ;;
  678: *[)]
  679:   ext_output=yes
  680:   ext_shared=no
  681:   ;;
  682: esac
  683: 
  684: PHP_ALWAYS_SHARED([$1])
  685: ])
  686: 
  687: dnl PHP_ARG_ANALYZE
  688: dnl internal
  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])])
  692: ])
  693: 
  694: dnl
  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.
  701: dnl
  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)])
  705: ])
  706: 
  707: dnl PHP_REAL_ARG_WITH
  708: dnl internal
  709: AC_DEFUN([PHP_REAL_ARG_WITH],[
  710: ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  711: AC_ARG_WITH($1,[$3],$5=[$]withval,
  712: [
  713:   $5=ifelse($4,,no,$4)
  714:   ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
  715: ])
  716: PHP_ARG_ANALYZE($5,[$2],$6)
  717: ])
  718: 
  719: dnl
  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.
  726: dnl
  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)])
  730: ])
  731: 
  732: dnl PHP_REAL_ARG_ENABLE
  733: dnl internal
  734: AC_DEFUN([PHP_REAL_ARG_ENABLE],[
  735: ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  736: AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
  737: [
  738:   $5=ifelse($4,,no,$4)
  739:   ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
  740: ])
  741: PHP_ARG_ANALYZE($5,[$2],$6)
  742: ])
  743: 
  744: dnl -------------------------------------------------------------------------
  745: dnl Build macros
  746: dnl -------------------------------------------------------------------------
  747: 
  748: dnl
  749: dnl PHP_BUILD_THREAD_SAFE
  750: dnl
  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.])
  755:   fi
  756: ])
  757: 
  758: dnl
  759: dnl PHP_REQUIRE_CXX
  760: dnl
  761: AC_DEFUN([PHP_REQUIRE_CXX],[
  762:   if test -z "$php_cxx_done"; then
  763:     AC_PROG_CXX
  764:     AC_PROG_CXXCPP
  765:     PHP_ADD_LIBRARY(stdc++)
  766:     php_cxx_done=yes
  767:   fi
  768: ])
  769: 
  770: dnl
  771: dnl PHP_BUILD_SHARED
  772: dnl
  773: AC_DEFUN([PHP_BUILD_SHARED],[
  774:   PHP_BUILD_PROGRAM
  775:   OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
  776:   php_sapi_module=shared
  777:   
  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
  784:   php_lo=$shared_lo
  785: ])
  786: 
  787: dnl
  788: dnl PHP_BUILD_STATIC
  789: dnl
  790: AC_DEFUN([PHP_BUILD_STATIC],[
  791:   PHP_BUILD_PROGRAM
  792:   OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
  793:   php_sapi_module=static
  794: ])
  795: 
  796: dnl
  797: dnl PHP_BUILD_BUNDLE
  798: dnl
  799: AC_DEFUN([PHP_BUILD_BUNDLE],[
  800:   PHP_BUILD_PROGRAM
  801:   OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle]
  802:   php_sapi_module=static
  803: ])
  804: 
  805: dnl
  806: dnl PHP_BUILD_PROGRAM
  807: dnl
  808: AC_DEFUN([PHP_BUILD_PROGRAM],[
  809:   php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  810:   php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
  811:   php_c_post=
  812:   php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  813:   php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
  814:   php_cxx_post=
  815:   php_lo=lo
  816: 
  817:   case $with_pic in
  818:     yes) pic_setting='-prefer-pic';;
  819:     no)  pic_setting='-prefer-non-pic';;
  820:   esac
  821: 
  822:   shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  823:   shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting
  824:   shared_c_post=
  825:   shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  826:   shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting
  827:   shared_cxx_post=
  828:   shared_lo=lo
  829: ])
  830: 
  831: dnl
  832: dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext)
  833: dnl
  834: dnl Basically sets up the link-stage for building module-name
  835: dnl from object_var in build-dir.
  836: dnl
  837: AC_DEFUN([PHP_SHARED_MODULE],[
  838:   install_modules="install-modules"
  839: 
  840:   case $host_alias in
  841:     *aix*[)]
  842:       suffix=so
  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'
  844:       ;;
  845:     *netware*[)]
  846:       suffix=nlm
  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)'
  848:       ;;
  849:     *[)]
  850:       suffix=la
  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)'
  852:       ;;
  853:   esac
  854: 
  855:   if test "x$5" = "xyes"; then
  856:     PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix"
  857:   else
  858:     PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix"
  859:   fi
  860:   PHP_SUBST($2)
  861:   cat >>Makefile.objects<<EOF
  862: \$(phplibdir)/$1.$suffix: $3/$1.$suffix
  863: 	\$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir)
  864: 
  865: $3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
  866: 	$link_cmd
  867: 
  868: EOF
  869: ])
  870: 
  871: dnl
  872: dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
  873: dnl
  874: dnl Selects the SAPI name and type (static, shared, bundle, program)
  875: dnl and optionally also the source-files for the SAPI-specific
  876: dnl objects.
  877: dnl
  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
  882:     AC_MSG_ERROR([
  883: +--------------------------------------------------------------------+
  884: |                        *** ATTENTION ***                           |
  885: |                                                                    |
  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: +--------------------------------------------------------------------+
  889: ])
  890:   else
  891:     PHP_SAPI=$1
  892:   fi  
  893: 
  894:   PHP_ADD_BUILD_DIR([sapi/$1])
  895: 
  896:   PHP_INSTALLED_SAPIS="$PHP_INSTALLED_SAPIS $1"
  897: 
  898:   ifelse($2,program,[
  899:     PHP_BUILD_PROGRAM
  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)])
  904:   ],[
  905:     case "$2" in
  906:     static[)] PHP_BUILD_STATIC;;
  907:     shared[)] PHP_BUILD_SHARED;;
  908:     bundle[)] PHP_BUILD_BUNDLE;;
  909:     esac
  910:     install_sapi="install-sapi"
  911:     ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
  912:   ])
  913: ])
  914: 
  915: dnl deprecated
  916: AC_DEFUN([PHP_EXTENSION],[
  917:   sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
  918: 
  919:   PHP_NEW_EXTENSION($1, $sources, $2, $3)
  920: 
  921:   if test -r "$ext_srcdir/Makefile.frag"; then
  922:     PHP_ADD_MAKEFILE_FRAGMENT
  923:   fi
  924: ])
  925: 
  926: AC_DEFUN([PHP_ADD_BUILD_DIR],[
  927:   ifelse($2,,[
  928:     BUILD_DIR="$BUILD_DIR $1"
  929:   ], [
  930:     $php_shtool mkdir -p $1
  931:   ])
  932: ])
  933: 
  934: AC_DEFUN([PHP_GEN_BUILD_DIRS],[
  935:   $php_shtool mkdir -p $BUILD_DIR
  936: ])
  937: 
  938: dnl
  939: dnl PHP_NEW_EXTENSION(extname, sources [, shared [, sapi_class [, extra-cflags [, cxx [, zend_ext]]]]])
  940: dnl
  941: dnl Includes an extension in the build.
  942: dnl
  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)
  956: 
  957:   ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`])
  958: 
  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"
  966:     fi
  967:   else
  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)
  972:       case $host_alias in
  973:         *netware*[)]
  974:           PHP_SHARED_MODULE(php$1,shared_objects_$1, $ext_builddir, $6, $7)
  975:           ;;
  976:         *[)]
  977:           PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7)
  978:           ;;
  979:       esac
  980:       AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
  981:     fi
  982:   fi
  983: 
  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
  987:         PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cli)
  988:         PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cgi)
  989:         PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,fpm)
  990:     EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
  991:   fi
  992:   PHP_ADD_BUILD_DIR($ext_builddir)
  993: 
  994: dnl Set for phpize builds only
  995: dnl --------------------------- 
  996:   if test "$ext_builddir" = "."; then
  997:     PHP_PECL_EXTENSION=$1
  998:     PHP_SUBST(PHP_PECL_EXTENSION)
  999:   fi
 1000: ])
 1001: 
 1002: dnl
 1003: dnl PHP_WITH_SHARED
 1004: dnl
 1005: dnl Checks whether $withval is "shared" or starts with "shared,XXX"
 1006: dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
 1007: dnl from $withval.
 1008: dnl
 1009: AC_DEFUN([PHP_WITH_SHARED],[
 1010:   PHP_ARG_ANALYZE_EX(withval)
 1011:   shared=$ext_shared
 1012:   unset ext_shared ext_output
 1013: ])
 1014: 
 1015: dnl
 1016: dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf])
 1017: dnl
 1018: dnl This macro is scanned by genif.sh when it builds the internal functions
 1019: dnl list, so that modules can be init'd in the correct order
 1020: dnl $1 = name of extension, $2 = extension upon which it depends
 1021: dnl $3 = optional: if true, it's ok for $2 to have not been configured
 1022: dnl default is false and should halt the build.
 1023: dnl To be effective, this macro must be invoked *after* PHP_NEW_EXTENSION.
 1024: dnl The extension on which it depends must also have been configured.
 1025: dnl See ADD_EXTENSION_DEP in win32 build 
 1026: dnl
 1027: AC_DEFUN([PHP_ADD_EXTENSION_DEP], [
 1028:   am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]
 1029:   is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED]
 1030:   is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__)
 1031:   if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
 1032:     AC_MSG_ERROR([
 1033: You've configured extension $1 to build statically, but it
 1034: depends on extension $2, which you've configured to build shared.
 1035: You either need to build $1 shared or build $2 statically for the
 1036: build to be successful.
 1037: ])
 1038:   fi
 1039:   dnl Some systems require that we link $2 to $1 when building
 1040: ])
 1041: 
 1042: dnl -------------------------------------------------------------------------
 1043: dnl Checks for structures, typedefs, broken functions, etc.
 1044: dnl -------------------------------------------------------------------------
 1045: 
 1046: dnl Internal helper macros
 1047: dnl
 1048: dnl _PHP_DEF_HAVE_FILE(what, filename)
 1049: AC_DEFUN([_PHP_DEF_HAVE_FILE], [
 1050:   php_def_have_what=HAVE_[]`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_' `
 1051:   echo "#define $php_def_have_what 1" >> $2
 1052: ])
 1053: dnl
 1054: dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
 1055: dnl
 1056: AC_DEFUN([_PHP_CHECK_SIZEOF], [
 1057:   php_cache_value=php_cv_sizeof_[]$1
 1058:   AC_CACHE_VAL(php_cv_sizeof_[]$1, [
 1059:     old_LIBS=$LIBS
 1060:     LIBS=
 1061:     old_LDFLAGS=$LDFLAGS
 1062:     LDFLAGS=
 1063:     AC_TRY_RUN([#include <stdio.h>
 1064: #if STDC_HEADERS
 1065: #include <stdlib.h>
 1066: #include <stddef.h>
 1067: #endif
 1068: #ifdef HAVE_INTTYPES_H
 1069: #include <inttypes.h>
 1070: #endif
 1071: #ifdef HAVE_UNISTD_H
 1072: #include <unistd.h>
 1073: #endif
 1074: $3
 1075: 
 1076: int main()
 1077: {
 1078: 	FILE *fp = fopen("conftestval", "w");
 1079: 	if (!fp) return(1);
 1080: 	fprintf(fp, "%d\n", sizeof($1));
 1081: 	return(0);
 1082: }
 1083:   ], [
 1084:     eval $php_cache_value=`cat conftestval`
 1085:   ], [
 1086:     eval $php_cache_value=0
 1087:   ], [
 1088:     ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2])
 1089: ])
 1090:   LDFLAGS=$old_LDFLAGS
 1091:   LIBS=$old_LIBS
 1092: ])
 1093:   if eval test "\$$php_cache_value" != "0"; then
 1094: ifelse([$4],[],:,[$4])
 1095: ifelse([$5],[],,[else $5])
 1096:   fi
 1097: ])
 1098: 
 1099: dnl
 1100: dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
 1101: dnl
 1102: AC_DEFUN([PHP_CHECK_SIZEOF], [
 1103:   AC_MSG_CHECKING([size of $1])
 1104:   _PHP_CHECK_SIZEOF($1, $2, $3, [
 1105:     AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1])
 1106:     AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available])
 1107:   ])
 1108:   AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)])
 1109: ])
 1110: 
 1111: dnl
 1112: dnl PHP_CHECK_TYPES(type-list, include-file [, extra-headers])
 1113: dnl
 1114: AC_DEFUN([PHP_CHECK_TYPES], [
 1115:   for php_typename in $1; do
 1116:     AC_MSG_CHECKING([whether $php_typename exists])
 1117:     _PHP_CHECK_SIZEOF($php_typename, 0, $3, [
 1118:       _PHP_DEF_HAVE_FILE($php_typename, $2)
 1119:       AC_MSG_RESULT([yes])
 1120:     ], [
 1121:       AC_MSG_RESULT([no])
 1122:     ])
 1123:   done
 1124: ])
 1125: 
 1126: dnl
 1127: dnl PHP_CHECK_IN_ADDR_T
 1128: dnl
 1129: AC_DEFUN([PHP_CHECK_IN_ADDR_T], [
 1130: dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
 1131: AC_MSG_CHECKING([for in_addr_t])
 1132: AC_CACHE_VAL(ac_cv_type_in_addr_t,
 1133: [AC_EGREP_CPP(dnl
 1134: changequote(<<,>>)dnl
 1135: <<in_addr_t[^a-zA-Z_0-9]>>dnl
 1136: changequote([,]), [#include <sys/types.h>
 1137: #if STDC_HEADERS
 1138: #include <stdlib.h>
 1139: #include <stddef.h>
 1140: #endif
 1141: #ifdef HAVE_NETINET_IN_H
 1142: #include <netinet/in.h>
 1143: #endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
 1144: AC_MSG_RESULT([$ac_cv_type_in_addr_t])
 1145: if test $ac_cv_type_in_addr_t = no; then
 1146:   AC_DEFINE(in_addr_t, u_int, [ ])
 1147: fi
 1148: ])
 1149: 
 1150: dnl
 1151: dnl PHP_TIME_R_TYPE
 1152: dnl
 1153: dnl Check type of reentrant time-related functions
 1154: dnl Type can be: irix, hpux or POSIX
 1155: dnl
 1156: AC_DEFUN([PHP_TIME_R_TYPE],[
 1157: AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
 1158: AC_TRY_RUN([
 1159: #include <time.h>
 1160: 
 1161: main() {
 1162: char buf[27];
 1163: struct tm t;
 1164: time_t old = 0;
 1165: int r, s;
 1166: 
 1167: s = gmtime_r(&old, &t);
 1168: r = (int) asctime_r(&t, buf, 26);
 1169: if (r == s && s == 0) return (0);
 1170: return (1);
 1171: }
 1172: ],[
 1173:   ac_cv_time_r_type=hpux
 1174: ],[
 1175:   AC_TRY_RUN([
 1176: #include <time.h>
 1177: main() {
 1178:   struct tm t, *s;
 1179:   time_t old = 0;
 1180:   char buf[27], *p;
 1181:   
 1182:   s = gmtime_r(&old, &t);
 1183:   p = asctime_r(&t, buf, 26);
 1184:   if (p == buf && s == &t) return (0);
 1185:   return (1);
 1186: }
 1187:   ],[
 1188:     ac_cv_time_r_type=irix
 1189:   ],[
 1190:     ac_cv_time_r_type=POSIX
 1191:   ],[
 1192:     ac_cv_time_r_type=POSIX
 1193:   ])
 1194: ],[
 1195:   ac_cv_time_r_type=POSIX
 1196: ])
 1197: ])
 1198:   case $ac_cv_time_r_type in
 1199:   hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
 1200:   irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
 1201:   esac
 1202: ])
 1203: 
 1204: dnl
 1205: dnl PHP_DOES_PWRITE_WORK
 1206: dnl internal
 1207: AC_DEFUN([PHP_DOES_PWRITE_WORK],[
 1208:   AC_TRY_RUN([
 1209: #include <sys/types.h>
 1210: #include <sys/stat.h>
 1211: #include <fcntl.h>
 1212: #include <unistd.h>
 1213: #include <errno.h>
 1214: $1
 1215:     main() {
 1216:     int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
 1217: 
 1218:     if (fd < 0) exit(1);
 1219:     if (pwrite(fd, "text", 4, 0) != 4) exit(1);
 1220:     /* Linux glibc breakage until 2.2.5 */
 1221:     if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1);
 1222:     exit(0);
 1223:     }
 1224: 
 1225:   ],[
 1226:     ac_cv_pwrite=yes
 1227:   ],[
 1228:     ac_cv_pwrite=no
 1229:   ],[
 1230:     ac_cv_pwrite=no
 1231:   ])
 1232: ])
 1233: 
 1234: dnl PHP_DOES_PREAD_WORK
 1235: dnl internal
 1236: AC_DEFUN([PHP_DOES_PREAD_WORK],[
 1237:   echo test > conftest_in
 1238:   AC_TRY_RUN([
 1239: #include <sys/types.h>
 1240: #include <sys/stat.h>
 1241: #include <fcntl.h>
 1242: #include <unistd.h>
 1243: #include <errno.h>
 1244: $1
 1245:     main() {
 1246:     char buf[3]; 
 1247:     int fd = open("conftest_in", O_RDONLY);
 1248:     if (fd < 0) exit(1);
 1249:     if (pread(fd, buf, 2, 0) != 2) exit(1);
 1250:     /* Linux glibc breakage until 2.2.5 */
 1251:     if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1);
 1252:     exit(0);
 1253:     }
 1254:   ],[
 1255:     ac_cv_pread=yes
 1256:   ],[
 1257:     ac_cv_pread=no
 1258:   ],[
 1259:     ac_cv_pread=no
 1260:   ])
 1261:   rm -f conftest_in
 1262: ])
 1263: 
 1264: dnl
 1265: dnl PHP_PWRITE_TEST
 1266: dnl
 1267: AC_DEFUN([PHP_PWRITE_TEST],[
 1268:   AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
 1269:     PHP_DOES_PWRITE_WORK
 1270:     if test "$ac_cv_pwrite" = "no"; then
 1271:       PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
 1272:       if test "$ac_cv_pwrite" = "yes"; then
 1273:         ac_cv_pwrite=64
 1274:       fi
 1275:     fi
 1276:   ])
 1277: 
 1278:   if test "$ac_cv_pwrite" != "no"; then
 1279:     AC_DEFINE(HAVE_PWRITE, 1, [ ])
 1280:     if test "$ac_cv_pwrite" = "64"; then
 1281:       AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
 1282:     fi
 1283:   fi  
 1284: ])
 1285: 
 1286: dnl
 1287: dnl PHP_PREAD_TEST
 1288: dnl
 1289: AC_DEFUN([PHP_PREAD_TEST],[
 1290:   AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
 1291:     PHP_DOES_PREAD_WORK
 1292:     if test "$ac_cv_pread" = "no"; then
 1293:       PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
 1294:       if test "$ac_cv_pread" = "yes"; then
 1295:         ac_cv_pread=64
 1296:       fi
 1297:     fi
 1298:   ])
 1299: 
 1300:   if test "$ac_cv_pread" != "no"; then
 1301:     AC_DEFINE(HAVE_PREAD, 1, [ ])
 1302:     if test "$ac_cv_pread" = "64"; then
 1303:       AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
 1304:     fi
 1305:   fi  
 1306: ])
 1307: 
 1308: dnl
 1309: dnl PHP_MISSING_TIME_R_DECL
 1310: dnl
 1311: AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
 1312:   AC_MSG_CHECKING([for missing declarations of reentrant functions])
 1313:   AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
 1314:     :
 1315:   ],[
 1316:     AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
 1317:   ])
 1318:   AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
 1319:     :
 1320:   ],[
 1321:     AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
 1322:   ])
 1323:   AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
 1324:     :
 1325:   ],[
 1326:     AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
 1327:   ])
 1328:   AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
 1329:     :
 1330:   ],[
 1331:     AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
 1332:   ])
 1333:   AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
 1334:     :
 1335:   ],[
 1336:     AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
 1337:   ])
 1338:   AC_MSG_RESULT([done])
 1339: ])
 1340: 
 1341: dnl
 1342: dnl PHP_READDIR_R_TYPE
 1343: dnl 
 1344: AC_DEFUN([PHP_READDIR_R_TYPE],[
 1345:   dnl HAVE_READDIR_R is also defined by libmysql
 1346:   AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
 1347:   if test "$ac_cv_func_readdir_r" = "yes"; then
 1348:   AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
 1349:     AC_TRY_RUN([
 1350: #define _REENTRANT
 1351: #include <sys/types.h>
 1352: #include <dirent.h>
 1353: 
 1354: #ifndef PATH_MAX
 1355: #define PATH_MAX 1024
 1356: #endif
 1357: 
 1358: main() {
 1359:   DIR *dir;
 1360:   char entry[sizeof(struct dirent)+PATH_MAX];
 1361:   struct dirent *pentry = (struct dirent *) &entry;
 1362: 
 1363:   dir = opendir("/");
 1364:   if (!dir) 
 1365:     exit(1);
 1366:   if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
 1367:     exit(0);
 1368:   exit(1);
 1369: }
 1370:     ],[
 1371:       ac_cv_what_readdir_r=POSIX
 1372:     ],[
 1373:       AC_TRY_CPP([
 1374: #define _REENTRANT
 1375: #include <sys/types.h>
 1376: #include <dirent.h>
 1377: int readdir_r(DIR *, struct dirent *);
 1378:         ],[
 1379:           ac_cv_what_readdir_r=old-style
 1380:         ],[
 1381:           ac_cv_what_readdir_r=none
 1382:       ])
 1383:     ],[
 1384:       ac_cv_what_readdir_r=none
 1385:    ])
 1386:   ])
 1387:     case $ac_cv_what_readdir_r in
 1388:     POSIX)
 1389:       AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
 1390:     old-style)
 1391:       AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
 1392:     esac
 1393:   fi
 1394: ])
 1395: 
 1396: dnl
 1397: dnl PHP_TM_GMTOFF
 1398: dnl 
 1399: AC_DEFUN([PHP_TM_GMTOFF],[
 1400: AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
 1401: [AC_TRY_COMPILE([#include <sys/types.h>
 1402: #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
 1403:   ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
 1404: 
 1405: if test "$ac_cv_struct_tm_gmtoff" = yes; then
 1406:   AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
 1407: fi
 1408: ])
 1409: 
 1410: dnl
 1411: dnl PHP_STRUCT_FLOCK
 1412: dnl
 1413: AC_DEFUN([PHP_STRUCT_FLOCK],[
 1414: AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
 1415:     AC_TRY_COMPILE([
 1416: #include <unistd.h>
 1417: #include <fcntl.h>
 1418:         ],
 1419:         [struct flock x;],
 1420:         [
 1421:           ac_cv_struct_flock=yes
 1422:         ],[
 1423:           ac_cv_struct_flock=no
 1424:         ])
 1425: )
 1426: if test "$ac_cv_struct_flock" = "yes" ; then
 1427:     AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
 1428: fi
 1429: ])
 1430: 
 1431: dnl
 1432: dnl PHP_SOCKLEN_T
 1433: dnl
 1434: AC_DEFUN([PHP_SOCKLEN_T],[
 1435: AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
 1436:   AC_TRY_COMPILE([
 1437: #include <sys/types.h>
 1438: #include <sys/socket.h>
 1439: ],[
 1440: socklen_t x;
 1441: ],[
 1442:   ac_cv_socklen_t=yes
 1443: ],[
 1444:   ac_cv_socklen_t=no
 1445: ]))
 1446: if test "$ac_cv_socklen_t" = "yes"; then
 1447:   AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
 1448: fi
 1449: ])
 1450: 
 1451: dnl
 1452: dnl PHP_MISSING_FCLOSE_DECL
 1453: dnl
 1454: dnl See if we have broken header files like SunOS has.
 1455: dnl
 1456: AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
 1457:   AC_MSG_CHECKING([for fclose declaration])
 1458:   AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
 1459:     AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
 1460:     AC_MSG_RESULT([ok])
 1461:   ],[
 1462:     AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
 1463:     AC_MSG_RESULT([missing])
 1464:   ])
 1465: ])
 1466: 
 1467: dnl
 1468: dnl PHP_AC_BROKEN_SPRINTF
 1469: dnl
 1470: dnl Check for broken sprintf(), C99 conformance
 1471: dnl
 1472: AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[
 1473:   AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
 1474:     AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
 1475:       ac_cv_broken_sprintf=no
 1476:     ],[
 1477:       ac_cv_broken_sprintf=yes
 1478:     ],[
 1479:       ac_cv_broken_sprintf=no
 1480:     ])
 1481:   ])
 1482:   if test "$ac_cv_broken_sprintf" = "yes"; then
 1483:     AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform])
 1484:   else
 1485:     AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform])
 1486:   fi
 1487: ])
 1488: 
 1489: dnl
 1490: dnl PHP_AC_BROKEN_SNPRINTF
 1491: dnl
 1492: dnl Check for broken snprintf(), C99 conformance
 1493: dnl
 1494: AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[
 1495:   AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[
 1496:     AC_TRY_RUN([
 1497: #define NULL (0L)
 1498: main() {
 1499:   char buf[20];
 1500:   int res = 0;
 1501:   res = res || (snprintf(buf, 2, "marcus") != 6); 
 1502:   res = res || (buf[1] != '\0');
 1503:   /* Implementations may consider this as an encoding error */
 1504:   snprintf(buf, 0, "boerger");
 1505:   /* However, they MUST ignore the pointer */
 1506:   res = res || (buf[0] != 'm');
 1507:   res = res || (snprintf(NULL, 0, "boerger") != 7);
 1508:   res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
 1509:   exit(res); 
 1510: }
 1511:     ],[
 1512:       ac_cv_broken_snprintf=no
 1513:     ],[
 1514:       ac_cv_broken_snprintf=yes
 1515:     ],[
 1516:       ac_cv_broken_snprintf=no
 1517:     ])
 1518:   ])
 1519:   if test "$ac_cv_broken_snprintf" = "yes"; then
 1520:     AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform])
 1521:   else
 1522:     AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform])
 1523:   fi
 1524: ])
 1525: 
 1526: dnl
 1527: dnl PHP_SOLARIS_PIC_WEIRDNESS
 1528: dnl
 1529: dnl Solaris requires main code to be position independent in order
 1530: dnl to let shared objects find symbols.  Weird.  Ugly.
 1531: dnl
 1532: dnl Must be run after all --with-NN options that let the user
 1533: dnl choose dynamic extensions, and after the gcc test.
 1534: dnl
 1535: AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[
 1536:   AC_MSG_CHECKING([whether -fPIC is required])
 1537:   if test -n "$EXT_SHARED"; then
 1538:     os=`uname -sr 2>/dev/null`
 1539:     case $os in
 1540:       "SunOS 5.6"|"SunOS 5.7"[)]
 1541:         case $CC in
 1542:           gcc*|egcs*)
 1543:             CFLAGS="$CFLAGS -fPIC";;
 1544:           *[)]
 1545:             CFLAGS="$CFLAGS -fpic";;
 1546:         esac
 1547:         AC_MSG_RESULT([yes]);;
 1548:       *[)]
 1549:         AC_MSG_RESULT([no]);;
 1550:     esac
 1551:   else
 1552:     AC_MSG_RESULT([no])
 1553:   fi
 1554: ])
 1555: 
 1556: dnl
 1557: dnl PHP_SYS_LFS
 1558: dnl
 1559: dnl The problem is that the default compilation flags in Solaris 2.6 won't
 1560: dnl let programs access large files;  you need to tell the compiler that
 1561: dnl you actually want your programs to work on large files.  For more
 1562: dnl details about this brain damage please see:
 1563: dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
 1564: dnl
 1565: dnl Written by Paul Eggert <eggert@twinsun.com>.
 1566: dnl
 1567: AC_DEFUN([PHP_SYS_LFS],
 1568: [dnl
 1569:   # If available, prefer support for large files unless the user specified
 1570:   # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
 1571:   AC_MSG_CHECKING([whether large file support needs explicit enabling])
 1572:   ac_getconfs=''
 1573:   ac_result=yes
 1574:   ac_set=''
 1575:   ac_shellvars='CPPFLAGS LDFLAGS LIBS'
 1576:   for ac_shellvar in $ac_shellvars; do
 1577:     case $ac_shellvar in
 1578:       CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;;
 1579:       *[)] ac_lfsvar=LFS_$ac_shellvar ;;
 1580:     esac
 1581:     eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
 1582:     (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
 1583:     ac_getconf=`getconf $ac_lfsvar`
 1584:     ac_getconfs=$ac_getconfs$ac_getconf
 1585:     eval ac_test_$ac_shellvar=\$ac_getconf
 1586:   done
 1587:   case "$ac_result$ac_getconfs" in
 1588:     yes[)] ac_result=no ;;
 1589:   esac
 1590:   case "$ac_result$ac_set" in
 1591:     yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings"
 1592:   esac
 1593:   AC_MSG_RESULT([$ac_result])
 1594:   case $ac_result in
 1595:     yes[)]
 1596:       for ac_shellvar in $ac_shellvars; do
 1597:         eval $ac_shellvar=\$ac_test_$ac_shellvar
 1598:       done ;;
 1599:   esac
 1600: ])
 1601: 
 1602: dnl
 1603: dnl PHP_SOCKADDR_CHECKS
 1604: dnl
 1605: AC_DEFUN([PHP_SOCKADDR_CHECKS], [
 1606:   dnl Check for struct sockaddr_storage exists
 1607:   AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage,
 1608:     [AC_TRY_COMPILE([#include <sys/types.h>
 1609: #include <sys/socket.h>],
 1610:     [struct sockaddr_storage s; s],
 1611:     [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no])
 1612:   ])
 1613:   if test "$ac_cv_sockaddr_storage" = "yes"; then
 1614:     AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
 1615:   fi
 1616:   dnl Check if field sa_len exists in struct sockaddr 
 1617:   AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
 1618:     AC_TRY_COMPILE([#include <sys/types.h>
 1619: #include <sys/socket.h>],
 1620:     [static struct sockaddr sa; int n = (int) sa.sa_len; return n;],
 1621:     [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no])
 1622:   ])
 1623:   if test "$ac_cv_sockaddr_sa_len" = "yes"; then
 1624:     AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len])
 1625:   fi
 1626: ])
 1627: 
 1628: dnl
 1629: dnl PHP_DECLARED_TIMEZONE
 1630: dnl
 1631: AC_DEFUN([PHP_DECLARED_TIMEZONE],[
 1632:   AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
 1633:     AC_TRY_COMPILE([
 1634: #include <sys/types.h>
 1635: #include <time.h>
 1636: #ifdef HAVE_SYS_TIME_H
 1637: #include <sys/time.h>
 1638: #endif
 1639: ],[
 1640:     time_t foo = (time_t) timezone;
 1641: ],[
 1642:   ac_cv_declared_timezone=yes
 1643: ],[
 1644:   ac_cv_declared_timezone=no
 1645: ])])
 1646:   if test "$ac_cv_declared_timezone" = "yes"; then
 1647:     AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
 1648:   fi
 1649: ])
 1650: 
 1651: dnl
 1652: dnl PHP_EBCDIC
 1653: dnl
 1654: AC_DEFUN([PHP_EBCDIC], [
 1655:   AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
 1656:   AC_TRY_RUN( [
 1657: int main(void) { 
 1658:   return (unsigned char)'A' != (unsigned char)0xC1; 
 1659: } 
 1660: ],[
 1661:   ac_cv_ebcdic=yes
 1662: ],[
 1663:   ac_cv_ebcdic=no
 1664: ],[
 1665:   ac_cv_ebcdic=no
 1666: ])])
 1667:   if test "$ac_cv_ebcdic" = "yes"; then
 1668:     AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
 1669:   fi
 1670: ])
 1671: 
 1672: dnl
 1673: dnl PHP_BROKEN_GETCWD
 1674: dnl
 1675: dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a
 1676: dnl component of the path has execute but not read permissions
 1677: dnl
 1678: AC_DEFUN([PHP_BROKEN_GETCWD],[
 1679:   AC_MSG_CHECKING([for broken getcwd])
 1680:   os=`uname -sr 2>/dev/null`
 1681:   case $os in
 1682:     SunOS*[)]
 1683:       AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd])
 1684:       AC_MSG_RESULT([yes]);;
 1685:     *[)]
 1686:       AC_MSG_RESULT([no]);;
 1687:   esac
 1688: ])
 1689: 
 1690: dnl
 1691: dnl PHP_BROKEN_GLIBC_FOPEN_APPEND
 1692: dnl
 1693: AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
 1694:   AC_MSG_CHECKING([for broken libc stdio])
 1695:   AC_CACHE_VAL(_cv_have_broken_glibc_fopen_append,[
 1696:   AC_TRY_RUN([
 1697: #include <stdio.h>
 1698: int main(int argc, char *argv[])
 1699: {
 1700:   FILE *fp;
 1701:   long position;
 1702:   char *filename = "/tmp/phpglibccheck";
 1703:   
 1704:   fp = fopen(filename, "w");
 1705:   if (fp == NULL) {
 1706:     perror("fopen");
 1707:     exit(2);
 1708:   }
 1709:   fputs("foobar", fp);
 1710:   fclose(fp);
 1711: 
 1712:   fp = fopen(filename, "a+");
 1713:   position = ftell(fp);
 1714:   fclose(fp);
 1715:   unlink(filename);
 1716:   if (position == 0)
 1717:   return 1;
 1718:   return 0;
 1719: }
 1720: ],
 1721: [_cv_have_broken_glibc_fopen_append=no],
 1722: [_cv_have_broken_glibc_fopen_append=yes ],
 1723: AC_TRY_COMPILE([
 1724: #include <features.h>
 1725: ],[
 1726: #if !__GLIBC_PREREQ(2,2)
 1727: choke me
 1728: #endif
 1729: ],
 1730: [_cv_have_broken_glibc_fopen_append=yes],
 1731: [_cv_have_broken_glibc_fopen_append=no ])
 1732: )])
 1733: 
 1734:   if test "$_cv_have_broken_glibc_fopen_append" = "yes"; then
 1735:     AC_MSG_RESULT(yes)
 1736:     AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
 1737:   else
 1738:     AC_MSG_RESULT(no)
 1739:   fi
 1740: ])
 1741: 
 1742: dnl
 1743: dnl PHP_FOPENCOOKIE
 1744: dnl
 1745: AC_DEFUN([PHP_FOPENCOOKIE], [
 1746:   AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes])
 1747: 
 1748:   if test "$have_glibc_fopencookie" = "yes"; then
 1749: dnl this comes in two flavors:
 1750: dnl newer glibcs (since 2.1.2 ? )
 1751: dnl have a type called cookie_io_functions_t
 1752: AC_TRY_COMPILE([
 1753: #define _GNU_SOURCE
 1754: #include <stdio.h>
 1755: ], [cookie_io_functions_t cookie;], [have_cookie_io_functions_t=yes], [])
 1756: 
 1757:     if test "$have_cookie_io_functions_t" = "yes"; then
 1758:       cookie_io_functions_t=cookie_io_functions_t
 1759:       have_fopen_cookie=yes
 1760: 
 1761: dnl even newer glibcs have a different seeker definition...
 1762: AC_TRY_RUN([
 1763: #define _GNU_SOURCE
 1764: #include <stdio.h>
 1765: 
 1766: struct cookiedata {
 1767:   __off64_t pos;
 1768: };
 1769: 
 1770: __ssize_t reader(void *cookie, char *buffer, size_t size)
 1771: { return size; }
 1772: __ssize_t writer(void *cookie, const char *buffer, size_t size)
 1773: { return size; }
 1774: int closer(void *cookie)
 1775: { return 0; }
 1776: int seeker(void *cookie, __off64_t *position, int whence)
 1777: { ((struct cookiedata*)cookie)->pos = *position; return 0; }
 1778: 
 1779: cookie_io_functions_t funcs = {reader, writer, seeker, closer};
 1780: 
 1781: main() {
 1782:   struct cookiedata g = { 0 };
 1783:   FILE *fp = fopencookie(&g, "r", funcs);
 1784: 
 1785:   if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
 1786:     exit(0);
 1787:   exit(1);
 1788: }
 1789: 
 1790: ], [
 1791:   cookie_io_functions_use_off64_t=yes
 1792: ], [
 1793:   cookie_io_functions_use_off64_t=no
 1794: ], [
 1795:   cookie_io_functions_use_off64_t=no
 1796: ])
 1797:     
 1798:     else
 1799: 
 1800: dnl older glibc versions (up to 2.1.2 ?)
 1801: dnl call it _IO_cookie_io_functions_t
 1802: AC_TRY_COMPILE([
 1803: #define _GNU_SOURCE
 1804: #include <stdio.h>
 1805: ], [ _IO_cookie_io_functions_t cookie; ], [have_IO_cookie_io_functions_t=yes], [])
 1806:       if test "$have_cookie_io_functions_t" = "yes" ; then
 1807:         cookie_io_functions_t=_IO_cookie_io_functions_t
 1808:         have_fopen_cookie=yes
 1809:       fi
 1810:     fi
 1811: 
 1812:     if test "$have_fopen_cookie" = "yes" ; then
 1813:       AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
 1814:       AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
 1815:       if test "$cookie_io_functions_use_off64_t" = "yes" ; then
 1816:         AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ])
 1817:       fi
 1818:     fi
 1819:   fi
 1820: ])
 1821: 
 1822: dnl -------------------------------------------------------------------------
 1823: dnl Library/function existance and build sanity checks
 1824: dnl -------------------------------------------------------------------------
 1825: 
 1826: dnl
 1827: dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
 1828: dnl
 1829: dnl Wrapper for AC_CHECK_LIB
 1830: dnl
 1831: AC_DEFUN([PHP_CHECK_LIBRARY], [
 1832:   save_old_LDFLAGS=$LDFLAGS
 1833:   ac_stuff="$5"
 1834:   
 1835:   save_ext_shared=$ext_shared
 1836:   ext_shared=yes
 1837:   PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
 1838:   AC_CHECK_LIB([$1],[$2],[
 1839:     LDFLAGS=$save_old_LDFLAGS
 1840:     ext_shared=$save_ext_shared
 1841:     $3
 1842:   ],[
 1843:     LDFLAGS=$save_old_LDFLAGS
 1844:     ext_shared=$save_ext_shared
 1845:     unset ac_cv_lib_$1[]_$2
 1846:     $4
 1847:   ])dnl
 1848: ])
 1849: 
 1850: dnl
 1851: dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]])
 1852: dnl
 1853: dnl El cheapo wrapper for AC_CHECK_LIB
 1854: dnl
 1855: AC_DEFUN([PHP_CHECK_FRAMEWORK], [
 1856:   save_old_LDFLAGS=$LDFLAGS
 1857:   LDFLAGS="-framework $1 $LDFLAGS"
 1858:   dnl supplying "c" to AC_CHECK_LIB is technically cheating, but
 1859:   dnl rewriting AC_CHECK_LIB is overkill and this only affects
 1860:   dnl the "checking.." output anyway.
 1861:   AC_CHECK_LIB(c,[$2],[
 1862:     LDFLAGS=$save_old_LDFLAGS
 1863:     $3
 1864:   ],[
 1865:     LDFLAGS=$save_old_LDFLAGS
 1866:     $4
 1867:   ])
 1868: ])
 1869: 
 1870: dnl
 1871: dnl PHP_CHECK_FUNC_LIB(func, libs)
 1872: dnl
 1873: dnl This macro checks whether 'func' or '__func' exists
 1874: dnl in the specified library.
 1875: dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
 1876: dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC
 1877: dnl
 1878: dnl
 1879: dnl autoconf undefines the builtin "shift" :-(
 1880: dnl If possible, we use the builtin shift anyway, otherwise we use
 1881: dnl the ubercool definition I have tested so far with FreeBSD/GNU m4
 1882: ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
 1883: define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
 1884: ])
 1885: dnl
 1886: AC_DEFUN([PHP_CHECK_FUNC_LIB],[
 1887:   ifelse($2,,:,[
 1888:   unset ac_cv_lib_$2[]_$1
 1889:   unset ac_cv_lib_$2[]___$1
 1890:   unset found
 1891:   AC_CHECK_LIB($2, $1, [found=yes], [
 1892:     AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
 1893:   ])
 1894: 
 1895:   if test "$found" = "yes"; then
 1896:     ac_libs=$LIBS
 1897:     LIBS="$LIBS -l$2"
 1898:     AC_TRY_RUN([main() { return (0); }],[found=yes],[found=no],[found=no])
 1899:     LIBS=$ac_libs
 1900:   fi
 1901: 
 1902:   if test "$found" = "yes"; then
 1903:     PHP_ADD_LIBRARY($2)
 1904:     PHP_DEF_HAVE($1)
 1905:     PHP_DEF_HAVE(lib$2)
 1906:     ac_cv_func_$1=yes
 1907:   else
 1908:     PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
 1909:   fi
 1910:   ])
 1911: ])
 1912: 
 1913: dnl
 1914: dnl PHP_CHECK_FUNC(func, ...)
 1915: dnl
 1916: dnl This macro checks whether 'func' or '__func' exists
 1917: dnl in the default libraries and as a fall back in the specified library.
 1918: dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
 1919: dnl
 1920: AC_DEFUN([PHP_CHECK_FUNC],[
 1921:   unset ac_cv_func_$1
 1922:   unset ac_cv_func___$1
 1923:   unset found
 1924:   
 1925:   AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
 1926: 
 1927:   case $found in
 1928:   yes[)] 
 1929:     PHP_DEF_HAVE($1)
 1930:     ac_cv_func_$1=yes
 1931:   ;;
 1932:   ifelse($#,1,,[
 1933:     *[)] PHP_CHECK_FUNC_LIB($@) ;;
 1934:   ])
 1935:   esac
 1936: ])
 1937: 
 1938: dnl
 1939: dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]])
 1940: dnl
 1941: dnl This macro checks whether build works and given function exists.
 1942: dnl
 1943: AC_DEFUN([PHP_TEST_BUILD], [
 1944:   old_LIBS=$LIBS
 1945:   LIBS="$4 $LIBS"
 1946:   AC_TRY_RUN([
 1947:     $5
 1948:     char $1();
 1949:     int main() {
 1950:       $1();
 1951:       return 0;
 1952:     }
 1953:   ], [
 1954:     LIBS=$old_LIBS
 1955:     $2
 1956:   ],[
 1957:     LIBS=$old_LIBS
 1958:     $3
 1959:   ],[
 1960:     LIBS=$old_LIBS
 1961:   ])
 1962: ])
 1963: 
 1964: dnl -------------------------------------------------------------------------
 1965: dnl Platform characteristics checks
 1966: dnl -------------------------------------------------------------------------
 1967: 
 1968: dnl
 1969: dnl PHP_SHLIB_SUFFIX_NAMES
 1970: dnl
 1971: dnl Determines link library suffix SHLIB_SUFFIX_NAME
 1972: dnl which can be: .so, .sl or .dylib
 1973: dnl
 1974: dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME
 1975: dnl suffix can be: .so or .sl
 1976: dnl
 1977: AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[
 1978:  AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
 1979:  PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
 1980:  PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME)
 1981:  SHLIB_SUFFIX_NAME=so
 1982:  SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME
 1983:  case $host_alias in
 1984:  *hpux*[)]
 1985:    SHLIB_SUFFIX_NAME=sl
 1986:    SHLIB_DL_SUFFIX_NAME=sl
 1987:    ;;
 1988:  *darwin*[)]
 1989:    SHLIB_SUFFIX_NAME=dylib
 1990:    SHLIB_DL_SUFFIX_NAME=so
 1991:    ;;
 1992:  esac
 1993: ])
 1994: 
 1995: dnl
 1996: dnl PHP_CHECK_64BIT([do if 32], [do if 64])
 1997: dnl
 1998: dnl This macro is used to detect if we're at 64-bit platform or not.
 1999: dnl It could be useful for those external libs, that have different precompiled 
 2000: dnl versions in different directories.
 2001: dnl
 2002: AC_DEFUN([PHP_CHECK_64BIT],[
 2003:   AC_CHECK_SIZEOF(long int, 4)
 2004:   AC_MSG_CHECKING([checking if we're at 64-bit platform])
 2005:   if test "$ac_cv_sizeof_long_int" = "4" ; then
 2006:     AC_MSG_RESULT([no])
 2007:     $1
 2008:   else
 2009:     AC_MSG_RESULT([yes])
 2010:     $2
 2011:   fi
 2012: ])
 2013: 
 2014: dnl
 2015: dnl PHP_C_BIGENDIAN
 2016: dnl
 2017: dnl Replacement macro for AC_C_BIGENDIAN
 2018: dnl
 2019: AC_DEFUN([PHP_C_BIGENDIAN],
 2020: [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
 2021:  [
 2022:   ac_cv_c_bigendian_php=unknown
 2023:   AC_TRY_RUN(
 2024:   [
 2025: int main(void)
 2026: {
 2027:   short one = 1;
 2028:   char *cp = (char *)&one;
 2029: 
 2030:   if (*cp == 0) {
 2031:     return(0);
 2032:   } else {
 2033:     return(1);
 2034:   }
 2035: }
 2036:   ], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
 2037:  ])
 2038:  if test $ac_cv_c_bigendian_php = yes; then
 2039:    AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word])
 2040:  fi
 2041: ])
 2042: 
 2043: dnl -------------------------------------------------------------------------
 2044: dnl Checks for programs: PHP_PROG_<program>
 2045: dnl -------------------------------------------------------------------------
 2046: 
 2047: dnl
 2048: dnl PHP_PROG_SENDMAIL
 2049: dnl
 2050: dnl Search for the sendmail binary
 2051: dnl
 2052: AC_DEFUN([PHP_PROG_SENDMAIL], [
 2053:   PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
 2054:   AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH)
 2055:   PHP_SUBST(PROG_SENDMAIL)
 2056: ])
 2057: 
 2058: dnl
 2059: dnl PHP_PROG_AWK
 2060: dnl
 2061: dnl Some vendors force mawk before gawk; mawk is broken so we don't like that
 2062: dnl
 2063: AC_DEFUN([PHP_PROG_AWK], [
 2064:   AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
 2065:   case "$AWK" in
 2066:     *mawk)
 2067:       AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
 2068:       ;;
 2069:     *gawk)  
 2070:       ;;
 2071:     bork)   
 2072:       AC_MSG_ERROR([Could not find awk; Install GNU awk])
 2073:       ;;
 2074:     *)
 2075:       AC_MSG_CHECKING([if $AWK is broken])
 2076:       if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
 2077:         AC_MSG_RESULT([yes])
 2078:         AC_MSG_ERROR([You should install GNU awk])
 2079:       else
 2080:         AC_MSG_RESULT([no])
 2081:       fi
 2082:       ;;
 2083:   esac
 2084:   PHP_SUBST(AWK)
 2085: ])
 2086: 
 2087: dnl
 2088: dnl PHP_PROG_BISON
 2089: dnl
 2090: dnl Search for bison and check it's version
 2091: dnl
 2092: AC_DEFUN([PHP_PROG_BISON], [
 2093:   AC_PROG_YACC
 2094:   LIBZEND_BISON_CHECK
 2095:   PHP_SUBST(YACC)
 2096: ])
 2097: 
 2098: dnl
 2099: dnl PHP_PROG_LEX
 2100: dnl
 2101: dnl Search for (f)lex and check it's version
 2102: dnl
 2103: AC_DEFUN([PHP_PROG_LEX], [
 2104: dnl we only support certain flex versions
 2105:   flex_version_list="2.5.4"
 2106:    
 2107:   AC_PROG_LEX
 2108:   if test "$LEX" = "flex"; then
 2109: dnl AC_DECL_YYTEXT is obsolete since autoconf 2.50 and merged into AC_PROG_LEX
 2110: dnl this is what causes that annoying "PHP_PROG_LEX is expanded from" warning with autoconf 2.50+
 2111: dnl it should be removed once we drop support of autoconf 2.13 (if ever)
 2112:     AC_DECL_YYTEXT
 2113:     :
 2114:   fi
 2115:   dnl ## Make flex scanners use const if they can, even if __STDC__ is not
 2116:   dnl ## true, for compilers like Sun's that only set __STDC__ true in
 2117:   dnl ## "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
 2118:   AC_C_CONST
 2119:   if test "$ac_cv_c_const" = "yes" ; then
 2120:     LEX_CFLAGS="-DYY_USE_CONST"
 2121:   fi
 2122: 
 2123:   if test "$LEX" = "flex"; then
 2124:     AC_CACHE_CHECK([for flex version], php_cv_flex_version, [
 2125:       flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'`
 2126:       php_cv_flex_version=invalid
 2127:       for flex_check_version in $flex_version_list; do
 2128:         if test "$flex_version" = "$flex_check_version"; then
 2129:           php_cv_flex_version="$flex_check_version (ok)"
 2130:         fi
 2131:       done
 2132:     ])
 2133:   else
 2134:     flex_version=none
 2135:   fi
 2136:   
 2137:   case $php_cv_flex_version in
 2138:     ""|invalid[)]
 2139:       if test -f "$abs_srcdir/Zend/zend_language_scanner.c" && test -f "$abs_srcdir/Zend/zend_ini_scanner.c"; then
 2140:         AC_MSG_WARN([flex versions supported for regeneration of the Zend/PHP parsers: $flex_version_list  (found: $flex_version)])
 2141:       else
 2142:         flex_msg="Supported flex versions are: $flex_version_list"
 2143:         if test "$flex_version" = "none"; then
 2144:           flex_msg="flex not found. flex is required to generate the Zend/PHP parsers! $flex_msg"
 2145:         else
 2146:           flex_msg="Found invalid flex version: $flex_version. $flex_msg"
 2147:         fi
 2148:         AC_MSG_ERROR([$flex_msg])
 2149:       fi
 2150:       LEX="exit 0;"
 2151:       ;;
 2152:   esac
 2153:   PHP_SUBST(LEX)
 2154: ])
 2155: 
 2156: dnl
 2157: dnl PHP_PROG_RE2C
 2158: dnl
 2159: dnl Search for the re2c binary and check the version
 2160: dnl
 2161: AC_DEFUN([PHP_PROG_RE2C],[
 2162:   AC_CHECK_PROG(RE2C, re2c, re2c)
 2163:   if test -n "$RE2C"; then
 2164:     AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [
 2165:       re2c_vernum=`$RE2C --vernum 2>/dev/null`
 2166:       if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1304"; then
 2167:         php_cv_re2c_version=invalid
 2168:       else
 2169:         php_cv_re2c_version="`$RE2C --version | cut -d ' ' -f 2  2>/dev/null` (ok)"
 2170:       fi 
 2171:     ])
 2172:   fi
 2173:   case $php_cv_re2c_version in
 2174:     ""|invalid[)]
 2175:       AC_MSG_WARN([You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.])
 2176:       RE2C="exit 0;"
 2177:       ;;
 2178:   esac
 2179:   PHP_SUBST(RE2C)
 2180: ])
 2181: 
 2182: dnl -------------------------------------------------------------------------
 2183: dnl Common setup macros: PHP_SETUP_<what>
 2184: dnl -------------------------------------------------------------------------
 2185: 
 2186: dnl
 2187: dnl PHP_SETUP_ICU([shared-add])
 2188: dnl
 2189: dnl Common setup macro for ICU
 2190: dnl
 2191: AC_DEFUN([PHP_SETUP_ICU],[
 2192:   PHP_ARG_WITH(icu-dir,,
 2193:   [  --with-icu-dir=DIR      Specify where ICU libraries and headers can be found], DEFAULT, no)
 2194: 
 2195:   if test "$PHP_ICU_DIR" = "no"; then
 2196:     PHP_ICU_DIR=DEFAULT
 2197:   fi
 2198: 
 2199:   if test "$PHP_ICU_DIR" = "DEFAULT"; then
 2200:     dnl Try to find icu-config
 2201:     AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
 2202:   else
 2203:     ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
 2204:   fi
 2205: 
 2206:   AC_MSG_CHECKING([for location of ICU headers and libraries])
 2207: 
 2208:   dnl Trust icu-config to know better what the install prefix is..
 2209:   icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
 2210:   if test "$?" != "0" || test -z "$icu_install_prefix"; then
 2211:     AC_MSG_RESULT([not found])
 2212:     AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
 2213:   else
 2214:     AC_MSG_RESULT([$icu_install_prefix])
 2215: 
 2216:     dnl Check ICU version
 2217:     AC_MSG_CHECKING([for ICU 3.4 or greater])
 2218:     icu_version_full=`$ICU_CONFIG --version`
 2219:     ac_IFS=$IFS
 2220:     IFS="."
 2221:     set $icu_version_full
 2222:     IFS=$ac_IFS
 2223:     icu_version=`expr [$]1 \* 1000 + [$]2`
 2224:     AC_MSG_RESULT([found $icu_version_full])
 2225: 
 2226:     if test "$icu_version" -lt "3004"; then
 2227:       AC_MSG_ERROR([ICU version 3.4 or later is required])
 2228:     fi
 2229: 
 2230:     ICU_VERSION=$icu_version
 2231:     ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
 2232:     ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
 2233:     PHP_EVAL_INCLINE($ICU_INCS)
 2234:     PHP_EVAL_LIBLINE($ICU_LIBS, $1)
 2235:   fi
 2236: ])
 2237: 
 2238: dnl
 2239: dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]])
 2240: dnl
 2241: dnl Common setup macro for kerberos
 2242: dnl
 2243: AC_DEFUN([PHP_SETUP_KERBEROS],[
 2244:   found_kerberos=no
 2245:   unset KERBEROS_CFLAGS
 2246:   unset KERBEROS_LIBS
 2247: 
 2248:   dnl First try to find krb5-config
 2249:   if test -z "$KRB5_CONFIG"; then
 2250:     AC_PATH_PROG(KRB5_CONFIG, krb5-config, no, [$PATH:/usr/kerberos/bin:/usr/local/bin])
 2251:   fi
 2252: 
 2253:   dnl If krb5-config is found try using it
 2254:   if test "$PHP_KERBEROS" = "yes" && test -x "$KRB5_CONFIG"; then
 2255:     KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi`
 2256:     KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi`
 2257: 
 2258:     if test -n "$KERBEROS_LIBS"; then
 2259:       found_kerberos=yes
 2260:       PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1)
 2261:       PHP_EVAL_INCLINE($KERBEROS_CFLAGS)
 2262:     fi
 2263:   fi
 2264: 
 2265:   dnl If still not found use old skool method
 2266:   if test "$found_kerberos" = "no"; then
 2267: 
 2268:     if test "$PHP_KERBEROS" = "yes"; then
 2269:       PHP_KERBEROS="/usr/kerberos /usr/local /usr"
 2270:     fi
 2271: 
 2272:     for i in $PHP_KERBEROS; do
 2273:       if test -f $i/$PHP_LIBDIR/libkrb5.a || test -f $i/$PHP_LIBDIR/libkrb5.$SHLIB_SUFFIX_NAME; then
 2274:         PHP_KERBEROS_DIR=$i
 2275:         break
 2276:       fi
 2277:     done
 2278: 
 2279:     if test "$PHP_KERBEROS_DIR"; then
 2280:       found_kerberos=yes
 2281:       PHP_ADD_LIBPATH($PHP_KERBEROS_DIR/$PHP_LIBDIR, $1)
 2282:       PHP_ADD_LIBRARY(gssapi_krb5, 1, $1)
 2283:       PHP_ADD_LIBRARY(krb5, 1, $1)
 2284:       PHP_ADD_LIBRARY(k5crypto, 1, $1)
 2285:       PHP_ADD_LIBRARY(com_err,  1, $1)
 2286:       PHP_ADD_INCLUDE($PHP_KERBEROS_DIR/include)
 2287:     fi
 2288:   fi
 2289: 
 2290:   if test "$found_kerberos" = "yes"; then
 2291: ifelse([$2],[],:,[$2])
 2292: ifelse([$3],[],,[else $3])
 2293:   fi
 2294: ])
 2295: 
 2296: dnl 
 2297: dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
 2298: dnl
 2299: dnl Common setup macro for openssl
 2300: dnl
 2301: AC_DEFUN([PHP_SETUP_OPENSSL],[
 2302:   found_openssl=no
 2303:   unset OPENSSL_INCDIR
 2304:   unset OPENSSL_LIBDIR
 2305: 
 2306:   dnl Empty variable means 'no'
 2307:   test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
 2308:   test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
 2309: 
 2310:   dnl Fallbacks for different configure options
 2311:   if test -n "$PHP_OPENSSL" && test "$PHP_OPENSSL" != "no"; then
 2312:     PHP_OPENSSL_DIR=$PHP_OPENSSL
 2313:   elif test -n "$PHP_IMAP_SSL" && test "$PHP_IMAP_SSL" != "no"; then
 2314:     PHP_OPENSSL_DIR=$PHP_IMAP_SSL
 2315:   fi
 2316: 
 2317:   dnl First try to find pkg-config
 2318:   if test -z "$PKG_CONFIG"; then
 2319:     AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
 2320:   fi
 2321: 
 2322:   dnl If pkg-config is found try using it
 2323:   if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
 2324:     if $PKG_CONFIG --atleast-version=0.9.6 openssl; then
 2325:       found_openssl=yes
 2326:       OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
 2327:       OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
 2328:       OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
 2329:     else
 2330:       AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
 2331:     fi
 2332: 
 2333:     if test -n "$OPENSSL_LIBS" && test -n "$OPENSSL_INCS"; then
 2334:       PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
 2335:       PHP_EVAL_INCLINE($OPENSSL_INCS)
 2336:     fi
 2337:   fi
 2338: 
 2339:   dnl If pkg-config fails for some reason, revert to the old method
 2340:   if test "$found_openssl" = "no"; then
 2341:   
 2342:     if test "$PHP_OPENSSL_DIR" = "yes"; then
 2343:       PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
 2344:     fi
 2345: 
 2346:     for i in $PHP_OPENSSL_DIR; do
 2347:       if test -r $i/include/openssl/evp.h; then
 2348:         OPENSSL_INCDIR=$i/include
 2349:       fi
 2350:       if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
 2351:         OPENSSL_LIBDIR=$i/$PHP_LIBDIR
 2352:       fi
 2353:       test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
 2354:     done
 2355: 
 2356:     if test -z "$OPENSSL_INCDIR"; then
 2357:       AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
 2358:     fi
 2359: 
 2360:     if test -z "$OPENSSL_LIBDIR"; then
 2361:       AC_MSG_ERROR([Cannot find OpenSSL's libraries])
 2362:     fi
 2363: 
 2364:     old_CPPFLAGS=$CPPFLAGS
 2365:     CPPFLAGS=-I$OPENSSL_INCDIR
 2366:     AC_MSG_CHECKING([for OpenSSL version])
 2367:     AC_EGREP_CPP(yes,[
 2368: #include <openssl/opensslv.h>
 2369: #if OPENSSL_VERSION_NUMBER >= 0x0090600fL
 2370:   yes
 2371: #endif
 2372:     ],[
 2373:       AC_MSG_RESULT([>= 0.9.6])
 2374:     ],[
 2375:       AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
 2376:     ])
 2377:     CPPFLAGS=$old_CPPFLAGS
 2378: 
 2379:     PHP_ADD_INCLUDE($OPENSSL_INCDIR)
 2380:   
 2381:     PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
 2382:       PHP_ADD_LIBRARY(crypto,,$1)
 2383:     ],[
 2384:       AC_MSG_ERROR([libcrypto not found!])
 2385:     ],[
 2386:       -L$OPENSSL_LIBDIR
 2387:     ])
 2388: 
 2389:     old_LIBS=$LIBS
 2390:     LIBS="$LIBS -lcrypto"
 2391:     PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
 2392:       found_openssl=yes
 2393:     ],[
 2394:       AC_MSG_ERROR([libssl not found!])
 2395:     ],[
 2396:       -L$OPENSSL_LIBDIR
 2397:     ])
 2398:     LIBS=$old_LIBS
 2399:     PHP_ADD_LIBRARY(ssl,,$1)
 2400:     PHP_ADD_LIBRARY(crypto,,$1)
 2401: 
 2402:     PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1)
 2403:   fi
 2404: 
 2405:   if test "$found_openssl" = "yes"; then
 2406:   dnl For apache 1.3.x static build
 2407:   OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
 2408:   AC_SUBST(OPENSSL_INCDIR_OPT)
 2409: 
 2410: ifelse([$2],[],:,[$2])
 2411: ifelse([$3],[],,[else $3])
 2412:   fi
 2413: ])
 2414: 
 2415: dnl 
 2416: dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
 2417: dnl
 2418: dnl Common setup macro for iconv
 2419: dnl
 2420: AC_DEFUN([PHP_SETUP_ICONV], [
 2421:   found_iconv=no
 2422:   unset ICONV_DIR
 2423: 
 2424:   # Create the directories for a VPATH build:
 2425:   $php_shtool mkdir -p ext/iconv
 2426: 
 2427:   echo > ext/iconv/php_have_bsd_iconv.h
 2428:   echo > ext/iconv/php_have_ibm_iconv.h
 2429:   echo > ext/iconv/php_have_glibc_iconv.h
 2430:   echo > ext/iconv/php_have_libiconv.h
 2431:   echo > ext/iconv/php_have_iconv.h
 2432:   echo > ext/iconv/php_php_iconv_impl.h
 2433:   echo > ext/iconv/php_iconv_aliased_libiconv.h
 2434:   echo > ext/iconv/php_php_iconv_h_path.h
 2435:   echo > ext/iconv/php_iconv_supports_errno.h
 2436: 
 2437:   dnl
 2438:   dnl Check libc first if no path is provided in --with-iconv
 2439:   dnl
 2440:   if test "$PHP_ICONV" = "yes"; then
 2441:     AC_CHECK_FUNC(iconv, [
 2442:       found_iconv=yes
 2443:     ],[
 2444:       AC_CHECK_FUNC(libiconv,[
 2445:         PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
 2446:         AC_DEFINE(HAVE_LIBICONV, 1, [ ])
 2447:         found_iconv=yes
 2448:       ])
 2449:     ])
 2450:   fi
 2451: 
 2452:   dnl
 2453:   dnl Check external libs for iconv funcs
 2454:   dnl
 2455:   if test "$found_iconv" = "no"; then
 2456: 
 2457:     for i in $PHP_ICONV /usr/local /usr; do
 2458:       if test -r $i/include/giconv.h; then
 2459:         AC_DEFINE(HAVE_GICONV_H, 1, [ ])
 2460:         ICONV_DIR=$i
 2461:         iconv_lib_name=giconv
 2462:         break
 2463:       elif test -r $i/include/iconv.h; then
 2464:         ICONV_DIR=$i
 2465:         iconv_lib_name=iconv
 2466:         break
 2467:       fi
 2468:     done
 2469: 
 2470:     if test -z "$ICONV_DIR"; then
 2471:       AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
 2472:     fi
 2473:   
 2474:     if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
 2475:        test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
 2476:     then
 2477:       PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
 2478:         found_iconv=yes
 2479:         PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
 2480:         AC_DEFINE(HAVE_LIBICONV,1,[ ])
 2481:         PHP_DEFINE([ICONV_ALIASED_LIBICONV],1,[ext/iconv])
 2482:         AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv])
 2483:       ], [
 2484:         PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
 2485:           found_iconv=yes
 2486:         ], [], [
 2487:           -L$ICONV_DIR/$PHP_LIBDIR
 2488:         ])
 2489:       ], [
 2490:         -L$ICONV_DIR/$PHP_LIBDIR
 2491:       ])
 2492:     fi
 2493:   fi
 2494: 
 2495:   if test "$found_iconv" = "yes"; then
 2496:     PHP_DEFINE(HAVE_ICONV,1,[ext/iconv])
 2497:     AC_DEFINE(HAVE_ICONV,1,[ ])
 2498:     if test -n "$ICONV_DIR"; then
 2499:       PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1)
 2500:       PHP_ADD_INCLUDE($ICONV_DIR/include)
 2501:     fi
 2502:     $2
 2503: ifelse([$3],[],,[else $3])
 2504:   fi
 2505: ])
 2506: 
 2507: dnl 
 2508: dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]])
 2509: dnl
 2510: dnl Common setup macro for libxml
 2511: dnl
 2512: AC_DEFUN([PHP_SETUP_LIBXML], [
 2513: AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
 2514: [
 2515:   for i in $PHP_LIBXML_DIR /usr/local /usr; do
 2516:     if test -x "$i/bin/xml2-config"; then
 2517:       ac_cv_php_xml2_config_path="$i/bin/xml2-config"
 2518:       break
 2519:     fi
 2520:   done
 2521: ])
 2522: 
 2523:   if test -x "$ac_cv_php_xml2_config_path"; then
 2524:     XML2_CONFIG="$ac_cv_php_xml2_config_path"
 2525:     libxml_full_version=`$XML2_CONFIG --version`
 2526:     ac_IFS=$IFS
 2527:     IFS="."
 2528:     set $libxml_full_version
 2529:     IFS=$ac_IFS
 2530:     LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
 2531:     if test "$LIBXML_VERSION" -ge "2006011"; then
 2532:       LIBXML_LIBS=`$XML2_CONFIG --libs`
 2533:       LIBXML_INCS=`$XML2_CONFIG --cflags`
 2534:       PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
 2535:       PHP_EVAL_INCLINE($LIBXML_INCS)
 2536: 
 2537:       dnl Check that build works with given libs
 2538:       AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
 2539:         PHP_TEST_BUILD(xmlInitParser,
 2540:         [
 2541:           php_cv_libxml_build_works=yes
 2542:         ], [
 2543:           AC_MSG_RESULT(no)
 2544:           AC_MSG_ERROR([build test failed.  Please check the config.log for details.])
 2545:         ], [
 2546:           [$]$1
 2547:         ])
 2548:       ])
 2549:       if test "$php_cv_libxml_build_works" = "yes"; then
 2550:         AC_DEFINE(HAVE_LIBXML, 1, [ ])
 2551:       fi
 2552:       $2
 2553:     else
 2554:       AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
 2555:     fi
 2556: ifelse([$3],[],,[else $3])
 2557:   fi
 2558: ])
 2559: 
 2560: dnl -------------------------------------------------------------------------
 2561: dnl Misc. macros
 2562: dnl -------------------------------------------------------------------------
 2563: 
 2564: dnl 
 2565: dnl PHP_INSTALL_HEADERS(path [, file ...])
 2566: dnl
 2567: dnl PHP header files to be installed
 2568: dnl
 2569: AC_DEFUN([PHP_INSTALL_HEADERS],[
 2570:   ifelse([$2],[],[
 2571:     for header_file in $1; do
 2572:       PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [
 2573:         INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
 2574:       ])
 2575:     done 
 2576:   ], [
 2577:     header_path=$1
 2578:     for header_file in $2; do
 2579:       hp_hf="$header_path/$header_file"
 2580:       PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [
 2581:         INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf"
 2582:       ])
 2583:     done 
 2584:   ])
 2585: ])
 2586: 
 2587: dnl
 2588: dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
 2589: dnl
 2590: dnl This macro is used to get a comparable
 2591: dnl version for apache1/2.
 2592: dnl
 2593: AC_DEFUN([PHP_AP_EXTRACT_VERSION],[
 2594:   ac_output=`$1 -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'`
 2595:   ac_IFS=$IFS
 2596: IFS="- /.
 2597: "
 2598:   set $ac_output
 2599:   IFS=$ac_IFS
 2600: 
 2601:   APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
 2602: ])
 2603: 
 2604: dnl
 2605: dnl PHP_DEBUG_MACRO(filename)
 2606: dnl 
 2607: AC_DEFUN([PHP_DEBUG_MACRO],[
 2608:   DEBUG_LOG=$1
 2609:   cat >$1 <<X
 2610: CONFIGURE:  $CONFIGURE_COMMAND
 2611: CC:         $CC
 2612: CFLAGS:     $CFLAGS
 2613: CPPFLAGS:   $CPPFLAGS
 2614: CXX:        $CXX
 2615: CXXFLAGS:   $CXXFLAGS
 2616: INCLUDES:   $INCLUDES
 2617: LDFLAGS:    $LDFLAGS
 2618: LIBS:       $LIBS
 2619: DLIBS:      $DLIBS
 2620: SAPI:       $PHP_SAPI
 2621: PHP_RPATHS: $PHP_RPATHS
 2622: uname -a:   `uname -a`
 2623: 
 2624: X
 2625:     cat >conftest.$ac_ext <<X
 2626: main()
 2627: {
 2628:   exit(0);
 2629: }
 2630: X
 2631:     (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
 2632:     rm -fr conftest*
 2633: ])
 2634: 
 2635: dnl
 2636: dnl PHP_CONFIG_NICE(filename)
 2637: dnl
 2638: dnl Generates the config.nice file
 2639: dnl
 2640: AC_DEFUN([PHP_CONFIG_NICE],[
 2641:   AC_REQUIRE([AC_PROG_EGREP])
 2642:   AC_REQUIRE([LT_AC_PROG_SED])
 2643:   PHP_SUBST_OLD(EGREP)
 2644:   PHP_SUBST_OLD(SED)
 2645:   test -f $1 && mv $1 $1.old
 2646:   rm -f $1.old
 2647:   cat >$1<<EOF
 2648: #! /bin/sh
 2649: #
 2650: # Created by configure
 2651: 
 2652: EOF
 2653: 
 2654:   for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do
 2655:     eval val=\$$var
 2656:     if test -n "$val"; then
 2657:       echo "$var='$val' \\" >> $1
 2658:     fi
 2659:   done
 2660: 
 2661:   echo "'[$]0' \\" >> $1
 2662:   if test `expr -- [$]0 : "'.*"` = 0; then
 2663:     CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'"
 2664:   else 
 2665:     CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0"
 2666:   fi
 2667:   for arg in $ac_configure_args; do
 2668:     if test `expr -- $arg : "'.*"` = 0; then
 2669:       if test `expr -- $arg : "--.*"` = 0; then
 2670:         break;
 2671:       fi
 2672:       echo "'[$]arg' \\" >> $1
 2673:       CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS '[$]arg'"
 2674:     else
 2675:       if test `expr -- $arg : "'--.*"` = 0; then
 2676:         break;
 2677:       fi
 2678:       echo "[$]arg \\" >> $1
 2679:       CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS [$]arg"
 2680:     fi
 2681:   done
 2682:   echo '"[$]@"' >> $1
 2683:   chmod +x $1
 2684:   CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS"
 2685:   PHP_SUBST_OLD(CONFIGURE_COMMAND)
 2686:   PHP_SUBST_OLD(CONFIGURE_OPTIONS)
 2687: ])
 2688: 
 2689: dnl
 2690: dnl PHP_CHECK_CONFIGURE_OPTIONS
 2691: dnl
 2692: AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
 2693:   for arg in $ac_configure_args; do
 2694:     case $arg in
 2695:       --with-*[)]
 2696:         arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
 2697:         ;;
 2698:       --without-*[)]
 2699:         arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
 2700:         ;;
 2701:       --enable-*[)]
 2702:         arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
 2703:         ;;
 2704:       --disable-*[)]
 2705:         arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
 2706:         ;;
 2707:       *[)]
 2708:         continue
 2709:         ;;
 2710:     esac
 2711:     case $arg_name in
 2712:       # Allow --disable-all / --enable-all
 2713:       enable-all[)];;
 2714: 
 2715:       # Allow certain libtool options
 2716:       enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];;
 2717: 
 2718:       # Allow certain TSRM options
 2719:       with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads[)];;
 2720: 
 2721:       # Allow certain Zend options
 2722:       with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];;
 2723: 
 2724:       # All the rest must be set using the PHP_ARG_* macros
 2725:       # PHP_ARG_* macros set php_enable_<arg_name> or php_with_<arg_name>
 2726:       *[)]
 2727:         # Options that exist before PHP 6
 2728:         if test "$PHP_MAJOR_VERSION" -lt "6"; then
 2729:           case $arg_name in
 2730:             enable-zend-multibyte[)] continue;;
 2731:           esac 
 2732:         fi
 2733: 
 2734:         is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'`
 2735:         if eval test "x\$$is_arg_set" = "x"; then
 2736:           PHP_UNKNOWN_CONFIGURE_OPTIONS="$PHP_UNKNOWN_CONFIGURE_OPTIONS
 2737: [$]arg"
 2738:         fi
 2739:         ;;
 2740:     esac
 2741:   done
 2742: ])
 2743: 
 2744: dnl
 2745: dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]])
 2746: dnl
 2747: AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[
 2748:   AC_CACHE_CHECK([for PDO includes], pdo_cv_inc_path, [
 2749:     AC_MSG_CHECKING([for PDO includes])
 2750:     if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
 2751:       pdo_cv_inc_path=$abs_srcdir/ext
 2752:     elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
 2753:       pdo_cv_inc_path=$abs_srcdir/ext
 2754:     elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
 2755:       pdo_cv_inc_path=$prefix/include/php/ext
 2756:     fi
 2757:   ])
 2758:   if test -n "$pdo_cv_inc_path"; then
 2759: ifelse([$1],[],:,[$1])
 2760:   else
 2761: ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2])
 2762:   fi
 2763: ])
 2764: 
 2765: dnl
 2766: dnl PHP_DETECT_ICC
 2767: dnl Detect Intel C++ Compiler and unset $GCC if ICC found
 2768: AC_DEFUN([PHP_DETECT_ICC],
 2769: [
 2770:   ICC="no"
 2771:   AC_MSG_CHECKING([for icc])
 2772:   AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
 2773:     ICC="no"
 2774:     AC_MSG_RESULT([no]),
 2775:     ICC="yes"
 2776:     GCC="no"
 2777:     AC_MSG_RESULT([yes])
 2778:   )
 2779: ])
 2780: 
 2781: dnl PHP_DETECT_SUNCC
 2782: dnl Detect if the systems default compiler is suncc.
 2783: dnl We also set some usefull CFLAGS if the user didn't set any
 2784: AC_DEFUN([PHP_DETECT_SUNCC],[
 2785:   SUNCC="no"
 2786:   AC_MSG_CHECKING([for suncc])
 2787:   AC_EGREP_CPP([^__SUNPRO_C], [__SUNPRO_C],
 2788:     SUNCC="no"
 2789:     AC_MSG_RESULT([no]),
 2790:     SUNCC="yes"
 2791:     GCC="no"
 2792:     test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload"
 2793:     GCC=""
 2794:     AC_MSG_RESULT([yes])
 2795:   )
 2796: ])
 2797: 
 2798: dnl
 2799: dnl PHP_CRYPT_R_STYLE
 2800: dnl detect the style of crypt_r() is any is available
 2801: dnl see APR_CHECK_CRYPT_R_STYLE() for original version
 2802: dnl
 2803: AC_DEFUN([PHP_CRYPT_R_STYLE],
 2804: [
 2805:   AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[
 2806:     php_cv_crypt_r_style=none
 2807:     AC_TRY_COMPILE([
 2808: #define _REENTRANT 1
 2809: #include <crypt.h>
 2810: ],[
 2811: CRYPTD buffer;
 2812: crypt_r("passwd", "hash", &buffer);
 2813: ], 
 2814: php_cv_crypt_r_style=cryptd)
 2815: 
 2816:     if test "$php_cv_crypt_r_style" = "none"; then
 2817:       AC_TRY_COMPILE([
 2818: #define _REENTRANT 1
 2819: #include <crypt.h>
 2820: ],[
 2821: struct crypt_data buffer;
 2822: crypt_r("passwd", "hash", &buffer);
 2823: ], 
 2824: php_cv_crypt_r_style=struct_crypt_data)
 2825:     fi
 2826: 
 2827:     if test "$php_cv_crypt_r_style" = "none"; then
 2828:       AC_TRY_COMPILE([
 2829: #define _REENTRANT 1
 2830: #define _GNU_SOURCE
 2831: #include <crypt.h>
 2832: ],[
 2833: struct crypt_data buffer;
 2834: crypt_r("passwd", "hash", &buffer);
 2835: ], 
 2836: php_cv_crypt_r_style=struct_crypt_data_gnu_source)
 2837:     fi
 2838:     ])
 2839: 
 2840:   if test "$php_cv_crypt_r_style" = "cryptd"; then
 2841:     AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
 2842:   fi
 2843:   if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
 2844:     AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
 2845:   fi
 2846:   if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
 2847:     AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE])
 2848:   fi
 2849:   if test "$php_cv_crypt_r_style" = "none"; then
 2850:     AC_MSG_ERROR([Unable to detect data struct used by crypt_r])
 2851:   fi
 2852: ])
 2853: 
 2854: dnl
 2855: dnl PHP_TEST_WRITE_STDOUT
 2856: dnl
 2857: AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
 2858:   AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
 2859:     AC_TRY_RUN([
 2860: #ifdef HAVE_UNISTD_H
 2861: #include <unistd.h>
 2862: #endif
 2863: 
 2864: #define TEXT "This is the test message -- "
 2865: 
 2866: main()
 2867: {
 2868:   int n;
 2869: 
 2870:   n = write(1, TEXT, sizeof(TEXT)-1);
 2871:   return (!(n == sizeof(TEXT)-1));
 2872: }
 2873:     ],[
 2874:       ac_cv_write_stdout=yes
 2875:     ],[
 2876:       ac_cv_write_stdout=no
 2877:     ],[
 2878:       ac_cv_write_stdout=no
 2879:     ])
 2880:   ])
 2881:   if test "$ac_cv_write_stdout" = "yes"; then
 2882:     AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])
 2883:   fi
 2884: ])
 2885: 
 2886: dnl
 2887: dnl PHP_INIT_DTRACE(providerdesc, header-file, sources [, module])
 2888: dnl
 2889: AC_DEFUN([PHP_INIT_DTRACE],[
 2890: dnl Set paths properly when called from extension
 2891:   case "$4" in
 2892:     ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir;;
 2893:     /*[)] ac_srcdir=`echo "$4"|cut -c 2-`"/"; ac_bdir=$ac_srcdir;;
 2894:     *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$4/";;
 2895:   esac
 2896: 
 2897: dnl providerdesc
 2898:   ac_provsrc=$1
 2899:   old_IFS=[$]IFS
 2900:   IFS=.
 2901:   set $ac_provsrc
 2902:   ac_provobj=[$]1
 2903:   IFS=$old_IFS
 2904: 
 2905: dnl header-file
 2906:   ac_hdrobj=$2
 2907: 
 2908: dnl Add providerdesc.o into global objects when needed
 2909:   case $host_alias in
 2910:   *freebsd*)
 2911:     PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.o"
 2912:     PHP_LDFLAGS="$PHP_LDFLAGS -lelf"
 2913:     ;;
 2914:   *solaris*)
 2915:     PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS [$]ac_bdir[$]ac_provsrc.o"
 2916:     ;;
 2917:   esac
 2918: 
 2919: dnl DTrace objects
 2920:   old_IFS=[$]IFS
 2921:   for ac_src in $3; do
 2922:     IFS=.
 2923:     set $ac_src
 2924:     ac_obj=[$]1
 2925:     IFS=$old_IFS
 2926: 
 2927:     PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo"
 2928:   done;
 2929: 
 2930:   case [$]php_sapi_module in
 2931:   shared[)]
 2932:     for ac_lo in $PHP_DTRACE_OBJS; do
 2933:       dtrace_objs="[$]dtrace_objs `echo $ac_lo | $SED -e 's,\.lo$,.o,' -e 's#\(.*\)\/#\1\/.libs\/#'`"
 2934:     done;
 2935:     ;;
 2936:   *[)]
 2937:     dtrace_objs='$(PHP_DTRACE_OBJS:.lo=.o)'
 2938:     ;;
 2939:   esac
 2940: 
 2941: dnl Generate Makefile.objects entries
 2942:   cat>>Makefile.objects<<EOF
 2943: 
 2944: $ac_bdir[$]ac_hdrobj: $abs_srcdir/$ac_provsrc
 2945: 	dtrace -h -C -s $ac_srcdir[$]ac_provsrc -o \$[]@ && \$(SED) -ibak 's,PHP_,DTRACE_,g' \$[]@
 2946: 
 2947: \$(PHP_DTRACE_OBJS): $ac_bdir[$]ac_hdrobj
 2948: 
 2949: $ac_bdir[$]ac_provsrc.o: \$(PHP_DTRACE_OBJS)
 2950: 	dtrace -G -o \$[]@ -s $abs_srcdir/$ac_provsrc $dtrace_objs
 2951: 
 2952: EOF
 2953: ])

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>