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.

1878 lines
46 KiB

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