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.

2965 lines
76 KiB

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