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.

2855 lines
73 KiB

21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
23 years ago
25 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
26 years ago
23 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
27 years ago
21 years ago
25 years ago
21 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
21 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
19 years ago
  1. dnl
  2. dnl $Id$
  3. dnl
  4. dnl This file contains local autoconf functions.
  5. dnl
  6. dnl -------------------------------------------------------------------------
  7. dnl Output stylize macros for configure (help/runtime)
  8. dnl -------------------------------------------------------------------------
  9. dnl
  10. dnl PHP_HELP_SEPARATOR(title)
  11. dnl
  12. dnl Adds separator title into the configure --help display.
  13. dnl
  14. AC_DEFUN([PHP_HELP_SEPARATOR],[
  15. AC_ARG_ENABLE([],[
  16. $1
  17. ],[])
  18. ])
  19. dnl
  20. dnl PHP_CONFIGURE_PART(title)
  21. dnl
  22. dnl Adds separator title configure output (idea borrowed from mm)
  23. dnl
  24. AC_DEFUN([PHP_CONFIGURE_PART],[
  25. AC_MSG_RESULT()
  26. AC_MSG_RESULT([${T_MD}$1${T_ME}])
  27. ])
  28. dnl -------------------------------------------------------------------------
  29. dnl Build system helper macros
  30. dnl -------------------------------------------------------------------------
  31. dnl
  32. dnl PHP_DEF_HAVE(what)
  33. dnl
  34. dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [ ])'
  35. dnl
  36. AC_DEFUN([PHP_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___), 1, [ ])])
  37. dnl
  38. dnl PHP_RUN_ONCE(namespace, variable, code)
  39. dnl
  40. dnl execute code, if variable is not set in namespace
  41. dnl
  42. AC_DEFUN([PHP_RUN_ONCE],[
  43. changequote({,})
  44. unique=`echo $2|$SED 's/[^a-zA-Z0-9]/_/g'`
  45. changequote([,])
  46. cmd="echo $ac_n \"\$$1$unique$ac_c\""
  47. if test -n "$unique" && test "`eval $cmd`" = "" ; then
  48. eval "$1$unique=set"
  49. $3
  50. fi
  51. ])
  52. dnl
  53. dnl PHP_EXPAND_PATH(path, variable)
  54. dnl
  55. dnl expands path to an absolute path and assigns it to variable
  56. dnl
  57. AC_DEFUN([PHP_EXPAND_PATH],[
  58. if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
  59. $2=$1
  60. else
  61. changequote({,})
  62. ep_dir="`echo $1|$SED 's%/*[^/][^/]*/*$%%'`"
  63. changequote([,])
  64. ep_realdir="`(cd \"$ep_dir\" && pwd)`"
  65. $2="$ep_realdir/`basename \"$1\"`"
  66. fi
  67. ])
  68. dnl
  69. dnl PHP_DEFINE(WHAT [, value[, directory]])
  70. dnl
  71. dnl Creates builddir/include/what.h and in there #define WHAT value
  72. dnl
  73. AC_DEFUN([PHP_DEFINE],[
  74. [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > ]ifelse([$3],,[include],[$3])[/php_]translit($1,A-Z,a-z)[.h]
  75. ])
  76. dnl
  77. dnl PHP_SUBST(varname)
  78. dnl
  79. dnl Adds variable with it's value into Makefile, e.g.:
  80. dnl CC = gcc
  81. dnl
  82. AC_DEFUN([PHP_SUBST],[
  83. PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
  84. ])
  85. dnl
  86. dnl PHP_SUBST_OLD(varname)
  87. dnl
  88. dnl Same as PHP_SUBST() but also substitutes all @VARNAME@
  89. dnl instances in every file passed to AC_OUTPUT()
  90. dnl
  91. AC_DEFUN([PHP_SUBST_OLD],[
  92. PHP_SUBST($1)
  93. AC_SUBST($1)
  94. ])
  95. dnl
  96. dnl PHP_OUTPUT(file)
  97. dnl
  98. dnl Adds "file" to the list of files generated by AC_OUTPUT
  99. dnl This macro can be used several times.
  100. dnl
  101. AC_DEFUN([PHP_OUTPUT],[
  102. PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  103. ])
  104. dnl -------------------------------------------------------------------------
  105. dnl Build system base macros
  106. dnl -------------------------------------------------------------------------
  107. dnl
  108. dnl PHP_CANONICAL_HOST_TARGET
  109. dnl
  110. AC_DEFUN([PHP_CANONICAL_HOST_TARGET],[
  111. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  112. AC_REQUIRE([AC_CANONICAL_TARGET])dnl
  113. dnl Make sure we do not continue if host_alias is empty.
  114. if test -z "$host_alias" && test -n "$host"; then
  115. host_alias=$host
  116. fi
  117. if test -z "$host_alias"; then
  118. AC_MSG_ERROR([host_alias is not set!])
  119. fi
  120. ])
  121. dnl
  122. dnl PHP_INIT_BUILD_SYSTEM
  123. dnl
  124. AC_DEFUN([PHP_INIT_BUILD_SYSTEM],[
  125. AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
  126. test -d include || $php_shtool mkdir include
  127. > Makefile.objects
  128. > Makefile.fragments
  129. dnl We need to play tricks here to avoid matching the grep line itself
  130. pattern=define
  131. $EGREP $pattern'.*include/php' $srcdir/configure|$SED 's/.*>//'|xargs touch 2>/dev/null
  132. ])
  133. dnl
  134. dnl PHP_GEN_GLOBAL_MAKEFILE
  135. dnl
  136. dnl Generates the global makefile.
  137. dnl
  138. AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[
  139. cat >Makefile <<EOF
  140. srcdir = $abs_srcdir
  141. builddir = $abs_builddir
  142. top_srcdir = $abs_srcdir
  143. top_builddir = $abs_builddir
  144. EOF
  145. for i in $PHP_VAR_SUBST; do
  146. eval echo "$i = \$$i" >> Makefile
  147. done
  148. cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile
  149. ])
  150. dnl
  151. dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile [, ext_srcdir [, ext_builddir]]])
  152. dnl
  153. dnl Processes a file called Makefile.frag in the source directory
  154. dnl of the most recently added extension. $(srcdir) and $(builddir)
  155. dnl are substituted with the proper paths. Can be used to supply
  156. dnl custom rules and/or additional targets.
  157. dnl
  158. AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[
  159. ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1)
  160. ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2)
  161. ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3)
  162. test -f "$src" && $SED -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
  163. ])
  164. dnl
  165. dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
  166. dnl
  167. dnl Adds sources which are located relative to source-path to the
  168. dnl array of type type. Sources are processed with optional
  169. dnl special-flags which are passed to the compiler. Sources
  170. dnl can be either written in C or C++ (filenames shall end in .c
  171. dnl or .cpp, respectively).
  172. dnl
  173. dnl Note: If source-path begins with a "/", the "/" is removed and
  174. dnl the path is interpreted relative to the top build-directory.
  175. dnl
  176. dnl which array to append to?
  177. AC_DEFUN([PHP_ADD_SOURCES],[
  178. PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,cli,PHP_CLI_OBJS,ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS)))
  179. ])
  180. dnl
  181. dnl _PHP_ASSIGN_BUILD_VARS(type)
  182. dnl internal, don't use
  183. AC_DEFUN([_PHP_ASSIGN_BUILD_VARS],[
  184. ifelse($1,shared,[
  185. b_c_pre=$shared_c_pre
  186. b_cxx_pre=$shared_cxx_pre
  187. b_c_meta=$shared_c_meta
  188. b_cxx_meta=$shared_cxx_meta
  189. b_c_post=$shared_c_post
  190. b_cxx_post=$shared_cxx_post
  191. ],[
  192. b_c_pre=$php_c_pre
  193. b_cxx_pre=$php_cxx_pre
  194. b_c_meta=$php_c_meta
  195. b_cxx_meta=$php_cxx_meta
  196. b_c_post=$php_c_post
  197. b_cxx_post=$php_cxx_post
  198. ])dnl
  199. b_lo=[$]$1_lo
  200. ])
  201. dnl
  202. dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
  203. dnl
  204. dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the
  205. dnl name of the array target-var directly, as well as whether
  206. dnl shared objects will be built from the sources.
  207. dnl
  208. dnl Should not be used directly.
  209. dnl
  210. AC_DEFUN([PHP_ADD_SOURCES_X],[
  211. dnl relative to source- or build-directory?
  212. dnl ac_srcdir/ac_bdir include trailing slash
  213. case $1 in
  214. ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;;
  215. /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;;
  216. *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;;
  217. esac
  218. dnl how to build .. shared or static?
  219. ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php))
  220. dnl iterate over the sources
  221. old_IFS=[$]IFS
  222. for ac_src in $2; do
  223. dnl remove the suffix
  224. IFS=.
  225. set $ac_src
  226. ac_obj=[$]1
  227. IFS=$old_IFS
  228. dnl append to the array which has been dynamically chosen at m4 time
  229. $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
  230. dnl choose the right compiler/flags/etc. for the source-file
  231. case $ac_src in
  232. *.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" ;;
  233. *.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" ;;
  234. *.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" ;;
  235. *.cpp|*.cc|*.cxx[)] 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" ;;
  236. esac
  237. dnl create a rule for the object/source combo
  238. cat >>Makefile.objects<<EOF
  239. $ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src
  240. $ac_comp
  241. EOF
  242. done
  243. ])
  244. dnl -------------------------------------------------------------------------
  245. dnl Compiler characteristics checks
  246. dnl -------------------------------------------------------------------------
  247. dnl
  248. dnl PHP_TARGET_RDYNAMIC
  249. dnl
  250. dnl Checks whether -rdynamic is supported by the compiler. This
  251. dnl is necessary for some targets to populate the global symbol
  252. dnl table. Otherwise, dynamic modules would not be able to resolve
  253. dnl PHP-related symbols.
  254. dnl
  255. dnl If successful, adds -rdynamic to PHP_LDFLAGS.
  256. dnl
  257. AC_DEFUN([PHP_TARGET_RDYNAMIC],[
  258. if test -n "$GCC"; then
  259. dnl we should use a PHP-specific macro here
  260. PHP_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes)
  261. if test "$gcc_rdynamic" = "yes"; then
  262. PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic"
  263. fi
  264. fi
  265. ])
  266. dnl
  267. dnl PHP_RUNPATH_SWITCH
  268. dnl
  269. dnl Checks for -R, etc. switch
  270. dnl
  271. AC_DEFUN([PHP_RUNPATH_SWITCH],[
  272. AC_MSG_CHECKING([if compiler supports -R])
  273. AC_CACHE_VAL(php_cv_cc_dashr,[
  274. SAVE_LIBS=$LIBS
  275. LIBS="-R /usr/$PHP_LIBDIR $LIBS"
  276. AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
  277. LIBS=$SAVE_LIBS])
  278. AC_MSG_RESULT([$php_cv_cc_dashr])
  279. if test $php_cv_cc_dashr = "yes"; then
  280. ld_runpath_switch=-R
  281. else
  282. AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
  283. AC_CACHE_VAL(php_cv_cc_rpath,[
  284. SAVE_LIBS=$LIBS
  285. LIBS="-Wl,-rpath,/usr/$PHP_LIBDIR $LIBS"
  286. AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
  287. LIBS=$SAVE_LIBS])
  288. AC_MSG_RESULT([$php_cv_cc_rpath])
  289. if test $php_cv_cc_rpath = "yes"; then
  290. ld_runpath_switch=-Wl,-rpath,
  291. else
  292. dnl something innocuous
  293. ld_runpath_switch=-L
  294. fi
  295. fi
  296. if test "$PHP_RPATH" = "no"; then
  297. ld_runpath_switch=
  298. fi
  299. ])
  300. dnl
  301. dnl PHP_CHECK_GCC_ARG(arg, action-if-found, action-if-not-found)
  302. dnl
  303. AC_DEFUN([PHP_CHECK_GCC_ARG],[
  304. gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z-,a-z_)
  305. AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z-,a-z_), [
  306. echo 'void somefunc() { };' > conftest.c
  307. cmd='$CC $1 -c conftest.c'
  308. if eval $cmd 2>&1 | $EGREP -e $1 >/dev/null ; then
  309. ac_result=no
  310. else
  311. ac_result=yes
  312. fi
  313. eval $gcc_arg_name=$ac_result
  314. rm -f conftest.*
  315. ])
  316. if eval test "\$$gcc_arg_name" = "yes"; then
  317. $2
  318. else
  319. :
  320. $3
  321. fi
  322. ])
  323. dnl
  324. dnl PHP_LIBGCC_LIBPATH(gcc)
  325. dnl
  326. dnl Stores the location of libgcc in libgcc_libpath
  327. dnl
  328. AC_DEFUN([PHP_LIBGCC_LIBPATH],[
  329. changequote({,})
  330. libgcc_libpath=`$1 --print-libgcc-file-name|$SED 's%/*[^/][^/]*$%%'`
  331. changequote([,])
  332. ])
  333. dnl -------------------------------------------------------------------------
  334. dnl Macros to modify LIBS, INCLUDES, etc. variables
  335. dnl -------------------------------------------------------------------------
  336. dnl
  337. dnl PHP_REMOVE_USR_LIB(NAME)
  338. dnl
  339. dnl Removes all -L/usr/$PHP_LIBDIR entries from variable NAME
  340. dnl
  341. AC_DEFUN([PHP_REMOVE_USR_LIB],[
  342. unset ac_new_flags
  343. for i in [$]$1; do
  344. case [$]i in
  345. -L/usr/$PHP_LIBDIR|-L/usr/$PHP_LIBDIR/[)] ;;
  346. *[)] ac_new_flags="[$]ac_new_flags [$]i" ;;
  347. esac
  348. done
  349. $1=[$]ac_new_flags
  350. ])
  351. dnl
  352. dnl PHP_EVAL_LIBLINE(libline, SHARED-LIBADD)
  353. dnl
  354. dnl Use this macro, if you need to add libraries and or library search
  355. dnl paths to the PHP build system which are only given in compiler
  356. dnl notation.
  357. dnl
  358. AC_DEFUN([PHP_EVAL_LIBLINE],[
  359. for ac_i in $1; do
  360. case $ac_i in
  361. -pthread[)]
  362. if test "$ext_shared" = "yes"; then
  363. $2="[$]$2 -pthread"
  364. else
  365. PHP_RUN_ONCE(EXTRA_LDFLAGS, [$ac_i], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ac_i"])
  366. fi
  367. ;;
  368. -l*[)]
  369. ac_ii=`echo $ac_i|cut -c 3-`
  370. PHP_ADD_LIBRARY($ac_ii,1,$2)
  371. ;;
  372. -L*[)]
  373. ac_ii=`echo $ac_i|cut -c 3-`
  374. PHP_ADD_LIBPATH($ac_ii,$2)
  375. ;;
  376. esac
  377. done
  378. ])
  379. dnl
  380. dnl PHP_EVAL_INCLINE(headerline)
  381. dnl
  382. dnl Use this macro, if you need to add header search paths to the PHP
  383. dnl build system which are only given in compiler notation.
  384. dnl
  385. AC_DEFUN([PHP_EVAL_INCLINE],[
  386. for ac_i in $1; do
  387. case $ac_i in
  388. -I*[)]
  389. ac_ii=`echo $ac_i|cut -c 3-`
  390. PHP_ADD_INCLUDE($ac_ii)
  391. ;;
  392. esac
  393. done
  394. ])
  395. dnl internal, don't use
  396. AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[
  397. PHP_RUN_ONCE(LIBPATH, $1, [
  398. test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1"
  399. LDFLAGS="$LDFLAGS -L$1"
  400. PHP_RPATHS="$PHP_RPATHS $1"
  401. ])
  402. ])dnl
  403. dnl
  404. dnl
  405. dnl PHP_ADD_LIBPATH(path [, SHARED-LIBADD])
  406. dnl
  407. dnl Adds a path to linkpath/runpath (LDFLAGS)
  408. dnl
  409. AC_DEFUN([PHP_ADD_LIBPATH],[
  410. if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
  411. PHP_EXPAND_PATH($1, ai_p)
  412. ifelse([$2],,[
  413. _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  414. ],[
  415. if test "$ext_shared" = "yes"; then
  416. $2="-L$ai_p [$]$2"
  417. test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2"
  418. else
  419. _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  420. fi
  421. ])
  422. fi
  423. ])
  424. dnl
  425. dnl PHP_UTILIZE_RPATHS()
  426. dnl
  427. dnl builds RPATHS/LDFLAGS from PHP_RPATHS
  428. dnl
  429. AC_DEFUN([PHP_UTILIZE_RPATHS],[
  430. OLD_RPATHS=$PHP_RPATHS
  431. unset PHP_RPATHS
  432. for i in $OLD_RPATHS; do
  433. dnl Can be passed to native cc/libtool
  434. PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
  435. dnl Libtool-specific
  436. PHP_RPATHS="$PHP_RPATHS -R $i"
  437. dnl cc-specific
  438. NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
  439. done
  440. if test "$PHP_RPATH" = "no"; then
  441. unset PHP_RPATHS
  442. unset NATIVE_RPATHS
  443. fi
  444. ])
  445. dnl
  446. dnl PHP_ADD_INCLUDE(path [,before])
  447. dnl
  448. dnl add an include path.
  449. dnl if before is 1, add in the beginning of INCLUDES.
  450. dnl
  451. AC_DEFUN([PHP_ADD_INCLUDE],[
  452. if test "$1" != "/usr/include"; then
  453. PHP_EXPAND_PATH($1, ai_p)
  454. PHP_RUN_ONCE(INCLUDEPATH, $ai_p, [
  455. if test "$2"; then
  456. INCLUDES="-I$ai_p $INCLUDES"
  457. else
  458. INCLUDES="$INCLUDES -I$ai_p"
  459. fi
  460. ])
  461. fi
  462. ])
  463. dnl internal, don't use
  464. AC_DEFUN([_PHP_X_ADD_LIBRARY],[dnl
  465. ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl
  466. ])dnl
  467. dnl
  468. dnl internal, don't use
  469. AC_DEFUN([_PHP_ADD_LIBRARY_SKELETON],[
  470. case $1 in
  471. c|c_r|pthread*[)] ;;
  472. *[)] ifelse($3,,[
  473. _PHP_X_ADD_LIBRARY($1,$2,$5)
  474. ],[
  475. if test "$ext_shared" = "yes"; then
  476. _PHP_X_ADD_LIBRARY($1,$2,$3)
  477. else
  478. $4($1,$2)
  479. fi
  480. ]) ;;
  481. esac
  482. ])dnl
  483. dnl
  484. dnl
  485. dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
  486. dnl
  487. dnl add a library to the link line
  488. dnl
  489. AC_DEFUN([PHP_ADD_LIBRARY],[
  490. _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS])
  491. ])
  492. dnl
  493. dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]])
  494. dnl
  495. dnl add a library to the link line (deferred, not used during configure)
  496. dnl
  497. AC_DEFUN([PHP_ADD_LIBRARY_DEFER],[
  498. _PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS])
  499. ])
  500. dnl
  501. dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
  502. dnl
  503. dnl add a library to the link line and path to linkpath/runpath.
  504. dnl if shared-libadd is not empty and $ext_shared is yes,
  505. dnl shared-libadd will be assigned the library information
  506. dnl
  507. AC_DEFUN([PHP_ADD_LIBRARY_WITH_PATH],[
  508. ifelse($3,,[
  509. if test -n "$2"; then
  510. PHP_ADD_LIBPATH($2)
  511. fi
  512. PHP_ADD_LIBRARY($1)
  513. ],[
  514. if test "$ext_shared" = "yes"; then
  515. $3="-l$1 [$]$3"
  516. if test -n "$2"; then
  517. PHP_ADD_LIBPATH($2,$3)
  518. fi
  519. else
  520. PHP_ADD_LIBRARY_WITH_PATH($1,$2)
  521. fi
  522. ])
  523. ])
  524. dnl
  525. dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd])
  526. dnl
  527. dnl add a library to the link line (deferred)
  528. dnl and path to linkpath/runpath (not deferred)
  529. dnl if shared-libadd is not empty and $ext_shared is yes,
  530. dnl shared-libadd will be assigned the library information
  531. dnl
  532. AC_DEFUN([PHP_ADD_LIBRARY_DEFER_WITH_PATH],[
  533. ifelse($3,,[
  534. if test -n "$2"; then
  535. PHP_ADD_LIBPATH($2)
  536. fi
  537. PHP_ADD_LIBRARY_DEFER($1)
  538. ],[
  539. if test "$ext_shared" = "yes"; then
  540. $3="-l$1 [$]$3"
  541. if test -n "$2"; then
  542. PHP_ADD_LIBPATH($2,$3)
  543. fi
  544. else
  545. PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2)
  546. fi
  547. ])
  548. ])
  549. dnl
  550. dnl PHP_ADD_FRAMEWORK(framework [,before])
  551. dnl
  552. dnl add a (Darwin / Mac OS X) framework to the link
  553. dnl line. if before is 1, the framework is added
  554. dnl to the beginning of the line.
  555. dnl
  556. AC_DEFUN([PHP_ADD_FRAMEWORK], [
  557. PHP_RUN_ONCE(FRAMEWORKS, $1, [
  558. if test "$2"; then
  559. PHP_FRAMEWORKS="-framework $1 $PHP_FRAMEWORKS"
  560. else
  561. PHP_FRAMEWORKS="$PHP_FRAMEWORKS -framework $1"
  562. fi
  563. ])
  564. ])
  565. dnl
  566. dnl PHP_ADD_FRAMEWORKPATH(path [,before])
  567. dnl
  568. dnl add a (Darwin / Mac OS X) framework path to the link
  569. dnl and include lines. default paths include (but are
  570. dnl not limited to) /Local/Library/Frameworks and
  571. dnl /System/Library/Frameworks, so these don't need
  572. dnl to be specifically added. if before is 1, the
  573. dnl framework path is added to the beginning of the
  574. dnl relevant lines.
  575. dnl
  576. AC_DEFUN([PHP_ADD_FRAMEWORKPATH], [
  577. PHP_EXPAND_PATH($1, ai_p)
  578. PHP_RUN_ONCE(FRAMEWORKPATH, $ai_p, [
  579. if test "$2"; then
  580. PHP_FRAMEWORKPATH="-F$ai_p $PHP_FRAMEWORKPATH"
  581. else
  582. PHP_FRAMEWORKPATH="$PHP_FRAMEWORKPATH -F$ai_p"
  583. fi
  584. ])
  585. ])
  586. dnl
  587. dnl PHP_ADD_FRAMEWORK_WITH_PATH(framework, path)
  588. dnl
  589. dnl Adds a (Darwin / Mac OS X) framework path and the
  590. dnl framework itself to the link and include lines.
  591. dnl
  592. AC_DEFUN([PHP_ADD_FRAMEWORK_WITH_PATH], [
  593. PHP_ADD_FRAMEWORKPATH($2)
  594. PHP_ADD_FRAMEWORK($1)
  595. ])
  596. dnl
  597. dnl PHP_SET_LIBTOOL_VARIABLE(var)
  598. dnl
  599. dnl Set libtool variable
  600. dnl
  601. AC_DEFUN([PHP_SET_LIBTOOL_VARIABLE],[
  602. if test -z "$LIBTOOL"; then
  603. LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
  604. else
  605. LIBTOOL="$LIBTOOL $1"
  606. fi
  607. ])
  608. dnl -------------------------------------------------------------------------
  609. dnl Wrapper macros for AC_ARG_WITH / AC_ARG_ENABLE
  610. dnl -------------------------------------------------------------------------
  611. dnl PHP_ARG_ANALYZE_EX
  612. dnl internal
  613. AC_DEFUN([PHP_ARG_ANALYZE_EX],[
  614. ext_output="yes, shared"
  615. ext_shared=yes
  616. case [$]$1 in
  617. shared,*[)]
  618. $1=`echo "[$]$1"|$SED 's/^shared,//'`
  619. ;;
  620. shared[)]
  621. $1=yes
  622. ;;
  623. no[)]
  624. ext_output=no
  625. ext_shared=no
  626. ;;
  627. *[)]
  628. ext_output=yes
  629. ext_shared=no
  630. ;;
  631. esac
  632. PHP_ALWAYS_SHARED([$1])
  633. ])
  634. dnl PHP_ARG_ANALYZE
  635. dnl internal
  636. AC_DEFUN([PHP_ARG_ANALYZE],[
  637. ifelse([$3],yes,[PHP_ARG_ANALYZE_EX([$1])],[ext_output=ifelse([$]$1,,no,[$]$1)])
  638. ifelse([$2],,,[AC_MSG_RESULT([$ext_output])])
  639. ])
  640. dnl
  641. dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val[, extension-or-not]])
  642. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  643. dnl default-val defaults to no. This will also set the variable ext_shared,
  644. dnl and will overwrite any previous variable of that name.
  645. dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
  646. dnl the PHP_ARG_ANALYZE_EX.
  647. dnl
  648. AC_DEFUN([PHP_ARG_WITH],[
  649. php_with_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
  650. PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
  651. ])
  652. dnl PHP_REAL_ARG_WITH
  653. dnl internal
  654. AC_DEFUN([PHP_REAL_ARG_WITH],[
  655. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  656. AC_ARG_WITH($1,[$3],$5=[$]withval,
  657. [
  658. $5=ifelse($4,,no,$4)
  659. if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
  660. $5=$PHP_ENABLE_ALL
  661. fi
  662. ])
  663. PHP_ARG_ANALYZE($5,[$2],$6)
  664. ])
  665. dnl
  666. dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val[, extension-or-not]])
  667. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  668. dnl default-val defaults to no. This will also set the variable ext_shared,
  669. dnl and will overwrite any previous variable of that name.
  670. dnl If extension-or-not is yes (default), then do the ENABLE_ALL check and run
  671. dnl the PHP_ARG_ANALYZE_EX.
  672. dnl
  673. AC_DEFUN([PHP_ARG_ENABLE],[
  674. php_enable_[]translit($1,A-Z0-9-,a-z0-9_)=ifelse($4,,no,$4)
  675. PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_),[ifelse($5,,yes,$5)])
  676. ])
  677. dnl PHP_REAL_ARG_ENABLE
  678. dnl internal
  679. AC_DEFUN([PHP_REAL_ARG_ENABLE],[
  680. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  681. AC_ARG_ENABLE($1,[$3],$5=[$]enableval,
  682. [
  683. $5=ifelse($4,,no,$4)
  684. if test "$PHP_ENABLE_ALL" && test "$6" = "yes"; then
  685. $5=$PHP_ENABLE_ALL
  686. fi
  687. ])
  688. PHP_ARG_ANALYZE($5,[$2],$6)
  689. ])
  690. dnl -------------------------------------------------------------------------
  691. dnl Build macros
  692. dnl -------------------------------------------------------------------------
  693. dnl
  694. dnl PHP_BUILD_THREAD_SAFE
  695. dnl
  696. AC_DEFUN([PHP_BUILD_THREAD_SAFE],[
  697. enable_maintainer_zts=yes
  698. if test "$pthreads_working" != "yes"; then
  699. AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.])
  700. fi
  701. ])
  702. dnl
  703. dnl PHP_REQUIRE_CXX
  704. dnl
  705. AC_DEFUN([PHP_REQUIRE_CXX],[
  706. if test -z "$php_cxx_done"; then
  707. AC_PROG_CXX
  708. AC_PROG_CXXCPP
  709. php_cxx_done=yes
  710. fi
  711. ])
  712. dnl
  713. dnl PHP_BUILD_SHARED
  714. dnl
  715. AC_DEFUN([PHP_BUILD_SHARED],[
  716. PHP_BUILD_PROGRAM
  717. OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
  718. php_build_target=shared
  719. php_c_pre=$shared_c_pre
  720. php_c_meta=$shared_c_meta
  721. php_c_post=$shared_c_post
  722. php_cxx_pre=$shared_cxx_pre
  723. php_cxx_meta=$shared_cxx_meta
  724. php_cxx_post=$shared_cxx_post
  725. php_lo=$shared_lo
  726. ])
  727. dnl
  728. dnl PHP_BUILD_STATIC
  729. dnl
  730. AC_DEFUN([PHP_BUILD_STATIC],[
  731. PHP_BUILD_PROGRAM
  732. OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
  733. php_build_target=static
  734. ])
  735. dnl
  736. dnl PHP_BUILD_BUNDLE
  737. dnl
  738. AC_DEFUN([PHP_BUILD_BUNDLE],[
  739. PHP_BUILD_PROGRAM
  740. OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle]
  741. php_build_target=static
  742. ])
  743. dnl
  744. dnl PHP_BUILD_PROGRAM
  745. dnl
  746. AC_DEFUN([PHP_BUILD_PROGRAM],[
  747. OVERALL_TARGET=[]ifelse($1,,php,$1)
  748. php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  749. php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
  750. php_c_post=
  751. php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  752. php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
  753. php_cxx_post=
  754. php_lo=lo
  755. case $with_pic in
  756. yes) pic_setting='-prefer-pic';;
  757. no) pic_setting='-prefer-non-pic';;
  758. esac
  759. shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  760. shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting
  761. shared_c_post=
  762. shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  763. shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting
  764. shared_cxx_post=
  765. shared_lo=lo
  766. php_build_target=program
  767. ])
  768. dnl
  769. dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext)
  770. dnl
  771. dnl Basically sets up the link-stage for building module-name
  772. dnl from object_var in build-dir.
  773. dnl
  774. AC_DEFUN([PHP_SHARED_MODULE],[
  775. install_modules="install-modules"
  776. case $host_alias in
  777. *aix*[)]
  778. suffix=so
  779. link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -Wl,-G -o '$3'/$1.la -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) $(translit($1,a-z_-,A-Z__)_SHARED_LIBADD) && mv -f '$3'/.libs/$1.so '$3'/$1.so'
  780. ;;
  781. *netware*[)]
  782. suffix=nlm
  783. link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -o [$]@ -shared -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) ifelse($1, php5lib, , -L$(top_builddir)/netware -lphp5lib) $(translit(ifelse($1, php5lib, $1, m4_substr($1, 3)),a-z_-,A-Z__)_SHARED_LIBADD)'
  784. ;;
  785. *[)]
  786. suffix=la
  787. link_cmd='$(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)'
  788. ;;
  789. esac
  790. if test "x$5" = "xyes"; then
  791. PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix"
  792. else
  793. PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix"
  794. fi
  795. PHP_SUBST($2)
  796. cat >>Makefile.objects<<EOF
  797. \$(phplibdir)/$1.$suffix: $3/$1.$suffix
  798. \$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir)
  799. $3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
  800. $link_cmd
  801. EOF
  802. ])
  803. dnl
  804. dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
  805. dnl
  806. dnl Selects the SAPI name and type (static, shared, programm)
  807. dnl and optionally also the source-files for the SAPI-specific
  808. dnl objects.
  809. dnl
  810. AC_DEFUN([PHP_SELECT_SAPI],[
  811. PHP_SAPI=$1
  812. case "$2" in
  813. static[)] PHP_BUILD_STATIC;;
  814. shared[)] PHP_BUILD_SHARED;;
  815. bundle[)] PHP_BUILD_BUNDLE;;
  816. program[)] PHP_BUILD_PROGRAM($5);;
  817. esac
  818. ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
  819. ])
  820. dnl deprecated
  821. AC_DEFUN([PHP_EXTENSION],[
  822. sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
  823. PHP_NEW_EXTENSION($1, $sources, $2, $3)
  824. if test -r "$ext_srcdir/Makefile.frag"; then
  825. PHP_ADD_MAKEFILE_FRAGMENT
  826. fi
  827. ])
  828. AC_DEFUN([PHP_ADD_BUILD_DIR],[
  829. ifelse($2,,[
  830. BUILD_DIR="$BUILD_DIR $1"
  831. ], [
  832. $php_shtool mkdir -p $1
  833. ])
  834. ])
  835. AC_DEFUN([PHP_GEN_BUILD_DIRS],[
  836. $php_shtool mkdir -p $BUILD_DIR
  837. ])
  838. dnl
  839. dnl PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags[, cxx[, zend_ext]]]]])
  840. dnl
  841. dnl Includes an extension in the build.
  842. dnl
  843. dnl "extname" is the name of the ext/ subdir where the extension resides.
  844. dnl "sources" is a list of files relative to the subdir which are used
  845. dnl to build the extension.
  846. dnl "shared" can be set to "shared" or "yes" to build the extension as
  847. dnl a dynamically loadable library. Optional parameter "sapi_class" can
  848. dnl be set to "cli" to mark extension build only with CLI or CGI sapi's.
  849. dnl "extra-cflags" are passed to the compiler, with
  850. dnl @ext_srcdir@ and @ext_builddir@ being substituted.
  851. dnl "cxx" can be used to indicate that a C++ shared module is desired.
  852. dnl "zend_ext" indicates a zend extension.
  853. AC_DEFUN([PHP_NEW_EXTENSION],[
  854. ext_builddir=[]PHP_EXT_BUILDDIR($1)
  855. ext_srcdir=[]PHP_EXT_SRCDIR($1)
  856. ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`])
  857. if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then
  858. dnl ---------------------------------------------- Static module
  859. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
  860. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
  861. EXT_STATIC="$EXT_STATIC $1"
  862. if test "$3" != "nocli"; then
  863. EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
  864. fi
  865. else
  866. if test "$3" = "shared" || test "$3" = "yes"; then
  867. dnl ---------------------------------------------- Shared module
  868. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes
  869. PHP_ADD_SOURCES_X(PHP_EXT_DIR($1),$2,$ac_extra,shared_objects_$1,yes)
  870. case $host_alias in
  871. *netware*[)]
  872. PHP_SHARED_MODULE(php$1,shared_objects_$1, $ext_builddir, $6, $7)
  873. ;;
  874. *[)]
  875. PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7)
  876. ;;
  877. esac
  878. AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
  879. fi
  880. fi
  881. if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then
  882. dnl ---------------------------------------------- CLI static module
  883. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
  884. if test "$PHP_SAPI" = "cgi"; then
  885. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
  886. EXT_STATIC="$EXT_STATIC $1"
  887. else
  888. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cli)
  889. fi
  890. EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
  891. fi
  892. PHP_ADD_BUILD_DIR($ext_builddir)
  893. dnl Set for phpize builds only
  894. dnl ---------------------------
  895. if test "$ext_builddir" = "."; then
  896. PHP_PECL_EXTENSION=$1
  897. PHP_SUBST(PHP_PECL_EXTENSION)
  898. fi
  899. ])
  900. dnl
  901. dnl PHP_WITH_SHARED
  902. dnl
  903. dnl Checks whether $withval is "shared" or starts with "shared,XXX"
  904. dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
  905. dnl from $withval.
  906. dnl
  907. AC_DEFUN([PHP_WITH_SHARED],[
  908. PHP_ARG_ANALYZE_EX(withval)
  909. shared=$ext_shared
  910. unset ext_shared ext_output
  911. ])
  912. dnl
  913. dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf])
  914. dnl
  915. dnl This macro is scanned by genif.sh when it builds the internal functions
  916. dnl list, so that modules can be init'd in the correct order
  917. dnl $1 = name of extension, $2 = extension upon which it depends
  918. dnl $3 = optional: if true, it's ok for $2 to have not been configured
  919. dnl default is false and should halt the build.
  920. dnl To be effective, this macro must be invoked *after* PHP_NEW_EXTENSION.
  921. dnl The extension on which it depends must also have been configured.
  922. dnl See ADD_EXTENSION_DEP in win32 build
  923. dnl
  924. AC_DEFUN([PHP_ADD_EXTENSION_DEP], [
  925. am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]
  926. is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED]
  927. is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__)
  928. if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
  929. AC_MSG_ERROR([
  930. You've configured extension $1 to build statically, but it
  931. depends on extension $2, which you've configured to build shared.
  932. You either need to build $1 shared or build $2 statically for the
  933. build to be successful.
  934. ])
  935. fi
  936. if test "x$is_it_enabled" = "xno" && test "x$3" != "xtrue"; then
  937. AC_MSG_ERROR([
  938. You've configured extension $1, which depends on extension $2,
  939. but you've either not enabled $2, or have disabled it.
  940. ])
  941. fi
  942. dnl Some systems require that we link $2 to $1 when building
  943. ])
  944. dnl -------------------------------------------------------------------------
  945. dnl Checks for structures, typedefs, broken functions, etc.
  946. dnl -------------------------------------------------------------------------
  947. dnl Internal helper macros
  948. dnl
  949. dnl _PHP_DEF_HAVE_FILE(what, filename)
  950. AC_DEFUN([_PHP_DEF_HAVE_FILE], [
  951. php_def_have_what=HAVE_[]`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_' `
  952. echo "#define $php_def_have_what 1" >> $2
  953. ])
  954. dnl
  955. dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
  956. dnl
  957. AC_DEFUN([_PHP_CHECK_SIZEOF], [
  958. php_cache_value=php_cv_sizeof_[]$1
  959. AC_CACHE_VAL(php_cv_sizeof_[]$1, [
  960. old_LIBS=$LIBS
  961. LIBS=
  962. old_LDFLAGS=$LDFLAGS
  963. LDFLAGS=
  964. AC_TRY_RUN([#include <stdio.h>
  965. #if STDC_HEADERS
  966. #include <stdlib.h>
  967. #include <stddef.h>
  968. #endif
  969. #ifdef HAVE_INTTYPES_H
  970. #include <inttypes.h>
  971. #endif
  972. #ifdef HAVE_UNISTD_H
  973. #include <unistd.h>
  974. #endif
  975. $3
  976. int main()
  977. {
  978. FILE *fp = fopen("conftestval", "w");
  979. if (!fp) return(1);
  980. fprintf(fp, "%d\n", sizeof($1));
  981. return(0);
  982. }
  983. ], [
  984. eval $php_cache_value=`cat conftestval`
  985. ], [
  986. eval $php_cache_value=0
  987. ], [
  988. ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2])
  989. ])
  990. LDFLAGS=$old_LDFLAGS
  991. LIBS=$old_LIBS
  992. ])
  993. if eval test "\$$php_cache_value" != "0"; then
  994. ifelse([$4],[],:,[$4])
  995. ifelse([$5],[],,[else $5])
  996. fi
  997. ])
  998. dnl
  999. dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
  1000. dnl
  1001. AC_DEFUN(PHP_CHECK_SIZEOF, [
  1002. AC_MSG_CHECKING([size of $1])
  1003. _PHP_CHECK_SIZEOF($1, $2, $3, [
  1004. AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1])
  1005. AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available])
  1006. ])
  1007. AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)])
  1008. ])
  1009. dnl
  1010. dnl PHP_CHECK_TYPES(type-list, include-file [, extra-headers])
  1011. dnl
  1012. AC_DEFUN([PHP_CHECK_TYPES], [
  1013. for php_typename in $1; do
  1014. AC_MSG_CHECKING([whether $php_typename exists])
  1015. _PHP_CHECK_SIZEOF($php_typename, 0, $3, [
  1016. _PHP_DEF_HAVE_FILE($php_typename, $2)
  1017. AC_MSG_RESULT([yes])
  1018. ], [
  1019. AC_MSG_RESULT([no])
  1020. ])
  1021. done
  1022. ])
  1023. dnl
  1024. dnl PHP_CHECK_IN_ADDR_T
  1025. dnl
  1026. AC_DEFUN([PHP_CHECK_IN_ADDR_T], [
  1027. dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
  1028. AC_MSG_CHECKING([for in_addr_t])
  1029. AC_CACHE_VAL(ac_cv_type_in_addr_t,
  1030. [AC_EGREP_CPP(dnl
  1031. changequote(<<,>>)dnl
  1032. <<in_addr_t[^a-zA-Z_0-9]>>dnl
  1033. changequote([,]), [#include <sys/types.h>
  1034. #if STDC_HEADERS
  1035. #include <stdlib.h>
  1036. #include <stddef.h>
  1037. #endif
  1038. #ifdef HAVE_NETINET_IN_H
  1039. #include <netinet/in.h>
  1040. #endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
  1041. AC_MSG_RESULT([$ac_cv_type_in_addr_t])
  1042. if test $ac_cv_type_in_addr_t = no; then
  1043. AC_DEFINE(in_addr_t, u_int, [ ])
  1044. fi
  1045. ])
  1046. dnl
  1047. dnl PHP_TIME_R_TYPE
  1048. dnl
  1049. dnl Check type of reentrant time-related functions
  1050. dnl Type can be: irix, hpux or POSIX
  1051. dnl
  1052. AC_DEFUN([PHP_TIME_R_TYPE],[
  1053. AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
  1054. AC_TRY_RUN([
  1055. #include <time.h>
  1056. main() {
  1057. char buf[27];
  1058. struct tm t;
  1059. time_t old = 0;
  1060. int r, s;
  1061. s = gmtime_r(&old, &t);
  1062. r = (int) asctime_r(&t, buf, 26);
  1063. if (r == s && s == 0) return (0);
  1064. return (1);
  1065. }
  1066. ],[
  1067. ac_cv_time_r_type=hpux
  1068. ],[
  1069. AC_TRY_RUN([
  1070. #include <time.h>
  1071. main() {
  1072. struct tm t, *s;
  1073. time_t old = 0;
  1074. char buf[27], *p;
  1075. s = gmtime_r(&old, &t);
  1076. p = asctime_r(&t, buf, 26);
  1077. if (p == buf && s == &t) return (0);
  1078. return (1);
  1079. }
  1080. ],[
  1081. ac_cv_time_r_type=irix
  1082. ],[
  1083. ac_cv_time_r_type=POSIX
  1084. ],[
  1085. ac_cv_time_r_type=POSIX
  1086. ])
  1087. ],[
  1088. ac_cv_time_r_type=POSIX
  1089. ])
  1090. ])
  1091. case $ac_cv_time_r_type in
  1092. hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
  1093. irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
  1094. esac
  1095. ])
  1096. dnl
  1097. dnl PHP_DOES_PWRITE_WORK
  1098. dnl internal
  1099. AC_DEFUN([PHP_DOES_PWRITE_WORK],[
  1100. AC_TRY_RUN([
  1101. #include <sys/types.h>
  1102. #include <sys/stat.h>
  1103. #include <fcntl.h>
  1104. #include <unistd.h>
  1105. #include <errno.h>
  1106. $1
  1107. main() {
  1108. int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
  1109. if (fd < 0) exit(1);
  1110. if (pwrite(fd, "text", 4, 0) != 4) exit(1);
  1111. /* Linux glibc breakage until 2.2.5 */
  1112. if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1);
  1113. exit(0);
  1114. }
  1115. ],[
  1116. ac_cv_pwrite=yes
  1117. ],[
  1118. ac_cv_pwrite=no
  1119. ],[
  1120. ac_cv_pwrite=no
  1121. ])
  1122. ])
  1123. dnl PHP_DOES_PREAD_WORK
  1124. dnl internal
  1125. AC_DEFUN([PHP_DOES_PREAD_WORK],[
  1126. echo test > conftest_in
  1127. AC_TRY_RUN([
  1128. #include <sys/types.h>
  1129. #include <sys/stat.h>
  1130. #include <fcntl.h>
  1131. #include <unistd.h>
  1132. #include <errno.h>
  1133. $1
  1134. main() {
  1135. char buf[3];
  1136. int fd = open("conftest_in", O_RDONLY);
  1137. if (fd < 0) exit(1);
  1138. if (pread(fd, buf, 2, 0) != 2) exit(1);
  1139. /* Linux glibc breakage until 2.2.5 */
  1140. if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1);
  1141. exit(0);
  1142. }
  1143. ],[
  1144. ac_cv_pread=yes
  1145. ],[
  1146. ac_cv_pread=no
  1147. ],[
  1148. ac_cv_pread=no
  1149. ])
  1150. rm -f conftest_in
  1151. ])
  1152. dnl
  1153. dnl PHP_PWRITE_TEST
  1154. dnl
  1155. AC_DEFUN([PHP_PWRITE_TEST],[
  1156. AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
  1157. PHP_DOES_PWRITE_WORK
  1158. if test "$ac_cv_pwrite" = "no"; then
  1159. PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
  1160. if test "$ac_cv_pwrite" = "yes"; then
  1161. ac_cv_pwrite=64
  1162. fi
  1163. fi
  1164. ])
  1165. if test "$ac_cv_pwrite" != "no"; then
  1166. AC_DEFINE(HAVE_PWRITE, 1, [ ])
  1167. if test "$ac_cv_pwrite" = "64"; then
  1168. AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
  1169. fi
  1170. fi
  1171. ])
  1172. dnl
  1173. dnl PHP_PREAD_TEST
  1174. dnl
  1175. AC_DEFUN([PHP_PREAD_TEST],[
  1176. AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
  1177. PHP_DOES_PREAD_WORK
  1178. if test "$ac_cv_pread" = "no"; then
  1179. PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
  1180. if test "$ac_cv_pread" = "yes"; then
  1181. ac_cv_pread=64
  1182. fi
  1183. fi
  1184. ])
  1185. if test "$ac_cv_pread" != "no"; then
  1186. AC_DEFINE(HAVE_PREAD, 1, [ ])
  1187. if test "$ac_cv_pread" = "64"; then
  1188. AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
  1189. fi
  1190. fi
  1191. ])
  1192. dnl
  1193. dnl PHP_MISSING_TIME_R_DECL
  1194. dnl
  1195. AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
  1196. AC_MSG_CHECKING([for missing declarations of reentrant functions])
  1197. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
  1198. :
  1199. ],[
  1200. AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
  1201. ])
  1202. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
  1203. :
  1204. ],[
  1205. AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
  1206. ])
  1207. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
  1208. :
  1209. ],[
  1210. AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
  1211. ])
  1212. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
  1213. :
  1214. ],[
  1215. AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
  1216. ])
  1217. AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
  1218. :
  1219. ],[
  1220. AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
  1221. ])
  1222. AC_MSG_RESULT([done])
  1223. ])
  1224. dnl
  1225. dnl PHP_READDIR_R_TYPE
  1226. dnl
  1227. AC_DEFUN([PHP_READDIR_R_TYPE],[
  1228. dnl HAVE_READDIR_R is also defined by libmysql
  1229. AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
  1230. if test "$ac_cv_func_readdir_r" = "yes"; then
  1231. AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
  1232. AC_TRY_RUN([
  1233. #define _REENTRANT
  1234. #include <sys/types.h>
  1235. #include <dirent.h>
  1236. #ifndef PATH_MAX
  1237. #define PATH_MAX 1024
  1238. #endif
  1239. main() {
  1240. DIR *dir;
  1241. char entry[sizeof(struct dirent)+PATH_MAX];
  1242. struct dirent *pentry = (struct dirent *) &entry;
  1243. dir = opendir("/");
  1244. if (!dir)
  1245. exit(1);
  1246. if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
  1247. exit(0);
  1248. exit(1);
  1249. }
  1250. ],[
  1251. ac_cv_what_readdir_r=POSIX
  1252. ],[
  1253. AC_TRY_CPP([
  1254. #define _REENTRANT
  1255. #include <sys/types.h>
  1256. #include <dirent.h>
  1257. int readdir_r(DIR *, struct dirent *);
  1258. ],[
  1259. ac_cv_what_readdir_r=old-style
  1260. ],[
  1261. ac_cv_what_readdir_r=none
  1262. ])
  1263. ],[
  1264. ac_cv_what_readdir_r=none
  1265. ])
  1266. ])
  1267. case $ac_cv_what_readdir_r in
  1268. POSIX)
  1269. AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
  1270. old-style)
  1271. AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
  1272. esac
  1273. fi
  1274. ])
  1275. dnl
  1276. dnl PHP_TM_GMTOFF
  1277. dnl
  1278. AC_DEFUN([PHP_TM_GMTOFF],[
  1279. AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
  1280. [AC_TRY_COMPILE([#include <sys/types.h>
  1281. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  1282. ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
  1283. if test "$ac_cv_struct_tm_gmtoff" = yes; then
  1284. AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
  1285. fi
  1286. ])
  1287. dnl
  1288. dnl PHP_STRUCT_FLOCK
  1289. dnl
  1290. AC_DEFUN([PHP_STRUCT_FLOCK],[
  1291. AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
  1292. AC_TRY_COMPILE([
  1293. #include <unistd.h>
  1294. #include <fcntl.h>
  1295. ],
  1296. [struct flock x;],
  1297. [
  1298. ac_cv_struct_flock=yes
  1299. ],[
  1300. ac_cv_struct_flock=no
  1301. ])
  1302. )
  1303. if test "$ac_cv_struct_flock" = "yes" ; then
  1304. AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
  1305. fi
  1306. ])
  1307. dnl
  1308. dnl PHP_SOCKLEN_T
  1309. dnl
  1310. AC_DEFUN([PHP_SOCKLEN_T],[
  1311. AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
  1312. AC_TRY_COMPILE([
  1313. #include <sys/types.h>
  1314. #include <sys/socket.h>
  1315. ],[
  1316. socklen_t x;
  1317. ],[
  1318. ac_cv_socklen_t=yes
  1319. ],[
  1320. ac_cv_socklen_t=no
  1321. ]))
  1322. if test "$ac_cv_socklen_t" = "yes"; then
  1323. AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
  1324. fi
  1325. ])
  1326. dnl
  1327. dnl PHP_MISSING_FCLOSE_DECL
  1328. dnl
  1329. dnl See if we have broken header files like SunOS has.
  1330. dnl
  1331. AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
  1332. AC_MSG_CHECKING([for fclose declaration])
  1333. AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
  1334. AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
  1335. AC_MSG_RESULT([ok])
  1336. ],[
  1337. AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
  1338. AC_MSG_RESULT([missing])
  1339. ])
  1340. ])
  1341. dnl
  1342. dnl PHP_AC_BROKEN_SPRINTF
  1343. dnl
  1344. dnl Check for broken sprintf(), C99 conformance
  1345. dnl
  1346. AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[
  1347. AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
  1348. AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
  1349. ac_cv_broken_sprintf=no
  1350. ],[
  1351. ac_cv_broken_sprintf=yes
  1352. ],[
  1353. ac_cv_broken_sprintf=no
  1354. ])
  1355. ])
  1356. if test "$ac_cv_broken_sprintf" = "yes"; then
  1357. AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform])
  1358. else
  1359. AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform])
  1360. fi
  1361. ])
  1362. dnl
  1363. dnl PHP_AC_BROKEN_SNPRINTF
  1364. dnl
  1365. dnl Check for broken snprintf(), C99 conformance
  1366. dnl
  1367. AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[
  1368. AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[
  1369. AC_TRY_RUN([
  1370. #define NULL (0L)
  1371. main() {
  1372. char buf[20];
  1373. int res = 0;
  1374. res = res || (snprintf(buf, 2, "marcus") != 6);
  1375. res = res || (buf[1] != '\0');
  1376. /* Implementations may consider this as an encoding error */
  1377. snprintf(buf, 0, "boerger");
  1378. /* However, they MUST ignore the pointer */
  1379. res = res || (buf[0] != 'm');
  1380. res = res || (snprintf(NULL, 0, "boerger") != 7);
  1381. res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
  1382. exit(res);
  1383. }
  1384. ],[
  1385. ac_cv_broken_snprintf=no
  1386. ],[
  1387. ac_cv_broken_snprintf=yes
  1388. ],[
  1389. ac_cv_broken_snprintf=no
  1390. ])
  1391. ])
  1392. if test "$ac_cv_broken_snprintf" = "yes"; then
  1393. AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform])
  1394. else
  1395. AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform])
  1396. fi
  1397. ])
  1398. dnl
  1399. dnl PHP_SOLARIS_PIC_WEIRDNESS
  1400. dnl
  1401. dnl Solaris requires main code to be position independent in order
  1402. dnl to let shared objects find symbols. Weird. Ugly.
  1403. dnl
  1404. dnl Must be run after all --with-NN options that let the user
  1405. dnl choose dynamic extensions, and after the gcc test.
  1406. dnl
  1407. AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[
  1408. AC_MSG_CHECKING([whether -fPIC is required])
  1409. if test -n "$EXT_SHARED"; then
  1410. os=`uname -sr 2>/dev/null`
  1411. case $os in
  1412. "SunOS 5.6"|"SunOS 5.7"[)]
  1413. case $CC in
  1414. gcc*|egcs*)
  1415. CFLAGS="$CFLAGS -fPIC";;
  1416. *[)]
  1417. CFLAGS="$CFLAGS -fpic";;
  1418. esac
  1419. AC_MSG_RESULT([yes]);;
  1420. *[)]
  1421. AC_MSG_RESULT([no]);;
  1422. esac
  1423. else
  1424. AC_MSG_RESULT([no])
  1425. fi
  1426. ])
  1427. dnl
  1428. dnl PHP_SYS_LFS
  1429. dnl
  1430. dnl The problem is that the default compilation flags in Solaris 2.6 won't
  1431. dnl let programs access large files; you need to tell the compiler that
  1432. dnl you actually want your programs to work on large files. For more
  1433. dnl details about this brain damage please see:
  1434. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  1435. dnl
  1436. dnl Written by Paul Eggert <eggert@twinsun.com>.
  1437. dnl
  1438. AC_DEFUN([PHP_SYS_LFS],
  1439. [dnl
  1440. # If available, prefer support for large files unless the user specified
  1441. # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
  1442. AC_MSG_CHECKING([whether large file support needs explicit enabling])
  1443. ac_getconfs=''
  1444. ac_result=yes
  1445. ac_set=''
  1446. ac_shellvars='CPPFLAGS LDFLAGS LIBS'
  1447. for ac_shellvar in $ac_shellvars; do
  1448. case $ac_shellvar in
  1449. CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;;
  1450. *[)] ac_lfsvar=LFS_$ac_shellvar ;;
  1451. esac
  1452. eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
  1453. (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
  1454. ac_getconf=`getconf $ac_lfsvar`
  1455. ac_getconfs=$ac_getconfs$ac_getconf
  1456. eval ac_test_$ac_shellvar=\$ac_getconf
  1457. done
  1458. case "$ac_result$ac_getconfs" in
  1459. yes[)] ac_result=no ;;
  1460. esac
  1461. case "$ac_result$ac_set" in
  1462. yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings"
  1463. esac
  1464. AC_MSG_RESULT([$ac_result])
  1465. case $ac_result in
  1466. yes[)]
  1467. for ac_shellvar in $ac_shellvars; do
  1468. eval $ac_shellvar=\$ac_test_$ac_shellvar
  1469. done ;;
  1470. esac
  1471. ])
  1472. dnl
  1473. dnl PHP_SOCKADDR_CHECKS
  1474. dnl
  1475. AC_DEFUN([PHP_SOCKADDR_CHECKS], [
  1476. dnl Check for struct sockaddr_storage exists
  1477. AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage,
  1478. [AC_TRY_COMPILE([#include <sys/types.h>
  1479. #include <sys/socket.h>],
  1480. [struct sockaddr_storage s; s],
  1481. [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no])
  1482. ])
  1483. if test "$ac_cv_sockaddr_storage" = "yes"; then
  1484. AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
  1485. fi
  1486. dnl Check if field sa_len exists in struct sockaddr
  1487. AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  1488. AC_TRY_COMPILE([#include <sys/types.h>
  1489. #include <sys/socket.h>],
  1490. [static struct sockaddr sa; int n = (int) sa.sa_len; return n;],
  1491. [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no])
  1492. ])
  1493. if test "$ac_cv_sockaddr_sa_len" = "yes"; then
  1494. AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len])
  1495. fi
  1496. ])
  1497. dnl
  1498. dnl PHP_DECLARED_TIMEZONE
  1499. dnl
  1500. AC_DEFUN([PHP_DECLARED_TIMEZONE],[
  1501. AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
  1502. AC_TRY_COMPILE([
  1503. #include <sys/types.h>
  1504. #include <time.h>
  1505. #ifdef HAVE_SYS_TIME_H
  1506. #include <sys/time.h>
  1507. #endif
  1508. ],[
  1509. time_t foo = (time_t) timezone;
  1510. ],[
  1511. ac_cv_declared_timezone=yes
  1512. ],[
  1513. ac_cv_declared_timezone=no
  1514. ])])
  1515. if test "$ac_cv_declared_timezone" = "yes"; then
  1516. AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
  1517. fi
  1518. ])
  1519. dnl
  1520. dnl PHP_EBCDIC
  1521. dnl
  1522. AC_DEFUN([PHP_EBCDIC], [
  1523. AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
  1524. AC_TRY_RUN( [
  1525. int main(void) {
  1526. return (unsigned char)'A' != (unsigned char)0xC1;
  1527. }
  1528. ],[
  1529. ac_cv_ebcdic=yes
  1530. ],[
  1531. ac_cv_ebcdic=no
  1532. ],[
  1533. ac_cv_ebcdic=no
  1534. ])])
  1535. if test "$ac_cv_ebcdic" = "yes"; then
  1536. AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
  1537. fi
  1538. ])
  1539. dnl
  1540. dnl PHP_BROKEN_GETCWD
  1541. dnl
  1542. dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a
  1543. dnl component of the path has execute but not read permissions
  1544. dnl
  1545. AC_DEFUN([PHP_BROKEN_GETCWD],[
  1546. AC_MSG_CHECKING([for broken getcwd])
  1547. os=`uname -sr 2>/dev/null`
  1548. case $os in
  1549. SunOS*[)]
  1550. AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd])
  1551. AC_MSG_RESULT([yes]);;
  1552. *[)]
  1553. AC_MSG_RESULT([no]);;
  1554. esac
  1555. ])
  1556. dnl
  1557. dnl PHP_BROKEN_GLIBC_FOPEN_APPEND
  1558. dnl
  1559. AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
  1560. AC_MSG_CHECKING([for broken libc stdio])
  1561. AC_CACHE_VAL(have_broken_glibc_fopen_append,[
  1562. AC_TRY_RUN([
  1563. #include <stdio.h>
  1564. int main(int argc, char *argv[])
  1565. {
  1566. FILE *fp;
  1567. long position;
  1568. char *filename = "/tmp/phpglibccheck";
  1569. fp = fopen(filename, "w");
  1570. if (fp == NULL) {
  1571. perror("fopen");
  1572. exit(2);
  1573. }
  1574. fputs("foobar", fp);
  1575. fclose(fp);
  1576. fp = fopen(filename, "a+");
  1577. position = ftell(fp);
  1578. fclose(fp);
  1579. unlink(filename);
  1580. if (position == 0)
  1581. return 1;
  1582. return 0;
  1583. }
  1584. ],
  1585. [have_broken_glibc_fopen_append=no],
  1586. [have_broken_glibc_fopen_append=yes ],
  1587. AC_TRY_COMPILE([
  1588. #include <features.h>
  1589. ],[
  1590. #if !__GLIBC_PREREQ(2,2)
  1591. choke me
  1592. #endif
  1593. ],
  1594. [have_broken_glibc_fopen_append=yes],
  1595. [have_broken_glibc_fopen_append=no ])
  1596. )])
  1597. if test "$have_broken_glibc_fopen_append" = "yes"; then
  1598. AC_MSG_RESULT(yes)
  1599. AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
  1600. else
  1601. AC_MSG_RESULT(no)
  1602. fi
  1603. ])
  1604. dnl
  1605. dnl PHP_FOPENCOOKIE
  1606. dnl
  1607. AC_DEFUN([PHP_FOPENCOOKIE], [
  1608. AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes])
  1609. if test "$have_glibc_fopencookie" = "yes"; then
  1610. dnl this comes in two flavors:
  1611. dnl newer glibcs (since 2.1.2 ? )
  1612. dnl have a type called cookie_io_functions_t
  1613. AC_TRY_COMPILE([
  1614. #define _GNU_SOURCE
  1615. #include <stdio.h>
  1616. ], [cookie_io_functions_t cookie;], [have_cookie_io_functions_t=yes], [])
  1617. if test "$have_cookie_io_functions_t" = "yes"; then
  1618. cookie_io_functions_t=cookie_io_functions_t
  1619. have_fopen_cookie=yes
  1620. dnl even newer glibcs have a different seeker definition...
  1621. AC_TRY_RUN([
  1622. #define _GNU_SOURCE
  1623. #include <stdio.h>
  1624. struct cookiedata {
  1625. __off64_t pos;
  1626. };
  1627. __ssize_t reader(void *cookie, char *buffer, size_t size)
  1628. { return size; }
  1629. __ssize_t writer(void *cookie, const char *buffer, size_t size)
  1630. { return size; }
  1631. int closer(void *cookie)
  1632. { return 0; }
  1633. int seeker(void *cookie, __off64_t *position, int whence)
  1634. { ((struct cookiedata*)cookie)->pos = *position; return 0; }
  1635. cookie_io_functions_t funcs = {reader, writer, seeker, closer};
  1636. main() {
  1637. struct cookiedata g = { 0 };
  1638. FILE *fp = fopencookie(&g, "r", funcs);
  1639. if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
  1640. exit(0);
  1641. exit(1);
  1642. }
  1643. ], [
  1644. cookie_io_functions_use_off64_t=yes
  1645. ], [
  1646. cookie_io_functions_use_off64_t=no
  1647. ], [
  1648. cookie_io_functions_use_off64_t=no
  1649. ])
  1650. else
  1651. dnl older glibc versions (up to 2.1.2 ?)
  1652. dnl call it _IO_cookie_io_functions_t
  1653. AC_TRY_COMPILE([
  1654. #define _GNU_SOURCE
  1655. #include <stdio.h>
  1656. ], [ _IO_cookie_io_functions_t cookie; ], [have_IO_cookie_io_functions_t=yes], [])
  1657. if test "$have_cookie_io_functions_t" = "yes" ; then
  1658. cookie_io_functions_t=_IO_cookie_io_functions_t
  1659. have_fopen_cookie=yes
  1660. fi
  1661. fi
  1662. if test "$have_fopen_cookie" = "yes" ; then
  1663. AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
  1664. AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
  1665. if test "$cookie_io_functions_use_off64_t" = "yes" ; then
  1666. AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ])
  1667. fi
  1668. fi
  1669. fi
  1670. ])
  1671. dnl -------------------------------------------------------------------------
  1672. dnl Library/function existance and build sanity checks
  1673. dnl -------------------------------------------------------------------------
  1674. dnl
  1675. dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
  1676. dnl
  1677. dnl Wrapper for AC_CHECK_LIB
  1678. dnl
  1679. AC_DEFUN([PHP_CHECK_LIBRARY], [
  1680. save_old_LDFLAGS=$LDFLAGS
  1681. ac_stuff="$5"
  1682. save_ext_shared=$ext_shared
  1683. ext_shared=yes
  1684. PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
  1685. AC_CHECK_LIB([$1],[$2],[
  1686. LDFLAGS=$save_old_LDFLAGS
  1687. ext_shared=$save_ext_shared
  1688. $3
  1689. ],[
  1690. LDFLAGS=$save_old_LDFLAGS
  1691. ext_shared=$save_ext_shared
  1692. unset ac_cv_lib_$1[]_$2
  1693. $4
  1694. ])dnl
  1695. ])
  1696. dnl
  1697. dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]])
  1698. dnl
  1699. dnl El cheapo wrapper for AC_CHECK_LIB
  1700. dnl
  1701. AC_DEFUN([PHP_CHECK_FRAMEWORK], [
  1702. save_old_LDFLAGS=$LDFLAGS
  1703. LDFLAGS="-framework $1 $LDFLAGS"
  1704. dnl supplying "c" to AC_CHECK_LIB is technically cheating, but
  1705. dnl rewriting AC_CHECK_LIB is overkill and this only affects
  1706. dnl the "checking.." output anyway.
  1707. AC_CHECK_LIB(c,[$2],[
  1708. LDFLAGS=$save_old_LDFLAGS
  1709. $3
  1710. ],[
  1711. LDFLAGS=$save_old_LDFLAGS
  1712. $4
  1713. ])
  1714. ])
  1715. dnl
  1716. dnl PHP_CHECK_FUNC_LIB(func, libs)
  1717. dnl
  1718. dnl This macro checks whether 'func' or '__func' exists
  1719. dnl in the specified library.
  1720. dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
  1721. dnl This should be called in the ACTION-IF-NOT-FOUND part of PHP_CHECK_FUNC
  1722. dnl
  1723. dnl
  1724. dnl autoconf undefines the builtin "shift" :-(
  1725. dnl If possible, we use the builtin shift anyway, otherwise we use
  1726. dnl the ubercool definition I have tested so far with FreeBSD/GNU m4
  1727. ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
  1728. define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
  1729. ])
  1730. dnl
  1731. AC_DEFUN([PHP_CHECK_FUNC_LIB],[
  1732. ifelse($2,,:,[
  1733. unset ac_cv_lib_$2[]_$1
  1734. unset ac_cv_lib_$2[]___$1
  1735. unset found
  1736. AC_CHECK_LIB($2, $1, [found=yes], [
  1737. AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
  1738. ])
  1739. if test "$found" = "yes"; then
  1740. ac_libs=$LIBS
  1741. LIBS="$LIBS -l$2"
  1742. AC_TRY_RUN([main() { return (0); }],[found=yes],[found=no],[found=no])
  1743. LIBS=$ac_libs
  1744. fi
  1745. if test "$found" = "yes"; then
  1746. PHP_ADD_LIBRARY($2)
  1747. PHP_DEF_HAVE($1)
  1748. PHP_DEF_HAVE(lib$2)
  1749. ac_cv_func_$1=yes
  1750. else
  1751. PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
  1752. fi
  1753. ])
  1754. ])
  1755. dnl
  1756. dnl PHP_CHECK_FUNC(func, ...)
  1757. dnl
  1758. dnl This macro checks whether 'func' or '__func' exists
  1759. dnl in the default libraries and as a fall back in the specified library.
  1760. dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
  1761. dnl
  1762. AC_DEFUN([PHP_CHECK_FUNC],[
  1763. unset ac_cv_func_$1
  1764. unset ac_cv_func___$1
  1765. unset found
  1766. AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
  1767. case $found in
  1768. yes[)]
  1769. PHP_DEF_HAVE($1)
  1770. ac_cv_func_$1=yes
  1771. ;;
  1772. ifelse($#,1,,[
  1773. *[)] PHP_CHECK_FUNC_LIB($@) ;;
  1774. ])
  1775. esac
  1776. ])
  1777. dnl
  1778. dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]])
  1779. dnl
  1780. dnl This macro checks whether build works and given function exists.
  1781. dnl
  1782. AC_DEFUN([PHP_TEST_BUILD], [
  1783. old_LIBS=$LIBS
  1784. LIBS="$4 $LIBS"
  1785. AC_TRY_RUN([
  1786. $5
  1787. char $1();
  1788. int main() {
  1789. $1();
  1790. return 0;
  1791. }
  1792. ], [
  1793. LIBS=$old_LIBS
  1794. $2
  1795. ],[
  1796. LIBS=$old_LIBS
  1797. $3
  1798. ],[
  1799. LIBS=$old_LIBS
  1800. ])
  1801. ])
  1802. dnl -------------------------------------------------------------------------
  1803. dnl Platform characteristics checks
  1804. dnl -------------------------------------------------------------------------
  1805. dnl
  1806. dnl PHP_SHLIB_SUFFIX_NAMES
  1807. dnl
  1808. dnl Determines link library suffix SHLIB_SUFFIX_NAME
  1809. dnl which can be: .so, .sl or .dylib
  1810. dnl
  1811. dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME
  1812. dnl suffix can be: .so or .sl
  1813. dnl
  1814. AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[
  1815. AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
  1816. PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
  1817. PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME)
  1818. SHLIB_SUFFIX_NAME=so
  1819. SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME
  1820. case $host_alias in
  1821. *hpux*[)]
  1822. SHLIB_SUFFIX_NAME=sl
  1823. SHLIB_DL_SUFFIX_NAME=sl
  1824. ;;
  1825. *darwin*[)]
  1826. SHLIB_SUFFIX_NAME=dylib
  1827. SHLIB_DL_SUFFIX_NAME=so
  1828. ;;
  1829. esac
  1830. ])
  1831. dnl
  1832. dnl PHP_CHECK_64BIT([do if 32], [do if 64])
  1833. dnl
  1834. dnl This macro is used to detect if we're at 64-bit platform or not.
  1835. dnl It could be useful for those external libs, that have different precompiled
  1836. dnl versions in different directories.
  1837. dnl
  1838. AC_DEFUN([PHP_CHECK_64BIT],[
  1839. AC_CHECK_SIZEOF(long int, 4)
  1840. AC_MSG_CHECKING([checking if we're at 64-bit platform])
  1841. if test "$ac_cv_sizeof_long_int" = "4" ; then
  1842. AC_MSG_RESULT([no])
  1843. $1
  1844. else
  1845. AC_MSG_RESULT([yes])
  1846. $2
  1847. fi
  1848. ])
  1849. dnl
  1850. dnl PHP_C_BIGENDIAN
  1851. dnl
  1852. dnl Replacement macro for AC_C_BIGENDIAN
  1853. dnl
  1854. AC_DEFUN([PHP_C_BIGENDIAN],
  1855. [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
  1856. [
  1857. ac_cv_c_bigendian_php=unknown
  1858. AC_TRY_RUN(
  1859. [
  1860. int main(void)
  1861. {
  1862. short one = 1;
  1863. char *cp = (char *)&one;
  1864. if (*cp == 0) {
  1865. return(0);
  1866. } else {
  1867. return(1);
  1868. }
  1869. }
  1870. ], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
  1871. ])
  1872. if test $ac_cv_c_bigendian_php = yes; then
  1873. AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word])
  1874. fi
  1875. ])
  1876. dnl -------------------------------------------------------------------------
  1877. dnl Checks for programs: PHP_PROG_<program>
  1878. dnl -------------------------------------------------------------------------
  1879. dnl
  1880. dnl PHP_PROG_SENDMAIL
  1881. dnl
  1882. dnl Search for the sendmail binary
  1883. dnl
  1884. AC_DEFUN([PHP_PROG_SENDMAIL], [
  1885. PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
  1886. AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH)
  1887. PHP_SUBST(PROG_SENDMAIL)
  1888. ])
  1889. dnl
  1890. dnl PHP_PROG_AWK
  1891. dnl
  1892. dnl Some vendors force mawk before gawk; mawk is broken so we don't like that
  1893. dnl
  1894. AC_DEFUN([PHP_PROG_AWK], [
  1895. AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
  1896. case "$AWK" in
  1897. *mawk)
  1898. AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
  1899. ;;
  1900. *gawk)
  1901. ;;
  1902. bork)
  1903. AC_MSG_ERROR([Could not find awk; Install GNU awk])
  1904. ;;
  1905. *)
  1906. AC_MSG_CHECKING([if $AWK is broken])
  1907. if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
  1908. AC_MSG_RESULT([yes])
  1909. AC_MSG_ERROR([You should install GNU awk])
  1910. else
  1911. AC_MSG_RESULT([no])
  1912. fi
  1913. ;;
  1914. esac
  1915. PHP_SUBST(AWK)
  1916. ])
  1917. dnl
  1918. dnl PHP_PROG_BISON
  1919. dnl
  1920. dnl Search for bison and check it's version
  1921. dnl
  1922. AC_DEFUN([PHP_PROG_BISON], [
  1923. AC_PROG_YACC
  1924. LIBZEND_BISON_CHECK
  1925. PHP_SUBST(YACC)
  1926. ])
  1927. dnl
  1928. dnl PHP_PROG_LEX
  1929. dnl
  1930. dnl Search for (f)lex and check it's version
  1931. dnl
  1932. AC_DEFUN([PHP_PROG_LEX], [
  1933. dnl we only support certain flex versions
  1934. flex_version_list="2.5.4"
  1935. AC_PROG_LEX
  1936. if test "$LEX" = "flex"; then
  1937. dnl AC_DECL_YYTEXT is obsolete since autoconf 2.50 and merged into AC_PROG_LEX
  1938. dnl this is what causes that annoying "PHP_PROG_LEX is expanded from" warning with autoconf 2.50+
  1939. dnl it should be removed once we drop support of autoconf 2.13 (if ever)
  1940. AC_DECL_YYTEXT
  1941. :
  1942. fi
  1943. dnl ## Make flex scanners use const if they can, even if __STDC__ is not
  1944. dnl ## true, for compilers like Sun's that only set __STDC__ true in
  1945. dnl ## "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
  1946. AC_C_CONST
  1947. if test "$ac_cv_c_const" = "yes" ; then
  1948. LEX_CFLAGS="-DYY_USE_CONST"
  1949. fi
  1950. if test "$LEX" = "flex"; then
  1951. AC_CACHE_CHECK([for flex version], php_cv_flex_version, [
  1952. flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'`
  1953. php_cv_flex_version=invalid
  1954. for flex_check_version in $flex_version_list; do
  1955. if test "$flex_version" = "$flex_check_version"; then
  1956. php_cv_flex_version="$flex_check_version (ok)"
  1957. fi
  1958. done
  1959. ])
  1960. else
  1961. flex_version=none
  1962. fi
  1963. case $php_cv_flex_version in
  1964. ""|invalid[)]
  1965. if test -f "$abs_srcdir/Zend/zend_language_scanner.c" && test -f "$abs_srcdir/Zend/zend_ini_scanner.c"; then
  1966. AC_MSG_WARN([flex versions supported for regeneration of the Zend/PHP parsers: $flex_version_list (found: $flex_version)])
  1967. else
  1968. flex_msg="Supported flex versions are: $flex_version_list"
  1969. if test "$flex_version" = "none"; then
  1970. flex_msg="flex not found. flex is required to generate the Zend/PHP parsers! $flex_msg"
  1971. else
  1972. flex_msg="Found invalid flex version: $flex_version. $flex_msg"
  1973. fi
  1974. AC_MSG_ERROR([$flex_msg])
  1975. fi
  1976. LEX="exit 0;"
  1977. ;;
  1978. esac
  1979. PHP_SUBST(LEX)
  1980. ])
  1981. dnl
  1982. dnl PHP_PROG_RE2C
  1983. dnl
  1984. dnl Search for the re2c binary and check the version
  1985. dnl
  1986. AC_DEFUN([PHP_PROG_RE2C],[
  1987. AC_CHECK_PROG(RE2C, re2c, re2c)
  1988. if test -n "$RE2C"; then
  1989. AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [
  1990. re2c_vernum=`$RE2C --vernum 2>/dev/null`
  1991. if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1304"; then
  1992. php_cv_re2c_version=invalid
  1993. else
  1994. php_cv_re2c_version="`$RE2C --version | cut -d ' ' -f 2 2>/dev/null` (ok)"
  1995. fi
  1996. ])
  1997. fi
  1998. case $php_cv_re2c_version in
  1999. ""|invalid[)]
  2000. AC_MSG_WARN([You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.])
  2001. RE2C="exit 0;"
  2002. ;;
  2003. esac
  2004. PHP_SUBST(RE2C)
  2005. ])
  2006. dnl -------------------------------------------------------------------------
  2007. dnl Common setup macros: PHP_SETUP_<what>
  2008. dnl -------------------------------------------------------------------------
  2009. dnl
  2010. dnl PHP_SETUP_ICU([shared-add])
  2011. dnl
  2012. dnl Common setup macro for ICU
  2013. dnl
  2014. AC_DEFUN([PHP_SETUP_ICU],[
  2015. PHP_ARG_WITH(icu-dir,,
  2016. [ --with-icu-dir=DIR Specify where ICU libraries and headers can be found], DEFAULT, no)
  2017. if test "$PHP_ICU_DIR" = "no"; then
  2018. PHP_ICU_DIR=DEFAULT
  2019. fi
  2020. if test "$PHP_ICU_DIR" = "DEFAULT"; then
  2021. dnl Try to find icu-config
  2022. AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
  2023. else
  2024. ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
  2025. fi
  2026. AC_MSG_CHECKING([for location of ICU headers and libraries])
  2027. dnl Trust icu-config to know better what the install prefix is..
  2028. icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
  2029. if test "$?" != "0" || test -z "$icu_install_prefix"; then
  2030. AC_MSG_RESULT([not found])
  2031. AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
  2032. else
  2033. AC_MSG_RESULT([$icu_install_prefix])
  2034. dnl Check ICU version
  2035. AC_MSG_CHECKING([for ICU 3.4 or greater])
  2036. icu_version_full=`$ICU_CONFIG --version`
  2037. ac_IFS=$IFS
  2038. IFS="."
  2039. set $icu_version_full
  2040. IFS=$ac_IFS
  2041. icu_version=`expr [$]1 \* 1000 + [$]2`
  2042. AC_MSG_RESULT([found $icu_version_full])
  2043. if test "$icu_version" -lt "3004"; then
  2044. AC_MSG_ERROR([ICU version 3.4 or later is required])
  2045. fi
  2046. ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
  2047. ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
  2048. PHP_EVAL_INCLINE($ICU_INCS)
  2049. PHP_EVAL_LIBLINE($ICU_LIBS, $1)
  2050. fi
  2051. ])
  2052. dnl
  2053. dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]])
  2054. dnl
  2055. dnl Common setup macro for kerberos
  2056. dnl
  2057. AC_DEFUN([PHP_SETUP_KERBEROS],[
  2058. found_kerberos=no
  2059. unset KERBEROS_CFLAGS
  2060. unset KERBEROS_LIBS
  2061. dnl First try to find krb5-config
  2062. if test -z "$KRB5_CONFIG"; then
  2063. AC_PATH_PROG(KRB5_CONFIG, krb5-config, no, [$PATH:/usr/kerberos/bin:/usr/local/bin])
  2064. fi
  2065. dnl If krb5-config is found try using it
  2066. if test "$PHP_KERBEROS" = "yes" && test -x "$KRB5_CONFIG"; then
  2067. KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi`
  2068. KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi`
  2069. if test -n "$KERBEROS_LIBS" && test -n "$KERBEROS_CFLAGS"; then
  2070. found_kerberos=yes
  2071. PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1)
  2072. PHP_EVAL_INCLINE($KERBEROS_CFLAGS)
  2073. fi
  2074. fi
  2075. dnl If still not found use old skool method
  2076. if test "$found_kerberos" = "no"; then
  2077. if test "$PHP_KERBEROS" = "yes"; then
  2078. PHP_KERBEROS="/usr/kerberos /usr/local /usr"
  2079. fi
  2080. for i in $PHP_KERBEROS; do
  2081. if test -f $i/$PHP_LIBDIR/libkrb5.a || test -f $i/$PHP_LIBDIR/libkrb5.$SHLIB_SUFFIX_NAME; then
  2082. PHP_KERBEROS_DIR=$i
  2083. break
  2084. fi
  2085. done
  2086. if test "$PHP_KERBEROS_DIR"; then
  2087. found_kerberos=yes
  2088. PHP_ADD_LIBPATH($PHP_KERBEROS_DIR/$PHP_LIBDIR, $1)
  2089. PHP_ADD_LIBRARY(gssapi_krb5, 1, $1)
  2090. PHP_ADD_LIBRARY(krb5, 1, $1)
  2091. PHP_ADD_LIBRARY(k5crypto, 1, $1)
  2092. PHP_ADD_LIBRARY(com_err, 1, $1)
  2093. PHP_ADD_INCLUDE($PHP_KERBEROS_DIR/include)
  2094. fi
  2095. fi
  2096. if test "$found_kerberos" = "yes"; then
  2097. ifelse([$2],[],:,[$2])
  2098. ifelse([$3],[],,[else $3])
  2099. fi
  2100. ])
  2101. dnl
  2102. dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
  2103. dnl
  2104. dnl Common setup macro for openssl
  2105. dnl
  2106. AC_DEFUN([PHP_SETUP_OPENSSL],[
  2107. found_openssl=no
  2108. unset OPENSSL_INCDIR
  2109. unset OPENSSL_LIBDIR
  2110. dnl Empty variable means 'no'
  2111. test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
  2112. test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
  2113. dnl Fallbacks for different configure options
  2114. if test "$PHP_OPENSSL" != "no"; then
  2115. PHP_OPENSSL_DIR=$PHP_OPENSSL
  2116. elif test "$PHP_IMAP_SSL" != "no"; then
  2117. PHP_OPENSSL_DIR=$PHP_IMAP_SSL
  2118. fi
  2119. dnl First try to find pkg-config
  2120. if test -z "$PKG_CONFIG"; then
  2121. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2122. fi
  2123. dnl If pkg-config is found try using it
  2124. if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
  2125. if $PKG_CONFIG --atleast-version=0.9.6 openssl; then
  2126. found_openssl=yes
  2127. OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
  2128. OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
  2129. OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
  2130. else
  2131. AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
  2132. fi
  2133. if test -n "$OPENSSL_LIBS" && test -n "$OPENSSL_INCS"; then
  2134. PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
  2135. PHP_EVAL_INCLINE($OPENSSL_INCS)
  2136. fi
  2137. fi
  2138. dnl If pkg-config fails for some reason, revert to the old method
  2139. if test "$found_openssl" = "no"; then
  2140. if test "$PHP_OPENSSL_DIR" = "yes"; then
  2141. PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
  2142. fi
  2143. for i in $PHP_OPENSSL_DIR; do
  2144. if test -r $i/include/openssl/evp.h; then
  2145. OPENSSL_INCDIR=$i/include
  2146. fi
  2147. if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
  2148. OPENSSL_LIBDIR=$i/$PHP_LIBDIR
  2149. fi
  2150. test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
  2151. done
  2152. if test -z "$OPENSSL_INCDIR"; then
  2153. AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
  2154. fi
  2155. if test -z "$OPENSSL_LIBDIR"; then
  2156. AC_MSG_ERROR([Cannot find OpenSSL's libraries])
  2157. fi
  2158. old_CPPFLAGS=$CPPFLAGS
  2159. CPPFLAGS=-I$OPENSSL_INCDIR
  2160. AC_MSG_CHECKING([for OpenSSL version])
  2161. AC_EGREP_CPP(yes,[
  2162. #include <openssl/opensslv.h>
  2163. #if OPENSSL_VERSION_NUMBER >= 0x0090600fL
  2164. yes
  2165. #endif
  2166. ],[
  2167. AC_MSG_RESULT([>= 0.9.6])
  2168. ],[
  2169. AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
  2170. ])
  2171. CPPFLAGS=$old_CPPFLAGS
  2172. PHP_ADD_INCLUDE($OPENSSL_INCDIR)
  2173. PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
  2174. PHP_ADD_LIBRARY(crypto,,$1)
  2175. ],[
  2176. AC_MSG_ERROR([libcrypto not found!])
  2177. ],[
  2178. -L$OPENSSL_LIBDIR
  2179. ])
  2180. old_LIBS=$LIBS
  2181. LIBS="$LIBS -lcrypto"
  2182. PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
  2183. found_openssl=yes
  2184. ],[
  2185. AC_MSG_ERROR([libssl not found!])
  2186. ],[
  2187. -L$OPENSSL_LIBDIR
  2188. ])
  2189. LIBS=$old_LIBS
  2190. PHP_ADD_LIBRARY(ssl,,$1)
  2191. PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1)
  2192. fi
  2193. if test "$found_openssl" = "yes"; then
  2194. dnl For apache 1.3.x static build
  2195. OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
  2196. AC_SUBST(OPENSSL_INCDIR_OPT)
  2197. ifelse([$2],[],:,[$2])
  2198. ifelse([$3],[],,[else $3])
  2199. fi
  2200. ])
  2201. dnl
  2202. dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
  2203. dnl
  2204. dnl Common setup macro for iconv
  2205. dnl
  2206. AC_DEFUN([PHP_SETUP_ICONV], [
  2207. found_iconv=no
  2208. unset ICONV_DIR
  2209. # Create the directories for a VPATH build:
  2210. $php_shtool mkdir -p ext/iconv
  2211. echo > ext/iconv/php_have_bsd_iconv.h
  2212. echo > ext/iconv/php_have_glibc_iconv.h
  2213. echo > ext/iconv/php_have_libiconv.h
  2214. echo > ext/iconv/php_have_iconv.h
  2215. echo > ext/iconv/php_php_iconv_impl.h
  2216. echo > ext/iconv/php_php_iconv_h_path.h
  2217. echo > ext/iconv/php_iconv_supports_errno.h
  2218. dnl
  2219. dnl Check libc first if no path is provided in --with-iconv
  2220. dnl
  2221. if test "$PHP_ICONV" = "yes"; then
  2222. AC_CHECK_FUNC(iconv, [
  2223. found_iconv=yes
  2224. ],[
  2225. AC_CHECK_FUNC(libiconv,[
  2226. PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
  2227. AC_DEFINE(HAVE_LIBICONV, 1, [ ])
  2228. found_iconv=yes
  2229. ])
  2230. ])
  2231. fi
  2232. dnl
  2233. dnl Check external libs for iconv funcs
  2234. dnl
  2235. if test "$found_iconv" = "no"; then
  2236. for i in $PHP_ICONV /usr/local /usr; do
  2237. if test -r $i/include/giconv.h; then
  2238. AC_DEFINE(HAVE_GICONV_H, 1, [ ])
  2239. ICONV_DIR=$i
  2240. iconv_lib_name=giconv
  2241. break
  2242. elif test -r $i/include/iconv.h; then
  2243. ICONV_DIR=$i
  2244. iconv_lib_name=iconv
  2245. break
  2246. fi
  2247. done
  2248. if test -z "$ICONV_DIR"; then
  2249. AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
  2250. fi
  2251. if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
  2252. test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
  2253. then
  2254. PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
  2255. found_iconv=yes
  2256. PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
  2257. AC_DEFINE(HAVE_LIBICONV,1,[ ])
  2258. ], [
  2259. PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
  2260. found_iconv=yes
  2261. ], [], [
  2262. -L$ICONV_DIR/$PHP_LIBDIR
  2263. ])
  2264. ], [
  2265. -L$ICONV_DIR/$PHP_LIBDIR
  2266. ])
  2267. fi
  2268. fi
  2269. if test "$found_iconv" = "yes"; then
  2270. PHP_DEFINE(HAVE_ICONV,1,[ext/iconv])
  2271. AC_DEFINE(HAVE_ICONV,1,[ ])
  2272. if test -n "$ICONV_DIR"; then
  2273. PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1)
  2274. PHP_ADD_INCLUDE($ICONV_DIR/include)
  2275. fi
  2276. $2
  2277. ifelse([$3],[],,[else $3])
  2278. fi
  2279. ])
  2280. dnl
  2281. dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]])
  2282. dnl
  2283. dnl Common setup macro for libxml
  2284. dnl
  2285. AC_DEFUN([PHP_SETUP_LIBXML], [
  2286. AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
  2287. [
  2288. for i in $PHP_LIBXML_DIR /usr/local /usr; do
  2289. if test -x "$i/bin/xml2-config"; then
  2290. ac_cv_php_xml2_config_path="$i/bin/xml2-config"
  2291. break
  2292. fi
  2293. done
  2294. ])
  2295. if test -x "$ac_cv_php_xml2_config_path"; then
  2296. XML2_CONFIG="$ac_cv_php_xml2_config_path"
  2297. libxml_full_version=`$XML2_CONFIG --version`
  2298. ac_IFS=$IFS
  2299. IFS="."
  2300. set $libxml_full_version
  2301. IFS=$ac_IFS
  2302. LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
  2303. if test "$LIBXML_VERSION" -ge "2006011"; then
  2304. LIBXML_LIBS=`$XML2_CONFIG --libs`
  2305. LIBXML_INCS=`$XML2_CONFIG --cflags`
  2306. PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
  2307. PHP_EVAL_INCLINE($LIBXML_INCS)
  2308. dnl Check that build works with given libs
  2309. AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
  2310. PHP_TEST_BUILD(xmlInitParser,
  2311. [
  2312. php_cv_libxml_build_works=yes
  2313. ], [
  2314. AC_MSG_RESULT(no)
  2315. AC_MSG_ERROR([build test failed. Please check the config.log for details.])
  2316. ], [
  2317. [$]$1
  2318. ])
  2319. ])
  2320. if test "$php_cv_libxml_build_works" = "yes"; then
  2321. AC_DEFINE(HAVE_LIBXML, 1, [ ])
  2322. fi
  2323. $2
  2324. else
  2325. AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
  2326. fi
  2327. ifelse([$3],[],,[else $3])
  2328. fi
  2329. ])
  2330. dnl -------------------------------------------------------------------------
  2331. dnl Misc. macros
  2332. dnl -------------------------------------------------------------------------
  2333. dnl
  2334. dnl PHP_INSTALL_HEADERS(path [, file ...])
  2335. dnl
  2336. dnl PHP header files to be installed
  2337. dnl
  2338. AC_DEFUN([PHP_INSTALL_HEADERS],[
  2339. ifelse([$2],[],[
  2340. for header_file in $1; do
  2341. PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [
  2342. INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
  2343. ])
  2344. done
  2345. ], [
  2346. header_path=$1
  2347. for header_file in $2; do
  2348. hp_hf="$header_path/$header_file"
  2349. PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [
  2350. INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf"
  2351. ])
  2352. done
  2353. ])
  2354. ])
  2355. dnl
  2356. dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
  2357. dnl
  2358. dnl This macro is used to get a comparable
  2359. dnl version for apache1/2.
  2360. dnl
  2361. AC_DEFUN([PHP_AP_EXTRACT_VERSION],[
  2362. ac_output=`$1 -v 2>&1 | grep version`
  2363. ac_IFS=$IFS
  2364. IFS="- /.
  2365. "
  2366. set $ac_output
  2367. IFS=$ac_IFS
  2368. APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
  2369. ])
  2370. dnl
  2371. dnl PHP_DEBUG_MACRO(filename)
  2372. dnl
  2373. AC_DEFUN([PHP_DEBUG_MACRO],[
  2374. DEBUG_LOG=$1
  2375. cat >$1 <<X
  2376. CONFIGURE: $CONFIGURE_COMMAND
  2377. CC: $CC
  2378. CFLAGS: $CFLAGS
  2379. CPPFLAGS: $CPPFLAGS
  2380. CXX: $CXX
  2381. CXXFLAGS: $CXXFLAGS
  2382. INCLUDES: $INCLUDES
  2383. LDFLAGS: $LDFLAGS
  2384. LIBS: $LIBS
  2385. DLIBS: $DLIBS
  2386. SAPI: $PHP_SAPI
  2387. PHP_RPATHS: $PHP_RPATHS
  2388. uname -a: `uname -a`
  2389. X
  2390. cat >conftest.$ac_ext <<X
  2391. main()
  2392. {
  2393. exit(0);
  2394. }
  2395. X
  2396. (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
  2397. rm -fr conftest*
  2398. ])
  2399. dnl
  2400. dnl PHP_CONFIG_NICE(filename)
  2401. dnl
  2402. dnl Generates the config.nice file
  2403. dnl
  2404. AC_DEFUN([PHP_CONFIG_NICE],[
  2405. AC_REQUIRE([AC_PROG_EGREP])
  2406. AC_REQUIRE([LT_AC_PROG_SED])
  2407. PHP_SUBST_OLD(EGREP)
  2408. PHP_SUBST_OLD(SED)
  2409. test -f $1 && mv $1 $1.old
  2410. rm -f $1.old
  2411. cat >$1<<EOF
  2412. #! /bin/sh
  2413. #
  2414. # Created by configure
  2415. EOF
  2416. for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do
  2417. eval val=\$$var
  2418. if test -n "$val"; then
  2419. echo "$var='$val' \\" >> $1
  2420. fi
  2421. done
  2422. echo "'[$]0' \\" >> $1
  2423. if test `expr -- [$]0 : "'.*"` = 0; then
  2424. CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'"
  2425. else
  2426. CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0"
  2427. fi
  2428. for arg in $ac_configure_args; do
  2429. if test `expr -- $arg : "'.*"` = 0; then
  2430. if test `expr -- $arg : "--.*"` = 0; then
  2431. break;
  2432. fi
  2433. echo "'[$]arg' \\" >> $1
  2434. CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS '[$]arg'"
  2435. else
  2436. if test `expr -- $arg : "'--.*"` = 0; then
  2437. break;
  2438. fi
  2439. echo "[$]arg \\" >> $1
  2440. CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS [$]arg"
  2441. fi
  2442. done
  2443. echo '"[$]@"' >> $1
  2444. chmod +x $1
  2445. CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS"
  2446. PHP_SUBST_OLD(CONFIGURE_COMMAND)
  2447. PHP_SUBST_OLD(CONFIGURE_OPTIONS)
  2448. ])
  2449. dnl
  2450. dnl PHP_CHECK_CONFIGURE_OPTIONS
  2451. dnl
  2452. AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
  2453. for arg in $ac_configure_args; do
  2454. case $arg in
  2455. --with-*[)]
  2456. arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
  2457. ;;
  2458. --without-*[)]
  2459. arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
  2460. ;;
  2461. --enable-*[)]
  2462. arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
  2463. ;;
  2464. --disable-*[)]
  2465. arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
  2466. ;;
  2467. *[)]
  2468. continue
  2469. ;;
  2470. esac
  2471. case $arg_name in
  2472. # Allow --disable-all / --enable-all
  2473. enable-all[)];;
  2474. # Allow certain libtool options
  2475. enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];;
  2476. # Allow certain TSRM options
  2477. with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads[)];;
  2478. # Allow certain Zend options
  2479. with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];;
  2480. # All the rest must be set using the PHP_ARG_* macros
  2481. # PHP_ARG_* macros set php_enable_<arg_name> or php_with_<arg_name>
  2482. *[)]
  2483. # Options that exist before PHP 6
  2484. if test "$PHP_MAJOR_VERSION" -lt "6"; then
  2485. case $arg_name in
  2486. enable-zend-multibyte[)] continue;;
  2487. esac
  2488. fi
  2489. is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'`
  2490. if eval test "x\$$is_arg_set" = "x"; then
  2491. PHP_UNKNOWN_CONFIGURE_OPTIONS="$PHP_UNKNOWN_CONFIGURE_OPTIONS
  2492. [$]arg"
  2493. fi
  2494. ;;
  2495. esac
  2496. done
  2497. ])
  2498. dnl
  2499. dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]])
  2500. dnl
  2501. AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[
  2502. AC_CACHE_CHECK([for PDO includes], pdo_inc_path, [
  2503. AC_MSG_CHECKING([for PDO includes])
  2504. if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
  2505. pdo_inc_path=$abs_srcdir/ext
  2506. elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
  2507. pdo_inc_path=$abs_srcdir/ext
  2508. elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
  2509. pdo_inc_path=$prefix/include/php/ext
  2510. fi
  2511. ])
  2512. if test -n "$pdo_inc_path"; then
  2513. ifelse([$1],[],:,[$1])
  2514. else
  2515. ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2])
  2516. fi
  2517. ])
  2518. dnl
  2519. dnl PHP_DETECT_ICC
  2520. dnl Detect Intel C++ Compiler and unset $GCC if ICC found
  2521. AC_DEFUN([PHP_DETECT_ICC],
  2522. [
  2523. ICC="no"
  2524. AC_MSG_CHECKING([for icc])
  2525. AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
  2526. ICC="no"
  2527. AC_MSG_RESULT([no]),
  2528. ICC="yes"
  2529. GCC="no"
  2530. AC_MSG_RESULT([yes])
  2531. )
  2532. ])
  2533. dnl
  2534. dnl PHP_CRYPT_R_STYLE
  2535. dnl detect the style of crypt_r() is any is available
  2536. dnl see APR_CHECK_CRYPT_R_STYLE() for original version
  2537. dnl
  2538. AC_DEFUN([PHP_CRYPT_R_STYLE],
  2539. [
  2540. AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[
  2541. php_cv_crypt_r_style=none
  2542. AC_TRY_COMPILE([
  2543. #define _REENTRANT 1
  2544. #include <crypt.h>
  2545. ],[
  2546. CRYPTD buffer;
  2547. crypt_r("passwd", "hash", &buffer);
  2548. ],
  2549. php_cv_crypt_r_style=cryptd)
  2550. if test "$php_cv_crypt_r_style" = "none"; then
  2551. AC_TRY_COMPILE([
  2552. #define _REENTRANT 1
  2553. #include <crypt.h>
  2554. ],[
  2555. struct crypt_data buffer;
  2556. crypt_r("passwd", "hash", &buffer);
  2557. ],
  2558. php_cv_crypt_r_style=struct_crypt_data)
  2559. fi
  2560. if test "$php_cv_crypt_r_style" = "none"; then
  2561. AC_TRY_COMPILE([
  2562. #define _REENTRANT 1
  2563. #define _GNU_SOURCE
  2564. #include <crypt.h>
  2565. ],[
  2566. struct crypt_data buffer;
  2567. crypt_r("passwd", "hash", &buffer);
  2568. ],
  2569. php_cv_crypt_r_style=struct_crypt_data_gnu_source)
  2570. fi
  2571. ])
  2572. if test "$php_cv_crypt_r_style" = "cryptd"; then
  2573. AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
  2574. fi
  2575. if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
  2576. AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
  2577. fi
  2578. if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
  2579. AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE])
  2580. fi
  2581. if test "$php_cv_crypt_r_style" = "none"; then
  2582. AC_MSG_ERROR([Unable to detect data struct used by crypt_r])
  2583. fi
  2584. ])
  2585. dnl
  2586. dnl PHP_TEST_WRITE_STDOUT
  2587. dnl
  2588. AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
  2589. AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
  2590. AC_TRY_RUN([
  2591. #ifdef HAVE_UNISTD_H
  2592. #include <unistd.h>
  2593. #endif
  2594. #define TEXT "This is the test message -- "
  2595. main()
  2596. {
  2597. int n;
  2598. n = write(1, TEXT, sizeof(TEXT)-1);
  2599. return (!(n == sizeof(TEXT)-1));
  2600. }
  2601. ],[
  2602. ac_cv_write_stdout=yes
  2603. ],[
  2604. ac_cv_write_stdout=no
  2605. ],[
  2606. ac_cv_write_stdout=no
  2607. ])
  2608. ])
  2609. if test "$ac_cv_write_stdout" = "yes"; then
  2610. AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])
  2611. fi
  2612. ])