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.

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