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.

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