You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1815 lines
44 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
26 years ago
26 years ago
27 years ago
25 years ago
25 years ago
25 years ago
25 years ago
27 years ago
27 years ago
25 years ago
27 years ago
25 years ago
  1. dnl $Id$
  2. dnl
  3. dnl This file contains local autoconf functions.
  4. dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile[, ext_srcdir[, ext_builddir]]])
  5. dnl
  6. dnl Processes a file called Makefile.frag in the source directory
  7. dnl of the most recently added extension. $(srcdir) and $(builddir)
  8. dnl are substituted with the proper paths. Can be used to supply
  9. dnl custom rules and/or additional targets.
  10. dnl
  11. AC_DEFUN(PHP_ADD_MAKEFILE_FRAGMENT,[
  12. ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1)
  13. ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2)
  14. ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3)
  15. sed -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
  16. ])
  17. dnl PHP_DEFINE(WHAT[, value])
  18. dnl
  19. dnl Creates builddir/include/what.h and in there #define WHAT value
  20. dnl
  21. AC_DEFUN(PHP_DEFINE,[
  22. [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > include/php_]translit($1,A-Z,a-z)[.h]
  23. ])
  24. dnl PHP_INIT_BUILD_SYSTEM
  25. dnl
  26. AC_DEFUN(PHP_INIT_BUILD_SYSTEM,[
  27. mkdir include >/dev/null 2>&1
  28. > Makefile.objects
  29. > Makefile.fragments
  30. dnl We need to play tricks here to avoid matching the egrep line itself
  31. pattern=define
  32. egrep $pattern'.*include/php' $srcdir/configure|sed 's/.*>//'|xargs touch 2>/dev/null
  33. ])
  34. dnl PHP_GEN_GLOBAL_MAKEFILE
  35. dnl
  36. dnl Generates the global makefile.
  37. dnl
  38. AC_DEFUN(PHP_GEN_GLOBAL_MAKEFILE,[
  39. cat >Makefile <<EOF
  40. srcdir = $abs_srcdir
  41. builddir = $abs_builddir
  42. top_srcdir = $abs_srcdir
  43. top_builddir = $abs_builddir
  44. EOF
  45. for i in $PHP_VAR_SUBST; do
  46. eval echo "$i = \$$i" >> Makefile
  47. done
  48. cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile
  49. ])
  50. dnl PHP_ADD_SOURCES(source-path, sources[, special-flags[, type]])
  51. dnl
  52. dnl Adds sources which are located relative to source-path to the
  53. dnl array of type type. Sources are processed with optional
  54. dnl special-flags which are passed to the compiler. Sources
  55. dnl can be either written in C or C++ (filenames shall end in .c
  56. dnl or .cpp, respectively).
  57. dnl
  58. dnl Note: If source-path begins with a "/", the "/" is removed and
  59. dnl the path is interpreted relative to the top build-directory.
  60. dnl
  61. dnl which array to append to?
  62. AC_DEFUN(PHP_ADD_SOURCES,[
  63. PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,cli,PHP_CLI_OBJS,ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS)))
  64. ])
  65. dnl
  66. dnl PHP_ASSIGN_BUILD_VARS(type)
  67. dnl internal, don't use
  68. AC_DEFUN(PHP_ASSIGN_BUILD_VARS,[
  69. ifelse($1,shared,[
  70. b_c_pre=$shared_c_pre
  71. b_cxx_pre=$shared_cxx_pre
  72. b_c_meta=$shared_c_meta
  73. b_cxx_meta=$shared_cxx_meta
  74. b_c_post=$shared_c_post
  75. b_cxx_post=$shared_cxx_post
  76. ],[
  77. b_c_pre=$php_c_pre
  78. b_cxx_pre=$php_cxx_pre
  79. b_c_meta=$php_c_meta
  80. b_cxx_meta=$php_cxx_meta
  81. b_c_post=$php_c_post
  82. b_cxx_post=$php_cxx_post
  83. ])dnl
  84. b_lo=[$]$1_lo
  85. ])
  86. dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
  87. dnl
  88. dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the
  89. dnl name of the array target-var directly, as well as whether
  90. dnl shared objects will be built from the sources. Should not be
  91. dnl used directly.
  92. dnl
  93. AC_DEFUN(PHP_ADD_SOURCES_X,[
  94. dnl relative to source- or build-directory?
  95. dnl ac_srcdir/ac_bdir include trailing slash
  96. case $1 in
  97. ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;;
  98. /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;;
  99. *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;;
  100. esac
  101. dnl how to build .. shared or static?
  102. ifelse($5,yes,PHP_ASSIGN_BUILD_VARS(shared),PHP_ASSIGN_BUILD_VARS(php))
  103. dnl iterate over the sources
  104. old_IFS=[$]IFS
  105. for ac_src in $2; do
  106. dnl remove the suffix
  107. IFS=.
  108. set $ac_src
  109. ac_obj=[$]1
  110. IFS=$old_IFS
  111. dnl append to the array which has been dynamically chosen at m4 time
  112. $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
  113. dnl choose the right compiler/flags/etc. for the source-file
  114. case $ac_src in
  115. *.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" ;;
  116. *.cpp[)] 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" ;;
  117. esac
  118. dnl create a rule for the object/source combo
  119. cat >>Makefile.objects<<EOF
  120. $ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src
  121. $ac_comp
  122. EOF
  123. done
  124. ])
  125. dnl
  126. dnl Disable building CLI
  127. dnl
  128. AC_DEFUN(PHP_DISABLE_CLI,[
  129. disable_cli=1
  130. ])
  131. dnl
  132. dnl Separator into the configure --help display.
  133. dnl
  134. AC_DEFUN(PHP_HELP_SEPARATOR,[
  135. AC_ARG_ENABLE([],[
  136. $1
  137. ],[])
  138. ])
  139. dnl
  140. dnl PHP_TARGET_RDYNAMIC
  141. dnl
  142. dnl Checks whether -rdynamic is supported by the compiler. This
  143. dnl is necessary for some targets to populate the global symbol
  144. dnl table. Otherwise, dynamic modules would not be able to resolve
  145. dnl PHP-related symbols.
  146. dnl
  147. dnl If successful, adds -rdynamic to PHP_LDFLAGS.
  148. dnl
  149. AC_DEFUN(PHP_TARGET_RDYNAMIC,[
  150. if test -n "$GCC"; then
  151. dnl we should use a PHP-specific macro here
  152. TSRM_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes)
  153. if test "$gcc_rdynamic" = "yes"; then
  154. PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic"
  155. fi
  156. fi
  157. ])
  158. AC_DEFUN(PHP_REMOVE_USR_LIB,[
  159. unset ac_new_flags
  160. for i in [$]$1; do
  161. case [$]i in
  162. -L/usr/lib|-L/usr/lib/) ;;
  163. *) ac_new_flags="[$]ac_new_flags [$]i" ;;
  164. esac
  165. done
  166. $1=[$]ac_new_flags
  167. ])
  168. AC_DEFUN(PHP_SETUP_OPENSSL,[
  169. if test "$PHP_OPENSSL" = "yes"; then
  170. PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl"
  171. fi
  172. for i in $PHP_OPENSSL; do
  173. if test -r $i/include/openssl/evp.h; then
  174. OPENSSL_INCDIR=$i/include
  175. fi
  176. if test -r $i/lib/libssl.a -o -r $i/lib/libssl.$SHLIB_SUFFIX_NAME; then
  177. OPENSSL_LIBDIR=$i/lib
  178. fi
  179. done
  180. if test -z "$OPENSSL_INCDIR"; then
  181. AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
  182. fi
  183. if test -z "$OPENSSL_LIBDIR"; then
  184. AC_MSG_ERROR([Cannot find OpenSSL's libraries])
  185. fi
  186. old_CPPFLAGS=$CPPFLAGS
  187. CPPFLAGS=-I$OPENSSL_INCDIR
  188. AC_MSG_CHECKING([for OpenSSL version])
  189. AC_EGREP_CPP(yes,[
  190. #include <openssl/opensslv.h>
  191. #if OPENSSL_VERSION_NUMBER >= 0x0090500fL
  192. yes
  193. #endif
  194. ],[
  195. AC_MSG_RESULT([>= 0.9.5])
  196. ],[
  197. AC_MSG_ERROR([OpenSSL version 0.9.5 or greater required.])
  198. ])
  199. CPPFLAGS=$old_CPPFLAGS
  200. PHP_ADD_INCLUDE($OPENSSL_INCDIR)
  201. PHP_ADD_LIBPATH($OPENSSL_LIBDIR)
  202. PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
  203. PHP_ADD_LIBRARY(crypto)
  204. ],[
  205. AC_MSG_ERROR([libcrypto not found!])
  206. ],[
  207. -L$OPENSSL_LIBDIR
  208. ])
  209. PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
  210. PHP_ADD_LIBRARY(ssl)
  211. ],[
  212. AC_MSG_ERROR([libssl not found!])
  213. ],[
  214. -L$OPENSSL_LIBDIR
  215. ])
  216. OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
  217. AC_SUBST(OPENSSL_INCDIR_OPT)
  218. ])
  219. dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD)
  220. dnl
  221. dnl Use this macro, if you need to add libraries and or library search
  222. dnl paths to the PHP build system which are only given in compiler
  223. dnl notation.
  224. dnl
  225. AC_DEFUN(PHP_EVAL_LIBLINE,[
  226. for ac_i in $1; do
  227. case $ac_i in
  228. -l*)
  229. ac_ii=`echo $ac_i|cut -c 3-`
  230. PHP_ADD_LIBRARY($ac_ii,1,$2)
  231. ;;
  232. -L*)
  233. ac_ii=`echo $ac_i|cut -c 3-`
  234. PHP_ADD_LIBPATH($ac_ii,$2)
  235. ;;
  236. esac
  237. done
  238. ])
  239. dnl PHP_EVAL_INCLINE(LINE)
  240. dnl
  241. dnl Use this macro, if you need to add header search paths to the PHP
  242. dnl build system which are only given in compiler notation.
  243. dnl
  244. AC_DEFUN(PHP_EVAL_INCLINE,[
  245. for ac_i in $1; do
  246. case $ac_i in
  247. -I*)
  248. ac_ii=`echo $ac_i|cut -c 3-`
  249. PHP_ADD_INCLUDE($ac_ii)
  250. ;;
  251. esac
  252. done
  253. ])
  254. AC_DEFUN(PHP_READDIR_R_TYPE,[
  255. dnl HAVE_READDIR_R is also defined by libmysql
  256. AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
  257. if test "$ac_cv_func_readdir_r" = "yes"; then
  258. AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
  259. AC_TRY_RUN([
  260. #define _REENTRANT
  261. #include <sys/types.h>
  262. #include <dirent.h>
  263. #ifndef PATH_MAX
  264. #define PATH_MAX 1024
  265. #endif
  266. main() {
  267. DIR *dir;
  268. char entry[sizeof(struct dirent)+PATH_MAX];
  269. struct dirent *pentry = (struct dirent *) &entry;
  270. dir = opendir("/");
  271. if (!dir)
  272. exit(1);
  273. if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
  274. exit(0);
  275. exit(1);
  276. }
  277. ],[
  278. ac_cv_what_readdir_r=POSIX
  279. ],[
  280. AC_TRY_CPP([
  281. #define _REENTRANT
  282. #include <sys/types.h>
  283. #include <dirent.h>
  284. int readdir_r(DIR *, struct dirent *);
  285. ],[
  286. ac_cv_what_readdir_r=old-style
  287. ],[
  288. ac_cv_what_readdir_r=none
  289. ])
  290. ],[
  291. ac_cv_what_readdir_r=none
  292. ])
  293. ])
  294. case $ac_cv_what_readdir_r in
  295. POSIX)
  296. AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
  297. old-style)
  298. AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
  299. esac
  300. fi
  301. ])
  302. AC_DEFUN(PHP_SHLIB_SUFFIX_NAME,[
  303. PHP_SUBST(SHLIB_SUFFIX_NAME)
  304. SHLIB_SUFFIX_NAME=so
  305. case $host_alias in
  306. *hpux*)
  307. SHLIB_SUFFIX_NAME=sl
  308. ;;
  309. *darwin*)
  310. SHLIB_SUFFIX_NAME=dylib
  311. ;;
  312. esac
  313. ])
  314. AC_DEFUN(PHP_DEBUG_MACRO,[
  315. DEBUG_LOG=$1
  316. cat >$1 <<X
  317. CONFIGURE: $CONFIGURE_COMMAND
  318. CC: $CC
  319. CFLAGS: $CFLAGS
  320. CPPFLAGS: $CPPFLAGS
  321. CXX: $CXX
  322. CXXFLAGS: $CXXFLAGS
  323. INCLUDES: $INCLUDES
  324. LDFLAGS: $LDFLAGS
  325. LIBS: $LIBS
  326. DLIBS: $DLIBS
  327. SAPI: $PHP_SAPI
  328. PHP_RPATHS: $PHP_RPATHS
  329. uname -a: `uname -a`
  330. X
  331. cat >conftest.$ac_ext <<X
  332. main()
  333. {
  334. exit(0);
  335. }
  336. X
  337. (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
  338. rm -fr conftest*
  339. ])
  340. AC_DEFUN(PHP_DOES_PWRITE_WORK,[
  341. AC_TRY_RUN([
  342. #include <sys/types.h>
  343. #include <sys/stat.h>
  344. #include <fcntl.h>
  345. #include <unistd.h>
  346. #include <errno.h>
  347. $1
  348. main() {
  349. int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
  350. if (fd < 0) exit(1);
  351. if (pwrite(fd, "text", 4, 0) != 4) exit(1);
  352. /* Linux glibc breakage until 2.2.5 */
  353. if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1);
  354. exit(0);
  355. }
  356. ],[
  357. ac_cv_pwrite=yes
  358. ],[
  359. ac_cv_pwrite=no
  360. ],[
  361. ac_cv_pwrite=no
  362. ])
  363. ])
  364. AC_DEFUN(PHP_DOES_PREAD_WORK,[
  365. echo test > conftest_in
  366. AC_TRY_RUN([
  367. #include <sys/types.h>
  368. #include <sys/stat.h>
  369. #include <fcntl.h>
  370. #include <unistd.h>
  371. #include <errno.h>
  372. $1
  373. main() {
  374. char buf[3];
  375. int fd = open("conftest_in", O_RDONLY);
  376. if (fd < 0) exit(1);
  377. if (pread(fd, buf, 2, 0) != 2) exit(1);
  378. /* Linux glibc breakage until 2.2.5 */
  379. if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1);
  380. exit(0);
  381. }
  382. ],[
  383. ac_cv_pread=yes
  384. ],[
  385. ac_cv_pread=no
  386. ],[
  387. ac_cv_pread=no
  388. ])
  389. rm -f conftest_in
  390. ])
  391. AC_DEFUN(PHP_PWRITE_TEST,[
  392. AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
  393. PHP_DOES_PWRITE_WORK
  394. if test "$ac_cv_pwrite" = "no"; then
  395. PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
  396. if test "$ac_cv_pwrite" = "yes"; then
  397. ac_cv_pwrite=64
  398. fi
  399. fi
  400. ])
  401. if test "$ac_cv_pwrite" != "no"; then
  402. AC_DEFINE(HAVE_PWRITE, 1, [ ])
  403. if test "$ac_cv_pwrite" = "64"; then
  404. AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
  405. fi
  406. fi
  407. ])
  408. AC_DEFUN(PHP_PREAD_TEST,[
  409. AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
  410. PHP_DOES_PREAD_WORK
  411. if test "$ac_cv_pread" = "no"; then
  412. PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
  413. if test "$ac_cv_pread" = "yes"; then
  414. ac_cv_pread=64
  415. fi
  416. fi
  417. ])
  418. if test "$ac_cv_pread" != "no"; then
  419. AC_DEFINE(HAVE_PREAD, 1, [ ])
  420. if test "$ac_cv_pread" = "64"; then
  421. AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
  422. fi
  423. fi
  424. ])
  425. AC_DEFUN(PHP_MISSING_TIME_R_DECL,[
  426. AC_MSG_CHECKING([for missing declarations of reentrant functions])
  427. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
  428. :
  429. ],[
  430. AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
  431. ])
  432. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
  433. :
  434. ],[
  435. AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
  436. ])
  437. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
  438. :
  439. ],[
  440. AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
  441. ])
  442. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
  443. :
  444. ],[
  445. AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
  446. ])
  447. AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
  448. :
  449. ],[
  450. AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
  451. ])
  452. AC_MSG_RESULT([done])
  453. ])
  454. dnl
  455. dnl PHP_LIBGCC_LIBPATH(gcc)
  456. dnl Stores the location of libgcc in libgcc_libpath
  457. dnl
  458. AC_DEFUN(PHP_LIBGCC_LIBPATH,[
  459. changequote({,})
  460. libgcc_libpath=`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'`
  461. changequote([,])
  462. ])
  463. AC_DEFUN(PHP_ARG_ANALYZE_EX,[
  464. ext_output="yes, shared"
  465. ext_shared=yes
  466. case [$]$1 in
  467. shared,*)
  468. $1=`echo "[$]$1"|sed 's/^shared,//'`
  469. ;;
  470. shared)
  471. $1=yes
  472. ;;
  473. no)
  474. ext_output=no
  475. ext_shared=no
  476. ;;
  477. *)
  478. ext_output=yes
  479. ext_shared=no
  480. ;;
  481. esac
  482. PHP_ALWAYS_SHARED([$1])
  483. ])
  484. AC_DEFUN(PHP_ARG_ANALYZE,[
  485. ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])])
  486. ifelse([$2],,,[AC_MSG_RESULT([$ext_output])])
  487. ])
  488. dnl
  489. dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]])
  490. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  491. dnl default-val defaults to no. This will also set the variable ext_shared,
  492. dnl and will overwrite any previous variable of that name.
  493. dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
  494. dnl the PHP_ARG_ANALYZE_EX.
  495. dnl
  496. AC_DEFUN(PHP_ARG_WITH,[
  497. PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
  498. ])
  499. AC_DEFUN(PHP_REAL_ARG_WITH,[
  500. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  501. AC_ARG_WITH($1,[$3],$5=[$]withval,
  502. [
  503. $5=ifelse($4,,no,$4)
  504. if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
  505. $5=$PHP_ENABLE_ALL
  506. fi
  507. ])
  508. PHP_ARG_ANALYZE($5,[$2],$6)
  509. ])
  510. dnl
  511. dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]])
  512. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  513. dnl default-val defaults to no. This will also set the variable ext_shared,
  514. dnl and will overwrite any previous variable of that name.
  515. dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
  516. dnl the PHP_ARG_ANALYZE_EX.
  517. dnl
  518. AC_DEFUN(PHP_ARG_ENABLE,[
  519. PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_),[ifelse($5,,yes,$5)])
  520. ])
  521. AC_DEFUN(PHP_REAL_ARG_ENABLE,[
  522. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  523. AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
  524. [
  525. $5=ifelse($4,,no,$4)
  526. if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
  527. $5=$PHP_ENABLE_ALL
  528. fi
  529. ])
  530. PHP_ARG_ANALYZE($5,[$2],$6)
  531. ])
  532. AC_DEFUN(PHP_MODULE_PTR,[
  533. EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1,"
  534. ])
  535. AC_DEFUN(PHP_CONFIG_NICE,[
  536. rm -f $1
  537. cat >$1<<EOF
  538. #! /bin/sh
  539. #
  540. # Created by configure
  541. EOF
  542. for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS CC CXX; do
  543. eval val=\$$var
  544. if test -n "$val"; then
  545. echo "$var='$val' \\" >> $1
  546. fi
  547. done
  548. for arg in [$]0 "[$]@"; do
  549. echo "'[$]arg' \\" >> $1
  550. done
  551. echo '"[$]@"' >> $1
  552. chmod +x $1
  553. ])
  554. AC_DEFUN(PHP_TIME_R_TYPE,[
  555. AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
  556. AC_TRY_RUN([
  557. #include <time.h>
  558. main() {
  559. char buf[27];
  560. struct tm t;
  561. time_t old = 0;
  562. int r, s;
  563. s = gmtime_r(&old, &t);
  564. r = (int) asctime_r(&t, buf, 26);
  565. if (r == s && s == 0) return (0);
  566. return (1);
  567. }
  568. ],[
  569. ac_cv_time_r_type=hpux
  570. ],[
  571. AC_TRY_RUN([
  572. #include <time.h>
  573. main() {
  574. struct tm t, *s;
  575. time_t old = 0;
  576. char buf[27], *p;
  577. s = gmtime_r(&old, &t);
  578. p = asctime_r(&t, buf, 26);
  579. if (p == buf && s == &t) return (0);
  580. return (1);
  581. }
  582. ],[
  583. ac_cv_time_r_type=irix
  584. ],[
  585. ac_cv_time_r_type=POSIX
  586. ])
  587. ],[
  588. ac_cv_time_r_type=POSIX
  589. ])
  590. ])
  591. case $ac_cv_time_r_type in
  592. hpux) AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
  593. irix) AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
  594. esac
  595. ])
  596. AC_DEFUN(PHP_SUBST,[
  597. PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
  598. ])
  599. AC_DEFUN(PHP_SUBST_OLD,[
  600. PHP_SUBST($1)
  601. AC_SUBST($1)
  602. ])
  603. AC_DEFUN(PHP_MKDIR_P_CHECK,[
  604. AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
  605. test -d conftestdir && rm -rf conftestdir
  606. mkdir -p conftestdir/somedir >/dev/null 2>&1
  607. dnl `mkdir -p' must be quiet about creating existing directories
  608. mkdir -p conftestdir/somedir >/dev/null 2>&1
  609. if test "$?" = "0" && test -d conftestdir/somedir; then
  610. ac_cv_mkdir_p=yes
  611. else
  612. ac_cv_mkdir_p=no
  613. fi
  614. rm -rf conftestdir
  615. ])
  616. ])
  617. AC_DEFUN(PHP_TM_GMTOFF,[
  618. AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
  619. [AC_TRY_COMPILE([#include <sys/types.h>
  620. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  621. ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
  622. if test "$ac_cv_struct_tm_gmtoff" = yes; then
  623. AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
  624. fi
  625. ])
  626. dnl PHP_CONFIGURE_PART(MESSAGE)
  627. dnl Idea borrowed from mm
  628. AC_DEFUN(PHP_CONFIGURE_PART,[
  629. AC_MSG_RESULT()
  630. AC_MSG_RESULT([${T_MD}$1${T_ME}])
  631. ])
  632. AC_DEFUN(PHP_PROG_SENDMAIL,[
  633. AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib)
  634. if test -n "$PROG_SENDMAIL"; then
  635. AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail])
  636. fi
  637. ])
  638. AC_DEFUN(PHP_RUNPATH_SWITCH,[
  639. dnl check for -R, etc. switch
  640. AC_MSG_CHECKING([if compiler supports -R])
  641. AC_CACHE_VAL(php_cv_cc_dashr,[
  642. SAVE_LIBS=$LIBS
  643. LIBS="-R /usr/lib $LIBS"
  644. AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
  645. LIBS=$SAVE_LIBS])
  646. AC_MSG_RESULT([$php_cv_cc_dashr])
  647. if test $php_cv_cc_dashr = "yes"; then
  648. ld_runpath_switch=-R
  649. else
  650. AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
  651. AC_CACHE_VAL(php_cv_cc_rpath,[
  652. SAVE_LIBS=$LIBS
  653. LIBS="-Wl,-rpath,/usr/lib $LIBS"
  654. AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
  655. LIBS=$SAVE_LIBS])
  656. AC_MSG_RESULT([$php_cv_cc_rpath])
  657. if test $php_cv_cc_rpath = "yes"; then
  658. ld_runpath_switch=-Wl,-rpath,
  659. else
  660. dnl something innocuous
  661. ld_runpath_switch=-L
  662. fi
  663. fi
  664. ])
  665. AC_DEFUN(PHP_STRUCT_FLOCK,[
  666. AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
  667. AC_TRY_COMPILE([
  668. #include <unistd.h>
  669. #include <fcntl.h>
  670. ],
  671. [struct flock x;],
  672. [
  673. ac_cv_struct_flock=yes
  674. ],[
  675. ac_cv_struct_flock=no
  676. ])
  677. )
  678. if test "$ac_cv_struct_flock" = "yes" ; then
  679. AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
  680. fi
  681. ])
  682. AC_DEFUN(PHP_SOCKLEN_T,[
  683. AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
  684. AC_TRY_COMPILE([
  685. #include <sys/types.h>
  686. #include <sys/socket.h>
  687. ],[
  688. socklen_t x;
  689. ],[
  690. ac_cv_socklen_t=yes
  691. ],[
  692. ac_cv_socklen_t=no
  693. ]))
  694. if test "$ac_cv_socklen_t" = "yes"; then
  695. AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
  696. fi
  697. ])
  698. dnl
  699. dnl PHP_SET_SYM_FILE(path)
  700. dnl
  701. dnl set the path of the file which contains the symbol export list
  702. dnl
  703. AC_DEFUN(PHP_SET_SYM_FILE,
  704. [
  705. PHP_SYM_FILE=$1
  706. ])
  707. dnl
  708. dnl PHP_BUILD_THREAD_SAFE
  709. dnl
  710. AC_DEFUN(PHP_BUILD_THREAD_SAFE,[
  711. enable_experimental_zts=yes
  712. if test "$pthreads_working" != "yes"; then
  713. AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.])
  714. fi
  715. ])
  716. AC_DEFUN(PHP_REQUIRE_CXX,[
  717. if test -z "$php_cxx_done"; then
  718. AC_PROG_CXX
  719. AC_PROG_CXXCPP
  720. php_cxx_done=yes
  721. fi
  722. ])
  723. dnl
  724. dnl PHP_BUILD_SHARED
  725. dnl
  726. AC_DEFUN(PHP_BUILD_SHARED,[
  727. PHP_BUILD_PROGRAM
  728. OVERALL_TARGET=libphp4.la
  729. php_build_target=shared
  730. php_c_pre=$shared_c_pre
  731. php_c_meta=$shared_c_meta
  732. php_c_post=$shared_c_post
  733. php_cxx_pre=$shared_cxx_pre
  734. php_cxx_meta=$shared_cxx_meta
  735. php_cxx_post=$shared_cxx_post
  736. php_lo=$shared_lo
  737. ])
  738. dnl
  739. dnl PHP_BUILD_STATIC
  740. dnl
  741. AC_DEFUN(PHP_BUILD_STATIC,[
  742. PHP_BUILD_PROGRAM
  743. OVERALL_TARGET=libphp4.la
  744. php_build_target=static
  745. ])
  746. dnl
  747. dnl PHP_BUILD_BUNDLE
  748. dnl
  749. AC_DEFUN(PHP_BUILD_BUNDLE,[
  750. PHP_BUILD_PROGRAM
  751. OVERALL_TARGET=libs/libphp4.bundle
  752. php_build_target=static
  753. ])
  754. dnl
  755. dnl PHP_BUILD_PROGRAM
  756. dnl
  757. AC_DEFUN(PHP_BUILD_PROGRAM,[
  758. OVERALL_TARGET=[]ifelse($1,,php,$1)
  759. php_c_pre='$(CC)'
  760. php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
  761. php_c_post=' && echo > $[@]'
  762. php_cxx_pre='$(CXX)'
  763. php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
  764. php_cxx_post=' && echo > $[@]'
  765. php_lo=o
  766. shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  767. shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -prefer-pic'
  768. shared_c_post=
  769. shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  770. shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) -prefer-pic'
  771. shared_cxx_post=
  772. shared_lo=lo
  773. php_build_target=program
  774. ])
  775. dnl
  776. dnl AC_PHP_ONCE(namespace, variable, code)
  777. dnl
  778. dnl execute code, if variable is not set in namespace
  779. dnl
  780. AC_DEFUN(AC_PHP_ONCE,[
  781. changequote({,})
  782. unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'`
  783. changequote([,])
  784. cmd="echo $ac_n \"\$$1$unique$ac_c\""
  785. if test -n "$unique" && test "`eval $cmd`" = "" ; then
  786. eval "$1$unique=set"
  787. $3
  788. fi
  789. ])
  790. dnl
  791. dnl PHP_EXPAND_PATH(path, variable)
  792. dnl
  793. dnl expands path to an absolute path and assigns it to variable
  794. dnl
  795. AC_DEFUN(PHP_EXPAND_PATH,[
  796. if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
  797. $2=$1
  798. else
  799. changequote({,})
  800. ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`"
  801. changequote([,])
  802. ep_realdir="`(cd \"$ep_dir\" && pwd)`"
  803. $2="$ep_realdir/`basename \"$1\"`"
  804. fi
  805. ])
  806. dnl
  807. dnl internal, don't use
  808. AC_DEFUN(PHP_ADD_LIBPATH_GLOBAL,[
  809. AC_PHP_ONCE(LIBPATH, $1, [
  810. test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1"
  811. LDFLAGS="$LDFLAGS -L$1"
  812. PHP_RPATHS="$PHP_RPATHS $1"
  813. ])
  814. ])dnl
  815. dnl
  816. dnl
  817. dnl
  818. dnl PHP_ADD_LIBPATH(path[, shared-libadd])
  819. dnl
  820. dnl add a library to linkpath/runpath
  821. dnl
  822. AC_DEFUN(PHP_ADD_LIBPATH,[
  823. if test "$1" != "/usr/lib"; then
  824. PHP_EXPAND_PATH($1, ai_p)
  825. ifelse([$2],,[
  826. PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  827. ],[
  828. if test "$ext_shared" = "yes"; then
  829. $2="$ld_runpath_switch$ai_p -L$ai_p [$]$2"
  830. else
  831. PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  832. fi
  833. ])
  834. fi
  835. ])
  836. dnl
  837. dnl PHP_UTILIZE_RPATHS()
  838. dnl
  839. dnl builds RPATHS/LDFLAGS from PHP_RPATHS
  840. dnl
  841. AC_DEFUN(PHP_UTILIZE_RPATHS,[
  842. OLD_RPATHS=$PHP_RPATHS
  843. unset PHP_RPATHS
  844. for i in $OLD_RPATHS; do
  845. dnl Can be passed to native cc/libtool
  846. PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
  847. dnl Libtool-specific
  848. PHP_RPATHS="$PHP_RPATHS -R $i"
  849. dnl cc-specific
  850. NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
  851. done
  852. if test "$PHP_RPATH" = "no"; then
  853. unset PHP_RPATHS
  854. unset NATIVE_RPATHS
  855. fi
  856. ])
  857. dnl
  858. dnl PHP_ADD_INCLUDE(path [,before])
  859. dnl
  860. dnl add an include path.
  861. dnl if before is 1, add in the beginning of INCLUDES.
  862. dnl
  863. AC_DEFUN(PHP_ADD_INCLUDE,[
  864. if test "$1" != "/usr/include"; then
  865. PHP_EXPAND_PATH($1, ai_p)
  866. AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
  867. if test "$2"; then
  868. INCLUDES="-I$ai_p $INCLUDES"
  869. else
  870. INCLUDES="$INCLUDES -I$ai_p"
  871. fi
  872. ])
  873. fi
  874. ])
  875. dnl
  876. dnl internal, don't use
  877. AC_DEFUN(PHP_X_ADD_LIBRARY,[dnl
  878. ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl
  879. ])dnl
  880. dnl
  881. dnl internal, don't use
  882. AC_DEFUN(PHP_ADD_LIBRARY_SKELETON,[
  883. case $1 in
  884. c|c_r|pthread*[)] ;;
  885. *[)] ifelse($3,,[
  886. PHP_X_ADD_LIBRARY($1,$2,$5)
  887. ],[
  888. if test "$ext_shared" = "yes"; then
  889. PHP_X_ADD_LIBRARY($1,$2,$3)
  890. else
  891. $4($1,$2)
  892. fi
  893. ]) ;;
  894. esac
  895. ])dnl
  896. dnl
  897. dnl
  898. dnl
  899. dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
  900. dnl
  901. dnl add a library to the link line
  902. dnl
  903. AC_DEFUN(PHP_ADD_LIBRARY,[
  904. PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS])
  905. ])
  906. dnl
  907. dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]])
  908. dnl
  909. dnl add a library to the link line (deferred)
  910. dnl
  911. AC_DEFUN(PHP_ADD_LIBRARY_DEFER,[
  912. PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS])
  913. ])
  914. dnl
  915. dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
  916. dnl
  917. dnl add a library to the link line and path to linkpath/runpath.
  918. dnl if shared-libadd is not empty and $ext_shared is yes,
  919. dnl shared-libadd will be assigned the library information
  920. dnl
  921. AC_DEFUN(PHP_ADD_LIBRARY_WITH_PATH,[
  922. ifelse($3,,[
  923. if test -n "$2"; then
  924. PHP_ADD_LIBPATH($2)
  925. fi
  926. PHP_ADD_LIBRARY($1)
  927. ],[
  928. if test "$ext_shared" = "yes"; then
  929. $3="-l$1 [$]$3"
  930. if test -n "$2"; then
  931. PHP_ADD_LIBPATH($2,$3)
  932. fi
  933. else
  934. PHP_ADD_LIBRARY_WITH_PATH($1,$2)
  935. fi
  936. ])
  937. ])
  938. dnl
  939. dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd])
  940. dnl
  941. dnl add a library to the link line (deferred)
  942. dnl and path to linkpath/runpath (not deferred)
  943. dnl if shared-libadd is not empty and $ext_shared is yes,
  944. dnl shared-libadd will be assigned the library information
  945. dnl
  946. AC_DEFUN(PHP_ADD_LIBRARY_DEFER_WITH_PATH,[
  947. ifelse($3,,[
  948. if test -n "$2"; then
  949. PHP_ADD_LIBPATH($2)
  950. fi
  951. PHP_ADD_LIBRARY_DEFER($1)
  952. ],[
  953. if test "$ext_shared" = "yes"; then
  954. $3="-l$1 [$]$3"
  955. if test -n "$2"; then
  956. PHP_ADD_LIBPATH($2,$3)
  957. fi
  958. else
  959. PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2)
  960. fi
  961. ])
  962. ])
  963. dnl
  964. dnl PHP_ADD_FRAMEWORK(framework [,before])
  965. dnl
  966. dnl add a (Darwin / Mac OS X) framework to the link
  967. dnl line. if before is 1, the framework is added
  968. dnl to the beginning of the line.
  969. AC_DEFUN(PHP_ADD_FRAMEWORK, [
  970. AC_PHP_ONCE(FRAMEWORKS, $1, [
  971. if test "$2"; then
  972. PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS"
  973. else
  974. PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1"
  975. fi
  976. ])
  977. ])
  978. dnl
  979. dnl PHP_ADD_FRAMEWORKPATH(path [,before])
  980. dnl
  981. dnl add a (Darwin / Mac OS X) framework path to the link
  982. dnl and include lines. default paths include (but are
  983. dnl not limited to) /Local/Library/Frameworks and
  984. dnl /System/Library/Frameworks, so these don't need
  985. dnl to be specifically added. if before is 1, the
  986. dnl framework path is added to the beginning of the
  987. dnl relevant lines.
  988. AC_DEFUN(PHP_ADD_FRAMEWORKPATH, [
  989. PHP_EXPAND_PATH($1, ai_p)
  990. AC_PHP_ONCE(FRAMEWORKPATH, $ai_p, [
  991. if test "$2"; then
  992. PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH"
  993. else
  994. PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p"
  995. fi
  996. ])
  997. ])
  998. dnl
  999. dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path)
  1000. dnl
  1001. dnl add a (Darwin / Mac OS X) framework path and the
  1002. dnl framework itself to the link and include lines.
  1003. AC_DEFUN(PHP_ADD_FRAMEWORK_WITH_PATH, [
  1004. PHP_ADD_FRAMEWORKPATH($2)
  1005. PHP_ADD_FRAMEWORK($1)
  1006. ])
  1007. dnl
  1008. dnl Set libtool variable
  1009. dnl
  1010. AC_DEFUN(PHP_SET_LIBTOOL_VARIABLE,[
  1011. LIBTOOL='$(SHELL) libtool $1'
  1012. ])
  1013. dnl
  1014. dnl Check for cc option
  1015. dnl
  1016. AC_DEFUN(PHP_CHECK_CC_OPTION,[
  1017. echo "main(){return 0;}" > conftest.$ac_ext
  1018. opt=$1
  1019. changequote({,})
  1020. var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'`
  1021. changequote([,])
  1022. AC_MSG_CHECKING([if compiler supports -$1 really])
  1023. ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1"
  1024. if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then
  1025. eval php_cc_$var=no
  1026. AC_MSG_RESULT([no])
  1027. else
  1028. if eval ./conftest 2>/dev/null ; then
  1029. eval php_cc_$var=yes
  1030. AC_MSG_RESULT([yes])
  1031. else
  1032. eval php_cc_$var=no
  1033. AC_MSG_RESULT([no])
  1034. fi
  1035. fi
  1036. ])
  1037. AC_DEFUN(PHP_REGEX,[
  1038. if test "$REGEX_TYPE" = "php"; then
  1039. AC_DEFINE(HSREGEX,1,[ ])
  1040. AC_DEFINE(REGEX,1,[ ])
  1041. PHP_ADD_SOURCES(regex, regcomp.c regexec.c regerror.c regfree.c)
  1042. elif test "$REGEX_TYPE" = "system"; then
  1043. AC_DEFINE(REGEX,0,[ ])
  1044. fi
  1045. AC_MSG_CHECKING([which regex library to use])
  1046. AC_MSG_RESULT([$REGEX_TYPE])
  1047. ])
  1048. dnl
  1049. dnl See if we have broken header files like SunOS has.
  1050. dnl
  1051. AC_DEFUN(PHP_MISSING_FCLOSE_DECL,[
  1052. AC_MSG_CHECKING([for fclose declaration])
  1053. AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
  1054. AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
  1055. AC_MSG_RESULT([ok])
  1056. ],[
  1057. AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
  1058. AC_MSG_RESULT([missing])
  1059. ])
  1060. ])
  1061. dnl
  1062. dnl Check for broken sprintf(), C99 conformance
  1063. dnl
  1064. AC_DEFUN(PHP_AC_BROKEN_SPRINTF,[
  1065. AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
  1066. AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
  1067. ac_cv_broken_sprintf=no
  1068. ],[
  1069. ac_cv_broken_sprintf=yes
  1070. ],[
  1071. ac_cv_broken_sprintf=no
  1072. ])
  1073. ])
  1074. if test "$ac_cv_broken_sprintf" = "yes"; then
  1075. AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform])
  1076. else
  1077. AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform])
  1078. fi
  1079. ])
  1080. dnl
  1081. dnl Check for broken snprintf(), C99 conformance
  1082. dnl
  1083. AC_DEFUN(PHP_AC_BROKEN_SNPRINTF,[
  1084. AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[
  1085. AC_TRY_RUN([
  1086. #define NULL (0L)
  1087. main() {
  1088. char buf[20];
  1089. int res = 0;
  1090. res = res || (snprintf(buf, 2, "marcus") != 6);
  1091. res = res || (buf[1] != '\0');
  1092. res = res || (snprintf(buf, 0, "boerger") != 7);
  1093. res = res || (buf[0] != 'm');
  1094. res = res || (snprintf(NULL, 0, "boerger") != 7);
  1095. res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
  1096. exit(res);
  1097. }
  1098. ],[
  1099. ac_cv_broken_snprintf=no
  1100. ],[
  1101. ac_cv_broken_snprintf=yes
  1102. ],[
  1103. ac_cv_broken_snprintf=no
  1104. ])
  1105. ])
  1106. if test "$ac_cv_broken_snprintf" = "yes"; then
  1107. AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform])
  1108. else
  1109. AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform])
  1110. fi
  1111. ])
  1112. dnl PHP_SHARED_MODULE(module-name, object-var, build-dir)
  1113. dnl
  1114. dnl Basically sets up the link-stage for building module-name
  1115. dnl from object_var in build-dir.
  1116. dnl
  1117. AC_DEFUN(PHP_SHARED_MODULE,[
  1118. PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.la"
  1119. PHP_SUBST($2)
  1120. cat >>Makefile.objects<<EOF
  1121. \$(phplibdir)/$1.la: $3/$1.la
  1122. \$(LIBTOOL) --mode=install cp $3/$1.la \$(phplibdir)
  1123. $3/$1.la: \$($2) \$(translit($1,a-z-,A-Z_)_SHARED_DEPENDENCIES)
  1124. \$(LIBTOOL) --mode=link \$(CC) \$(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)
  1125. EOF
  1126. ])
  1127. dnl
  1128. dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
  1129. dnl
  1130. dnl Selects the SAPI name and type (static, shared, programm)
  1131. dnl and optionally also the source-files for the SAPI-specific
  1132. dnl objects.
  1133. dnl
  1134. AC_DEFUN(PHP_SELECT_SAPI,[
  1135. PHP_SAPI=$1
  1136. case "$2" in
  1137. static) PHP_BUILD_STATIC;;
  1138. shared) PHP_BUILD_SHARED;;
  1139. bundle) PHP_BUILD_BUNDLE;;
  1140. program) PHP_BUILD_PROGRAM($5);;
  1141. esac
  1142. ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
  1143. ])
  1144. dnl deprecated
  1145. AC_DEFUN(PHP_EXTENSION,[
  1146. sources=`awk -f $abs_srcdir/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
  1147. PHP_NEW_EXTENSION($1, $sources, $2, $3)
  1148. if test -r "$ext_srcdir/Makefile.frag"; then
  1149. PHP_ADD_MAKEFILE_FRAGMENT
  1150. fi
  1151. ])
  1152. AC_DEFUN(PHP_ADD_BUILD_DIR,[
  1153. BUILD_DIR="$BUILD_DIR $1"
  1154. ])
  1155. AC_DEFUN(PHP_GEN_BUILD_DIRS,[
  1156. PHP_MKDIR_P_CHECK
  1157. if test "$ac_cv_mkdir_p" = "yes"; then
  1158. mkdir -p $BUILD_DIR
  1159. fi
  1160. ])
  1161. dnl
  1162. dnl PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])
  1163. dnl
  1164. dnl Includes an extension in the build.
  1165. dnl
  1166. dnl "extname" is the name of the ext/ subdir where the extension resides.
  1167. dnl "sources" is a list of files relative to the subdir which are used
  1168. dnl to build the extension.
  1169. dnl "shared" can be set to "shared" or "yes" to build the extension as
  1170. dnl a dynamically loadable library. Optional parameter "sapi_class" can
  1171. dnl be set to "cli" to mark extension build only with CLI or CGI sapi's.
  1172. dnl extra-cflags are passed to the compiler, with @ext_srcdir@ being
  1173. dnl substituted.
  1174. AC_DEFUN(PHP_NEW_EXTENSION,[
  1175. ext_builddir=[]PHP_EXT_BUILDDIR($1)
  1176. ext_srcdir=[]PHP_EXT_SRCDIR($1)
  1177. ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|sed s#@ext_srcdir@#$ext_srcdir#g`])
  1178. if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then
  1179. dnl ---------------------------------------------- Static module
  1180. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
  1181. EXT_STATIC="$EXT_STATIC $1"
  1182. if test "$3" != "nocli"; then
  1183. EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
  1184. fi
  1185. else
  1186. if test "$3" = "shared" || test "$3" = "yes"; then
  1187. dnl ---------------------------------------------- Shared module
  1188. PHP_ADD_SOURCES_X(PHP_EXT_DIR($1),$2,$ac_extra,shared_objects_$1,yes)
  1189. PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir)
  1190. AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
  1191. fi
  1192. fi
  1193. if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then
  1194. dnl ---------------------------------------------- CLI static module
  1195. if test "$PHP_SAPI" = "cgi"; then
  1196. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
  1197. EXT_STATIC="$EXT_STATIC $1"
  1198. else
  1199. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cli)
  1200. fi
  1201. EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
  1202. fi
  1203. PHP_ADD_BUILD_DIR($ext_builddir)
  1204. ])
  1205. dnl
  1206. dnl Solaris requires main code to be position independent in order
  1207. dnl to let shared objects find symbols. Weird. Ugly.
  1208. dnl
  1209. dnl Must be run after all --with-NN options that let the user
  1210. dnl choose dynamic extensions, and after the gcc test.
  1211. dnl
  1212. AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[
  1213. AC_MSG_CHECKING([whether -fPIC is required])
  1214. if test -n "$EXT_SHARED"; then
  1215. os=`uname -sr 2>/dev/null`
  1216. case $os in
  1217. "SunOS 5.6"|"SunOS 5.7")
  1218. case $CC in
  1219. gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
  1220. *) CFLAGS="$CFLAGS -fpic";;
  1221. esac
  1222. AC_MSG_RESULT([yes]);;
  1223. *)
  1224. AC_MSG_RESULT([no]);;
  1225. esac
  1226. else
  1227. AC_MSG_RESULT([no])
  1228. fi
  1229. ])
  1230. dnl
  1231. dnl Checks whether $withval is "shared" or starts with "shared,XXX"
  1232. dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
  1233. dnl from $withval.
  1234. dnl
  1235. AC_DEFUN(PHP_WITH_SHARED,[
  1236. PHP_ARG_ANALYZE_EX(withval)
  1237. shared=$ext_shared
  1238. unset ext_shared ext_output
  1239. ])
  1240. dnl The problem is that the default compilation flags in Solaris 2.6 won't
  1241. dnl let programs access large files; you need to tell the compiler that
  1242. dnl you actually want your programs to work on large files. For more
  1243. dnl details about this brain damage please see:
  1244. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  1245. dnl Written by Paul Eggert <eggert@twinsun.com>.
  1246. AC_DEFUN(PHP_SYS_LFS,
  1247. [dnl
  1248. # If available, prefer support for large files unless the user specified
  1249. # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
  1250. AC_MSG_CHECKING([whether large file support needs explicit enabling])
  1251. ac_getconfs=''
  1252. ac_result=yes
  1253. ac_set=''
  1254. ac_shellvars='CPPFLAGS LDFLAGS LIBS'
  1255. for ac_shellvar in $ac_shellvars; do
  1256. case $ac_shellvar in
  1257. CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
  1258. *) ac_lfsvar=LFS_$ac_shellvar ;;
  1259. esac
  1260. eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
  1261. (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
  1262. ac_getconf=`getconf $ac_lfsvar`
  1263. ac_getconfs=$ac_getconfs$ac_getconf
  1264. eval ac_test_$ac_shellvar=\$ac_getconf
  1265. done
  1266. case "$ac_result$ac_getconfs" in
  1267. yes) ac_result=no ;;
  1268. esac
  1269. case "$ac_result$ac_set" in
  1270. yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
  1271. esac
  1272. AC_MSG_RESULT([$ac_result])
  1273. case $ac_result in
  1274. yes)
  1275. for ac_shellvar in $ac_shellvars; do
  1276. eval $ac_shellvar=\$ac_test_$ac_shellvar
  1277. done ;;
  1278. esac
  1279. ])
  1280. AC_DEFUN(PHP_SOCKADDR_SA_LEN,[
  1281. AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  1282. AC_TRY_COMPILE([#include <sys/types.h>
  1283. #include <sys/socket.h>],
  1284. [struct sockaddr s; s.sa_len;],
  1285. [ac_cv_sockaddr_sa_len=yes
  1286. AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[ ])],
  1287. [ac_cv_sockaddr_sa_len=no])
  1288. ])
  1289. ])
  1290. dnl ## PHP_OUTPUT(file)
  1291. dnl ## adds "file" to the list of files generated by AC_OUTPUT
  1292. dnl ## This macro can be used several times.
  1293. AC_DEFUN(PHP_OUTPUT,[
  1294. PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  1295. ])
  1296. AC_DEFUN(PHP_DECLARED_TIMEZONE,[
  1297. AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
  1298. AC_TRY_COMPILE([
  1299. #include <sys/types.h>
  1300. #include <time.h>
  1301. #ifdef HAVE_SYS_TIME_H
  1302. #include <sys/time.h>
  1303. #endif
  1304. ],[
  1305. time_t foo = (time_t) timezone;
  1306. ],[
  1307. ac_cv_declared_timezone=yes
  1308. ],[
  1309. ac_cv_declared_timezone=no
  1310. ])])
  1311. if test "$ac_cv_declared_timezone" = "yes"; then
  1312. AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
  1313. fi
  1314. ])
  1315. AC_DEFUN(PHP_EBCDIC,[
  1316. AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
  1317. AC_TRY_RUN( [
  1318. int main(void) {
  1319. return (unsigned char)'A' != (unsigned char)0xC1;
  1320. }
  1321. ],[
  1322. ac_cv_ebcdic=yes
  1323. ],[
  1324. ac_cv_ebcdic=no
  1325. ],[
  1326. ac_cv_ebcdic=no
  1327. ])])
  1328. if test "$ac_cv_ebcdic" = "yes"; then
  1329. AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
  1330. fi
  1331. ])
  1332. AC_DEFUN(PHP_FOPENCOOKIE,[
  1333. AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ])
  1334. if test "$have_glibc_fopencookie" = "yes" ; then
  1335. dnl this comes in two flavors:
  1336. dnl newer glibcs (since 2.1.2 ? )
  1337. dnl have a type called cookie_io_functions_t
  1338. AC_TRY_COMPILE([ #define _GNU_SOURCE
  1339. #include <stdio.h>
  1340. ],
  1341. [ cookie_io_functions_t cookie; ],
  1342. [ have_cookie_io_functions_t=yes ],
  1343. [] )
  1344. if test "$have_cookie_io_functions_t" = "yes" ; then
  1345. cookie_io_functions_t=cookie_io_functions_t
  1346. have_fopen_cookie=yes
  1347. dnl even newer glibcs have a different seeker definition...
  1348. AC_TRY_RUN([
  1349. #define _GNU_SOURCE
  1350. #include <stdio.h>
  1351. struct cookiedata {
  1352. fpos_t pos;
  1353. };
  1354. size_t reader(void *cookie, char *buffer, size_t size)
  1355. { return size; }
  1356. size_t writer(void *cookie, const char *buffer, size_t size)
  1357. { return size; }
  1358. int closer(void *cookie)
  1359. { return 0; }
  1360. int seeker(void *cookie, fpos_t *position, int whence)
  1361. { ((struct cookiedata*)cookie)->pos = *position; return 0; }
  1362. cookie_io_functions_t funcs = {reader, writer, seeker, closer};
  1363. main() {
  1364. struct cookiedata g = { 0 };
  1365. FILE *fp = fopencookie(&g, "r", funcs);
  1366. if (fp && fseek(fp, 69, SEEK_SET) == 0 && g.pos == 69)
  1367. exit(0);
  1368. exit(1);
  1369. }
  1370. ],
  1371. [ cookie_io_functions_use_fpos_t=yes ],
  1372. [ ] )
  1373. else
  1374. dnl older glibc versions (up to 2.1.2 ?)
  1375. dnl call it _IO_cookie_io_functions_t
  1376. AC_TRY_COMPILE([ #define _GNU_SOURCE
  1377. #include <stdio.h>
  1378. ],
  1379. [ _IO_cookie_io_functions_t cookie; ],
  1380. [ have_IO_cookie_io_functions_t=yes ],
  1381. [] )
  1382. if test "$have_cookie_io_functions_t" = "yes" ; then
  1383. cookie_io_functions_t=_IO_cookie_io_functions_t
  1384. have_fopen_cookie=yes
  1385. fi
  1386. fi
  1387. if test "$have_fopen_cookie" = "yes" ; then
  1388. AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
  1389. AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
  1390. if test "$cookie_io_functions_use_fpos_t" = "yes" ; then
  1391. AC_DEFINE(COOKIE_SEEKER_USES_FPOS_T, 1, [ ])
  1392. fi
  1393. fi
  1394. fi
  1395. ])
  1396. dnl
  1397. dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
  1398. dnl
  1399. dnl Wrapper for AC_CHECK_LIB
  1400. dnl
  1401. AC_DEFUN(PHP_CHECK_LIBRARY, [
  1402. save_old_LDFLAGS=$LDFLAGS
  1403. LDFLAGS="$5 $LDFLAGS"
  1404. AC_CHECK_LIB([$1],[$2],[
  1405. LDFLAGS=$save_old_LDFLAGS
  1406. $3
  1407. ],[
  1408. LDFLAGS=$save_old_LDFLAGS
  1409. $4
  1410. ])dnl
  1411. ])
  1412. dnl
  1413. dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]])
  1414. dnl
  1415. dnl El cheapo wrapper for AC_CHECK_LIB
  1416. dnl
  1417. AC_DEFUN(PHP_CHECK_FRAMEWORK, [
  1418. save_old_LDFLAGS=$LDFLAGS
  1419. LDFLAGS="-framework $1 $LDFLAGS"
  1420. dnl supplying "c" to AC_CHECK_LIB is technically cheating, but
  1421. dnl rewriting AC_CHECK_LIB is overkill and this only affects
  1422. dnl the "checking.." output anyway.
  1423. AC_CHECK_LIB(c,[$2],[
  1424. LDFLAGS=$save_old_LDFLAGS
  1425. $3
  1426. ],[
  1427. LDFLAGS=$save_old_LDFLAGS
  1428. $4
  1429. ])
  1430. ])
  1431. dnl
  1432. dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
  1433. dnl
  1434. dnl Common setup macro for iconv
  1435. dnl
  1436. AC_DEFUN(PHP_SETUP_ICONV, [
  1437. found_iconv=no
  1438. unset ICONV_DIR
  1439. dnl
  1440. dnl Check libc first if no path is provided in --with-iconv
  1441. dnl
  1442. if test "$PHP_ICONV" = "yes"; then
  1443. AC_CHECK_FUNC(iconv, [
  1444. PHP_DEFINE(HAVE_ICONV)
  1445. found_iconv=yes
  1446. ],[
  1447. AC_CHECK_FUNC(libiconv,[
  1448. PHP_DEFINE(HAVE_LIBICONV)
  1449. found_iconv=yes
  1450. ])
  1451. ])
  1452. fi
  1453. dnl
  1454. dnl Check external libs for iconv funcs
  1455. dnl
  1456. if test "$found_iconv" = "no"; then
  1457. for i in $PHP_ICONV /usr/local /usr; do
  1458. if test -r $i/include/giconv.h; then
  1459. AC_DEFINE(HAVE_GICONV_H, 1, [ ])
  1460. ICONV_DIR=$i
  1461. iconv_lib_name=giconv
  1462. break
  1463. elif test -r $i/include/iconv.h; then
  1464. ICONV_DIR=$i
  1465. iconv_lib_name=iconv
  1466. break
  1467. fi
  1468. done
  1469. if test -z "$ICONV_DIR"; then
  1470. AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
  1471. fi
  1472. if test -f $ICONV_DIR/lib/lib$iconv_lib_name.a ||
  1473. test -f $ICONV_DIR/lib/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
  1474. then
  1475. PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
  1476. found_iconv=yes
  1477. PHP_DEFINE(HAVE_LIBICONV)
  1478. ], [
  1479. PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
  1480. found_iconv=yes
  1481. PHP_DEFINE(HAVE_ICONV)
  1482. ], [], [
  1483. -L$ICONV_DIR/lib
  1484. ])
  1485. ], [
  1486. -L$ICONV_DIR/lib
  1487. ])
  1488. fi
  1489. fi
  1490. if test "$found_iconv" = "yes"; then
  1491. if test -n "$ICONV_DIR"; then
  1492. AC_DEFINE(HAVE_ICONV, 1, [ ])
  1493. PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/lib, $1)
  1494. PHP_ADD_INCLUDE($ICONV_DIR/include)
  1495. fi
  1496. $2
  1497. ifelse([$3],[],,[else $3])
  1498. fi
  1499. ])
  1500. AC_DEFUN(PHP_DEF_HAVE,[AC_DEFINE([HAVE_]translit($1,a-z_-,A-Z__), 1, [ ])])
  1501. dnl
  1502. dnl PHP_CHECK_FUNC_LIB(func, libs)
  1503. dnl This macro checks whether 'func' or '__func' exists
  1504. dnl in the specified library.
  1505. dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
  1506. dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC
  1507. dnl
  1508. dnl autoconf undefines the builtin "shift" :-(
  1509. dnl If possible, we use the builtin shift anyway, otherwise we use
  1510. dnl the ubercool definition I have tested so far with FreeBSD/GNU m4
  1511. ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
  1512. define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
  1513. ])
  1514. AC_DEFUN(PHP_CHECK_FUNC_LIB,[
  1515. ifelse($2,,:,[
  1516. unset ac_cv_lib_$2[]_$1
  1517. unset ac_cv_lib_$2[]___$1
  1518. unset found
  1519. AC_CHECK_LIB($2, $1, [found=yes], [
  1520. AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
  1521. ])
  1522. if test "$found" = "yes"; then
  1523. PHP_ADD_LIBRARY($2)
  1524. PHP_DEF_HAVE($1)
  1525. PHP_DEF_HAVE(lib$2)
  1526. ac_cv_func_$1=yes
  1527. else
  1528. PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
  1529. fi
  1530. ])
  1531. ])
  1532. dnl
  1533. dnl PHP_CHECK_FUNC(func, ...)
  1534. dnl This macro checks whether 'func' or '__func' exists
  1535. dnl in the default libraries and as a fall back in the specified library.
  1536. dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
  1537. dnl
  1538. AC_DEFUN(PHP_CHECK_FUNC,[
  1539. unset ac_cv_func_$1
  1540. unset ac_cv_func___$1
  1541. unset found
  1542. AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
  1543. case $found in
  1544. yes)
  1545. PHP_DEF_HAVE($1)
  1546. ac_cv_func_$1=yes
  1547. ;;
  1548. ifelse($#,1,,[
  1549. *) PHP_CHECK_FUNC_LIB($@) ;;
  1550. ])
  1551. esac
  1552. ])
  1553. dnl
  1554. dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
  1555. dnl This macro is used to get a comparable
  1556. dnl version for apache1/2.
  1557. dnl
  1558. AC_DEFUN(PHP_AP_EXTRACT_VERSION,[
  1559. ac_output=`$1 -v 2>&1`
  1560. ac_IFS=$IFS
  1561. IFS="- /.
  1562. "
  1563. set $ac_output
  1564. IFS=$ac_IFS
  1565. APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
  1566. ])
  1567. dnl PHP_PROG_SED
  1568. dnl ------------
  1569. dnl Check for a fully-functional sed program, that truncates
  1570. dnl as few characters as possible. Prefer GNU sed if found.
  1571. dnl
  1572. dnl Based on LT_AC_PROG_SED (libtool CVS)
  1573. dnl
  1574. AC_DEFUN([PHP_PROG_SED],
  1575. [AC_MSG_CHECKING([for a sed that does not truncate output])
  1576. AC_CACHE_VAL(ac_cv_path_sed,
  1577. [# Loop through the user's path and test for sed and gsed.
  1578. # Then use that list of sed's as ones to test for truncation.
  1579. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  1580. for as_dir in $PATH; do
  1581. IFS=$as_save_IFS
  1582. test -z "$as_dir" && as_dir=.
  1583. for ac_prog in sed gsed; do
  1584. if test -x "$as_dir/$ac_prog"; then
  1585. _sed_list="$_sed_list $as_dir/$ac_prog"
  1586. fi
  1587. done
  1588. done
  1589. # Create a temporary directory, and hook for its removal unless debugging.
  1590. $debug ||
  1591. {
  1592. trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
  1593. trap '{ (exit 1); exit 1; }' 1 2 13 15
  1594. }
  1595. # Create a (secure) tmp directory for tmp files.
  1596. : ${TMPDIR=/tmp}
  1597. {
  1598. tmp=`(umask 077 && mktemp -d -q "$TMPDIR/sedXXXXXX") 2>/dev/null` &&
  1599. test -n "$tmp" && test -d "$tmp"
  1600. } ||
  1601. {
  1602. tmp=$TMPDIR/sed$$-$RANDOM
  1603. (umask 077 && mkdir $tmp)
  1604. } ||
  1605. {
  1606. echo "$me: cannot create a temporary directory in $TMPDIR" >&2
  1607. { (exit 1); exit 1; }
  1608. }
  1609. _max=0
  1610. _count=0
  1611. for _sed in $_sed_list; do
  1612. test ! -f ${_sed} && break
  1613. cat /dev/null > "$tmp/sed.in"
  1614. _count=0
  1615. echo -n "0123456789" >"$tmp/sed.in"
  1616. # Check for GNU sed and select it if it is found.
  1617. if "${_sed}" --version 2>&1 < /dev/null | egrep '(GNU)' > /dev/null; then
  1618. ac_cv_path_sed=${_sed}
  1619. break;
  1620. fi
  1621. while true; do
  1622. cat "$tmp/sed.in" "$tmp/sed.in" >"$tmp/sed.tmp"
  1623. mv "$tmp/sed.tmp" "$tmp/sed.in"
  1624. cp "$tmp/sed.in" "$tmp/sed.nl"
  1625. echo >>"$tmp/sed.nl"
  1626. ${_sed} -e 's/a$//' < "$tmp/sed.nl" >"$tmp/sed.out" || break
  1627. cmp -s "$tmp/sed.out" "$tmp/sed.nl" || break
  1628. # 10000 chars as input seems more than enough
  1629. test $_count -gt 10 && break
  1630. _count=`expr $_count + 1`
  1631. if test $_count -gt $_max; then
  1632. _max=$_count
  1633. ac_cv_path_sed=$_sed
  1634. fi
  1635. done
  1636. done
  1637. rm -rf "$tmp"
  1638. ])
  1639. if test -z "$ac_cv_path_sed"; then
  1640. AC_MSG_ERROR([Could not find working sed on this system. Please install GNU sed.])
  1641. else
  1642. SED=$ac_cv_path_sed
  1643. PHP_SUBST(SED)
  1644. AC_MSG_RESULT([$SED])
  1645. fi
  1646. ])