xref: /PHP-5.5/acinclude.m4 (revision 3f42f2f5)
12a6da0f2Sfoobardnl
2257de2baSStig Bakkendnl $Id$
3257de2baSStig Bakkendnl
4257de2baSStig Bakkendnl This file contains local autoconf functions.
52a6da0f2Sfoobardnl
62a6da0f2Sfoobar
72a6da0f2Sfoobardnl -------------------------------------------------------------------------
82a6da0f2Sfoobardnl Output stylize macros for configure (help/runtime)
92a6da0f2Sfoobardnl -------------------------------------------------------------------------
10a2d42419SSascha Schumann
119d9d39a0SSascha Schumanndnl
122a6da0f2Sfoobardnl PHP_HELP_SEPARATOR(title)
139d9d39a0SSascha Schumanndnl
142a6da0f2Sfoobardnl Adds separator title into the configure --help display.
152a6da0f2Sfoobardnl
162a6da0f2SfoobarAC_DEFUN([PHP_HELP_SEPARATOR],[
172a6da0f2SfoobarAC_ARG_ENABLE([],[
182a6da0f2Sfoobar$1
192a6da0f2Sfoobar],[])
209d9d39a0SSascha Schumann])
219d9d39a0SSascha Schumann
222a6da0f2Sfoobardnl
232a6da0f2Sfoobardnl PHP_CONFIGURE_PART(title)
242a6da0f2Sfoobardnl
252a6da0f2Sfoobardnl Adds separator title configure output (idea borrowed from mm)
262a6da0f2Sfoobardnl
272a6da0f2SfoobarAC_DEFUN([PHP_CONFIGURE_PART],[
282a6da0f2Sfoobar  AC_MSG_RESULT()
292a6da0f2Sfoobar  AC_MSG_RESULT([${T_MD}$1${T_ME}])
302a6da0f2Sfoobar])
312a6da0f2Sfoobar
322a6da0f2Sfoobardnl -------------------------------------------------------------------------
332a6da0f2Sfoobardnl Build system helper macros
342a6da0f2Sfoobardnl -------------------------------------------------------------------------
352a6da0f2Sfoobar
362a6da0f2Sfoobardnl
372a6da0f2Sfoobardnl PHP_DEF_HAVE(what)
382a6da0f2Sfoobardnl
392a6da0f2Sfoobardnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'
402a6da0f2Sfoobardnl
418d91c1a4SfoobarAC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])])
422a6da0f2Sfoobar
432a6da0f2Sfoobardnl
442a6da0f2Sfoobardnl PHP_RUN_ONCE(namespace, variable, code)
452a6da0f2Sfoobardnl
462a6da0f2Sfoobardnl execute code, if variable is not set in namespace
472a6da0f2Sfoobardnl
482a6da0f2SfoobarAC_DEFUN([PHP_RUN_ONCE],[
492a6da0f2Sfoobar  changequote({,})
509ef2ea19Sfoobar  unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'`
512a6da0f2Sfoobar  changequote([,])
522a6da0f2Sfoobar  cmd="echo $ac_n \"\$$1$unique$ac_c\""
532a6da0f2Sfoobar  if test -n "$unique" && test "`eval $cmd`" = "" ; then
542a6da0f2Sfoobar    eval "$1$unique=set"
552a6da0f2Sfoobar    $3
562a6da0f2Sfoobar  fi
577382178fSSascha Schumann])
587382178fSSascha Schumann
592a6da0f2Sfoobardnl
602a6da0f2Sfoobardnl PHP_EXPAND_PATH(path, variable)
612a6da0f2Sfoobardnl
622a6da0f2Sfoobardnl expands path to an absolute path and assigns it to variable
632a6da0f2Sfoobardnl
642a6da0f2SfoobarAC_DEFUN([PHP_EXPAND_PATH],[
652a6da0f2Sfoobar  if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
662a6da0f2Sfoobar    $2=$1
672a6da0f2Sfoobar  else
682a6da0f2Sfoobar    changequote({,})
692531307bSAdam Harvey    ep_dir=`echo $1|$SED 's%/*[^/][^/]*/*$%%'`
702a6da0f2Sfoobar    changequote([,])
712531307bSAdam Harvey    ep_realdir=`(cd "$ep_dir" && pwd)`
722531307bSAdam Harvey    $2="$ep_realdir"/`basename "$1"`
732a6da0f2Sfoobar  fi
742a6da0f2Sfoobar])
759d9d39a0SSascha Schumann
762a6da0f2Sfoobardnl
772a6da0f2Sfoobardnl PHP_DEFINE(WHAT [, value[, directory]])
789d9d39a0SSascha Schumanndnl
79350de12bSSascha Schumanndnl Creates builddir/include/what.h and in there #define WHAT value
809d9d39a0SSascha Schumanndnl
81938ba73bSSascha SchumannAC_DEFUN([PHP_DEFINE],[
8248b11896SDerick Rethans  [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > ]ifelse([$3],,[include],[$3])[/php_]translit($1,A-Z,a-z)[.h]
839d9d39a0SSascha Schumann])
849d9d39a0SSascha Schumann
852a6da0f2Sfoobardnl
862a6da0f2Sfoobardnl PHP_SUBST(varname)
872a6da0f2Sfoobardnl
882a6da0f2Sfoobardnl Adds variable with it's value into Makefile, e.g.:
892a6da0f2Sfoobardnl CC = gcc
902a6da0f2Sfoobardnl
912a6da0f2SfoobarAC_DEFUN([PHP_SUBST],[
922a6da0f2Sfoobar  PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
932a6da0f2Sfoobar])
942a6da0f2Sfoobar
952a6da0f2Sfoobardnl
962a6da0f2Sfoobardnl PHP_SUBST_OLD(varname)
972a6da0f2Sfoobardnl
982a6da0f2Sfoobardnl Same as PHP_SUBST() but also substitutes all @VARNAME@
992a6da0f2Sfoobardnl instances in every file passed to AC_OUTPUT()
1002a6da0f2Sfoobardnl
1012a6da0f2SfoobarAC_DEFUN([PHP_SUBST_OLD],[
1022a6da0f2Sfoobar  PHP_SUBST($1)
1032a6da0f2Sfoobar  AC_SUBST($1)
1042a6da0f2Sfoobar])
1052a6da0f2Sfoobar
1062a6da0f2Sfoobardnl
1072a6da0f2Sfoobardnl PHP_OUTPUT(file)
1082a6da0f2Sfoobardnl
1092a6da0f2Sfoobardnl Adds "file" to the list of files generated by AC_OUTPUT
1102a6da0f2Sfoobardnl This macro can be used several times.
1112a6da0f2Sfoobardnl
1122a6da0f2SfoobarAC_DEFUN([PHP_OUTPUT],[
1132a6da0f2Sfoobar  PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
1142a6da0f2Sfoobar])
1152a6da0f2Sfoobar
1162a6da0f2Sfoobar
1172a6da0f2Sfoobardnl -------------------------------------------------------------------------
1182a6da0f2Sfoobardnl Build system base macros
1192a6da0f2Sfoobardnl -------------------------------------------------------------------------
1202a6da0f2Sfoobar
1212a6da0f2Sfoobardnl
1227a3d9addSfoobardnl PHP_CANONICAL_HOST_TARGET
1237a3d9addSfoobardnl
1247a3d9addSfoobarAC_DEFUN([PHP_CANONICAL_HOST_TARGET],[
1257a3d9addSfoobar  AC_REQUIRE([AC_CANONICAL_HOST])dnl
1267a3d9addSfoobar  AC_REQUIRE([AC_CANONICAL_TARGET])dnl
1277a3d9addSfoobar  dnl Make sure we do not continue if host_alias is empty.
1287a3d9addSfoobar  if test -z "$host_alias" && test -n "$host"; then
1297a3d9addSfoobar    host_alias=$host
1307a3d9addSfoobar  fi
1317a3d9addSfoobar  if test -z "$host_alias"; then
1327a3d9addSfoobar    AC_MSG_ERROR([host_alias is not set!])
1337a3d9addSfoobar  fi
1347a3d9addSfoobar])
1357a3d9addSfoobar
1362a6da0f2Sfoobardnl
1379d9d39a0SSascha Schumanndnl PHP_INIT_BUILD_SYSTEM
1389d9d39a0SSascha Schumanndnl
139938ba73bSSascha SchumannAC_DEFUN([PHP_INIT_BUILD_SYSTEM],[
1407a3d9addSfoobarAC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
14162625394Sfoobartest -d include || $php_shtool mkdir include
1429d9d39a0SSascha Schumann> Makefile.objects
1439d9d39a0SSascha Schumann> Makefile.fragments
14404e564deSSascha Schumanndnl We need to play tricks here to avoid matching the grep line itself
145350de12bSSascha Schumannpattern=define
1469ef2ea19Sfoobar$EGREP $pattern'.*include/php' $srcdir/configure|$SED 's/.*>//'|xargs touch 2>/dev/null
1479d9d39a0SSascha Schumann])
1489d9d39a0SSascha Schumann
1492a6da0f2Sfoobardnl
1509d9d39a0SSascha Schumanndnl PHP_GEN_GLOBAL_MAKEFILE
1519d9d39a0SSascha Schumanndnl
1529d9d39a0SSascha Schumanndnl Generates the global makefile.
1539d9d39a0SSascha Schumanndnl
154938ba73bSSascha SchumannAC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[
1559d9d39a0SSascha Schumann  cat >Makefile <<EOF
1569d9d39a0SSascha Schumannsrcdir = $abs_srcdir
1579d9d39a0SSascha Schumannbuilddir = $abs_builddir
1589d9d39a0SSascha Schumanntop_srcdir = $abs_srcdir
1599d9d39a0SSascha Schumanntop_builddir = $abs_builddir
1609d9d39a0SSascha SchumannEOF
1619d9d39a0SSascha Schumann  for i in $PHP_VAR_SUBST; do
1629d9d39a0SSascha Schumann    eval echo "$i = \$$i" >> Makefile
1639d9d39a0SSascha Schumann  done
1649d9d39a0SSascha Schumann
1659d9d39a0SSascha Schumann  cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile
1669d9d39a0SSascha Schumann])
1679d9d39a0SSascha Schumann
1682a6da0f2Sfoobardnl
1692a6da0f2Sfoobardnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile [, ext_srcdir [, ext_builddir]]])
1702a6da0f2Sfoobardnl
1712a6da0f2Sfoobardnl Processes a file called Makefile.frag in the source directory
1722a6da0f2Sfoobardnl of the most recently added extension. $(srcdir) and $(builddir)
1732a6da0f2Sfoobardnl are substituted with the proper paths. Can be used to supply
1742a6da0f2Sfoobardnl custom rules and/or additional targets.
1752a6da0f2Sfoobardnl
1762a6da0f2SfoobarAC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[
1772a6da0f2Sfoobar  ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1)
1782a6da0f2Sfoobar  ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2)
1792a6da0f2Sfoobar  ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3)
180f5d9f9cdSfoobar  test -f "$src" && $SED -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src  >> Makefile.fragments
1812a6da0f2Sfoobar])
1822a6da0f2Sfoobar
1832a6da0f2Sfoobardnl
1842a6da0f2Sfoobardnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
1859d9d39a0SSascha Schumanndnl
1869d9d39a0SSascha Schumanndnl Adds sources which are located relative to source-path to the
1879d9d39a0SSascha Schumanndnl array of type type.  Sources are processed with optional
1889d9d39a0SSascha Schumanndnl special-flags which are passed to the compiler.  Sources
1899d9d39a0SSascha Schumanndnl can be either written in C or C++ (filenames shall end in .c
1909d9d39a0SSascha Schumanndnl or .cpp, respectively).
1919d9d39a0SSascha Schumanndnl
1929d9d39a0SSascha Schumanndnl Note: If source-path begins with a "/", the "/" is removed and
1939d9d39a0SSascha Schumanndnl the path is interpreted relative to the top build-directory.
1949d9d39a0SSascha Schumanndnl
1959d9d39a0SSascha Schumanndnl which array to append to?
196938ba73bSSascha SchumannAC_DEFUN([PHP_ADD_SOURCES],[
19725aee9caSJani Taskinen  PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS))
1989d9d39a0SSascha Schumann])
1992a6da0f2Sfoobar
200c7403326SSascha Schumanndnl
201938ba73bSSascha Schumanndnl _PHP_ASSIGN_BUILD_VARS(type)
202c7403326SSascha Schumanndnl internal, don't use
203938ba73bSSascha SchumannAC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[
204350de12bSSascha Schumannifelse($1,shared,[
205350de12bSSascha Schumann  b_c_pre=$shared_c_pre
206350de12bSSascha Schumann  b_cxx_pre=$shared_cxx_pre
207350de12bSSascha Schumann  b_c_meta=$shared_c_meta
208350de12bSSascha Schumann  b_cxx_meta=$shared_cxx_meta
209350de12bSSascha Schumann  b_c_post=$shared_c_post
210350de12bSSascha Schumann  b_cxx_post=$shared_cxx_post
211350de12bSSascha Schumann],[
212350de12bSSascha Schumann  b_c_pre=$php_c_pre
213350de12bSSascha Schumann  b_cxx_pre=$php_cxx_pre
214350de12bSSascha Schumann  b_c_meta=$php_c_meta
215350de12bSSascha Schumann  b_cxx_meta=$php_cxx_meta
216350de12bSSascha Schumann  b_c_post=$php_c_post
217350de12bSSascha Schumann  b_cxx_post=$php_cxx_post
218350de12bSSascha Schumann])dnl
2199d9d39a0SSascha Schumann  b_lo=[$]$1_lo
2209d9d39a0SSascha Schumann])
2219d9d39a0SSascha Schumann
2222a6da0f2Sfoobardnl
2239d9d39a0SSascha Schumanndnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
2249d9d39a0SSascha Schumanndnl
2259d9d39a0SSascha Schumanndnl Additional to PHP_ADD_SOURCES (see above), this lets you set the
2269d9d39a0SSascha Schumanndnl name of the array target-var directly, as well as whether
2272a6da0f2Sfoobardnl shared objects will be built from the sources.
2282a6da0f2Sfoobardnl
2292a6da0f2Sfoobardnl Should not be used directly.
2309d9d39a0SSascha Schumanndnl
231938ba73bSSascha SchumannAC_DEFUN([PHP_ADD_SOURCES_X],[
2329d9d39a0SSascha Schumanndnl relative to source- or build-directory?
2338fae36cbSSascha Schumanndnl ac_srcdir/ac_bdir include trailing slash
2349d9d39a0SSascha Schumann  case $1 in
235c174a15aSAndrei Zmievski  ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;;
236e3e0dbf7SSascha Schumann  /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;;
2378fae36cbSSascha Schumann  *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;;
2389d9d39a0SSascha Schumann  esac
2399d9d39a0SSascha Schumann
2409d9d39a0SSascha Schumanndnl how to build .. shared or static?
241938ba73bSSascha Schumann  ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php))
2429d9d39a0SSascha Schumann
2439d9d39a0SSascha Schumanndnl iterate over the sources
244f02d3f45SSascha Schumann  old_IFS=[$]IFS
2459d9d39a0SSascha Schumann  for ac_src in $2; do
2469d9d39a0SSascha Schumann
2479d9d39a0SSascha Schumanndnl remove the suffix
2489d9d39a0SSascha Schumann      IFS=.
2499d9d39a0SSascha Schumann      set $ac_src
2509d9d39a0SSascha Schumann      ac_obj=[$]1
2519d9d39a0SSascha Schumann      IFS=$old_IFS
2529d9d39a0SSascha Schumann
2538fae36cbSSascha Schumanndnl append to the array which has been dynamically chosen at m4 time
2548fae36cbSSascha Schumann      $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
2559d9d39a0SSascha Schumann
2569d9d39a0SSascha Schumanndnl choose the right compiler/flags/etc. for the source-file
2579d9d39a0SSascha Schumann      case $ac_src in
25809f01611Sfoobar        *.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" ;;
25909f01611Sfoobar        *.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" ;;
26009f01611Sfoobar        *.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" ;;
26109f01611Sfoobar        *.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" ;;
2629d9d39a0SSascha Schumann      esac
2639d9d39a0SSascha Schumann
2649d9d39a0SSascha Schumanndnl create a rule for the object/source combo
26509f01611Sfoobar    cat >>Makefile.objects<<EOF
2668fae36cbSSascha Schumann$ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src
2679d9d39a0SSascha Schumann	$ac_comp
2689d9d39a0SSascha SchumannEOF
2699d9d39a0SSascha Schumann  done
2709d9d39a0SSascha Schumann])
271a481fddfSSascha Schumann
2722a6da0f2Sfoobardnl -------------------------------------------------------------------------
2732a6da0f2Sfoobardnl Compiler characteristics checks
2742a6da0f2Sfoobardnl -------------------------------------------------------------------------
2758a8741a1Sfoobar
276e843e8c5SSascha Schumanndnl
277e843e8c5SSascha Schumanndnl PHP_TARGET_RDYNAMIC
278e843e8c5SSascha Schumanndnl
279e843e8c5SSascha Schumanndnl Checks whether -rdynamic is supported by the compiler.  This
280e843e8c5SSascha Schumanndnl is necessary for some targets to populate the global symbol
281e843e8c5SSascha Schumanndnl table.  Otherwise, dynamic modules would not be able to resolve
282e843e8c5SSascha Schumanndnl PHP-related symbols.
283e843e8c5SSascha Schumanndnl
284e843e8c5SSascha Schumanndnl If successful, adds -rdynamic to PHP_LDFLAGS.
285e843e8c5SSascha Schumanndnl
286938ba73bSSascha SchumannAC_DEFUN([PHP_TARGET_RDYNAMIC],[
287e843e8c5SSascha Schumann  if test -n "$GCC"; then
288e843e8c5SSascha Schumann    dnl we should use a PHP-specific macro here
2892a6da0f2Sfoobar    PHP_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes)
290e843e8c5SSascha Schumann    if test "$gcc_rdynamic" = "yes"; then
291e843e8c5SSascha Schumann      PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic"
292e843e8c5SSascha Schumann    fi
293e843e8c5SSascha Schumann  fi
294e843e8c5SSascha Schumann])
295e843e8c5SSascha Schumann
2962a6da0f2Sfoobardnl
2972a6da0f2Sfoobardnl PHP_RUNPATH_SWITCH
2982a6da0f2Sfoobardnl
2992a6da0f2Sfoobardnl Checks for -R, etc. switch
3002a6da0f2Sfoobardnl
3012a6da0f2SfoobarAC_DEFUN([PHP_RUNPATH_SWITCH],[
3022a6da0f2SfoobarAC_MSG_CHECKING([if compiler supports -R])
3032a6da0f2SfoobarAC_CACHE_VAL(php_cv_cc_dashr,[
30409f01611Sfoobar  SAVE_LIBS=$LIBS
30509f01611Sfoobar  LIBS="-R /usr/$PHP_LIBDIR $LIBS"
30609f01611Sfoobar  AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
30709f01611Sfoobar  LIBS=$SAVE_LIBS])
3082a6da0f2SfoobarAC_MSG_RESULT([$php_cv_cc_dashr])
3092a6da0f2Sfoobarif test $php_cv_cc_dashr = "yes"; then
31009f01611Sfoobar  ld_runpath_switch=-R
3112a6da0f2Sfoobarelse
31209f01611Sfoobar  AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
31309f01611Sfoobar  AC_CACHE_VAL(php_cv_cc_rpath,[
31409f01611Sfoobar    SAVE_LIBS=$LIBS
31509f01611Sfoobar    LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS"
31609f01611Sfoobar    AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
31709f01611Sfoobar    LIBS=$SAVE_LIBS])
31809f01611Sfoobar  AC_MSG_RESULT([$php_cv_cc_rpath])
31909f01611Sfoobar  if test $php_cv_cc_rpath = "yes"; then
32009f01611Sfoobar    ld_runpath_switch=-Wl,-rpath,
32109f01611Sfoobar  else
32209f01611Sfoobar    dnl something innocuous
32309f01611Sfoobar    ld_runpath_switch=-L
32409f01611Sfoobar  fi
3252a6da0f2Sfoobarfi
326c6a7e4caSJani Taskinenif test "$PHP_RPATH" = "no"; then
327c6a7e4caSJani Taskinen  ld_runpath_switch=
328c6a7e4caSJani Taskinenfi
3292a6da0f2Sfoobar])
3302a6da0f2Sfoobar
3312a6da0f2Sfoobardnl
3322a6da0f2Sfoobardnl PHP_CHECK_GCC_ARG(arg, action-if-found, action-if-not-found)
3332a6da0f2Sfoobardnl
3342a6da0f2SfoobarAC_DEFUN([PHP_CHECK_GCC_ARG],[
3352a6da0f2Sfoobar  gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z-,a-z_)
3362a6da0f2Sfoobar  AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z-,a-z_), [
3372a6da0f2Sfoobar  echo 'void somefunc() { };' > conftest.c
3382a6da0f2Sfoobar  cmd='$CC $1 -c conftest.c'
3399ef2ea19Sfoobar  if eval $cmd 2>&1 | $EGREP -e $1 >/dev/null ; then
3402a6da0f2Sfoobar    ac_result=no
3412a6da0f2Sfoobar  else
3422a6da0f2Sfoobar    ac_result=yes
3432a6da0f2Sfoobar  fi
3442a6da0f2Sfoobar  eval $gcc_arg_name=$ac_result
3452a6da0f2Sfoobar  rm -f conftest.*
3462a6da0f2Sfoobar  ])
3472a6da0f2Sfoobar  if eval test "\$$gcc_arg_name" = "yes"; then
3482a6da0f2Sfoobar    $2
3492a6da0f2Sfoobar  else
3502a6da0f2Sfoobar    :
3512a6da0f2Sfoobar    $3
3522a6da0f2Sfoobar  fi
3532a6da0f2Sfoobar])
3542a6da0f2Sfoobar
3552a6da0f2Sfoobardnl
3562a6da0f2Sfoobardnl PHP_LIBGCC_LIBPATH(gcc)
3572a6da0f2Sfoobardnl
3582a6da0f2Sfoobardnl Stores the location of libgcc in libgcc_libpath
3592a6da0f2Sfoobardnl
3602a6da0f2SfoobarAC_DEFUN([PHP_LIBGCC_LIBPATH],[
3612a6da0f2Sfoobar  changequote({,})
3629ef2ea19Sfoobar  libgcc_libpath=`$1 --print-libgcc-file-name|$SED 's%/*[^/][^/]*$%%'`
3632a6da0f2Sfoobar  changequote([,])
3642a6da0f2Sfoobar])
3652a6da0f2Sfoobar
3662a6da0f2Sfoobardnl -------------------------------------------------------------------------
3672a6da0f2Sfoobardnl Macros to modify LIBS, INCLUDES, etc. variables
3682a6da0f2Sfoobardnl -------------------------------------------------------------------------
3692a6da0f2Sfoobar
3702a6da0f2Sfoobardnl
3712a6da0f2Sfoobardnl PHP_REMOVE_USR_LIB(NAME)
3722a6da0f2Sfoobardnl
3732a6da0f2Sfoobardnl Removes all -L/usr/$PHP_LIBDIR entries from variable NAME
3742a6da0f2Sfoobardnl
375938ba73bSSascha SchumannAC_DEFUN([PHP_REMOVE_USR_LIB],[
3769982ff56SSascha Schumann  unset ac_new_flags
3778f3ebfe4SSascha Schumann  for i in [$]$1; do
3788f3ebfe4SSascha Schumann    case [$]i in
379557cda47SJoe Orton    -L/usr/$PHP_LIBDIR|-L/usr/$PHP_LIBDIR/[)] ;;
380320a86b7SSascha Schumann    *[)] ac_new_flags="[$]ac_new_flags [$]i" ;;
3818f3ebfe4SSascha Schumann    esac
3828f3ebfe4SSascha Schumann  done
3838f3ebfe4SSascha Schumann  $1=[$]ac_new_flags
3848f3ebfe4SSascha Schumann])
385a79e857cSHartmut Holzgraefe
3862a6da0f2Sfoobardnl
3872a6da0f2Sfoobardnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD)
3889a63d8afSSascha Schumanndnl
3899a63d8afSSascha Schumanndnl Use this macro, if you need to add libraries and or library search
3909a63d8afSSascha Schumanndnl paths to the PHP build system which are only given in compiler
3919a63d8afSSascha Schumanndnl notation.
3929a63d8afSSascha Schumanndnl
393938ba73bSSascha SchumannAC_DEFUN([PHP_EVAL_LIBLINE],[
3949a63d8afSSascha Schumann  for ac_i in $1; do
395afdaee9eSSascha Schumann    case $ac_i in
39654d85cbfSfoobar    -pthread[)]
39754d85cbfSfoobar      if test "$ext_shared" = "yes"; then
39854d85cbfSfoobar        $2="[$]$2 -pthread"
39954d85cbfSfoobar      else
40054d85cbfSfoobar        PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"])
40154d85cbfSfoobar      fi
40254d85cbfSfoobar    ;;
403320a86b7SSascha Schumann    -l*[)]
4049a63d8afSSascha Schumann      ac_ii=`echo $ac_i|cut -c 3-`
405b9893954Sfoobar      PHP_ADD_LIBRARY($ac_ii,1,$2)
4069a63d8afSSascha Schumann    ;;
407320a86b7SSascha Schumann    -L*[)]
4089a63d8afSSascha Schumann      ac_ii=`echo $ac_i|cut -c 3-`
4098a26918eSfoobar      PHP_ADD_LIBPATH($ac_ii,$2)
4109a63d8afSSascha Schumann    ;;
4119a63d8afSSascha Schumann    esac
4129a63d8afSSascha Schumann  done
4139a63d8afSSascha Schumann])
4149a63d8afSSascha Schumann
4152a6da0f2Sfoobardnl
4162a6da0f2Sfoobardnl PHP_EVAL_INCLINE(headerline)
4179a63d8afSSascha Schumanndnl
4189a63d8afSSascha Schumanndnl Use this macro, if you need to add header search paths to the PHP
4199a63d8afSSascha Schumanndnl build system which are only given in compiler notation.
4209a63d8afSSascha Schumanndnl
421938ba73bSSascha SchumannAC_DEFUN([PHP_EVAL_INCLINE],[
4229a63d8afSSascha Schumann  for ac_i in $1; do
423afdaee9eSSascha Schumann    case $ac_i in
424320a86b7SSascha Schumann    -I*[)]
4259a63d8afSSascha Schumann      ac_ii=`echo $ac_i|cut -c 3-`
4268a26918eSfoobar      PHP_ADD_INCLUDE($ac_ii)
4279a63d8afSSascha Schumann    ;;
4289a63d8afSSascha Schumann    esac
4299a63d8afSSascha Schumann  done
4309a63d8afSSascha Schumann])
4313bf75192Sfoobar
4322a6da0f2Sfoobardnl internal, don't use
4332a6da0f2SfoobarAC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[
4342a6da0f2Sfoobar  PHP_RUN_ONCE(LIBPATH, $1, [
4352a6da0f2Sfoobar    test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1"
4362a6da0f2Sfoobar    LDFLAGS="$LDFLAGS -L$1"
4372a6da0f2Sfoobar    PHP_RPATHS="$PHP_RPATHS $1"
4382aaa538aSSascha Schumann  ])
4392a6da0f2Sfoobar])dnl
4402a6da0f2Sfoobardnl
4412a6da0f2Sfoobardnl
4422a6da0f2Sfoobardnl PHP_ADD_LIBPATH(path [, SHARED-LIBADD])
4432a6da0f2Sfoobardnl
4442a6da0f2Sfoobardnl Adds a path to linkpath/runpath (LDFLAGS)
4452a6da0f2Sfoobardnl
4462a6da0f2SfoobarAC_DEFUN([PHP_ADD_LIBPATH],[
447a0ab6b71Sfoobar  if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
4482a6da0f2Sfoobar    PHP_EXPAND_PATH($1, ai_p)
4492a6da0f2Sfoobar    ifelse([$2],,[
4502a6da0f2Sfoobar      _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
4512a6da0f2Sfoobar    ],[
4522a6da0f2Sfoobar      if test "$ext_shared" = "yes"; then
453c6a7e4caSJani Taskinen        $2="-L$ai_p [$]$2"
454c6a7e4caSJani Taskinen        test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2"
4552a6da0f2Sfoobar      else
4562a6da0f2Sfoobar        _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
4572a6da0f2Sfoobar      fi
4582a6da0f2Sfoobar    ])
4592aaa538aSSascha Schumann  fi
4602aaa538aSSascha Schumann])
4612aaa538aSSascha Schumann
4622a6da0f2Sfoobardnl
4632a6da0f2Sfoobardnl PHP_UTILIZE_RPATHS()
4642a6da0f2Sfoobardnl
4652a6da0f2Sfoobardnl builds RPATHS/LDFLAGS from PHP_RPATHS
4662a6da0f2Sfoobardnl
4672a6da0f2SfoobarAC_DEFUN([PHP_UTILIZE_RPATHS],[
4682a6da0f2Sfoobar  OLD_RPATHS=$PHP_RPATHS
4692a6da0f2Sfoobar  unset PHP_RPATHS
470f04936f8SSascha Schumann
4712a6da0f2Sfoobar  for i in $OLD_RPATHS; do
4722a6da0f2Sfoobardnl Can be passed to native cc/libtool
4732a6da0f2Sfoobar    PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
4742a6da0f2Sfoobardnl Libtool-specific
4752a6da0f2Sfoobar    PHP_RPATHS="$PHP_RPATHS -R $i"
4762a6da0f2Sfoobardnl cc-specific
4772a6da0f2Sfoobar    NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
4782a6da0f2Sfoobar  done
479db3d16dcSSascha Schumann
4802a6da0f2Sfoobar  if test "$PHP_RPATH" = "no"; then
4812a6da0f2Sfoobar    unset PHP_RPATHS
4822a6da0f2Sfoobar    unset NATIVE_RPATHS
4832a6da0f2Sfoobar  fi
484db3d16dcSSascha Schumann])
485e2eaf634SSascha Schumann
4862a6da0f2Sfoobardnl
4872a6da0f2Sfoobardnl PHP_ADD_INCLUDE(path [,before])
4882a6da0f2Sfoobardnl
4892a6da0f2Sfoobardnl add an include path.
4902a6da0f2Sfoobardnl if before is 1, add in the beginning of INCLUDES.
4912a6da0f2Sfoobardnl
4922a6da0f2SfoobarAC_DEFUN([PHP_ADD_INCLUDE],[
4932a6da0f2Sfoobar  if test "$1" != "/usr/include"; then
4942a6da0f2Sfoobar    PHP_EXPAND_PATH($1, ai_p)
4952a6da0f2Sfoobar    PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [
4962a6da0f2Sfoobar      if test "$2"; then
4972a6da0f2Sfoobar        INCLUDES="-I$ai_p $INCLUDES"
4982a6da0f2Sfoobar      else
4992a6da0f2Sfoobar        INCLUDES="$INCLUDES -I$ai_p"
5002a6da0f2Sfoobar      fi
5012a6da0f2Sfoobar    ])
5022a6da0f2Sfoobar  fi
5032a6da0f2Sfoobar])
504e1dd35bdSSascha Schumann
5052a6da0f2Sfoobardnl internal, don't use
5062a6da0f2SfoobarAC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl
5072a6da0f2Sfoobar  ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl
5082a6da0f2Sfoobar])dnl
5092a6da0f2Sfoobardnl
5102a6da0f2Sfoobardnl internal, don't use
5112a6da0f2SfoobarAC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[
5122a6da0f2Sfoobar  case $1 in
5132a6da0f2Sfoobar  c|c_r|pthread*[)] ;;
5142a6da0f2Sfoobar  *[)] ifelse($3,,[
5152a6da0f2Sfoobar    _PHP_X_ADD_LIBRARY($1,$2,$5)
516702d7afcSSascha Schumann  ],[
5172a6da0f2Sfoobar    if test "$ext_shared" = "yes"; then
5182a6da0f2Sfoobar      _PHP_X_ADD_LIBRARY($1,$2,$3)
5192a6da0f2Sfoobar    else
5202a6da0f2Sfoobar      $4($1,$2)
5212a6da0f2Sfoobar    fi
5222a6da0f2Sfoobar  ]) ;;
5232a6da0f2Sfoobar  esac
5242a6da0f2Sfoobar])dnl
5252a6da0f2Sfoobardnl
5262a6da0f2Sfoobardnl
5272a6da0f2Sfoobardnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
5282a6da0f2Sfoobardnl
5292a6da0f2Sfoobardnl add a library to the link line
5302a6da0f2Sfoobardnl
5312a6da0f2SfoobarAC_DEFUN([PHP_ADD_LIBRARY],[
5322a6da0f2Sfoobar  _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS])
533e2eaf634SSascha Schumann])
534e2eaf634SSascha Schumann
5352a6da0f2Sfoobardnl
5362a6da0f2Sfoobardnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]])
5372a6da0f2Sfoobardnl
5382a6da0f2Sfoobardnl add a library to the link line (deferred, not used during configure)
5392a6da0f2Sfoobardnl
5402a6da0f2SfoobarAC_DEFUN([PHP_ADD_LIBRARY_DEFER],[
5412a6da0f2Sfoobar  _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS])
542702d7afcSSascha Schumann])
543702d7afcSSascha Schumann
5442a6da0f2Sfoobardnl
5452a6da0f2Sfoobardnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
5462a6da0f2Sfoobardnl
5472a6da0f2Sfoobardnl add a library to the link line and path to linkpath/runpath.
5482a6da0f2Sfoobardnl if shared-libadd is not empty and $ext_shared is yes,
5492a6da0f2Sfoobardnl shared-libadd will be assigned the library information
5502a6da0f2Sfoobardnl
5512a6da0f2SfoobarAC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[
5522a6da0f2Sfoobarifelse($3,,[
5532a6da0f2Sfoobar  if test -n "$2"; then
5542a6da0f2Sfoobar    PHP_ADD_LIBPATH($2)
5552a6da0f2Sfoobar  fi
5562a6da0f2Sfoobar  PHP_ADD_LIBRARY($1)
5572a6da0f2Sfoobar],[
5582a6da0f2Sfoobar  if test "$ext_shared" = "yes"; then
5592a6da0f2Sfoobar    $3="-l$1 [$]$3"
5602a6da0f2Sfoobar    if test -n "$2"; then
5612a6da0f2Sfoobar      PHP_ADD_LIBPATH($2,$3)
562702d7afcSSascha Schumann    fi
5632a6da0f2Sfoobar  else
5642a6da0f2Sfoobar    PHP_ADD_LIBRARY_WITH_PATH($1,$2)
5652a6da0f2Sfoobar  fi
5662a6da0f2Sfoobar])
5672a6da0f2Sfoobar])
568702d7afcSSascha Schumann
5692a6da0f2Sfoobardnl
5702a6da0f2Sfoobardnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd])
5712a6da0f2Sfoobardnl
5722a6da0f2Sfoobardnl add a library to the link line (deferred)
5732a6da0f2Sfoobardnl and path to linkpath/runpath (not deferred)
5742a6da0f2Sfoobardnl if shared-libadd is not empty and $ext_shared is yes,
5752a6da0f2Sfoobardnl shared-libadd will be assigned the library information
5762a6da0f2Sfoobardnl
5772a6da0f2SfoobarAC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[
5782a6da0f2Sfoobarifelse($3,,[
5792a6da0f2Sfoobar  if test -n "$2"; then
5802a6da0f2Sfoobar    PHP_ADD_LIBPATH($2)
5812a6da0f2Sfoobar  fi
5822a6da0f2Sfoobar  PHP_ADD_LIBRARY_DEFER($1)
5832a6da0f2Sfoobar],[
5842a6da0f2Sfoobar  if test "$ext_shared" = "yes"; then
5852a6da0f2Sfoobar    $3="-l$1 [$]$3"
5862a6da0f2Sfoobar    if test -n "$2"; then
5872a6da0f2Sfoobar      PHP_ADD_LIBPATH($2,$3)
588e1dd35bdSSascha Schumann    fi
5892a6da0f2Sfoobar  else
5902a6da0f2Sfoobar    PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2)
5912a6da0f2Sfoobar  fi
5922a6da0f2Sfoobar])
593e2eaf634SSascha Schumann])
594e2eaf634SSascha Schumann
5952a6da0f2Sfoobardnl
5962a6da0f2Sfoobardnl PHP_ADD_FRAMEWORK(framework [,before])
5972a6da0f2Sfoobardnl
5982a6da0f2Sfoobardnl add a (Darwin / Mac OS X) framework to the link
5992a6da0f2Sfoobardnl line. if before is 1, the framework is added
6002a6da0f2Sfoobardnl to the beginning of the line.
6012a6da0f2Sfoobardnl
6022a6da0f2SfoobarAC_DEFUN([PHP_ADD_FRAMEWORK], [
6032a6da0f2Sfoobar  PHP_RUN_ONCE(FRAMEWORKS, $1, [
6042a6da0f2Sfoobar    if test "$2"; then
6052a6da0f2Sfoobar      PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS"
6062a6da0f2Sfoobar    else
6072a6da0f2Sfoobar      PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1"
608702d7afcSSascha Schumann    fi
609702d7afcSSascha Schumann  ])
6102a6da0f2Sfoobar])
611702d7afcSSascha Schumann
6122a6da0f2Sfoobardnl
6132a6da0f2Sfoobardnl PHP_ADD_FRAMEWORKPATH(path [,before])
6142a6da0f2Sfoobardnl
6152a6da0f2Sfoobardnl add a (Darwin / Mac OS X) framework path to the link
6162a6da0f2Sfoobardnl and include lines. default paths include (but are
6172a6da0f2Sfoobardnl not limited to) /Local/Library/Frameworks and
6182a6da0f2Sfoobardnl /System/Library/Frameworks, so these don't need
6192a6da0f2Sfoobardnl to be specifically added. if before is 1, the
6202a6da0f2Sfoobardnl framework path is added to the beginning of the
6212a6da0f2Sfoobardnl relevant lines.
6222a6da0f2Sfoobardnl
6232a6da0f2SfoobarAC_DEFUN([PHP_ADD_FRAMEWORKPATH], [
6242a6da0f2Sfoobar  PHP_EXPAND_PATH($1, ai_p)
6252a6da0f2Sfoobar  PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [
6262a6da0f2Sfoobar    if test "$2"; then
6272a6da0f2Sfoobar      PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH"
6282a6da0f2Sfoobar    else
6292a6da0f2Sfoobar      PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p"
630e1dd35bdSSascha Schumann    fi
6312a6da0f2Sfoobar  ])
632702d7afcSSascha Schumann])
633702d7afcSSascha Schumann
6342a6da0f2Sfoobardnl
6352a6da0f2Sfoobardnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path)
6362a6da0f2Sfoobardnl
6372a6da0f2Sfoobardnl Adds a (Darwin / Mac OS X) framework path and the
6382a6da0f2Sfoobardnl framework itself to the link and include lines.
6392a6da0f2Sfoobardnl
6402a6da0f2SfoobarAC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [
6412a6da0f2Sfoobar  PHP_ADD_FRAMEWORKPATH($2)
6422a6da0f2Sfoobar  PHP_ADD_FRAMEWORK($1)
643d0f3764eSSascha Schumann])
644d0f3764eSSascha Schumann
6451e31b775SSascha Schumanndnl
6462a6da0f2Sfoobardnl PHP_SET_LIBTOOL_VARIABLE(var)
6471e31b775SSascha Schumanndnl
6482a6da0f2Sfoobardnl Set libtool variable
6492a6da0f2Sfoobardnl
6502a6da0f2SfoobarAC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[
6512a6da0f2Sfoobar  if test -z "$LIBTOOL"; then
6522a6da0f2Sfoobar    LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
6532a6da0f2Sfoobar  else
6542a6da0f2Sfoobar    LIBTOOL="$LIBTOOL $1"
6552a6da0f2Sfoobar  fi
6561e31b775SSascha Schumann])
6571e31b775SSascha Schumann
6582a6da0f2Sfoobardnl -------------------------------------------------------------------------
6592a6da0f2Sfoobardnl Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE
6602a6da0f2Sfoobardnl -------------------------------------------------------------------------
6612a6da0f2Sfoobar
6622a6da0f2Sfoobardnl PHP_ARG_ANALYZE_EX
6632a6da0f2Sfoobardnl internal
664938ba73bSSascha SchumannAC_DEFUN([PHP_ARG_ANALYZE_EX],[
6652ea99fe1SSascha Schumannext_output="yes, shared"
6662ea99fe1SSascha Schumannext_shared=yes
667afdaee9eSSascha Schumanncase [$]$1 in
668320a86b7SSascha Schumannshared,*[)]
6699ef2ea19Sfoobar  $1=`echo "[$]$1"|$SED 's/^shared,//'`
670a481fddfSSascha Schumann  ;;
671320a86b7SSascha Schumannshared[)]
672a481fddfSSascha Schumann  $1=yes
673a481fddfSSascha Schumann  ;;
674320a86b7SSascha Schumannno[)]
6759982ff56SSascha Schumann  ext_output=no
676a481fddfSSascha Schumann  ext_shared=no
677a481fddfSSascha Schumann  ;;
678320a86b7SSascha Schumann*[)]
6799982ff56SSascha Schumann  ext_output=yes
680a481fddfSSascha Schumann  ext_shared=no
681a481fddfSSascha Schumann  ;;
682a481fddfSSascha Schumannesac
683a481fddfSSascha Schumann
6842ea99fe1SSascha SchumannPHP_ALWAYS_SHARED([$1])
6852ea99fe1SSascha Schumann])
686cae3b7dfSSascha Schumann
6872a6da0f2Sfoobardnl PHP_ARG_ANALYZE
6882a6da0f2Sfoobardnl internal
689938ba73bSSascha SchumannAC_DEFUN([PHP_ARG_ANALYZE],[
6902f676485Sfoobarifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)])
6919d9d39a0SSascha Schumannifelse([$2],,,[AC_MSG_RESULT([$ext_output])])
692a481fddfSSascha Schumann])
693a481fddfSSascha Schumann
6941e31b775SSascha Schumanndnl
6953bf75192Sfoobardnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]])
6961e31b775SSascha Schumanndnl Sets PHP_ARG_NAME either to the user value or to the default value.
697b1393e18SSascha Schumanndnl default-val defaults to no.  This will also set the variable ext_shared,
698b1393e18SSascha Schumanndnl and will overwrite any previous variable of that name.
6993bf75192Sfoobardnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
7003bf75192Sfoobardnl the PHP_ARG_ANALYZE_EX.
7011e31b775SSascha Schumanndnl
702938ba73bSSascha SchumannAC_DEFUN([PHP_ARG_WITH],[
70376b92b6dSJani Taskinenphp_with_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
7043bf75192SfoobarPHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
705a481fddfSSascha Schumann])
706a481fddfSSascha Schumann
7072a6da0f2Sfoobardnl PHP_REAL_ARG_WITH
7082a6da0f2Sfoobardnl internal
709938ba73bSSascha SchumannAC_DEFUN([PHP_REAL_ARG_WITH],[
7109d9d39a0SSascha Schumannifelse([$2],,,[AC_MSG_CHECKING([$2])])
7112a6da0f2SfoobarAC_ARG_WITH($1,[$3],$5=[$]withval,
7122a6da0f2Sfoobar[
7132a6da0f2Sfoobar  $5=ifelse($4,,no,$4)
714200dcee2SJani Taskinen  ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
7152a6da0f2Sfoobar])
7162a6da0f2SfoobarPHP_ARG_ANALYZE($5,[$2],$6)
717f2f8d38eSSascha Schumann])
718f2f8d38eSSascha Schumann
7192a6da0f2Sfoobardnl
7202a6da0f2Sfoobardnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]])
7212a6da0f2Sfoobardnl Sets PHP_ARG_NAME either to the user value or to the default value.
7222a6da0f2Sfoobardnl default-val defaults to no.  This will also set the variable ext_shared,
7232a6da0f2Sfoobardnl and will overwrite any previous variable of that name.
7242a6da0f2Sfoobardnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
7252a6da0f2Sfoobardnl the PHP_ARG_ANALYZE_EX.
7262a6da0f2Sfoobardnl
7272a6da0f2SfoobarAC_DEFUN([PHP_ARG_ENABLE],[
72876b92b6dSJani Taskinenphp_enable_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
72976b92b6dSJani TaskinenPHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
730f2f8d38eSSascha Schumann])
731f2f8d38eSSascha Schumann
7322a6da0f2Sfoobardnl PHP_REAL_ARG_ENABLE
7332a6da0f2Sfoobardnl internal
7342a6da0f2SfoobarAC_DEFUN([PHP_REAL_ARG_ENABLE],[
7352a6da0f2Sfoobarifelse([$2],,,[AC_MSG_CHECKING([$2])])
7362a6da0f2SfoobarAC_ARG_ENABLE($1,[$3],$5=[$]enableval,
7372a6da0f2Sfoobar[
7382a6da0f2Sfoobar  $5=ifelse($4,,no,$4)
739200dcee2SJani Taskinen  ifelse($6,yes,[test "$PHP_ENABLE_ALL" && $5=$PHP_ENABLE_ALL])
7402a6da0f2Sfoobar])
7412a6da0f2SfoobarPHP_ARG_ANALYZE($5,[$2],$6)
742f2f8d38eSSascha Schumann])
743f2f8d38eSSascha Schumann
7442a6da0f2Sfoobardnl -------------------------------------------------------------------------
7452a6da0f2Sfoobardnl Build macros
7462a6da0f2Sfoobardnl -------------------------------------------------------------------------
7472a6da0f2Sfoobar
748a4c75707SSascha Schumanndnl
749a4c75707SSascha Schumanndnl PHP_BUILD_THREAD_SAFE
7503d4bef49SThies C. Arntzendnl
751938ba73bSSascha SchumannAC_DEFUN([PHP_BUILD_THREAD_SAFE],[
7524c8473d6SZeev Suraski  enable_maintainer_zts=yes
753b6e4841eSSascha Schumann  if test "$pthreads_working" != "yes"; then
754acb7d69fSfoobar    AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.])
755b6e4841eSSascha Schumann  fi
756a4c75707SSascha Schumann])
757a4c75707SSascha Schumann
7582a6da0f2Sfoobardnl
7592a6da0f2Sfoobardnl PHP_REQUIRE_CXX
7602a6da0f2Sfoobardnl
761938ba73bSSascha SchumannAC_DEFUN([PHP_REQUIRE_CXX],[
762e5157159SSascha Schumann  if test -z "$php_cxx_done"; then
763ba5479a0Sfoobar    AC_PROG_CXX
764ba5479a0Sfoobar    AC_PROG_CXXCPP
7656238cf5aSHannes Magnusson    PHP_ADD_LIBRARY(stdc++)
766e5157159SSascha Schumann    php_cxx_done=yes
767e5157159SSascha Schumann  fi
768e5157159SSascha Schumann])
769e5157159SSascha Schumann
770232afa48SSascha Schumanndnl
771232afa48SSascha Schumanndnl PHP_BUILD_SHARED
772232afa48SSascha Schumanndnl
773938ba73bSSascha SchumannAC_DEFUN([PHP_BUILD_SHARED],[
7749d9d39a0SSascha Schumann  PHP_BUILD_PROGRAM
7758684e749SJani Taskinen  OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
77625aee9caSJani Taskinen  php_sapi_module=shared
7779d9d39a0SSascha Schumann
7789d9d39a0SSascha Schumann  php_c_pre=$shared_c_pre
7799d9d39a0SSascha Schumann  php_c_meta=$shared_c_meta
7809d9d39a0SSascha Schumann  php_c_post=$shared_c_post
7819d9d39a0SSascha Schumann  php_cxx_pre=$shared_cxx_pre
7829d9d39a0SSascha Schumann  php_cxx_meta=$shared_cxx_meta
7839d9d39a0SSascha Schumann  php_cxx_post=$shared_cxx_post
7849d9d39a0SSascha Schumann  php_lo=$shared_lo
785232afa48SSascha Schumann])
786232afa48SSascha Schumann
787232afa48SSascha Schumanndnl
788232afa48SSascha Schumanndnl PHP_BUILD_STATIC
789232afa48SSascha Schumanndnl
790938ba73bSSascha SchumannAC_DEFUN([PHP_BUILD_STATIC],[
7919d9d39a0SSascha Schumann  PHP_BUILD_PROGRAM
7928684e749SJani Taskinen  OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
79325aee9caSJani Taskinen  php_sapi_module=static
794232afa48SSascha Schumann])
795232afa48SSascha Schumann
796676afb33SMarko Karppinendnl
797676afb33SMarko Karppinendnl PHP_BUILD_BUNDLE
798676afb33SMarko Karppinendnl
799938ba73bSSascha SchumannAC_DEFUN([PHP_BUILD_BUNDLE],[
800676afb33SMarko Karppinen  PHP_BUILD_PROGRAM
8018684e749SJani Taskinen  OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle]
80225aee9caSJani Taskinen  php_sapi_module=static
803676afb33SMarko Karppinen])
804676afb33SMarko Karppinen
805232afa48SSascha Schumanndnl
806232afa48SSascha Schumanndnl PHP_BUILD_PROGRAM
807232afa48SSascha Schumanndnl
808938ba73bSSascha SchumannAC_DEFUN([PHP_BUILD_PROGRAM],[
809abfc90fbSfoobar  php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
8109d9d39a0SSascha Schumann  php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
811abfc90fbSfoobar  php_c_post=
812abfc90fbSfoobar  php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
8139d9d39a0SSascha Schumann  php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
814abfc90fbSfoobar  php_cxx_post=
815abfc90fbSfoobar  php_lo=lo
8166faa433dSfoobar
8176faa433dSfoobar  case $with_pic in
8186faa433dSfoobar    yes) pic_setting='-prefer-pic';;
8196faa433dSfoobar    no)  pic_setting='-prefer-non-pic';;
8206faa433dSfoobar  esac
8216faa433dSfoobar
8229d9d39a0SSascha Schumann  shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
8236faa433dSfoobar  shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting
8249d9d39a0SSascha Schumann  shared_c_post=
8259d9d39a0SSascha Schumann  shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
8266faa433dSfoobar  shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting
8279d9d39a0SSascha Schumann  shared_cxx_post=
8289d9d39a0SSascha Schumann  shared_lo=lo
829232afa48SSascha Schumann])
830232afa48SSascha Schumann
83143a466a0SSascha Schumanndnl
8322633dcabSMarcus Boergerdnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext)
83343a466a0SSascha Schumanndnl
8342a6da0f2Sfoobardnl Basically sets up the link-stage for building module-name
8352a6da0f2Sfoobardnl from object_var in build-dir.
83643a466a0SSascha Schumanndnl
8372a6da0f2SfoobarAC_DEFUN([PHP_SHARED_MODULE],[
8382a6da0f2Sfoobar  install_modules="install-modules"
83943a466a0SSascha Schumann
8402a6da0f2Sfoobar  case $host_alias in
8418de33674SDmitry Stogov    *aix*[)]
8428de33674SDmitry Stogov      suffix=so
8438de33674SDmitry Stogov      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'
8448de33674SDmitry Stogov      ;;
8456e0da825Sfoobar    *netware*[)]
8466e0da825Sfoobar      suffix=nlm
8475337c026SAnantha Kesari H Y      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)'
8486e0da825Sfoobar      ;;
8492a6da0f2Sfoobar    *[)]
8502a6da0f2Sfoobar      suffix=la
8512a6da0f2Sfoobar      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)'
8522a6da0f2Sfoobar      ;;
8532a6da0f2Sfoobar  esac
8542a6da0f2Sfoobar
8552633dcabSMarcus Boerger  if test "x$5" = "xyes"; then
8562633dcabSMarcus Boerger    PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix"
8572633dcabSMarcus Boerger  else
8582633dcabSMarcus Boerger    PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix"
8592633dcabSMarcus Boerger  fi
8602a6da0f2Sfoobar  PHP_SUBST($2)
8612a6da0f2Sfoobar  cat >>Makefile.objects<<EOF
8622a6da0f2Sfoobar\$(phplibdir)/$1.$suffix: $3/$1.$suffix
8632a6da0f2Sfoobar	\$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir)
8642a6da0f2Sfoobar
8652a6da0f2Sfoobar$3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
8662a6da0f2Sfoobar	$link_cmd
8672a6da0f2Sfoobar
8682a6da0f2SfoobarEOF
86943a466a0SSascha Schumann])
870