home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Online / Apache / lib / php / build / acinclude.m4 next >
Encoding:
M4 Source File  |  2001-03-06  |  21.0 KB  |  919 lines

  1. dnl $Id: acinclude.m4,v 1.114 2000/11/21 08:38:19 hholzgra Exp $
  2. dnl
  3. dnl This file contains local autoconf functions.
  4.  
  5. sinclude(dynlib.m4)
  6.  
  7. dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD)
  8. dnl
  9. dnl Use this macro, if you need to add libraries and or library search
  10. dnl paths to the PHP build system which are only given in compiler
  11. dnl notation.
  12. dnl
  13. AC_DEFUN(PHP_EVAL_LIBLINE,[
  14.   for ac_i in $1; do
  15.     case "$ac_i" in
  16.     -l*)
  17.       ac_ii=`echo $ac_i|cut -c 3-`
  18.       AC_ADD_LIBRARY($ac_ii,,$2)
  19.     ;;
  20.     -L*)
  21.       ac_ii=`echo $ac_i|cut -c 3-`
  22.       AC_ADD_LIBPATH($ac_ii,$2)
  23.     ;;
  24.     esac
  25.   done
  26. ])
  27.  
  28. dnl PHP_EVAL_INCLINE(LINE)
  29. dnl
  30. dnl Use this macro, if you need to add header search paths to the PHP
  31. dnl build system which are only given in compiler notation.
  32. dnl
  33. AC_DEFUN(PHP_EVAL_INCLINE,[
  34.   for ac_i in $1; do
  35.     case "$ac_i" in
  36.     -I*)
  37.       ac_ii=`echo $ac_i|cut -c 3-`
  38.       AC_ADD_INCLUDE($ac_ii)
  39.     ;;
  40.     esac
  41.   done
  42. ])
  43.     
  44. AC_DEFUN(PHP_READDIR_R_TYPE,[
  45.   dnl HAVE_READDIR_R is also defined by libmysql
  46.   AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
  47.   if test "$ac_cv_func_readdir_r" = "yes"; then
  48.   AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
  49.     AC_TRY_RUN([
  50. #define _REENTRANT
  51. #include <sys/types.h>
  52. #include <dirent.h>
  53.  
  54. #ifndef PATH_MAX
  55. #define PATH_MAX 1024
  56. #endif
  57.  
  58. main() {
  59.     DIR *dir;
  60.     char entry[sizeof(struct dirent)+PATH_MAX];
  61.     struct dirent *pentry = (struct dirent *) &entry;
  62.  
  63.     dir = opendir("/");
  64.     if (!dir) 
  65.         exit(1);
  66.     if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
  67.         exit(0);
  68.     exit(1);
  69. }
  70.     ],[
  71.       ac_cv_what_readdir_r=POSIX
  72.     ],[
  73.       AC_TRY_CPP([
  74. #define _REENTRANT
  75. #include <sys/types.h>
  76. #include <dirent.h>
  77. int readdir_r(DIR *, struct dirent *);
  78.         ],[
  79.           ac_cv_what_readdir_r=old-style
  80.         ],[
  81.           ac_cv_what_readdir_r=none
  82.       ])
  83.     ],[
  84.       ac_cv_what_readdir_r=none
  85.    ])
  86.   ])
  87.     case "$ac_cv_what_readdir_r" in
  88.     POSIX)
  89.       AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
  90.     old-style)
  91.       AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
  92.     esac
  93.   fi
  94. ])
  95.  
  96. AC_DEFUN(PHP_SHLIB_SUFFIX_NAME,[
  97.   PHP_SUBST(SHLIB_SUFFIX_NAME)
  98.   SHLIB_SUFFIX_NAME=so
  99.   case "$host_alias" in
  100.   *hpux*)
  101.     SHLIB_SUFFIX_NAME=sl
  102.     ;;
  103.   esac
  104. ])
  105.  
  106. AC_DEFUN(PHP_DEBUG_MACRO,[
  107.   DEBUG_LOG="$1"
  108.   cat >$1 <<X
  109. CONFIGURE:  $CONFIGURE_COMMAND
  110. CC:         $CC
  111. CFLAGS:     $CFLAGS
  112. CPPFLAGS:   $CPPFLAGS
  113. CXX:        $CXX
  114. CXXFLAGS:   $CXXFLAGS
  115. INCLUDES:   $INCLUDES
  116. LDFLAGS:    $LDFLAGS
  117. LIBS:       $LIBS
  118. DLIBS:      $DLIBS
  119. SAPI:       $PHP_SAPI
  120. PHP_RPATHS: $PHP_RPATHS
  121. uname -a:   `uname -a`
  122.  
  123. X
  124.     cat >conftest.$ac_ext <<X
  125. main()
  126. {
  127.   exit(0);
  128. }
  129. X
  130.     (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
  131.     rm -fr conftest*
  132. ])
  133.     
  134. AC_DEFUN(PHP_MISSING_TIME_R_DECL,[
  135.   AC_MSG_CHECKING(for missing declarations of reentrant functions)
  136.   AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
  137.     :
  138.   ],[
  139.     AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
  140.   ])
  141.   AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
  142.     :
  143.   ],[
  144.     AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
  145.   ])
  146.   AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
  147.     :
  148.   ],[
  149.     AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
  150.   ])
  151.   AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
  152.     :
  153.   ],[
  154.     AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
  155.   ])
  156.   AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
  157.     :
  158.   ],[
  159.     AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
  160.   ])
  161.   AC_MSG_RESULT(done)
  162. ])
  163.  
  164. dnl
  165. dnl PHP_LIBGCC_LIBPATH(gcc)
  166. dnl Stores the location of libgcc in libgcc_libpath
  167. dnl
  168. AC_DEFUN(PHP_LIBGCC_LIBPATH,[
  169.   changequote({,})
  170.   libgcc_libpath="`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'`"
  171.   changequote([,])
  172. ])
  173.  
  174. AC_DEFUN(PHP_ARG_ANALYZE,[
  175. case "[$]$1" in
  176. shared,*)
  177.   ext_output="yes, shared"
  178.   ext_shared=yes
  179.   $1=`echo $ac_n "[$]$1$ac_c"|sed s/^shared,//`
  180.   ;;
  181. shared)
  182.   ext_output="yes, shared"
  183.   ext_shared=yes
  184.   $1=yes
  185.   ;;
  186. no)
  187.   ext_output="no"
  188.   ext_shared=no
  189.   ;;
  190. *)
  191.   ext_output="yes"
  192.   ext_shared=no
  193.   ;;
  194. esac
  195.  
  196. if test "$php_always_shared" = "yes"; then
  197.   ext_output="yes, shared"
  198.   ext_shared=yes
  199.   test "[$]$1" = "no" && $1=yes
  200. fi
  201.  
  202. AC_MSG_RESULT($ext_output)
  203. ])
  204.  
  205. dnl
  206. dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val])
  207. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  208. dnl default-val defaults to no. 
  209. dnl
  210. AC_DEFUN(PHP_ARG_WITH,[
  211. PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_))
  212. ])
  213.  
  214. AC_DEFUN(PHP_REAL_ARG_WITH,[
  215. AC_MSG_CHECKING($2)
  216. AC_ARG_WITH($1,[$3],$5=[$]withval,$5=ifelse($4,,no,$4))
  217. PHP_ARG_ANALYZE($5)
  218. ])
  219.  
  220. dnl
  221. dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val])
  222. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  223. dnl default-val defaults to no. 
  224. dnl
  225. AC_DEFUN(PHP_ARG_ENABLE,[
  226. PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_))
  227. ])
  228.  
  229. AC_DEFUN(PHP_REAL_ARG_ENABLE,[
  230. AC_MSG_CHECKING($2)
  231. AC_ARG_ENABLE($1,[$3],$5=[$]enableval,$5=ifelse($4,,no,$4))
  232. PHP_ARG_ANALYZE($5)
  233. ])
  234.  
  235. AC_DEFUN(PHP_MODULE_PTR,[
  236.   EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1,"
  237. ])
  238.  
  239. AC_DEFUN(PHP_CONFIG_NICE,[
  240.   rm -f $1
  241.   cat >$1<<EOF
  242. #! /bin/sh
  243. #
  244. # Created by configure
  245.  
  246. EOF
  247.  
  248.   for arg in [$]0 "[$]@"; do
  249.     echo "\"[$]arg\" \\" >> $1
  250.   done
  251.   echo '"[$]@"' >> $1
  252.   chmod +x $1
  253. ])
  254.  
  255. AC_DEFUN(PHP_TIME_R_TYPE,[
  256. AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
  257. AC_TRY_RUN([
  258. #include <time.h>
  259. #include <stdlib.h>
  260.  
  261. main() {
  262. char buf[27];
  263. struct tm t;
  264. time_t old = 0;
  265. int r, s;
  266.  
  267. s = gmtime_r(&old, &t);
  268. r = (int) asctime_r(&t, buf, 26);
  269. if (r == s && s == 0) exit(0);
  270. exit(1);
  271. }
  272. ],[
  273.   ac_cv_time_r_type=hpux
  274. ],[
  275.   ac_cv_time_r_type=POSIX
  276. ],[
  277.   ac_cv_time_r_type=POSIX
  278. ])
  279. ])
  280. if test "$ac_cv_time_r_type" = "hpux"; then
  281.   AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x])
  282. fi
  283. ])
  284.  
  285. AC_DEFUN(PHP_SUBST,[
  286.   PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
  287.   AC_SUBST($1)
  288. ])
  289.  
  290. AC_DEFUN(PHP_FAST_OUTPUT,[
  291.   PHP_FAST_OUTPUT_FILES="$PHP_FAST_OUTPUT_FILES $1"
  292. ])
  293.  
  294. AC_DEFUN(PHP_MKDIR_P_CHECK,[
  295.   AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
  296.     test -d conftestdir && rm -rf conftestdir
  297.     mkdir -p conftestdir/somedir >/dev/null 2>&1
  298.     if test -d conftestdir/somedir; then
  299.       ac_cv_mkdir_p=yes
  300.     else
  301.       ac_cv_mkdir_p=no
  302.     fi
  303.     rm -rf conftestdir
  304.   ])
  305. ])
  306.  
  307. AC_DEFUN(PHP_GEN_CONFIG_VARS,[
  308.   PHP_MKDIR_P_CHECK
  309.   echo creating config_vars.mk
  310.   > config_vars.mk
  311.   for i in $PHP_VAR_SUBST; do
  312.     eval echo "$i = \$$i" >> config_vars.mk
  313.   done
  314. ])
  315.  
  316. AC_DEFUN(PHP_GEN_MAKEFILES,[
  317.   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $1
  318. ])
  319.  
  320. AC_DEFUN(PHP_TM_GMTOFF,[
  321. AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
  322. [AC_TRY_COMPILE([#include <sys/types.h>
  323. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  324.   ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
  325.  
  326. if test "$ac_cv_struct_tm_gmtoff" = yes; then
  327.   AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
  328. fi
  329. ])
  330.  
  331. dnl PHP_CONFIGURE_PART(MESSAGE)
  332. dnl Idea borrowed from mm
  333. AC_DEFUN(PHP_CONFIGURE_PART,[
  334.   AC_MSG_RESULT()
  335.   AC_MSG_RESULT(${T_MD}$1${T_ME})
  336. ])
  337.  
  338. AC_DEFUN(PHP_PROG_SENDMAIL,[
  339. AC_PATH_PROG(PROG_SENDMAIL, sendmail, /usr/lib/sendmail, $PATH:/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib)
  340. if test -n "$PROG_SENDMAIL"; then
  341.   AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail])
  342. fi
  343. ])
  344.  
  345. AC_DEFUN(PHP_RUNPATH_SWITCH,[
  346. dnl check for -R, etc. switch
  347. AC_MSG_CHECKING(if compiler supports -R)
  348. AC_CACHE_VAL(php_cv_cc_dashr,[
  349.     SAVE_LIBS="${LIBS}"
  350.     LIBS="-R /usr/lib ${LIBS}"
  351.     AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
  352.     LIBS="${SAVE_LIBS}"])
  353. AC_MSG_RESULT($php_cv_cc_dashr)
  354. if test $php_cv_cc_dashr = "yes"; then
  355.     ld_runpath_switch="-R"
  356. else
  357.     AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
  358.     AC_CACHE_VAL(php_cv_cc_rpath,[
  359.         SAVE_LIBS="${LIBS}"
  360.         LIBS="-Wl,-rpath,/usr/lib ${LIBS}"
  361.         AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
  362.         LIBS="${SAVE_LIBS}"])
  363.     AC_MSG_RESULT($php_cv_cc_rpath)
  364.     if test $php_cv_cc_rpath = "yes"; then
  365.         ld_runpath_switch="-Wl,-rpath,"
  366.     else
  367.         dnl something innocuous
  368.         ld_runpath_switch="-L"
  369.     fi
  370. fi
  371. ])
  372.  
  373. AC_DEFUN(PHP_STRUCT_FLOCK,[
  374. AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
  375.     AC_TRY_COMPILE([
  376. #include <unistd.h>
  377. #include <fcntl.h>
  378.         ],
  379.         [struct flock x;],
  380.         [
  381.           ac_cv_struct_flock=yes
  382.         ],[
  383.           ac_cv_struct_flock=no
  384.         ])
  385. )
  386. if test "$ac_cv_struct_flock" = "yes" ; then
  387.     AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
  388. fi
  389. ])
  390.  
  391. AC_DEFUN(PHP_SOCKLEN_T,[
  392. AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
  393.   AC_TRY_COMPILE([
  394. #include <sys/types.h>
  395. #include <sys/socket.h>
  396. ],[
  397. socklen_t x;
  398. ],[
  399.   ac_cv_socklen_t=yes
  400. ],[
  401.   ac_cv_socklen_t=no
  402. ]))
  403. if test "$ac_cv_socklen_t" = "yes"; then
  404.   AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
  405. fi
  406. ])
  407.  
  408. dnl
  409. dnl PHP_SET_SYM_FILE(path)
  410. dnl
  411. dnl set the path of the file which contains the symbol export list
  412. dnl
  413. AC_DEFUN(PHP_SET_SYM_FILE,
  414. [
  415.   PHP_SYM_FILE="$1"
  416. ])
  417.  
  418. dnl
  419. dnl PHP_BUILD_THREAD_SAFE
  420. dnl
  421. AC_DEFUN(PHP_BUILD_THREAD_SAFE,[
  422.   enable_experimental_zts=yes
  423.   if test "$pthreads_working" != "yes"; then
  424.     AC_MSG_ERROR(ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.)
  425.   fi
  426. ])
  427.  
  428. AC_DEFUN(PHP_REQUIRE_CXX,[
  429.   if test -z "$php_cxx_done"; then
  430.     AC_PROG_CXX
  431.     AC_PROG_CXXCPP
  432.     php_cxx_done=yes
  433.   fi
  434. ])
  435.  
  436. dnl
  437. dnl PHP_BUILD_SHARED
  438. dnl
  439. AC_DEFUN(PHP_BUILD_SHARED,[
  440.   php_build_target=shared
  441. ])
  442.  
  443. dnl
  444. dnl PHP_BUILD_STATIC
  445. dnl
  446. AC_DEFUN(PHP_BUILD_STATIC,[
  447.   php_build_target=static
  448. ])
  449.  
  450. dnl
  451. dnl PHP_BUILD_PROGRAM
  452. dnl
  453. AC_DEFUN(PHP_BUILD_PROGRAM,[
  454.   php_build_target=program
  455. ])
  456.  
  457. dnl
  458. dnl AC_PHP_ONCE(namespace, variable, code)
  459. dnl
  460. dnl execute code, if variable is not set in namespace
  461. dnl
  462. AC_DEFUN(AC_PHP_ONCE,[
  463.   changequote({,})
  464.   unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'`
  465.   changequote([,])
  466.   cmd="echo $ac_n \"\$$1$unique$ac_c\""
  467.   if test -n "$unique" && test "`eval $cmd`" = "" ; then
  468.     eval "$1$unique=set"
  469.     $3
  470.   fi
  471. ])
  472.  
  473. dnl
  474. dnl AC_EXPAND_PATH(path, variable)
  475. dnl
  476. dnl expands path to an absolute path and assigns it to variable
  477. dnl
  478. AC_DEFUN(AC_EXPAND_PATH,[
  479.   if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
  480.     $2="$1"
  481.   else
  482.     changequote({,})
  483.     ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`"
  484.     changequote([,])
  485.     ep_realdir="`(cd \"$ep_dir\" && pwd)`"
  486.     $2="$ep_realdir/`basename \"$1\"`"
  487.   fi
  488. ])
  489.  
  490. dnl
  491. dnl AC_ADD_LIBPATH(path[, shared-libadd])
  492. dnl
  493. dnl add a library to linkpath/runpath
  494. dnl
  495. AC_DEFUN(AC_ADD_LIBPATH,[
  496.   if test "$1" != "/usr/lib"; then
  497.     AC_EXPAND_PATH($1, ai_p)
  498.     if test "$ext_shared" = "yes" && test -n "$2"; then
  499.       $2="-R$1 -L$1 [$]$2"
  500.     else
  501.       AC_PHP_ONCE(LIBPATH, $ai_p, [
  502.         test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$ai_p"
  503.         LDFLAGS="$LDFLAGS -L$ai_p"
  504.         PHP_RPATHS="$PHP_RPATHS $ai_p"
  505.       ])
  506.     fi
  507.   fi
  508. ])
  509.  
  510. dnl
  511. dnl AC_BUILD_RPATH()
  512. dnl
  513. dnl builds RPATH from PHP_RPATHS
  514. dnl
  515. AC_DEFUN(AC_BUILD_RPATH,[
  516.   if test "$PHP_RPATH" = "yes" && test -n "$PHP_RPATHS"; then
  517.     OLD_RPATHS="$PHP_RPATHS"
  518.     PHP_RPATHS=""
  519.     for i in $OLD_RPATHS; do
  520.       PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
  521.       PHP_RPATHS="$PHP_RPATHS -R $i"
  522.       NATIVE_RPATHS="$NATIVE_RPATHS ${ld_runpath_switch}$i"
  523.     done
  524.   fi
  525. ])
  526.  
  527. dnl
  528. dnl AC_ADD_INCLUDE(path)
  529. dnl
  530. dnl add a include path
  531. dnl
  532. AC_DEFUN(AC_ADD_INCLUDE,[
  533.   if test "$1" != "/usr/include"; then
  534.     AC_EXPAND_PATH($1, ai_p)
  535.     AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
  536.       INCLUDES="$INCLUDES -I$ai_p"
  537.     ])
  538.   fi
  539. ])
  540.  
  541. AC_DEFUN(PHP_X_ADD_LIBRARY,[
  542.   ifelse($2,,$3="-l$1 [$]$3", $3="[$]$3 -l$1")
  543. ])
  544.  
  545. dnl
  546. dnl AC_ADD_LIBRARY(library[, append[, shared-libadd]])
  547. dnl
  548. dnl add a library to the link line
  549. dnl
  550. AC_DEFUN(AC_ADD_LIBRARY,[
  551.  case "$1" in
  552.  c|c_r|pthread*) ;;
  553.  *)
  554. ifelse($3,,[
  555.    PHP_X_ADD_LIBRARY($1,$2,LIBS)
  556. ],[
  557.    if test "$ext_shared" = "yes"; then
  558.      PHP_X_ADD_LIBRARY($1,$2,$3)
  559.    else
  560.      AC_ADD_LIBRARY($1,$2)
  561.    fi
  562. ])
  563.   ;;
  564.   esac
  565. ])
  566.  
  567. dnl
  568. dnl AC_ADD_LIBRARY_DEFER(library[, append])
  569. dnl
  570. dnl add a library to the link line (deferred)
  571. AC_DEFUN(AC_ADD_LIBRARY_DEFER,[
  572.   ifelse($#, 1, DLIBS="-l$1 $DLIBS", DLIBS="$DLIBS -l$1")
  573. ])
  574.  
  575. dnl
  576. dnl AC_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
  577. dnl
  578. dnl add a library to the link line and path to linkpath/runpath.
  579. dnl if shared-libadd is not empty and $ext_shared is yes,
  580. dnl shared-libadd will be assigned the library information
  581. dnl
  582. AC_DEFUN(AC_ADD_LIBRARY_WITH_PATH,[
  583. ifelse($3,,[
  584.   if test -n "$2"; then
  585.     AC_ADD_LIBPATH($2)
  586.   fi
  587.   AC_ADD_LIBRARY($1)
  588. ],[
  589.   if test "$ext_shared" = "yes"; then
  590.     $3="-l$1 [$]$3"
  591.     if test -n "$2"; then
  592.       AC_ADD_LIBPATH($2,$3)
  593.     fi
  594.   else
  595.     AC_ADD_LIBRARY_WITH_PATH($1,$2)
  596.   fi
  597. ])
  598. ])
  599.  
  600. dnl
  601. dnl AC_ADD_LIBRARY_DEFER_WITH_PATH(library, path)
  602. dnl
  603. dnl add a library to the link line (deferred)
  604. dnl and path to linkpath/runpath (not deferred)
  605. dnl
  606. AC_DEFUN(AC_ADD_LIBRARY_DEFER_WITH_PATH,[
  607.   AC_ADD_LIBPATH($2)
  608.   AC_ADD_LIBRARY_DEFER($1)
  609. ])
  610.  
  611. AC_DEFUN(AM_SET_LIBTOOL_VARIABLE,[
  612.   LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
  613. ])
  614.  
  615. dnl
  616. dnl Check for cc option
  617. dnl
  618. AC_DEFUN(AC_CHECK_CC_OPTION,[
  619.   echo "main(){return 0;}" > conftest.$ac_ext
  620.   opt="$1"
  621.   changequote({,})
  622.   var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'`
  623.   changequote([,])
  624.   AC_MSG_CHECKING([if compiler supports -$1 really])
  625.   ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1"
  626.   if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then
  627.     eval php_cc_$var=no
  628.     AC_MSG_RESULT(no)
  629.   else
  630.     if eval ./conftest 2>/dev/null ; then
  631.       eval php_cc_$var=yes
  632.       AC_MSG_RESULT(yes)
  633.     else
  634.       eval php_cc_$var=no
  635.       AC_MSG_RESULT(no)
  636.     fi
  637.   fi
  638. ])
  639.  
  640. AC_DEFUN(PHP_REGEX,[
  641.  
  642. if test "$REGEX_TYPE" = "php"; then
  643.   REGEX_LIB=regex/libregex.la
  644.   REGEX_DIR=regex
  645.   AC_DEFINE(HSREGEX,1,[ ])
  646.   AC_DEFINE(REGEX,1,[ ])
  647.   PHP_FAST_OUTPUT(regex/Makefile)
  648. elif test "$REGEX_TYPE" = "system"; then
  649.   AC_DEFINE(REGEX,0,[ ])
  650. fi
  651.  
  652. AC_MSG_CHECKING(which regex library to use)
  653. AC_MSG_RESULT($REGEX_TYPE)
  654.  
  655. PHP_SUBST(REGEX_DIR)
  656. PHP_SUBST(REGEX_LIB)
  657. PHP_SUBST(HSREGEX)
  658. ])
  659.  
  660. dnl
  661. dnl See if we have broken header files like SunOS has.
  662. dnl
  663. AC_DEFUN(AC_MISSING_FCLOSE_DECL,[
  664.   AC_MSG_CHECKING([for fclose declaration])
  665.   AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
  666.     AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
  667.     AC_MSG_RESULT(ok)
  668.   ],[
  669.     AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
  670.     AC_MSG_RESULT(missing)
  671.   ])
  672. ])
  673.  
  674. dnl
  675. dnl Check for broken sprintf()
  676. dnl
  677. AC_DEFUN(AC_BROKEN_SPRINTF,[
  678.   AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
  679.     AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
  680.       ac_cv_broken_sprintf=no
  681.     ],[
  682.       ac_cv_broken_sprintf=yes
  683.     ],[
  684.       ac_cv_broken_sprintf=no
  685.     ])
  686.   ])
  687.   if test "$ac_cv_broken_sprintf" = "yes"; then
  688.     AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [ ])
  689.   else
  690.     AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [ ])
  691.   fi
  692. ])
  693.  
  694. dnl
  695. dnl PHP_EXTENSION(extname [, shared])
  696. dnl
  697. dnl Includes an extension in the build.
  698. dnl
  699. dnl "extname" is the name of the ext/ subdir where the extension resides
  700. dnl "shared" can be set to "shared" or "yes" to build the extension as
  701. dnl a dynamically loadable library.
  702. dnl
  703. AC_DEFUN(PHP_EXTENSION,[
  704.   EXT_SUBDIRS="$EXT_SUBDIRS $1"
  705.   
  706.   if test -d "$abs_srcdir/ext/$1"; then
  707. dnl ---------------------------------------------- Internal Module
  708.     ext_builddir="ext/$1"
  709.     ext_srcdir="$abs_srcdir/ext/$1"
  710.   else
  711. dnl ---------------------------------------------- External Module
  712.     ext_builddir="."
  713.     ext_srcdir="$abs_srcdir"
  714.   fi
  715.  
  716.   if test "$2" != "shared" && test "$2" != "yes"; then
  717. dnl ---------------------------------------------- Static module
  718.     LIB_BUILD($ext_builddir)
  719.     EXT_LTLIBS="$EXT_LTLIBS $ext_builddir/lib$1.la"
  720.     EXT_STATIC="$EXT_STATIC $1"
  721.   else 
  722. dnl ---------------------------------------------- Shared module
  723.     LIB_BUILD($ext_builddir,yes)
  724.     AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z-,A-Z_), 1, Whether to build $1 as dynamic module)
  725.   fi
  726.  
  727.   PHP_FAST_OUTPUT($ext_builddir/Makefile)
  728. ])
  729.  
  730. dnl
  731. dnl Solaris requires main code to be position independent in order
  732. dnl to let shared objects find symbols.  Weird.  Ugly.
  733. dnl
  734. dnl Must be run after all --with-NN options that let the user
  735. dnl choose dynamic extensions, and after the gcc test.
  736. dnl
  737. AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[
  738.   AC_MSG_CHECKING(whether -fPIC is required)
  739.   if test "$EXT_SHARED" != ""; then
  740.     os=`uname -sr 2>/dev/null`
  741.     case "$os" in
  742.         "SunOS 5.6"|"SunOS 5.7")
  743.           case "$CC" in
  744.         gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
  745.         *) CFLAGS="$CFLAGS -fpic";;
  746.       esac
  747.       AC_MSG_RESULT(yes);;
  748.     *)
  749.       AC_MSG_RESULT(no);;
  750.     esac
  751.   else
  752.     AC_MSG_RESULT(no)
  753.   fi
  754. ])
  755.  
  756. dnl
  757. dnl Checks whether $withval is "shared" or starts with "shared,XXX"
  758. dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
  759. dnl from $withval.
  760. dnl
  761. AC_DEFUN(PHP_WITH_SHARED,[
  762.     case $withval in
  763.     shared)
  764.         shared=yes
  765.         withval=yes
  766.         ;;
  767.     shared,*)
  768.         shared=yes
  769.         withval=`echo $withval | sed -e 's/^shared,//'`      
  770.         ;;
  771.     *)
  772.         shared=no
  773.         ;;
  774.     esac
  775.     if test -n "$php_always_shared"; then
  776.         shared=yes
  777.     fi
  778. ])
  779.  
  780. dnl The problem is that the default compilation flags in Solaris 2.6 won't
  781. dnl let programs access large files;  you need to tell the compiler that
  782. dnl you actually want your programs to work on large files.  For more
  783. dnl details about this brain damage please see:
  784. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  785.  
  786. dnl Written by Paul Eggert <eggert@twinsun.com>.
  787.  
  788. AC_DEFUN(AC_SYS_LFS,
  789. [dnl
  790.   # If available, prefer support for large files unless the user specified
  791.   # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
  792.   AC_MSG_CHECKING(whether large file support needs explicit enabling)
  793.   ac_getconfs=''
  794.   ac_result=yes
  795.   ac_set=''
  796.   ac_shellvars='CPPFLAGS LDFLAGS LIBS'
  797.   for ac_shellvar in $ac_shellvars; do
  798.     case $ac_shellvar in
  799.       CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
  800.       *) ac_lfsvar=LFS_$ac_shellvar ;;
  801.     esac
  802.     eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
  803.     (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
  804.     ac_getconf=`getconf $ac_lfsvar`
  805.     ac_getconfs=$ac_getconfs$ac_getconf
  806.     eval ac_test_$ac_shellvar=\$ac_getconf
  807.   done
  808.   case "$ac_result$ac_getconfs" in
  809.     yes) ac_result=no ;;
  810.   esac
  811.   case "$ac_result$ac_set" in
  812.     yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
  813.   esac
  814.   AC_MSG_RESULT($ac_result)
  815.   case $ac_result in
  816.     yes)
  817.       for ac_shellvar in $ac_shellvars; do
  818.         eval $ac_shellvar=\$ac_test_$ac_shellvar
  819.       done ;;
  820.   esac
  821. ])
  822.  
  823. AC_DEFUN(AC_SOCKADDR_SA_LEN,[
  824.   AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  825.     AC_TRY_COMPILE([#include <sys/types.h>
  826. #include <sys/socket.h>],
  827.     [struct sockaddr s; s.sa_len;],
  828.     [ac_cv_sockaddr_sa_len=yes
  829.      AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[ ])],
  830.     [ac_cv_sockaddr_sa_len=no])
  831.   ])
  832. ])
  833.  
  834.  
  835. dnl ## PHP_OUTPUT(file)
  836. dnl ## adds "file" to the list of files generated by AC_OUTPUT
  837. dnl ## This macro can be used several times.
  838. AC_DEFUN(PHP_OUTPUT,[
  839.   PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  840. ])
  841.  
  842. AC_DEFUN(PHP_DECLARED_TIMEZONE,[
  843.   AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
  844.     AC_TRY_COMPILE([
  845. #include <sys/types.h>
  846. #include <time.h>
  847. #ifdef HAVE_SYS_TIME_H
  848. #include <sys/time.h>
  849. #endif
  850. ],[
  851.     time_t foo = (time_t) timezone;
  852. ],[
  853.   ac_cv_declared_timezone=yes
  854. ],[
  855.   ac_cv_declared_timezone=no
  856. ])])
  857.   if test "$ac_cv_declared_timezone" = "yes"; then
  858.     AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
  859.   fi
  860. ])
  861.  
  862. AC_DEFUN(PHP_EBCDIC,[
  863.   AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
  864.   AC_TRY_RUN( [
  865. int main(void) { 
  866.   return (unsigned char)'A' != (unsigned char)0xC1; 
  867. ],[
  868.   ac_cv_ebcdic="yes"
  869. ],[
  870.   ac_cv_ebcdic="no"
  871. ],[
  872.   ac_cv_ebcdic="no"
  873. ])])
  874.   if test "$ac_cv_ebcdic" = "yes"; then
  875.     AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
  876.   fi
  877. ])
  878.  
  879. AC_DEFUN(PHP_FOPENCOOKIE,[
  880.     AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ])
  881.  
  882.     if test "$have_glibc_fopencookie" = "yes" ; then
  883.           dnl this comes in two flavors:
  884.       dnl newer glibcs (since 2.1.2 ? )
  885.       dnl have a type called cookie_io_functions_t
  886.           AC_TRY_COMPILE([ #define _GNU_SOURCE
  887.                        #include <stdio.h>
  888.                                        ],
  889.                        [ cookie_io_functions_t cookie; ],
  890.                      [ have_cookie_io_functions_t=yes ],
  891.                                          [ ] )
  892.  
  893.           if test "$have_cookie_io_functions_t" = "yes" ; then
  894.         cookie_io_functions_t=cookie_io_functions_t
  895.           have_fopen_cookie=yes
  896.       else
  897.           dnl older glibc versions (up to 2.1.2 ?)
  898.         dnl call it _IO_cookie_io_functions_t
  899.             AC_TRY_COMPILE([ #define _GNU_SOURCE
  900.                        #include <stdio.h>
  901.                                        ],
  902.                        [ _IO_cookie_io_functions_t cookie; ],
  903.                      [ have_IO_cookie_io_functions_t=yes ],
  904.                                          [] )
  905.             if test "$have_cookie_io_functions_t" = "yes" ; then
  906.           cookie_io_functions_t=_IO_cookie_io_functions_t
  907.             have_fopen_cookie=yes
  908.             fi
  909.             fi
  910.  
  911.           if test "$have_fopen_cookie" = "yes" ; then
  912.             AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
  913.               AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
  914.       fi      
  915.  
  916.       fi
  917. ])
  918.