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.

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