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.

3321 lines
86 KiB

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