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.

2942 lines
75 KiB

21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
23 years ago
26 years ago
23 years ago
23 years ago
26 years ago
23 years ago
26 years ago
23 years ago
23 years ago
23 years ago
23 years ago
27 years ago
24 years ago
22 years ago
22 years ago
21 years ago
21 years ago
21 years ago
21 years ago
27 years ago
21 years ago
26 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
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 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
18 years ago
20 years ago
16 years ago
16 years ago
16 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. case $host_alias in
  710. *darwin*)
  711. PHP_ADD_LIBRARY(stdc++)
  712. ;;
  713. esac
  714. php_cxx_done=yes
  715. fi
  716. ])
  717. dnl
  718. dnl PHP_BUILD_SHARED
  719. dnl
  720. AC_DEFUN([PHP_BUILD_SHARED],[
  721. PHP_BUILD_PROGRAM
  722. OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
  723. php_build_target=shared
  724. php_c_pre=$shared_c_pre
  725. php_c_meta=$shared_c_meta
  726. php_c_post=$shared_c_post
  727. php_cxx_pre=$shared_cxx_pre
  728. php_cxx_meta=$shared_cxx_meta
  729. php_cxx_post=$shared_cxx_post
  730. php_lo=$shared_lo
  731. ])
  732. dnl
  733. dnl PHP_BUILD_STATIC
  734. dnl
  735. AC_DEFUN([PHP_BUILD_STATIC],[
  736. PHP_BUILD_PROGRAM
  737. OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
  738. php_build_target=static
  739. ])
  740. dnl
  741. dnl PHP_BUILD_BUNDLE
  742. dnl
  743. AC_DEFUN([PHP_BUILD_BUNDLE],[
  744. PHP_BUILD_PROGRAM
  745. OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle]
  746. php_build_target=static
  747. ])
  748. dnl
  749. dnl PHP_BUILD_PROGRAM
  750. dnl
  751. AC_DEFUN([PHP_BUILD_PROGRAM],[
  752. OVERALL_TARGET=[]ifelse($1,,php,$1)
  753. php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  754. php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
  755. php_c_post=
  756. php_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  757. php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
  758. php_cxx_post=
  759. php_lo=lo
  760. case $with_pic in
  761. yes) pic_setting='-prefer-pic';;
  762. no) pic_setting='-prefer-non-pic';;
  763. esac
  764. shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  765. shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) '$pic_setting
  766. shared_c_post=
  767. shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  768. shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) '$pic_setting
  769. shared_cxx_post=
  770. shared_lo=lo
  771. php_build_target=program
  772. ])
  773. dnl
  774. dnl PHP_SHARED_MODULE(module-name, object-var, build-dir, cxx, zend_ext)
  775. dnl
  776. dnl Basically sets up the link-stage for building module-name
  777. dnl from object_var in build-dir.
  778. dnl
  779. AC_DEFUN([PHP_SHARED_MODULE],[
  780. install_modules="install-modules"
  781. case $host_alias in
  782. *aix*[)]
  783. suffix=so
  784. 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'
  785. ;;
  786. *netware*[)]
  787. suffix=nlm
  788. 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)'
  789. ;;
  790. *[)]
  791. suffix=la
  792. 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)'
  793. ;;
  794. esac
  795. if test "x$5" = "xyes"; then
  796. PHP_ZEND_EX="$PHP_ZEND_EX \$(phplibdir)/$1.$suffix"
  797. else
  798. PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.$suffix"
  799. fi
  800. PHP_SUBST($2)
  801. cat >>Makefile.objects<<EOF
  802. \$(phplibdir)/$1.$suffix: $3/$1.$suffix
  803. \$(LIBTOOL) --mode=install cp $3/$1.$suffix \$(phplibdir)
  804. $3/$1.$suffix: \$($2) \$(translit($1,a-z_-,A-Z__)_SHARED_DEPENDENCIES)
  805. $link_cmd
  806. EOF
  807. ])
  808. dnl
  809. dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
  810. dnl
  811. dnl Selects the SAPI name and type (static, shared, programm)
  812. dnl and optionally also the source-files for the SAPI-specific
  813. dnl objects.
  814. dnl
  815. AC_DEFUN([PHP_SELECT_SAPI],[
  816. PHP_SAPI=$1
  817. case "$2" in
  818. static[)] PHP_BUILD_STATIC;;
  819. shared[)] PHP_BUILD_SHARED;;
  820. bundle[)] PHP_BUILD_BUNDLE;;
  821. program[)] PHP_BUILD_PROGRAM($5);;
  822. esac
  823. ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
  824. ])
  825. dnl deprecated
  826. AC_DEFUN([PHP_EXTENSION],[
  827. sources=`$AWK -f $abs_srcdir/build/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
  828. PHP_NEW_EXTENSION($1, $sources, $2, $3)
  829. if test -r "$ext_srcdir/Makefile.frag"; then
  830. PHP_ADD_MAKEFILE_FRAGMENT
  831. fi
  832. ])
  833. AC_DEFUN([PHP_ADD_BUILD_DIR],[
  834. ifelse($2,,[
  835. BUILD_DIR="$BUILD_DIR $1"
  836. ], [
  837. $php_shtool mkdir -p $1
  838. ])
  839. ])
  840. AC_DEFUN([PHP_GEN_BUILD_DIRS],[
  841. $php_shtool mkdir -p $BUILD_DIR
  842. ])
  843. dnl
  844. dnl PHP_NEW_EXTENSION(extname, sources [, shared [, sapi_class [, extra-cflags [, cxx [, zend_ext]]]]])
  845. dnl
  846. dnl Includes an extension in the build.
  847. dnl
  848. dnl "extname" is the name of the ext/ subdir where the extension resides.
  849. dnl "sources" is a list of files relative to the subdir which are used
  850. dnl to build the extension.
  851. dnl "shared" can be set to "shared" or "yes" to build the extension as
  852. dnl a dynamically loadable library. Optional parameter "sapi_class" can
  853. dnl be set to "cli" to mark extension build only with CLI or CGI sapi's.
  854. dnl "extra-cflags" are passed to the compiler, with
  855. dnl @ext_srcdir@ and @ext_builddir@ being substituted.
  856. dnl "cxx" can be used to indicate that a C++ shared module is desired.
  857. dnl "zend_ext" indicates a zend extension.
  858. AC_DEFUN([PHP_NEW_EXTENSION],[
  859. ext_builddir=[]PHP_EXT_BUILDDIR($1)
  860. ext_srcdir=[]PHP_EXT_SRCDIR($1)
  861. ifelse($5,,ac_extra=,[ac_extra=`echo "$5"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g`])
  862. if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then
  863. dnl ---------------------------------------------- Static module
  864. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
  865. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
  866. EXT_STATIC="$EXT_STATIC $1"
  867. if test "$3" != "nocli"; then
  868. EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
  869. fi
  870. else
  871. if test "$3" = "shared" || test "$3" = "yes"; then
  872. dnl ---------------------------------------------- Shared module
  873. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes
  874. PHP_ADD_SOURCES_X(PHP_EXT_DIR($1),$2,$ac_extra,shared_objects_$1,yes)
  875. case $host_alias in
  876. *netware*[)]
  877. PHP_SHARED_MODULE(php$1,shared_objects_$1, $ext_builddir, $6, $7)
  878. ;;
  879. *[)]
  880. PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7)
  881. ;;
  882. esac
  883. AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
  884. fi
  885. fi
  886. if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then
  887. dnl ---------------------------------------------- CLI static module
  888. [PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=no
  889. case "$PHP_SAPI" in
  890. cgi|embed[)]
  891. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
  892. EXT_STATIC="$EXT_STATIC $1"
  893. ;;
  894. *[)]
  895. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cli)
  896. ;;
  897. esac
  898. EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
  899. fi
  900. PHP_ADD_BUILD_DIR($ext_builddir)
  901. dnl Set for phpize builds only
  902. dnl ---------------------------
  903. if test "$ext_builddir" = "."; then
  904. PHP_PECL_EXTENSION=$1
  905. PHP_SUBST(PHP_PECL_EXTENSION)
  906. fi
  907. ])
  908. dnl
  909. dnl PHP_WITH_SHARED
  910. dnl
  911. dnl Checks whether $withval is "shared" or starts with "shared,XXX"
  912. dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
  913. dnl from $withval.
  914. dnl
  915. AC_DEFUN([PHP_WITH_SHARED],[
  916. PHP_ARG_ANALYZE_EX(withval)
  917. shared=$ext_shared
  918. unset ext_shared ext_output
  919. ])
  920. dnl
  921. dnl PHP_ADD_EXTENSION_DEP(extname, depends [, depconf])
  922. dnl
  923. dnl This macro is scanned by genif.sh when it builds the internal functions
  924. dnl list, so that modules can be init'd in the correct order
  925. dnl $1 = name of extension, $2 = extension upon which it depends
  926. dnl $3 = optional: if true, it's ok for $2 to have not been configured
  927. dnl default is false and should halt the build.
  928. dnl To be effective, this macro must be invoked *after* PHP_NEW_EXTENSION.
  929. dnl The extension on which it depends must also have been configured.
  930. dnl See ADD_EXTENSION_DEP in win32 build
  931. dnl
  932. AC_DEFUN([PHP_ADD_EXTENSION_DEP], [
  933. am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]
  934. is_it_shared=$[PHP_]translit($2,a-z_-,A-Z__)[_SHARED]
  935. is_it_enabled=$[PHP_]translit($2,a-z_-,A-Z__)
  936. if test "$am_i_shared" = "no" && test "$is_it_shared" = "yes" ; then
  937. AC_MSG_ERROR([
  938. You've configured extension $1 to build statically, but it
  939. depends on extension $2, which you've configured to build shared.
  940. You either need to build $1 shared or build $2 statically for the
  941. build to be successful.
  942. ])
  943. fi
  944. if test "x$is_it_enabled" = "xno" && test "x$3" != "xtrue"; then
  945. AC_MSG_ERROR([
  946. You've configured extension $1, which depends on extension $2,
  947. but you've either not enabled $2, or have disabled it.
  948. ])
  949. fi
  950. dnl Some systems require that we link $2 to $1 when building
  951. ])
  952. dnl -------------------------------------------------------------------------
  953. dnl Checks for structures, typedefs, broken functions, etc.
  954. dnl -------------------------------------------------------------------------
  955. dnl Internal helper macros
  956. dnl
  957. dnl _PHP_DEF_HAVE_FILE(what, filename)
  958. AC_DEFUN([_PHP_DEF_HAVE_FILE], [
  959. php_def_have_what=HAVE_[]`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz-' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_' `
  960. echo "#define $php_def_have_what 1" >> $2
  961. ])
  962. dnl
  963. dnl _PHP_CHECK_SIZEOF(type, cross-value, extra-headers [, found-action [, not-found-action]])
  964. dnl
  965. AC_DEFUN([_PHP_CHECK_SIZEOF], [
  966. php_cache_value=php_cv_sizeof_[]$1
  967. AC_CACHE_VAL(php_cv_sizeof_[]$1, [
  968. old_LIBS=$LIBS
  969. LIBS=
  970. old_LDFLAGS=$LDFLAGS
  971. LDFLAGS=
  972. AC_TRY_RUN([#include <stdio.h>
  973. #if STDC_HEADERS
  974. #include <stdlib.h>
  975. #include <stddef.h>
  976. #endif
  977. #ifdef HAVE_INTTYPES_H
  978. #include <inttypes.h>
  979. #endif
  980. #ifdef HAVE_UNISTD_H
  981. #include <unistd.h>
  982. #endif
  983. $3
  984. int main()
  985. {
  986. FILE *fp = fopen("conftestval", "w");
  987. if (!fp) return(1);
  988. fprintf(fp, "%d\n", sizeof($1));
  989. return(0);
  990. }
  991. ], [
  992. eval $php_cache_value=`cat conftestval`
  993. ], [
  994. eval $php_cache_value=0
  995. ], [
  996. ifelse([$2],,[eval $php_cache_value=0], [eval $php_cache_value=$2])
  997. ])
  998. LDFLAGS=$old_LDFLAGS
  999. LIBS=$old_LIBS
  1000. ])
  1001. if eval test "\$$php_cache_value" != "0"; then
  1002. ifelse([$4],[],:,[$4])
  1003. ifelse([$5],[],,[else $5])
  1004. fi
  1005. ])
  1006. dnl
  1007. dnl PHP_CHECK_SIZEOF(type, cross-value, extra-headers)
  1008. dnl
  1009. AC_DEFUN([PHP_CHECK_SIZEOF], [
  1010. AC_MSG_CHECKING([size of $1])
  1011. _PHP_CHECK_SIZEOF($1, $2, $3, [
  1012. AC_DEFINE_UNQUOTED([SIZEOF_]translit($1,a-z,A-Z_), [$]php_cv_sizeof_[]$1, [Size of $1])
  1013. AC_DEFINE_UNQUOTED([HAVE_]translit($1,a-z,A-Z_), 1, [Whether $1 is available])
  1014. ])
  1015. AC_MSG_RESULT([[$][php_cv_sizeof_]translit($1, ,_)])
  1016. ])
  1017. dnl
  1018. dnl PHP_CHECK_TYPES(type-list, include-file [, extra-headers])
  1019. dnl
  1020. AC_DEFUN([PHP_CHECK_TYPES], [
  1021. for php_typename in $1; do
  1022. AC_MSG_CHECKING([whether $php_typename exists])
  1023. _PHP_CHECK_SIZEOF($php_typename, 0, $3, [
  1024. _PHP_DEF_HAVE_FILE($php_typename, $2)
  1025. AC_MSG_RESULT([yes])
  1026. ], [
  1027. AC_MSG_RESULT([no])
  1028. ])
  1029. done
  1030. ])
  1031. dnl
  1032. dnl PHP_CHECK_IN_ADDR_T
  1033. dnl
  1034. AC_DEFUN([PHP_CHECK_IN_ADDR_T], [
  1035. dnl AIX keeps in_addr_t in /usr/include/netinet/in.h
  1036. AC_MSG_CHECKING([for in_addr_t])
  1037. AC_CACHE_VAL(ac_cv_type_in_addr_t,
  1038. [AC_EGREP_CPP(dnl
  1039. changequote(<<,>>)dnl
  1040. <<in_addr_t[^a-zA-Z_0-9]>>dnl
  1041. changequote([,]), [#include <sys/types.h>
  1042. #if STDC_HEADERS
  1043. #include <stdlib.h>
  1044. #include <stddef.h>
  1045. #endif
  1046. #ifdef HAVE_NETINET_IN_H
  1047. #include <netinet/in.h>
  1048. #endif], ac_cv_type_in_addr_t=yes, ac_cv_type_in_addr_t=no)])dnl
  1049. AC_MSG_RESULT([$ac_cv_type_in_addr_t])
  1050. if test $ac_cv_type_in_addr_t = no; then
  1051. AC_DEFINE(in_addr_t, u_int, [ ])
  1052. fi
  1053. ])
  1054. dnl
  1055. dnl PHP_TIME_R_TYPE
  1056. dnl
  1057. dnl Check type of reentrant time-related functions
  1058. dnl Type can be: irix, hpux or POSIX
  1059. dnl
  1060. AC_DEFUN([PHP_TIME_R_TYPE],[
  1061. AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
  1062. AC_TRY_RUN([
  1063. #include <time.h>
  1064. main() {
  1065. char buf[27];
  1066. struct tm t;
  1067. time_t old = 0;
  1068. int r, s;
  1069. s = gmtime_r(&old, &t);
  1070. r = (int) asctime_r(&t, buf, 26);
  1071. if (r == s && s == 0) return (0);
  1072. return (1);
  1073. }
  1074. ],[
  1075. ac_cv_time_r_type=hpux
  1076. ],[
  1077. AC_TRY_RUN([
  1078. #include <time.h>
  1079. main() {
  1080. struct tm t, *s;
  1081. time_t old = 0;
  1082. char buf[27], *p;
  1083. s = gmtime_r(&old, &t);
  1084. p = asctime_r(&t, buf, 26);
  1085. if (p == buf && s == &t) return (0);
  1086. return (1);
  1087. }
  1088. ],[
  1089. ac_cv_time_r_type=irix
  1090. ],[
  1091. ac_cv_time_r_type=POSIX
  1092. ],[
  1093. ac_cv_time_r_type=POSIX
  1094. ])
  1095. ],[
  1096. ac_cv_time_r_type=POSIX
  1097. ])
  1098. ])
  1099. case $ac_cv_time_r_type in
  1100. hpux[)] AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
  1101. irix[)] AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
  1102. esac
  1103. ])
  1104. dnl
  1105. dnl PHP_DOES_PWRITE_WORK
  1106. dnl internal
  1107. AC_DEFUN([PHP_DOES_PWRITE_WORK],[
  1108. AC_TRY_RUN([
  1109. #include <sys/types.h>
  1110. #include <sys/stat.h>
  1111. #include <fcntl.h>
  1112. #include <unistd.h>
  1113. #include <errno.h>
  1114. $1
  1115. main() {
  1116. int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
  1117. if (fd < 0) exit(1);
  1118. if (pwrite(fd, "text", 4, 0) != 4) exit(1);
  1119. /* Linux glibc breakage until 2.2.5 */
  1120. if (pwrite(fd, "text", 4, -1) != -1 || errno != EINVAL) exit(1);
  1121. exit(0);
  1122. }
  1123. ],[
  1124. ac_cv_pwrite=yes
  1125. ],[
  1126. ac_cv_pwrite=no
  1127. ],[
  1128. ac_cv_pwrite=no
  1129. ])
  1130. ])
  1131. dnl PHP_DOES_PREAD_WORK
  1132. dnl internal
  1133. AC_DEFUN([PHP_DOES_PREAD_WORK],[
  1134. echo test > conftest_in
  1135. AC_TRY_RUN([
  1136. #include <sys/types.h>
  1137. #include <sys/stat.h>
  1138. #include <fcntl.h>
  1139. #include <unistd.h>
  1140. #include <errno.h>
  1141. $1
  1142. main() {
  1143. char buf[3];
  1144. int fd = open("conftest_in", O_RDONLY);
  1145. if (fd < 0) exit(1);
  1146. if (pread(fd, buf, 2, 0) != 2) exit(1);
  1147. /* Linux glibc breakage until 2.2.5 */
  1148. if (pread(fd, buf, 2, -1) != -1 || errno != EINVAL) exit(1);
  1149. exit(0);
  1150. }
  1151. ],[
  1152. ac_cv_pread=yes
  1153. ],[
  1154. ac_cv_pread=no
  1155. ],[
  1156. ac_cv_pread=no
  1157. ])
  1158. rm -f conftest_in
  1159. ])
  1160. dnl
  1161. dnl PHP_PWRITE_TEST
  1162. dnl
  1163. AC_DEFUN([PHP_PWRITE_TEST],[
  1164. AC_CACHE_CHECK(whether pwrite works,ac_cv_pwrite,[
  1165. PHP_DOES_PWRITE_WORK
  1166. if test "$ac_cv_pwrite" = "no"; then
  1167. PHP_DOES_PWRITE_WORK([ssize_t pwrite(int, void *, size_t, off64_t);])
  1168. if test "$ac_cv_pwrite" = "yes"; then
  1169. ac_cv_pwrite=64
  1170. fi
  1171. fi
  1172. ])
  1173. if test "$ac_cv_pwrite" != "no"; then
  1174. AC_DEFINE(HAVE_PWRITE, 1, [ ])
  1175. if test "$ac_cv_pwrite" = "64"; then
  1176. AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
  1177. fi
  1178. fi
  1179. ])
  1180. dnl
  1181. dnl PHP_PREAD_TEST
  1182. dnl
  1183. AC_DEFUN([PHP_PREAD_TEST],[
  1184. AC_CACHE_CHECK(whether pread works,ac_cv_pread,[
  1185. PHP_DOES_PREAD_WORK
  1186. if test "$ac_cv_pread" = "no"; then
  1187. PHP_DOES_PREAD_WORK([ssize_t pread(int, void *, size_t, off64_t);])
  1188. if test "$ac_cv_pread" = "yes"; then
  1189. ac_cv_pread=64
  1190. fi
  1191. fi
  1192. ])
  1193. if test "$ac_cv_pread" != "no"; then
  1194. AC_DEFINE(HAVE_PREAD, 1, [ ])
  1195. if test "$ac_cv_pread" = "64"; then
  1196. AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
  1197. fi
  1198. fi
  1199. ])
  1200. dnl
  1201. dnl PHP_MISSING_TIME_R_DECL
  1202. dnl
  1203. AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
  1204. AC_MSG_CHECKING([for missing declarations of reentrant functions])
  1205. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
  1206. :
  1207. ],[
  1208. AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
  1209. ])
  1210. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
  1211. :
  1212. ],[
  1213. AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
  1214. ])
  1215. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
  1216. :
  1217. ],[
  1218. AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
  1219. ])
  1220. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
  1221. :
  1222. ],[
  1223. AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
  1224. ])
  1225. AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
  1226. :
  1227. ],[
  1228. AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
  1229. ])
  1230. AC_MSG_RESULT([done])
  1231. ])
  1232. dnl
  1233. dnl PHP_READDIR_R_TYPE
  1234. dnl
  1235. AC_DEFUN([PHP_READDIR_R_TYPE],[
  1236. dnl HAVE_READDIR_R is also defined by libmysql
  1237. AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
  1238. if test "$ac_cv_func_readdir_r" = "yes"; then
  1239. AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
  1240. AC_TRY_RUN([
  1241. #define _REENTRANT
  1242. #include <sys/types.h>
  1243. #include <dirent.h>
  1244. #ifndef PATH_MAX
  1245. #define PATH_MAX 1024
  1246. #endif
  1247. main() {
  1248. DIR *dir;
  1249. char entry[sizeof(struct dirent)+PATH_MAX];
  1250. struct dirent *pentry = (struct dirent *) &entry;
  1251. dir = opendir("/");
  1252. if (!dir)
  1253. exit(1);
  1254. if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
  1255. exit(0);
  1256. exit(1);
  1257. }
  1258. ],[
  1259. ac_cv_what_readdir_r=POSIX
  1260. ],[
  1261. AC_TRY_CPP([
  1262. #define _REENTRANT
  1263. #include <sys/types.h>
  1264. #include <dirent.h>
  1265. int readdir_r(DIR *, struct dirent *);
  1266. ],[
  1267. ac_cv_what_readdir_r=old-style
  1268. ],[
  1269. ac_cv_what_readdir_r=none
  1270. ])
  1271. ],[
  1272. ac_cv_what_readdir_r=none
  1273. ])
  1274. ])
  1275. case $ac_cv_what_readdir_r in
  1276. POSIX)
  1277. AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
  1278. old-style)
  1279. AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
  1280. esac
  1281. fi
  1282. ])
  1283. dnl
  1284. dnl PHP_TM_GMTOFF
  1285. dnl
  1286. AC_DEFUN([PHP_TM_GMTOFF],[
  1287. AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
  1288. [AC_TRY_COMPILE([#include <sys/types.h>
  1289. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  1290. ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
  1291. if test "$ac_cv_struct_tm_gmtoff" = yes; then
  1292. AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
  1293. fi
  1294. ])
  1295. dnl
  1296. dnl PHP_STRUCT_FLOCK
  1297. dnl
  1298. AC_DEFUN([PHP_STRUCT_FLOCK],[
  1299. AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
  1300. AC_TRY_COMPILE([
  1301. #include <unistd.h>
  1302. #include <fcntl.h>
  1303. ],
  1304. [struct flock x;],
  1305. [
  1306. ac_cv_struct_flock=yes
  1307. ],[
  1308. ac_cv_struct_flock=no
  1309. ])
  1310. )
  1311. if test "$ac_cv_struct_flock" = "yes" ; then
  1312. AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
  1313. fi
  1314. ])
  1315. dnl
  1316. dnl PHP_SOCKLEN_T
  1317. dnl
  1318. AC_DEFUN([PHP_SOCKLEN_T],[
  1319. AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
  1320. AC_TRY_COMPILE([
  1321. #include <sys/types.h>
  1322. #include <sys/socket.h>
  1323. ],[
  1324. socklen_t x;
  1325. ],[
  1326. ac_cv_socklen_t=yes
  1327. ],[
  1328. ac_cv_socklen_t=no
  1329. ]))
  1330. if test "$ac_cv_socklen_t" = "yes"; then
  1331. AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
  1332. fi
  1333. ])
  1334. dnl
  1335. dnl PHP_MISSING_FCLOSE_DECL
  1336. dnl
  1337. dnl See if we have broken header files like SunOS has.
  1338. dnl
  1339. AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
  1340. AC_MSG_CHECKING([for fclose declaration])
  1341. AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
  1342. AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
  1343. AC_MSG_RESULT([ok])
  1344. ],[
  1345. AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
  1346. AC_MSG_RESULT([missing])
  1347. ])
  1348. ])
  1349. dnl
  1350. dnl PHP_AC_BROKEN_SPRINTF
  1351. dnl
  1352. dnl Check for broken sprintf(), C99 conformance
  1353. dnl
  1354. AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[
  1355. AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
  1356. AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
  1357. ac_cv_broken_sprintf=no
  1358. ],[
  1359. ac_cv_broken_sprintf=yes
  1360. ],[
  1361. ac_cv_broken_sprintf=no
  1362. ])
  1363. ])
  1364. if test "$ac_cv_broken_sprintf" = "yes"; then
  1365. AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform])
  1366. else
  1367. AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform])
  1368. fi
  1369. ])
  1370. dnl
  1371. dnl PHP_AC_BROKEN_SNPRINTF
  1372. dnl
  1373. dnl Check for broken snprintf(), C99 conformance
  1374. dnl
  1375. AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[
  1376. AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[
  1377. AC_TRY_RUN([
  1378. #define NULL (0L)
  1379. main() {
  1380. char buf[20];
  1381. int res = 0;
  1382. res = res || (snprintf(buf, 2, "marcus") != 6);
  1383. res = res || (buf[1] != '\0');
  1384. /* Implementations may consider this as an encoding error */
  1385. snprintf(buf, 0, "boerger");
  1386. /* However, they MUST ignore the pointer */
  1387. res = res || (buf[0] != 'm');
  1388. res = res || (snprintf(NULL, 0, "boerger") != 7);
  1389. res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
  1390. exit(res);
  1391. }
  1392. ],[
  1393. ac_cv_broken_snprintf=no
  1394. ],[
  1395. ac_cv_broken_snprintf=yes
  1396. ],[
  1397. ac_cv_broken_snprintf=no
  1398. ])
  1399. ])
  1400. if test "$ac_cv_broken_snprintf" = "yes"; then
  1401. AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform])
  1402. else
  1403. AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform])
  1404. fi
  1405. ])
  1406. dnl
  1407. dnl PHP_SOLARIS_PIC_WEIRDNESS
  1408. dnl
  1409. dnl Solaris requires main code to be position independent in order
  1410. dnl to let shared objects find symbols. Weird. Ugly.
  1411. dnl
  1412. dnl Must be run after all --with-NN options that let the user
  1413. dnl choose dynamic extensions, and after the gcc test.
  1414. dnl
  1415. AC_DEFUN([PHP_SOLARIS_PIC_WEIRDNESS],[
  1416. AC_MSG_CHECKING([whether -fPIC is required])
  1417. if test -n "$EXT_SHARED"; then
  1418. os=`uname -sr 2>/dev/null`
  1419. case $os in
  1420. "SunOS 5.6"|"SunOS 5.7"[)]
  1421. case $CC in
  1422. gcc*|egcs*)
  1423. CFLAGS="$CFLAGS -fPIC";;
  1424. *[)]
  1425. CFLAGS="$CFLAGS -fpic";;
  1426. esac
  1427. AC_MSG_RESULT([yes]);;
  1428. *[)]
  1429. AC_MSG_RESULT([no]);;
  1430. esac
  1431. else
  1432. AC_MSG_RESULT([no])
  1433. fi
  1434. ])
  1435. dnl
  1436. dnl PHP_SYS_LFS
  1437. dnl
  1438. dnl The problem is that the default compilation flags in Solaris 2.6 won't
  1439. dnl let programs access large files; you need to tell the compiler that
  1440. dnl you actually want your programs to work on large files. For more
  1441. dnl details about this brain damage please see:
  1442. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  1443. dnl
  1444. dnl Written by Paul Eggert <eggert@twinsun.com>.
  1445. dnl
  1446. AC_DEFUN([PHP_SYS_LFS],
  1447. [dnl
  1448. # If available, prefer support for large files unless the user specified
  1449. # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
  1450. AC_MSG_CHECKING([whether large file support needs explicit enabling])
  1451. ac_getconfs=''
  1452. ac_result=yes
  1453. ac_set=''
  1454. ac_shellvars='CPPFLAGS LDFLAGS LIBS'
  1455. for ac_shellvar in $ac_shellvars; do
  1456. case $ac_shellvar in
  1457. CPPFLAGS[)] ac_lfsvar=LFS_CFLAGS ;;
  1458. *[)] ac_lfsvar=LFS_$ac_shellvar ;;
  1459. esac
  1460. eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
  1461. (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
  1462. ac_getconf=`getconf $ac_lfsvar`
  1463. ac_getconfs=$ac_getconfs$ac_getconf
  1464. eval ac_test_$ac_shellvar=\$ac_getconf
  1465. done
  1466. case "$ac_result$ac_getconfs" in
  1467. yes[)] ac_result=no ;;
  1468. esac
  1469. case "$ac_result$ac_set" in
  1470. yes?*[)] ac_result="yes, but $ac_set is already set, so use its settings"
  1471. esac
  1472. AC_MSG_RESULT([$ac_result])
  1473. case $ac_result in
  1474. yes[)]
  1475. for ac_shellvar in $ac_shellvars; do
  1476. eval $ac_shellvar=\$ac_test_$ac_shellvar
  1477. done ;;
  1478. esac
  1479. ])
  1480. dnl
  1481. dnl PHP_SOCKADDR_CHECKS
  1482. dnl
  1483. AC_DEFUN([PHP_SOCKADDR_CHECKS], [
  1484. dnl Check for struct sockaddr_storage exists
  1485. AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage,
  1486. [AC_TRY_COMPILE([#include <sys/types.h>
  1487. #include <sys/socket.h>],
  1488. [struct sockaddr_storage s; s],
  1489. [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no])
  1490. ])
  1491. if test "$ac_cv_sockaddr_storage" = "yes"; then
  1492. AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
  1493. fi
  1494. dnl Check if field sa_len exists in struct sockaddr
  1495. AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  1496. AC_TRY_COMPILE([#include <sys/types.h>
  1497. #include <sys/socket.h>],
  1498. [static struct sockaddr sa; int n = (int) sa.sa_len; return n;],
  1499. [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no])
  1500. ])
  1501. if test "$ac_cv_sockaddr_sa_len" = "yes"; then
  1502. AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len])
  1503. fi
  1504. ])
  1505. dnl
  1506. dnl PHP_DECLARED_TIMEZONE
  1507. dnl
  1508. AC_DEFUN([PHP_DECLARED_TIMEZONE],[
  1509. AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
  1510. AC_TRY_COMPILE([
  1511. #include <sys/types.h>
  1512. #include <time.h>
  1513. #ifdef HAVE_SYS_TIME_H
  1514. #include <sys/time.h>
  1515. #endif
  1516. ],[
  1517. time_t foo = (time_t) timezone;
  1518. ],[
  1519. ac_cv_declared_timezone=yes
  1520. ],[
  1521. ac_cv_declared_timezone=no
  1522. ])])
  1523. if test "$ac_cv_declared_timezone" = "yes"; then
  1524. AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
  1525. fi
  1526. ])
  1527. dnl
  1528. dnl PHP_EBCDIC
  1529. dnl
  1530. AC_DEFUN([PHP_EBCDIC], [
  1531. AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
  1532. AC_TRY_RUN( [
  1533. int main(void) {
  1534. return (unsigned char)'A' != (unsigned char)0xC1;
  1535. }
  1536. ],[
  1537. ac_cv_ebcdic=yes
  1538. ],[
  1539. ac_cv_ebcdic=no
  1540. ],[
  1541. ac_cv_ebcdic=no
  1542. ])])
  1543. if test "$ac_cv_ebcdic" = "yes"; then
  1544. AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
  1545. fi
  1546. ])
  1547. dnl
  1548. dnl PHP_BROKEN_GETCWD
  1549. dnl
  1550. dnl Some systems, notably Solaris, cause getcwd() or realpath to fail if a
  1551. dnl component of the path has execute but not read permissions
  1552. dnl
  1553. AC_DEFUN([PHP_BROKEN_GETCWD],[
  1554. AC_MSG_CHECKING([for broken getcwd])
  1555. os=`uname -sr 2>/dev/null`
  1556. case $os in
  1557. SunOS*[)]
  1558. AC_DEFINE(HAVE_BROKEN_GETCWD,1, [Define if system has broken getcwd])
  1559. AC_MSG_RESULT([yes]);;
  1560. *[)]
  1561. AC_MSG_RESULT([no]);;
  1562. esac
  1563. ])
  1564. dnl
  1565. dnl PHP_BROKEN_GLIBC_FOPEN_APPEND
  1566. dnl
  1567. AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND], [
  1568. AC_MSG_CHECKING([for broken libc stdio])
  1569. AC_CACHE_VAL(_cv_have_broken_glibc_fopen_append,[
  1570. AC_TRY_RUN([
  1571. #include <stdio.h>
  1572. int main(int argc, char *argv[])
  1573. {
  1574. FILE *fp;
  1575. long position;
  1576. char *filename = "/tmp/phpglibccheck";
  1577. fp = fopen(filename, "w");
  1578. if (fp == NULL) {
  1579. perror("fopen");
  1580. exit(2);
  1581. }
  1582. fputs("foobar", fp);
  1583. fclose(fp);
  1584. fp = fopen(filename, "a+");
  1585. position = ftell(fp);
  1586. fclose(fp);
  1587. unlink(filename);
  1588. if (position == 0)
  1589. return 1;
  1590. return 0;
  1591. }
  1592. ],
  1593. [_cv_have_broken_glibc_fopen_append=no],
  1594. [_cv_have_broken_glibc_fopen_append=yes ],
  1595. AC_TRY_COMPILE([
  1596. #include <features.h>
  1597. ],[
  1598. #if !__GLIBC_PREREQ(2,2)
  1599. choke me
  1600. #endif
  1601. ],
  1602. [_cv_have_broken_glibc_fopen_append=yes],
  1603. [_cv_have_broken_glibc_fopen_append=no ])
  1604. )])
  1605. if test "$_cv_have_broken_glibc_fopen_append" = "yes"; then
  1606. AC_MSG_RESULT(yes)
  1607. AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on fopen with mode a+])
  1608. else
  1609. AC_MSG_RESULT(no)
  1610. fi
  1611. ])
  1612. dnl
  1613. dnl PHP_FOPENCOOKIE
  1614. dnl
  1615. AC_DEFUN([PHP_FOPENCOOKIE], [
  1616. AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes])
  1617. if test "$have_glibc_fopencookie" = "yes"; then
  1618. dnl this comes in two flavors:
  1619. dnl newer glibcs (since 2.1.2 ? )
  1620. dnl have a type called cookie_io_functions_t
  1621. AC_TRY_COMPILE([
  1622. #define _GNU_SOURCE
  1623. #include <stdio.h>
  1624. ], [cookie_io_functions_t cookie;], [have_cookie_io_functions_t=yes], [])
  1625. if test "$have_cookie_io_functions_t" = "yes"; then
  1626. cookie_io_functions_t=cookie_io_functions_t
  1627. have_fopen_cookie=yes
  1628. dnl even newer glibcs have a different seeker definition...
  1629. AC_TRY_RUN([
  1630. #define _GNU_SOURCE
  1631. #include <stdio.h>
  1632. struct cookiedata {
  1633. __off64_t pos;
  1634. };
  1635. __ssize_t reader(void *cookie, char *buffer, size_t size)
  1636. { return size; }
  1637. __ssize_t writer(void *cookie, const char *buffer, size_t size)
  1638. { return size; }
  1639. int closer(void *cookie)
  1640. { return 0; }
  1641. int seeker(void *cookie, __off64_t *position, int whence)
  1642. { ((struct cookiedata*)cookie)->pos = *position; return 0; }
  1643. cookie_io_functions_t funcs = {reader, writer, seeker, closer};
  1644. main() {
  1645. struct cookiedata g = { 0 };
  1646. FILE *fp = fopencookie(&g, "r", funcs);
  1647. if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
  1648. exit(0);
  1649. exit(1);
  1650. }
  1651. ], [
  1652. cookie_io_functions_use_off64_t=yes
  1653. ], [
  1654. cookie_io_functions_use_off64_t=no
  1655. ], [
  1656. cookie_io_functions_use_off64_t=no
  1657. ])
  1658. else
  1659. dnl older glibc versions (up to 2.1.2 ?)
  1660. dnl call it _IO_cookie_io_functions_t
  1661. AC_TRY_COMPILE([
  1662. #define _GNU_SOURCE
  1663. #include <stdio.h>
  1664. ], [ _IO_cookie_io_functions_t cookie; ], [have_IO_cookie_io_functions_t=yes], [])
  1665. if test "$have_cookie_io_functions_t" = "yes" ; then
  1666. cookie_io_functions_t=_IO_cookie_io_functions_t
  1667. have_fopen_cookie=yes
  1668. fi
  1669. fi
  1670. if test "$have_fopen_cookie" = "yes" ; then
  1671. AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
  1672. AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
  1673. if test "$cookie_io_functions_use_off64_t" = "yes" ; then
  1674. AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ])
  1675. fi
  1676. fi
  1677. fi
  1678. ])
  1679. dnl -------------------------------------------------------------------------
  1680. dnl Library/function existance and build sanity checks
  1681. dnl -------------------------------------------------------------------------
  1682. dnl
  1683. dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
  1684. dnl
  1685. dnl Wrapper for AC_CHECK_LIB
  1686. dnl
  1687. AC_DEFUN([PHP_CHECK_LIBRARY], [
  1688. save_old_LDFLAGS=$LDFLAGS
  1689. ac_stuff="$5"
  1690. save_ext_shared=$ext_shared
  1691. ext_shared=yes
  1692. PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
  1693. AC_CHECK_LIB([$1],[$2],[
  1694. LDFLAGS=$save_old_LDFLAGS
  1695. ext_shared=$save_ext_shared
  1696. $3
  1697. ],[
  1698. LDFLAGS=$save_old_LDFLAGS
  1699. ext_shared=$save_ext_shared
  1700. unset ac_cv_lib_$1[]_$2
  1701. $4
  1702. ])dnl
  1703. ])
  1704. dnl
  1705. dnl PHP_CHECK_FRAMEWORK(framework, function [, action-found [, action-not-found ]])
  1706. dnl
  1707. dnl El cheapo wrapper for AC_CHECK_LIB
  1708. dnl
  1709. AC_DEFUN([PHP_CHECK_FRAMEWORK], [
  1710. save_old_LDFLAGS=$LDFLAGS
  1711. LDFLAGS="-framework $1 $LDFLAGS"
  1712. dnl supplying "c" to AC_CHECK_LIB is technically cheating, but
  1713. dnl rewriting AC_CHECK_LIB is overkill and this only affects
  1714. dnl the "checking.." output anyway.
  1715. AC_CHECK_LIB(c,[$2],[
  1716. LDFLAGS=$save_old_LDFLAGS
  1717. $3
  1718. ],[
  1719. LDFLAGS=$save_old_LDFLAGS
  1720. $4
  1721. ])
  1722. ])
  1723. dnl
  1724. dnl PHP_CHECK_FUNC_LIB(func, libs)
  1725. dnl
  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
  1732. dnl autoconf undefines the builtin "shift" :-(
  1733. dnl If possible, we use the builtin shift anyway, otherwise we use
  1734. dnl the ubercool definition I have tested so far with FreeBSD/GNU m4
  1735. ifdef([builtin],[builtin(define, phpshift, [builtin(shift, $@)])],[
  1736. define([phpshift],[ifelse(index([$@],[,]),-1,,[substr([$@],incr(index([$@],[,])))])])
  1737. ])
  1738. dnl
  1739. AC_DEFUN([PHP_CHECK_FUNC_LIB],[
  1740. ifelse($2,,:,[
  1741. unset ac_cv_lib_$2[]_$1
  1742. unset ac_cv_lib_$2[]___$1
  1743. unset found
  1744. AC_CHECK_LIB($2, $1, [found=yes], [
  1745. AC_CHECK_LIB($2, __$1, [found=yes], [found=no])
  1746. ])
  1747. if test "$found" = "yes"; then
  1748. ac_libs=$LIBS
  1749. LIBS="$LIBS -l$2"
  1750. AC_TRY_RUN([main() { return (0); }],[found=yes],[found=no],[found=no])
  1751. LIBS=$ac_libs
  1752. fi
  1753. if test "$found" = "yes"; then
  1754. PHP_ADD_LIBRARY($2)
  1755. PHP_DEF_HAVE($1)
  1756. PHP_DEF_HAVE(lib$2)
  1757. ac_cv_func_$1=yes
  1758. else
  1759. PHP_CHECK_FUNC_LIB($1,phpshift(phpshift($@)))
  1760. fi
  1761. ])
  1762. ])
  1763. dnl
  1764. dnl PHP_CHECK_FUNC(func, ...)
  1765. dnl
  1766. dnl This macro checks whether 'func' or '__func' exists
  1767. dnl in the default libraries and as a fall back in the specified library.
  1768. dnl Defines HAVE_func and HAVE_library if found and adds the library to LIBS.
  1769. dnl
  1770. AC_DEFUN([PHP_CHECK_FUNC],[
  1771. unset ac_cv_func_$1
  1772. unset ac_cv_func___$1
  1773. unset found
  1774. AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
  1775. case $found in
  1776. yes[)]
  1777. PHP_DEF_HAVE($1)
  1778. ac_cv_func_$1=yes
  1779. ;;
  1780. ifelse($#,1,,[
  1781. *[)] PHP_CHECK_FUNC_LIB($@) ;;
  1782. ])
  1783. esac
  1784. ])
  1785. dnl
  1786. dnl PHP_TEST_BUILD(function, action-if-ok, action-if-not-ok [, extra-libs [, extra-source]])
  1787. dnl
  1788. dnl This macro checks whether build works and given function exists.
  1789. dnl
  1790. AC_DEFUN([PHP_TEST_BUILD], [
  1791. old_LIBS=$LIBS
  1792. LIBS="$4 $LIBS"
  1793. AC_TRY_RUN([
  1794. $5
  1795. char $1();
  1796. int main() {
  1797. $1();
  1798. return 0;
  1799. }
  1800. ], [
  1801. LIBS=$old_LIBS
  1802. $2
  1803. ],[
  1804. LIBS=$old_LIBS
  1805. $3
  1806. ],[
  1807. LIBS=$old_LIBS
  1808. ])
  1809. ])
  1810. dnl -------------------------------------------------------------------------
  1811. dnl Platform characteristics checks
  1812. dnl -------------------------------------------------------------------------
  1813. dnl
  1814. dnl PHP_SHLIB_SUFFIX_NAMES
  1815. dnl
  1816. dnl Determines link library suffix SHLIB_SUFFIX_NAME
  1817. dnl which can be: .so, .sl or .dylib
  1818. dnl
  1819. dnl Determines shared library suffix SHLIB_DL_SUFFIX_NAME
  1820. dnl suffix can be: .so or .sl
  1821. dnl
  1822. AC_DEFUN([PHP_SHLIB_SUFFIX_NAMES],[
  1823. AC_REQUIRE([PHP_CANONICAL_HOST_TARGET])dnl
  1824. PHP_SUBST_OLD(SHLIB_SUFFIX_NAME)
  1825. PHP_SUBST_OLD(SHLIB_DL_SUFFIX_NAME)
  1826. SHLIB_SUFFIX_NAME=so
  1827. SHLIB_DL_SUFFIX_NAME=$SHLIB_SUFFIX_NAME
  1828. case $host_alias in
  1829. *hpux*[)]
  1830. SHLIB_SUFFIX_NAME=sl
  1831. SHLIB_DL_SUFFIX_NAME=sl
  1832. ;;
  1833. *darwin*[)]
  1834. SHLIB_SUFFIX_NAME=dylib
  1835. SHLIB_DL_SUFFIX_NAME=so
  1836. ;;
  1837. esac
  1838. ])
  1839. dnl
  1840. dnl PHP_CHECK_64BIT([do if 32], [do if 64])
  1841. dnl
  1842. dnl This macro is used to detect if we're at 64-bit platform or not.
  1843. dnl It could be useful for those external libs, that have different precompiled
  1844. dnl versions in different directories.
  1845. dnl
  1846. AC_DEFUN([PHP_CHECK_64BIT],[
  1847. AC_CHECK_SIZEOF(long int, 4)
  1848. AC_MSG_CHECKING([checking if we're at 64-bit platform])
  1849. if test "$ac_cv_sizeof_long_int" = "4" ; then
  1850. AC_MSG_RESULT([no])
  1851. $1
  1852. else
  1853. AC_MSG_RESULT([yes])
  1854. $2
  1855. fi
  1856. ])
  1857. dnl
  1858. dnl PHP_C_BIGENDIAN
  1859. dnl
  1860. dnl Replacement macro for AC_C_BIGENDIAN
  1861. dnl
  1862. AC_DEFUN([PHP_C_BIGENDIAN],
  1863. [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian_php,
  1864. [
  1865. ac_cv_c_bigendian_php=unknown
  1866. AC_TRY_RUN(
  1867. [
  1868. int main(void)
  1869. {
  1870. short one = 1;
  1871. char *cp = (char *)&one;
  1872. if (*cp == 0) {
  1873. return(0);
  1874. } else {
  1875. return(1);
  1876. }
  1877. }
  1878. ], [ac_cv_c_bigendian_php=yes], [ac_cv_c_bigendian_php=no], [ac_cv_c_bigendian_php=unknown])
  1879. ])
  1880. if test $ac_cv_c_bigendian_php = yes; then
  1881. AC_DEFINE(WORDS_BIGENDIAN, [], [Define if processor uses big-endian word])
  1882. fi
  1883. ])
  1884. dnl -------------------------------------------------------------------------
  1885. dnl Checks for programs: PHP_PROG_<program>
  1886. dnl -------------------------------------------------------------------------
  1887. dnl
  1888. dnl PHP_PROG_SENDMAIL
  1889. dnl
  1890. dnl Search for the sendmail binary
  1891. dnl
  1892. AC_DEFUN([PHP_PROG_SENDMAIL], [
  1893. PHP_ALT_PATH=/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib
  1894. AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:$PHP_ALT_PATH)
  1895. PHP_SUBST(PROG_SENDMAIL)
  1896. ])
  1897. dnl
  1898. dnl PHP_PROG_AWK
  1899. dnl
  1900. dnl Some vendors force mawk before gawk; mawk is broken so we don't like that
  1901. dnl
  1902. AC_DEFUN([PHP_PROG_AWK], [
  1903. AC_CHECK_PROGS(AWK, gawk nawk awk mawk, bork, /usr/xpg4/bin/:$PATH)
  1904. case "$AWK" in
  1905. *mawk)
  1906. AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
  1907. ;;
  1908. *gawk)
  1909. ;;
  1910. bork)
  1911. AC_MSG_ERROR([Could not find awk; Install GNU awk])
  1912. ;;
  1913. *)
  1914. AC_MSG_CHECKING([if $AWK is broken])
  1915. if ! $AWK 'function foo() {}' >/dev/null 2>&1 ; then
  1916. AC_MSG_RESULT([yes])
  1917. AC_MSG_ERROR([You should install GNU awk])
  1918. else
  1919. AC_MSG_RESULT([no])
  1920. fi
  1921. ;;
  1922. esac
  1923. PHP_SUBST(AWK)
  1924. ])
  1925. dnl
  1926. dnl PHP_PROG_BISON
  1927. dnl
  1928. dnl Search for bison and check it's version
  1929. dnl
  1930. AC_DEFUN([PHP_PROG_BISON], [
  1931. AC_PROG_YACC
  1932. LIBZEND_BISON_CHECK
  1933. PHP_SUBST(YACC)
  1934. ])
  1935. dnl
  1936. dnl PHP_PROG_LEX
  1937. dnl
  1938. dnl Search for (f)lex and check it's version
  1939. dnl
  1940. AC_DEFUN([PHP_PROG_LEX], [
  1941. dnl we only support certain flex versions
  1942. flex_version_list="2.5.4"
  1943. AC_PROG_LEX
  1944. if test "$LEX" = "flex"; then
  1945. dnl AC_DECL_YYTEXT is obsolete since autoconf 2.50 and merged into AC_PROG_LEX
  1946. dnl this is what causes that annoying "PHP_PROG_LEX is expanded from" warning with autoconf 2.50+
  1947. dnl it should be removed once we drop support of autoconf 2.13 (if ever)
  1948. AC_DECL_YYTEXT
  1949. :
  1950. fi
  1951. dnl ## Make flex scanners use const if they can, even if __STDC__ is not
  1952. dnl ## true, for compilers like Sun's that only set __STDC__ true in
  1953. dnl ## "limit-to-ANSI-standard" mode, not in "ANSI-compatible" mode
  1954. AC_C_CONST
  1955. if test "$ac_cv_c_const" = "yes" ; then
  1956. LEX_CFLAGS="-DYY_USE_CONST"
  1957. fi
  1958. if test "$LEX" = "flex"; then
  1959. AC_CACHE_CHECK([for flex version], php_cv_flex_version, [
  1960. flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'`
  1961. php_cv_flex_version=invalid
  1962. for flex_check_version in $flex_version_list; do
  1963. if test "$flex_version" = "$flex_check_version"; then
  1964. php_cv_flex_version="$flex_check_version (ok)"
  1965. fi
  1966. done
  1967. ])
  1968. else
  1969. flex_version=none
  1970. fi
  1971. case $php_cv_flex_version in
  1972. ""|invalid[)]
  1973. if test -f "$abs_srcdir/Zend/zend_language_scanner.c" && test -f "$abs_srcdir/Zend/zend_ini_scanner.c"; then
  1974. AC_MSG_WARN([flex versions supported for regeneration of the Zend/PHP parsers: $flex_version_list (found: $flex_version)])
  1975. else
  1976. flex_msg="Supported flex versions are: $flex_version_list"
  1977. if test "$flex_version" = "none"; then
  1978. flex_msg="flex not found. flex is required to generate the Zend/PHP parsers! $flex_msg"
  1979. else
  1980. flex_msg="Found invalid flex version: $flex_version. $flex_msg"
  1981. fi
  1982. AC_MSG_ERROR([$flex_msg])
  1983. fi
  1984. LEX="exit 0;"
  1985. ;;
  1986. esac
  1987. PHP_SUBST(LEX)
  1988. ])
  1989. dnl
  1990. dnl PHP_PROG_RE2C
  1991. dnl
  1992. dnl Search for the re2c binary and check the version
  1993. dnl
  1994. AC_DEFUN([PHP_PROG_RE2C],[
  1995. AC_CHECK_PROG(RE2C, re2c, re2c)
  1996. if test -n "$RE2C"; then
  1997. AC_CACHE_CHECK([for re2c version], php_cv_re2c_version, [
  1998. re2c_vernum=`$RE2C --vernum 2>/dev/null`
  1999. if test -z "$re2c_vernum" || test "$re2c_vernum" -lt "1304"; then
  2000. php_cv_re2c_version=invalid
  2001. else
  2002. php_cv_re2c_version="`$RE2C --version | cut -d ' ' -f 2 2>/dev/null` (ok)"
  2003. fi
  2004. ])
  2005. fi
  2006. case $php_cv_re2c_version in
  2007. ""|invalid[)]
  2008. AC_MSG_WARN([You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.])
  2009. RE2C="exit 0;"
  2010. ;;
  2011. esac
  2012. PHP_SUBST(RE2C)
  2013. ])
  2014. dnl -------------------------------------------------------------------------
  2015. dnl Common setup macros: PHP_SETUP_<what>
  2016. dnl -------------------------------------------------------------------------
  2017. dnl
  2018. dnl PHP_SETUP_ICU([shared-add])
  2019. dnl
  2020. dnl Common setup macro for ICU
  2021. dnl
  2022. AC_DEFUN([PHP_SETUP_ICU],[
  2023. PHP_ARG_WITH(icu-dir,,
  2024. [ --with-icu-dir=DIR Specify where ICU libraries and headers can be found], DEFAULT, no)
  2025. if test "$PHP_ICU_DIR" = "no"; then
  2026. PHP_ICU_DIR=DEFAULT
  2027. fi
  2028. if test "$PHP_ICU_DIR" = "DEFAULT"; then
  2029. dnl Try to find icu-config
  2030. AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
  2031. else
  2032. ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
  2033. fi
  2034. AC_MSG_CHECKING([for location of ICU headers and libraries])
  2035. dnl Trust icu-config to know better what the install prefix is..
  2036. icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
  2037. if test "$?" != "0" || test -z "$icu_install_prefix"; then
  2038. AC_MSG_RESULT([not found])
  2039. AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
  2040. else
  2041. AC_MSG_RESULT([$icu_install_prefix])
  2042. dnl Check ICU version
  2043. AC_MSG_CHECKING([for ICU 3.4 or greater])
  2044. icu_version_full=`$ICU_CONFIG --version`
  2045. ac_IFS=$IFS
  2046. IFS="."
  2047. set $icu_version_full
  2048. IFS=$ac_IFS
  2049. icu_version=`expr [$]1 \* 1000 + [$]2`
  2050. AC_MSG_RESULT([found $icu_version_full])
  2051. if test "$icu_version" -lt "3004"; then
  2052. AC_MSG_ERROR([ICU version 3.4 or later is required])
  2053. fi
  2054. ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
  2055. ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
  2056. PHP_EVAL_INCLINE($ICU_INCS)
  2057. PHP_EVAL_LIBLINE($ICU_LIBS, $1)
  2058. fi
  2059. ])
  2060. dnl
  2061. dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]])
  2062. dnl
  2063. dnl Common setup macro for kerberos
  2064. dnl
  2065. AC_DEFUN([PHP_SETUP_KERBEROS],[
  2066. found_kerberos=no
  2067. unset KERBEROS_CFLAGS
  2068. unset KERBEROS_LIBS
  2069. dnl First try to find krb5-config
  2070. if test -z "$KRB5_CONFIG"; then
  2071. AC_PATH_PROG(KRB5_CONFIG, krb5-config, no, [$PATH:/usr/kerberos/bin:/usr/local/bin])
  2072. fi
  2073. dnl If krb5-config is found try using it
  2074. if test "$PHP_KERBEROS" = "yes" && test -x "$KRB5_CONFIG"; then
  2075. KERBEROS_LIBS=`$KRB5_CONFIG --libs gssapi`
  2076. KERBEROS_CFLAGS=`$KRB5_CONFIG --cflags gssapi`
  2077. if test -n "$KERBEROS_LIBS" && test -n "$KERBEROS_CFLAGS"; then
  2078. found_kerberos=yes
  2079. PHP_EVAL_LIBLINE($KERBEROS_LIBS, $1)
  2080. PHP_EVAL_INCLINE($KERBEROS_CFLAGS)
  2081. fi
  2082. fi
  2083. dnl If still not found use old skool method
  2084. if test "$found_kerberos" = "no"; then
  2085. if test "$PHP_KERBEROS" = "yes"; then
  2086. PHP_KERBEROS="/usr/kerberos /usr/local /usr"
  2087. fi
  2088. for i in $PHP_KERBEROS; do
  2089. if test -f $i/$PHP_LIBDIR/libkrb5.a || test -f $i/$PHP_LIBDIR/libkrb5.$SHLIB_SUFFIX_NAME; then
  2090. PHP_KERBEROS_DIR=$i
  2091. break
  2092. fi
  2093. done
  2094. if test "$PHP_KERBEROS_DIR"; then
  2095. found_kerberos=yes
  2096. PHP_ADD_LIBPATH($PHP_KERBEROS_DIR/$PHP_LIBDIR, $1)
  2097. PHP_ADD_LIBRARY(gssapi_krb5, 1, $1)
  2098. PHP_ADD_LIBRARY(krb5, 1, $1)
  2099. PHP_ADD_LIBRARY(k5crypto, 1, $1)
  2100. PHP_ADD_LIBRARY(com_err, 1, $1)
  2101. PHP_ADD_INCLUDE($PHP_KERBEROS_DIR/include)
  2102. fi
  2103. fi
  2104. if test "$found_kerberos" = "yes"; then
  2105. ifelse([$2],[],:,[$2])
  2106. ifelse([$3],[],,[else $3])
  2107. fi
  2108. ])
  2109. dnl
  2110. dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
  2111. dnl
  2112. dnl Common setup macro for openssl
  2113. dnl
  2114. AC_DEFUN([PHP_SETUP_OPENSSL],[
  2115. found_openssl=no
  2116. unset OPENSSL_INCDIR
  2117. unset OPENSSL_LIBDIR
  2118. dnl Empty variable means 'no'
  2119. test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
  2120. test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
  2121. dnl Fallbacks for different configure options
  2122. if test "$PHP_OPENSSL" != "no"; then
  2123. PHP_OPENSSL_DIR=$PHP_OPENSSL
  2124. elif test "$PHP_IMAP_SSL" != "no"; then
  2125. PHP_OPENSSL_DIR=$PHP_IMAP_SSL
  2126. fi
  2127. dnl First try to find pkg-config
  2128. if test -z "$PKG_CONFIG"; then
  2129. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2130. fi
  2131. dnl If pkg-config is found try using it
  2132. if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
  2133. if $PKG_CONFIG --atleast-version=0.9.6 openssl; then
  2134. found_openssl=yes
  2135. OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
  2136. OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
  2137. OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
  2138. else
  2139. AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
  2140. fi
  2141. if test -n "$OPENSSL_LIBS" && test -n "$OPENSSL_INCS"; then
  2142. PHP_EVAL_LIBLINE($OPENSSL_LIBS, $1)
  2143. PHP_EVAL_INCLINE($OPENSSL_INCS)
  2144. fi
  2145. fi
  2146. dnl If pkg-config fails for some reason, revert to the old method
  2147. if test "$found_openssl" = "no"; then
  2148. if test "$PHP_OPENSSL_DIR" = "yes"; then
  2149. PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
  2150. fi
  2151. for i in $PHP_OPENSSL_DIR; do
  2152. if test -r $i/include/openssl/evp.h; then
  2153. OPENSSL_INCDIR=$i/include
  2154. fi
  2155. if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
  2156. OPENSSL_LIBDIR=$i/$PHP_LIBDIR
  2157. fi
  2158. test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
  2159. done
  2160. if test -z "$OPENSSL_INCDIR"; then
  2161. AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
  2162. fi
  2163. if test -z "$OPENSSL_LIBDIR"; then
  2164. AC_MSG_ERROR([Cannot find OpenSSL's libraries])
  2165. fi
  2166. old_CPPFLAGS=$CPPFLAGS
  2167. CPPFLAGS=-I$OPENSSL_INCDIR
  2168. AC_MSG_CHECKING([for OpenSSL version])
  2169. AC_EGREP_CPP(yes,[
  2170. #include <openssl/opensslv.h>
  2171. #if OPENSSL_VERSION_NUMBER >= 0x0090600fL
  2172. yes
  2173. #endif
  2174. ],[
  2175. AC_MSG_RESULT([>= 0.9.6])
  2176. ],[
  2177. AC_MSG_ERROR([OpenSSL version 0.9.6 or greater required.])
  2178. ])
  2179. CPPFLAGS=$old_CPPFLAGS
  2180. PHP_ADD_INCLUDE($OPENSSL_INCDIR)
  2181. PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
  2182. PHP_ADD_LIBRARY(crypto,,$1)
  2183. ],[
  2184. AC_MSG_ERROR([libcrypto not found!])
  2185. ],[
  2186. -L$OPENSSL_LIBDIR
  2187. ])
  2188. old_LIBS=$LIBS
  2189. LIBS="$LIBS -lcrypto"
  2190. PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
  2191. found_openssl=yes
  2192. ],[
  2193. AC_MSG_ERROR([libssl not found!])
  2194. ],[
  2195. -L$OPENSSL_LIBDIR
  2196. ])
  2197. LIBS=$old_LIBS
  2198. PHP_ADD_LIBRARY(ssl,,$1)
  2199. PHP_ADD_LIBPATH($OPENSSL_LIBDIR, $1)
  2200. fi
  2201. if test "$found_openssl" = "yes"; then
  2202. dnl For apache 1.3.x static build
  2203. OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
  2204. AC_SUBST(OPENSSL_INCDIR_OPT)
  2205. ifelse([$2],[],:,[$2])
  2206. ifelse([$3],[],,[else $3])
  2207. fi
  2208. ])
  2209. dnl
  2210. dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
  2211. dnl
  2212. dnl Common setup macro for iconv
  2213. dnl
  2214. AC_DEFUN([PHP_SETUP_ICONV], [
  2215. found_iconv=no
  2216. unset ICONV_DIR
  2217. # Create the directories for a VPATH build:
  2218. $php_shtool mkdir -p ext/iconv
  2219. echo > ext/iconv/php_have_bsd_iconv.h
  2220. echo > ext/iconv/php_have_ibm_iconv.h
  2221. echo > ext/iconv/php_have_glibc_iconv.h
  2222. echo > ext/iconv/php_have_libiconv.h
  2223. echo > ext/iconv/php_have_iconv.h
  2224. echo > ext/iconv/php_php_iconv_impl.h
  2225. echo > ext/iconv/php_iconv_aliased_libiconv.h
  2226. echo > ext/iconv/php_php_iconv_h_path.h
  2227. echo > ext/iconv/php_iconv_supports_errno.h
  2228. dnl
  2229. dnl Check libc first if no path is provided in --with-iconv
  2230. dnl
  2231. if test "$PHP_ICONV" = "yes"; then
  2232. AC_CHECK_FUNC(iconv, [
  2233. found_iconv=yes
  2234. ],[
  2235. AC_CHECK_FUNC(libiconv,[
  2236. PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
  2237. AC_DEFINE(HAVE_LIBICONV, 1, [ ])
  2238. found_iconv=yes
  2239. ])
  2240. ])
  2241. fi
  2242. dnl
  2243. dnl Check external libs for iconv funcs
  2244. dnl
  2245. if test "$found_iconv" = "no"; then
  2246. for i in $PHP_ICONV /usr/local /usr; do
  2247. if test -r $i/include/giconv.h; then
  2248. AC_DEFINE(HAVE_GICONV_H, 1, [ ])
  2249. ICONV_DIR=$i
  2250. iconv_lib_name=giconv
  2251. break
  2252. elif test -r $i/include/iconv.h; then
  2253. ICONV_DIR=$i
  2254. iconv_lib_name=iconv
  2255. break
  2256. fi
  2257. done
  2258. if test -z "$ICONV_DIR"; then
  2259. AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
  2260. fi
  2261. if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
  2262. test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
  2263. then
  2264. PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
  2265. found_iconv=yes
  2266. PHP_DEFINE(HAVE_LIBICONV,1,[ext/iconv])
  2267. AC_DEFINE(HAVE_LIBICONV,1,[ ])
  2268. PHP_DEFINE([ICONV_ALIASED_LIBICONV],1,[ext/iconv])
  2269. AC_DEFINE([ICONV_ALIASED_LIBICONV],1,[iconv() is aliased to libiconv() in -liconv])
  2270. ], [
  2271. PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
  2272. found_iconv=yes
  2273. ], [], [
  2274. -L$ICONV_DIR/$PHP_LIBDIR
  2275. ])
  2276. ], [
  2277. -L$ICONV_DIR/$PHP_LIBDIR
  2278. ])
  2279. fi
  2280. fi
  2281. if test "$found_iconv" = "yes"; then
  2282. PHP_DEFINE(HAVE_ICONV,1,[ext/iconv])
  2283. AC_DEFINE(HAVE_ICONV,1,[ ])
  2284. if test -n "$ICONV_DIR"; then
  2285. PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/$PHP_LIBDIR, $1)
  2286. PHP_ADD_INCLUDE($ICONV_DIR/include)
  2287. fi
  2288. $2
  2289. ifelse([$3],[],,[else $3])
  2290. fi
  2291. ])
  2292. dnl
  2293. dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]])
  2294. dnl
  2295. dnl Common setup macro for libxml
  2296. dnl
  2297. AC_DEFUN([PHP_SETUP_LIBXML], [
  2298. AC_CACHE_CHECK([for xml2-config path], ac_cv_php_xml2_config_path,
  2299. [
  2300. for i in $PHP_LIBXML_DIR /usr/local /usr; do
  2301. if test -x "$i/bin/xml2-config"; then
  2302. ac_cv_php_xml2_config_path="$i/bin/xml2-config"
  2303. break
  2304. fi
  2305. done
  2306. ])
  2307. if test -x "$ac_cv_php_xml2_config_path"; then
  2308. XML2_CONFIG="$ac_cv_php_xml2_config_path"
  2309. libxml_full_version=`$XML2_CONFIG --version`
  2310. ac_IFS=$IFS
  2311. IFS="."
  2312. set $libxml_full_version
  2313. IFS=$ac_IFS
  2314. LIBXML_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
  2315. if test "$LIBXML_VERSION" -ge "2006011"; then
  2316. LIBXML_LIBS=`$XML2_CONFIG --libs`
  2317. LIBXML_INCS=`$XML2_CONFIG --cflags`
  2318. PHP_EVAL_LIBLINE($LIBXML_LIBS, $1)
  2319. PHP_EVAL_INCLINE($LIBXML_INCS)
  2320. dnl Check that build works with given libs
  2321. AC_CACHE_CHECK(whether libxml build works, php_cv_libxml_build_works, [
  2322. PHP_TEST_BUILD(xmlInitParser,
  2323. [
  2324. php_cv_libxml_build_works=yes
  2325. ], [
  2326. AC_MSG_RESULT(no)
  2327. AC_MSG_ERROR([build test failed. Please check the config.log for details.])
  2328. ], [
  2329. [$]$1
  2330. ])
  2331. ])
  2332. if test "$php_cv_libxml_build_works" = "yes"; then
  2333. AC_DEFINE(HAVE_LIBXML, 1, [ ])
  2334. fi
  2335. $2
  2336. else
  2337. AC_MSG_ERROR([libxml2 version 2.6.11 or greater required.])
  2338. fi
  2339. ifelse([$3],[],,[else $3])
  2340. fi
  2341. ])
  2342. dnl -------------------------------------------------------------------------
  2343. dnl Misc. macros
  2344. dnl -------------------------------------------------------------------------
  2345. dnl
  2346. dnl PHP_INSTALL_HEADERS(path [, file ...])
  2347. dnl
  2348. dnl PHP header files to be installed
  2349. dnl
  2350. AC_DEFUN([PHP_INSTALL_HEADERS],[
  2351. ifelse([$2],[],[
  2352. for header_file in $1; do
  2353. PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [
  2354. INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
  2355. ])
  2356. done
  2357. ], [
  2358. header_path=$1
  2359. for header_file in $2; do
  2360. hp_hf="$header_path/$header_file"
  2361. PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [
  2362. INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf"
  2363. ])
  2364. done
  2365. ])
  2366. ])
  2367. dnl
  2368. dnl PHP_AP_EXTRACT_VERSION(/path/httpd)
  2369. dnl
  2370. dnl This macro is used to get a comparable
  2371. dnl version for apache1/2.
  2372. dnl
  2373. AC_DEFUN([PHP_AP_EXTRACT_VERSION],[
  2374. ac_output=`$1 -v 2>&1 | grep version`
  2375. ac_IFS=$IFS
  2376. IFS="- /.
  2377. "
  2378. set $ac_output
  2379. IFS=$ac_IFS
  2380. APACHE_VERSION=`expr [$]4 \* 1000000 + [$]5 \* 1000 + [$]6`
  2381. ])
  2382. dnl
  2383. dnl PHP_DEBUG_MACRO(filename)
  2384. dnl
  2385. AC_DEFUN([PHP_DEBUG_MACRO],[
  2386. DEBUG_LOG=$1
  2387. cat >$1 <<X
  2388. CONFIGURE: $CONFIGURE_COMMAND
  2389. CC: $CC
  2390. CFLAGS: $CFLAGS
  2391. CPPFLAGS: $CPPFLAGS
  2392. CXX: $CXX
  2393. CXXFLAGS: $CXXFLAGS
  2394. INCLUDES: $INCLUDES
  2395. LDFLAGS: $LDFLAGS
  2396. LIBS: $LIBS
  2397. DLIBS: $DLIBS
  2398. SAPI: $PHP_SAPI
  2399. PHP_RPATHS: $PHP_RPATHS
  2400. uname -a: `uname -a`
  2401. X
  2402. cat >conftest.$ac_ext <<X
  2403. main()
  2404. {
  2405. exit(0);
  2406. }
  2407. X
  2408. (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
  2409. rm -fr conftest*
  2410. ])
  2411. dnl
  2412. dnl PHP_CONFIG_NICE(filename)
  2413. dnl
  2414. dnl Generates the config.nice file
  2415. dnl
  2416. AC_DEFUN([PHP_CONFIG_NICE],[
  2417. AC_REQUIRE([AC_PROG_EGREP])
  2418. AC_REQUIRE([LT_AC_PROG_SED])
  2419. PHP_SUBST_OLD(EGREP)
  2420. PHP_SUBST_OLD(SED)
  2421. test -f $1 && mv $1 $1.old
  2422. rm -f $1.old
  2423. cat >$1<<EOF
  2424. #! /bin/sh
  2425. #
  2426. # Created by configure
  2427. EOF
  2428. for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS EXTRA_LDFLAGS_PROGRAM LIBS CC CXX; do
  2429. eval val=\$$var
  2430. if test -n "$val"; then
  2431. echo "$var='$val' \\" >> $1
  2432. fi
  2433. done
  2434. echo "'[$]0' \\" >> $1
  2435. if test `expr -- [$]0 : "'.*"` = 0; then
  2436. CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'"
  2437. else
  2438. CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0"
  2439. fi
  2440. for arg in $ac_configure_args; do
  2441. if test `expr -- $arg : "'.*"` = 0; then
  2442. if test `expr -- $arg : "--.*"` = 0; then
  2443. break;
  2444. fi
  2445. echo "'[$]arg' \\" >> $1
  2446. CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS '[$]arg'"
  2447. else
  2448. if test `expr -- $arg : "'--.*"` = 0; then
  2449. break;
  2450. fi
  2451. echo "[$]arg \\" >> $1
  2452. CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS [$]arg"
  2453. fi
  2454. done
  2455. echo '"[$]@"' >> $1
  2456. chmod +x $1
  2457. CONFIGURE_COMMAND="$CONFIGURE_COMMAND $CONFIGURE_OPTIONS"
  2458. PHP_SUBST_OLD(CONFIGURE_COMMAND)
  2459. PHP_SUBST_OLD(CONFIGURE_OPTIONS)
  2460. ])
  2461. dnl
  2462. dnl PHP_CHECK_CONFIGURE_OPTIONS
  2463. dnl
  2464. AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
  2465. for arg in $ac_configure_args; do
  2466. case $arg in
  2467. --with-*[)]
  2468. arg_name="`echo [$]arg | $SED -e 's/--with-/with-/g' -e 's/=.*//g'`"
  2469. ;;
  2470. --without-*[)]
  2471. arg_name="`echo [$]arg | $SED -e 's/--without-/with-/g' -e 's/=.*//g'`"
  2472. ;;
  2473. --enable-*[)]
  2474. arg_name="`echo [$]arg | $SED -e 's/--enable-/enable-/g' -e 's/=.*//g'`"
  2475. ;;
  2476. --disable-*[)]
  2477. arg_name="`echo [$]arg | $SED -e 's/--disable-/enable-/g' -e 's/=.*//g'`"
  2478. ;;
  2479. *[)]
  2480. continue
  2481. ;;
  2482. esac
  2483. case $arg_name in
  2484. # Allow --disable-all / --enable-all
  2485. enable-all[)];;
  2486. # Allow certain libtool options
  2487. enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];;
  2488. # Allow certain TSRM options
  2489. with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads[)];;
  2490. # Allow certain Zend options
  2491. with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];;
  2492. # All the rest must be set using the PHP_ARG_* macros
  2493. # PHP_ARG_* macros set php_enable_<arg_name> or php_with_<arg_name>
  2494. *[)]
  2495. # Options that exist before PHP 6
  2496. if test "$PHP_MAJOR_VERSION" -lt "6"; then
  2497. case $arg_name in
  2498. enable-zend-multibyte[)] continue;;
  2499. esac
  2500. fi
  2501. is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'`
  2502. if eval test "x\$$is_arg_set" = "x"; then
  2503. PHP_UNKNOWN_CONFIGURE_OPTIONS="$PHP_UNKNOWN_CONFIGURE_OPTIONS
  2504. [$]arg"
  2505. fi
  2506. ;;
  2507. esac
  2508. done
  2509. ])
  2510. dnl
  2511. dnl PHP_CHECK_PDO_INCLUDES([found [, not-found]])
  2512. dnl
  2513. AC_DEFUN([PHP_CHECK_PDO_INCLUDES],[
  2514. AC_CACHE_CHECK([for PDO includes], pdo_inc_path, [
  2515. AC_MSG_CHECKING([for PDO includes])
  2516. if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
  2517. pdo_inc_path=$abs_srcdir/ext
  2518. elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
  2519. pdo_inc_path=$abs_srcdir/ext
  2520. elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
  2521. pdo_inc_path=$prefix/include/php/ext
  2522. fi
  2523. ])
  2524. if test -n "$pdo_inc_path"; then
  2525. ifelse([$1],[],:,[$1])
  2526. else
  2527. ifelse([$2],[],[AC_MSG_ERROR([Cannot find php_pdo_driver.h.])],[$2])
  2528. fi
  2529. ])
  2530. dnl
  2531. dnl PHP_DETECT_ICC
  2532. dnl Detect Intel C++ Compiler and unset $GCC if ICC found
  2533. AC_DEFUN([PHP_DETECT_ICC],
  2534. [
  2535. ICC="no"
  2536. AC_MSG_CHECKING([for icc])
  2537. AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
  2538. ICC="no"
  2539. AC_MSG_RESULT([no]),
  2540. ICC="yes"
  2541. GCC="no"
  2542. AC_MSG_RESULT([yes])
  2543. )
  2544. ])
  2545. dnl PHP_DETECT_SUNCC
  2546. dnl Detect if the systems default compiler is suncc.
  2547. dnl We also set some usefull CFLAGS if the user didn't set any
  2548. AC_DEFUN([PHP_DETECT_SUNCC],[
  2549. SUNCC="no"
  2550. AC_MSG_CHECKING([for suncc])
  2551. AC_EGREP_CPP([^__SUNPRO_C], [__SUNPRO_C],
  2552. SUNCC="no"
  2553. AC_MSG_RESULT([no]),
  2554. SUNCC="yes"
  2555. GCC="no"
  2556. test -n "$auto_cflags" && CFLAGS="-O -xs -xstrconst -zlazyload"
  2557. GCC=""
  2558. AC_MSG_RESULT([yes])
  2559. )
  2560. ])
  2561. dnl
  2562. dnl PHP_CRYPT_R_STYLE
  2563. dnl detect the style of crypt_r() is any is available
  2564. dnl see APR_CHECK_CRYPT_R_STYLE() for original version
  2565. dnl
  2566. AC_DEFUN([PHP_CRYPT_R_STYLE],
  2567. [
  2568. AC_CACHE_CHECK([which data struct is used by crypt_r], php_cv_crypt_r_style,[
  2569. php_cv_crypt_r_style=none
  2570. AC_TRY_COMPILE([
  2571. #define _REENTRANT 1
  2572. #include <crypt.h>
  2573. ],[
  2574. CRYPTD buffer;
  2575. crypt_r("passwd", "hash", &buffer);
  2576. ],
  2577. php_cv_crypt_r_style=cryptd)
  2578. if test "$php_cv_crypt_r_style" = "none"; then
  2579. AC_TRY_COMPILE([
  2580. #define _REENTRANT 1
  2581. #include <crypt.h>
  2582. ],[
  2583. struct crypt_data buffer;
  2584. crypt_r("passwd", "hash", &buffer);
  2585. ],
  2586. php_cv_crypt_r_style=struct_crypt_data)
  2587. fi
  2588. if test "$php_cv_crypt_r_style" = "none"; then
  2589. AC_TRY_COMPILE([
  2590. #define _REENTRANT 1
  2591. #define _GNU_SOURCE
  2592. #include <crypt.h>
  2593. ],[
  2594. struct crypt_data buffer;
  2595. crypt_r("passwd", "hash", &buffer);
  2596. ],
  2597. php_cv_crypt_r_style=struct_crypt_data_gnu_source)
  2598. fi
  2599. ])
  2600. if test "$php_cv_crypt_r_style" = "cryptd"; then
  2601. AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD])
  2602. fi
  2603. if test "$php_cv_crypt_r_style" = "struct_crypt_data" -o "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
  2604. AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data])
  2605. fi
  2606. if test "$php_cv_crypt_r_style" = "struct_crypt_data_gnu_source"; then
  2607. AC_DEFINE(CRYPT_R_GNU_SOURCE, 1, [Define if struct crypt_data requires _GNU_SOURCE])
  2608. fi
  2609. if test "$php_cv_crypt_r_style" = "none"; then
  2610. AC_MSG_ERROR([Unable to detect data struct used by crypt_r])
  2611. fi
  2612. ])
  2613. dnl
  2614. dnl PHP_TEST_WRITE_STDOUT
  2615. dnl
  2616. AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
  2617. AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
  2618. AC_TRY_RUN([
  2619. #ifdef HAVE_UNISTD_H
  2620. #include <unistd.h>
  2621. #endif
  2622. #define TEXT "This is the test message -- "
  2623. main()
  2624. {
  2625. int n;
  2626. n = write(1, TEXT, sizeof(TEXT)-1);
  2627. return (!(n == sizeof(TEXT)-1));
  2628. }
  2629. ],[
  2630. ac_cv_write_stdout=yes
  2631. ],[
  2632. ac_cv_write_stdout=no
  2633. ],[
  2634. ac_cv_write_stdout=no
  2635. ])
  2636. ])
  2637. if test "$ac_cv_write_stdout" = "yes"; then
  2638. AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])
  2639. fi
  2640. ])
  2641. dnl
  2642. dnl Generate dtrace targets
  2643. dnl
  2644. AC_DEFUN([PHP_GENERATE_DTRACE],[
  2645. old_IFS=[$]IFS
  2646. IFS=.
  2647. set $ac_src
  2648. IFS=$old_IFS
  2649. build_target=$2
  2650. PHP_GLOBAL_OBJS="[$]PHP_GLOBAL_OBJS $1.o"
  2651. for src in $PHP_DTRACE_OBJS; do
  2652. case [$]build_target in
  2653. program|static)
  2654. obj="$obj `dirname $src`/`basename $src | sed 's,\.lo$,.o,'` " ;;
  2655. *)
  2656. obj="$obj `dirname $src`/.libs/`basename $src | sed 's,\.lo$,.o,'` " ;;
  2657. esac
  2658. done
  2659. cat >>Makefile.objects<<EOF
  2660. $1.o: \$(PHP_DTRACE_OBJS)
  2661. dtrace -G -o $abs_builddir/$1.o -s $abs_srcdir/$1 $obj
  2662. EOF
  2663. ])
  2664. dnl
  2665. dnl Link given source files with dtrace
  2666. dnl PHP_ADD_DTRACE(providerdesc, sources, module)
  2667. dnl
  2668. AC_DEFUN([PHP_ADD_DTRACE],[
  2669. case "$3" in
  2670. ""[)] unset ac_bdir;;
  2671. /*[)] ac_bdir=$ac_srcdir;;
  2672. *[)] extdir=PHP_EXT_DIR($3); ac_bdir="$extdir/";;
  2673. esac
  2674. old_IFS=[$]IFS
  2675. for ac_src in $2; do
  2676. IFS=.
  2677. set $ac_src
  2678. ac_obj=[$]1
  2679. IFS=$old_IFS
  2680. PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo"
  2681. done;
  2682. ])
  2683. dnl
  2684. dnl Generate platform specific dtrace header
  2685. dnl
  2686. AC_DEFUN([PHP_INIT_DTRACE], [
  2687. dtrace -h -C -s $abs_srcdir/$1 -o $abs_builddir/$2
  2688. if test "$?" != "0"; then
  2689. AC_MSG_ERROR([cannot create DTrace header file])
  2690. fi
  2691. $SED -ibak 's,PHP_,DTRACE_,g' $abs_builddir/$2
  2692. ])