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.

1473 lines
36 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
26 years ago
26 years ago
27 years ago
25 years ago
25 years ago
25 years ago
25 years ago
27 years ago
28 years ago
25 years ago
27 years ago
25 years ago
  1. dnl $Id$
  2. dnl
  3. dnl This file contains local autoconf functions.
  4. dnl PHP_ADD_MAKEFILE_FRAGMENT([srcfile[, ext_srcdir[, ext_builddir]]])
  5. dnl
  6. dnl Processes a file called Makefile.frag in the source directory
  7. dnl of the most recently added extension. $(srcdir) and $(builddir)
  8. dnl are substituted with the proper paths. Can be used to supply
  9. dnl custom rules and/or additional targets.
  10. dnl
  11. AC_DEFUN(PHP_ADD_MAKEFILE_FRAGMENT,[
  12. ifelse($1,,src=$ext_srcdir/Makefile.frag,src=$1)
  13. ifelse($2,,ac_srcdir=$ext_srcdir,ac_srcdir=$2)
  14. ifelse($3,,ac_builddir=$ext_builddir,ac_builddir=$3)
  15. sed -e "s#\$(srcdir)#$ac_srcdir#g" -e "s#\$(builddir)#$ac_builddir#g" $src >> Makefile.fragments
  16. ])
  17. dnl PHP_DEFINE(WHAT[, value])
  18. dnl
  19. dnl Creates builddir/include/what.h and in there #define WHAT value
  20. dnl
  21. AC_DEFUN(PHP_DEFINE,[
  22. [echo "#define ]$1[]ifelse([$2],,[ 1],[ $2])[" > include/php_]translit($1,A-Z,a-z)[.h]
  23. ])
  24. dnl PHP_INIT_BUILD_SYSTEM
  25. dnl
  26. AC_DEFUN(PHP_INIT_BUILD_SYSTEM,[
  27. mkdir include >/dev/null 2>&1
  28. > Makefile.objects
  29. > Makefile.fragments
  30. dnl We need to play tricks here to avoid matching the egrep line itself
  31. pattern=define
  32. egrep $pattern'.*include/php' $srcdir/configure|sed 's/.*>//'|xargs touch 2>/dev/null
  33. ])
  34. dnl PHP_GEN_GLOBAL_MAKEFILE
  35. dnl
  36. dnl Generates the global makefile.
  37. dnl
  38. AC_DEFUN(PHP_GEN_GLOBAL_MAKEFILE,[
  39. cat >Makefile <<EOF
  40. srcdir = $abs_srcdir
  41. builddir = $abs_builddir
  42. top_srcdir = $abs_srcdir
  43. top_builddir = $abs_builddir
  44. EOF
  45. for i in $PHP_VAR_SUBST; do
  46. eval echo "$i = \$$i" >> Makefile
  47. done
  48. cat $abs_srcdir/Makefile.global Makefile.fragments Makefile.objects >> Makefile
  49. ])
  50. dnl PHP_ADD_SOURCES(source-path, sources[, special-flags[, type]])
  51. dnl
  52. dnl Adds sources which are located relative to source-path to the
  53. dnl array of type type. Sources are processed with optional
  54. dnl special-flags which are passed to the compiler. Sources
  55. dnl can be either written in C or C++ (filenames shall end in .c
  56. dnl or .cpp, respectively).
  57. dnl
  58. dnl Note: If source-path begins with a "/", the "/" is removed and
  59. dnl the path is interpreted relative to the top build-directory.
  60. dnl
  61. dnl which array to append to?
  62. AC_DEFUN(PHP_ADD_SOURCES,[
  63. PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,cli,PHP_CLI_OBJS,ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS)))
  64. ])
  65. dnl
  66. dnl PHP_ASSIGN_BUILD_VARS(type)
  67. dnl internal, don't use
  68. AC_DEFUN(PHP_ASSIGN_BUILD_VARS,[
  69. ifelse($1,shared,[
  70. b_c_pre=$shared_c_pre
  71. b_cxx_pre=$shared_cxx_pre
  72. b_c_meta=$shared_c_meta
  73. b_cxx_meta=$shared_cxx_meta
  74. b_c_post=$shared_c_post
  75. b_cxx_post=$shared_cxx_post
  76. ],[
  77. b_c_pre=$php_c_pre
  78. b_cxx_pre=$php_cxx_pre
  79. b_c_meta=$php_c_meta
  80. b_cxx_meta=$php_cxx_meta
  81. b_c_post=$php_c_post
  82. b_cxx_post=$php_cxx_post
  83. ])dnl
  84. b_lo=[$]$1_lo
  85. ])
  86. dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared[, special-post-flags]]]])
  87. dnl
  88. dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the
  89. dnl name of the array target-var directly, as well as whether
  90. dnl shared objects will be built from the sources. Should not be
  91. dnl used directly.
  92. dnl
  93. AC_DEFUN(PHP_ADD_SOURCES_X,[
  94. dnl relative to source- or build-directory?
  95. dnl ac_srcdir/ac_bdir include trailing slash
  96. case $1 in
  97. ""[)] ac_srcdir="$abs_srcdir/"; unset ac_bdir; ac_inc="-I. -I$abs_srcdir" ;;
  98. /*[)] ac_srcdir=`echo $ac_n "$1$ac_c"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;;
  99. *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;;
  100. esac
  101. dnl how to build .. shared or static?
  102. ifelse($5,yes,PHP_ASSIGN_BUILD_VARS(shared),PHP_ASSIGN_BUILD_VARS(php))
  103. dnl iterate over the sources
  104. old_IFS=[$]IFS
  105. for ac_src in $2; do
  106. dnl remove the suffix
  107. IFS=.
  108. set $ac_src
  109. ac_obj=[$]1
  110. IFS=$old_IFS
  111. dnl append to the array which has been dynamically chosen at m4 time
  112. $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
  113. dnl choose the right compiler/flags/etc. for the source-file
  114. case $ac_src in
  115. *.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" ;;
  116. *.cpp[)] 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" ;;
  117. esac
  118. dnl create a rule for the object/source combo
  119. cat >>Makefile.objects<<EOF
  120. $ac_bdir[$]ac_obj.lo: $ac_srcdir[$]ac_src
  121. $ac_comp
  122. EOF
  123. done
  124. ])
  125. dnl
  126. dnl Disable building CLI
  127. dnl
  128. AC_DEFUN(PHP_DISABLE_CLI,[
  129. disable_cli=1
  130. ])
  131. dnl
  132. dnl Separator into the configure --help display.
  133. dnl
  134. AC_DEFUN(PHP_HELP_SEPARATOR,[
  135. AC_ARG_ENABLE([],[
  136. $1
  137. ],[])
  138. ])
  139. dnl
  140. dnl PHP_TARGET_RDYNAMIC
  141. dnl
  142. dnl Checks whether -rdynamic is supported by the compiler. This
  143. dnl is necessary for some targets to populate the global symbol
  144. dnl table. Otherwise, dynamic modules would not be able to resolve
  145. dnl PHP-related symbols.
  146. dnl
  147. dnl If successful, adds -rdynamic to PHP_LDFLAGS.
  148. dnl
  149. AC_DEFUN(PHP_TARGET_RDYNAMIC,[
  150. if test -n "$GCC"; then
  151. dnl we should use a PHP-specific macro here
  152. TSRM_CHECK_GCC_ARG(-rdynamic, gcc_rdynamic=yes)
  153. if test "$gcc_rdynamic" = "yes"; then
  154. PHP_LDFLAGS="$PHP_LDFLAGS -rdynamic"
  155. fi
  156. fi
  157. ])
  158. AC_DEFUN(PHP_REMOVE_USR_LIB,[
  159. unset ac_new_flags
  160. for i in [$]$1; do
  161. case [$]i in
  162. -L/usr/lib|-L/usr/lib/) ;;
  163. *) ac_new_flags="[$]ac_new_flags [$]i" ;;
  164. esac
  165. done
  166. $1=[$]ac_new_flags
  167. ])
  168. AC_DEFUN(PHP_SETUP_OPENSSL,[
  169. if test "$PHP_OPENSSL" = "yes"; then
  170. PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl"
  171. fi
  172. for i in $PHP_OPENSSL; do
  173. if test -r $i/include/openssl/evp.h; then
  174. OPENSSL_INCDIR=$i/include
  175. fi
  176. if test -r $i/lib/libssl.a -o -r $i/lib/libssl.$SHLIB_SUFFIX_NAME; then
  177. OPENSSL_LIBDIR=$i/lib
  178. fi
  179. done
  180. if test -z "$OPENSSL_INCDIR"; then
  181. AC_MSG_ERROR([Cannot find OpenSSL's <evp.h>])
  182. fi
  183. if test -z "$OPENSSL_LIBDIR"; then
  184. AC_MSG_ERROR([Cannot find OpenSSL's libraries])
  185. fi
  186. old_CPPFLAGS=$CPPFLAGS
  187. CPPFLAGS=-I$OPENSSL_INCDIR
  188. AC_MSG_CHECKING([for OpenSSL version])
  189. AC_EGREP_CPP(yes,[
  190. #include <openssl/opensslv.h>
  191. #if OPENSSL_VERSION_NUMBER >= 0x0090500fL
  192. yes
  193. #endif
  194. ],[
  195. AC_MSG_RESULT([>= 0.9.5])
  196. ],[
  197. AC_MSG_ERROR([OpenSSL version 0.9.5 or greater required.])
  198. ])
  199. CPPFLAGS=$old_CPPFLAGS
  200. PHP_ADD_INCLUDE($OPENSSL_INCDIR)
  201. PHP_ADD_LIBPATH($OPENSSL_LIBDIR)
  202. PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
  203. PHP_ADD_LIBRARY(crypto)
  204. ],[
  205. AC_MSG_ERROR([libcrypto not found!])
  206. ],[
  207. -L$OPENSSL_LIBDIR
  208. ])
  209. PHP_CHECK_LIBRARY(ssl, SSL_CTX_set_ssl_version, [
  210. PHP_ADD_LIBRARY(ssl)
  211. ],[
  212. AC_MSG_ERROR([libssl not found!])
  213. ],[
  214. -L$OPENSSL_LIBDIR
  215. ])
  216. OPENSSL_INCDIR_OPT=-I$OPENSSL_INCDIR
  217. AC_SUBST(OPENSSL_INCDIR_OPT)
  218. ])
  219. dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD)
  220. dnl
  221. dnl Use this macro, if you need to add libraries and or library search
  222. dnl paths to the PHP build system which are only given in compiler
  223. dnl notation.
  224. dnl
  225. AC_DEFUN(PHP_EVAL_LIBLINE,[
  226. for ac_i in $1; do
  227. case $ac_i in
  228. -l*)
  229. ac_ii=`echo $ac_i|cut -c 3-`
  230. PHP_ADD_LIBRARY($ac_ii,,$2)
  231. ;;
  232. -L*)
  233. ac_ii=`echo $ac_i|cut -c 3-`
  234. PHP_ADD_LIBPATH($ac_ii,$2)
  235. ;;
  236. esac
  237. done
  238. ])
  239. dnl PHP_EVAL_INCLINE(LINE)
  240. dnl
  241. dnl Use this macro, if you need to add header search paths to the PHP
  242. dnl build system which are only given in compiler notation.
  243. dnl
  244. AC_DEFUN(PHP_EVAL_INCLINE,[
  245. for ac_i in $1; do
  246. case $ac_i in
  247. -I*)
  248. ac_ii=`echo $ac_i|cut -c 3-`
  249. PHP_ADD_INCLUDE($ac_ii)
  250. ;;
  251. esac
  252. done
  253. ])
  254. AC_DEFUN(PHP_READDIR_R_TYPE,[
  255. dnl HAVE_READDIR_R is also defined by libmysql
  256. AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
  257. if test "$ac_cv_func_readdir_r" = "yes"; then
  258. AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
  259. AC_TRY_RUN([
  260. #define _REENTRANT
  261. #include <sys/types.h>
  262. #include <dirent.h>
  263. #ifndef PATH_MAX
  264. #define PATH_MAX 1024
  265. #endif
  266. main() {
  267. DIR *dir;
  268. char entry[sizeof(struct dirent)+PATH_MAX];
  269. struct dirent *pentry = (struct dirent *) &entry;
  270. dir = opendir("/");
  271. if (!dir)
  272. exit(1);
  273. if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
  274. exit(0);
  275. exit(1);
  276. }
  277. ],[
  278. ac_cv_what_readdir_r=POSIX
  279. ],[
  280. AC_TRY_CPP([
  281. #define _REENTRANT
  282. #include <sys/types.h>
  283. #include <dirent.h>
  284. int readdir_r(DIR *, struct dirent *);
  285. ],[
  286. ac_cv_what_readdir_r=old-style
  287. ],[
  288. ac_cv_what_readdir_r=none
  289. ])
  290. ],[
  291. ac_cv_what_readdir_r=none
  292. ])
  293. ])
  294. case $ac_cv_what_readdir_r in
  295. POSIX)
  296. AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
  297. old-style)
  298. AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
  299. esac
  300. fi
  301. ])
  302. AC_DEFUN(PHP_SHLIB_SUFFIX_NAME,[
  303. PHP_SUBST(SHLIB_SUFFIX_NAME)
  304. SHLIB_SUFFIX_NAME=so
  305. case $host_alias in
  306. *hpux*)
  307. SHLIB_SUFFIX_NAME=sl
  308. ;;
  309. *darwin*)
  310. SHLIB_SUFFIX_NAME=dylib
  311. ;;
  312. esac
  313. ])
  314. AC_DEFUN(PHP_DEBUG_MACRO,[
  315. DEBUG_LOG=$1
  316. cat >$1 <<X
  317. CONFIGURE: $CONFIGURE_COMMAND
  318. CC: $CC
  319. CFLAGS: $CFLAGS
  320. CPPFLAGS: $CPPFLAGS
  321. CXX: $CXX
  322. CXXFLAGS: $CXXFLAGS
  323. INCLUDES: $INCLUDES
  324. LDFLAGS: $LDFLAGS
  325. LIBS: $LIBS
  326. DLIBS: $DLIBS
  327. SAPI: $PHP_SAPI
  328. PHP_RPATHS: $PHP_RPATHS
  329. uname -a: `uname -a`
  330. X
  331. cat >conftest.$ac_ext <<X
  332. main()
  333. {
  334. exit(0);
  335. }
  336. X
  337. (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
  338. rm -fr conftest*
  339. ])
  340. AC_DEFUN(PHP_MISSING_PREAD_DECL,[
  341. AC_CACHE_CHECK(whether pread works without custom declaration,ac_cv_pread,[
  342. AC_TRY_COMPILE([#include <unistd.h>],[size_t (*func)() = pread],[
  343. ac_cv_pread=yes
  344. ],[
  345. echo test > conftest_in
  346. AC_TRY_RUN([
  347. #include <sys/types.h>
  348. #include <sys/stat.h>
  349. #include <fcntl.h>
  350. main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) == 2); }
  351. ],[
  352. ac_cv_pread=yes
  353. ],[
  354. echo test > conftest_in
  355. AC_TRY_RUN([
  356. #include <sys/types.h>
  357. #include <sys/stat.h>
  358. #include <fcntl.h>
  359. #include <unistd.h>
  360. ssize_t pread(int, void *, size_t, off64_t);
  361. main() { char buf[3]; return !(pread(open("conftest_in", O_RDONLY), buf, 2, 0) == 2); }
  362. ],[
  363. ac_cv_pread=64
  364. ],[
  365. ac_cv_pread=no
  366. ])
  367. ],[
  368. ac_cv_pread=no
  369. ])
  370. ])
  371. ])
  372. case $ac_cv_pread in
  373. no) ac_cv_func_pread=no;;
  374. 64) AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default]);;
  375. esac
  376. ])
  377. AC_DEFUN(PHP_MISSING_PWRITE_DECL,[
  378. AC_CACHE_CHECK(whether pwrite works without custom declaration,ac_cv_pwrite,[
  379. AC_TRY_COMPILE([#include <unistd.h>],[size_t (*func)() = pwrite],[
  380. ac_cv_pwrite=yes
  381. ],[
  382. AC_TRY_RUN([
  383. #include <sys/types.h>
  384. #include <sys/stat.h>
  385. #include <fcntl.h>
  386. main() { return !(pwrite(open("conftest_out", O_WRONLY|O_CREAT, 0600), "Ok", 2, 0) == 2); }
  387. ],[
  388. ac_cv_pwrite=yes
  389. ],[
  390. AC_TRY_RUN([
  391. #include <sys/types.h>
  392. #include <sys/stat.h>
  393. #include <fcntl.h>
  394. #include <unistd.h>
  395. ssize_t pwrite(int, void *, size_t, off64_t);
  396. main() { return !(pwrite(open("conftest_out", O_WRONLY|O_CREAT, 0600), "Ok", 2, 0) == 2); }
  397. ],[
  398. ac_cv_pwrite=64
  399. ],[
  400. ac_cv_pwrite=no
  401. ])
  402. ],[
  403. ac_cv_pwrite=no
  404. ])
  405. ])
  406. ])
  407. case $ac_cv_pwrite in
  408. no) ac_cv_func_pwrite=no;;
  409. 64) AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default]);;
  410. esac
  411. ])
  412. AC_DEFUN(PHP_MISSING_TIME_R_DECL,[
  413. AC_MSG_CHECKING([for missing declarations of reentrant functions])
  414. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
  415. :
  416. ],[
  417. AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
  418. ])
  419. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
  420. :
  421. ],[
  422. AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
  423. ])
  424. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
  425. :
  426. ],[
  427. AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
  428. ])
  429. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
  430. :
  431. ],[
  432. AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
  433. ])
  434. AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
  435. :
  436. ],[
  437. AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
  438. ])
  439. AC_MSG_RESULT([done])
  440. ])
  441. dnl
  442. dnl PHP_LIBGCC_LIBPATH(gcc)
  443. dnl Stores the location of libgcc in libgcc_libpath
  444. dnl
  445. AC_DEFUN(PHP_LIBGCC_LIBPATH,[
  446. changequote({,})
  447. libgcc_libpath=`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'`
  448. changequote([,])
  449. ])
  450. AC_DEFUN(PHP_ARG_ANALYZE_EX,[
  451. ext_output="yes, shared"
  452. ext_shared=yes
  453. case [$]$1 in
  454. shared,*)
  455. $1=`echo "[$]$1"|sed 's/^shared,//'`
  456. ;;
  457. shared)
  458. $1=yes
  459. ;;
  460. no)
  461. ext_output=no
  462. ext_shared=no
  463. ;;
  464. *)
  465. ext_output=yes
  466. ext_shared=no
  467. ;;
  468. esac
  469. PHP_ALWAYS_SHARED([$1])
  470. ])
  471. AC_DEFUN(PHP_ARG_ANALYZE,[
  472. PHP_ARG_ANALYZE_EX([$1])
  473. ifelse([$2],,,[AC_MSG_RESULT([$ext_output])])
  474. ])
  475. dnl
  476. dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val])
  477. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  478. dnl default-val defaults to no. This will also set the variable ext_shared,
  479. dnl and will overwrite any previous variable of that name.
  480. dnl
  481. AC_DEFUN(PHP_ARG_WITH,[
  482. PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_))
  483. ])
  484. AC_DEFUN(PHP_REAL_ARG_WITH,[
  485. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  486. AC_ARG_WITH($1,[$3],$5=[$]withval,$5=ifelse($4,,no,$4))
  487. PHP_ARG_ANALYZE($5,[$2])
  488. ])
  489. dnl
  490. dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val])
  491. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  492. dnl default-val defaults to no. This will also set the variable ext_shared,
  493. dnl and will overwrite any previous variable of that name.
  494. dnl
  495. AC_DEFUN(PHP_ARG_ENABLE,[
  496. PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_))
  497. ])
  498. AC_DEFUN(PHP_REAL_ARG_ENABLE,[
  499. ifelse([$2],,,[AC_MSG_CHECKING([$2])])
  500. AC_ARG_ENABLE($1,[$3],$5=[$]enableval,$5=ifelse($4,,no,$4))
  501. PHP_ARG_ANALYZE($5,[$2])
  502. ])
  503. AC_DEFUN(PHP_MODULE_PTR,[
  504. EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1,"
  505. ])
  506. AC_DEFUN(PHP_CONFIG_NICE,[
  507. rm -f $1
  508. cat >$1<<EOF
  509. #! /bin/sh
  510. #
  511. # Created by configure
  512. EOF
  513. for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS CC CXX; do
  514. eval val=\$$var
  515. if test -n "$val"; then
  516. echo "$var='$val' \\" >> $1
  517. fi
  518. done
  519. for arg in [$]0 "[$]@"; do
  520. echo "'[$]arg' \\" >> $1
  521. done
  522. echo '"[$]@"' >> $1
  523. chmod +x $1
  524. ])
  525. AC_DEFUN(PHP_TIME_R_TYPE,[
  526. AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
  527. AC_TRY_RUN([
  528. #include <time.h>
  529. main() {
  530. char buf[27];
  531. struct tm t;
  532. time_t old = 0;
  533. int r, s;
  534. s = gmtime_r(&old, &t);
  535. r = (int) asctime_r(&t, buf, 26);
  536. if (r == s && s == 0) return (0);
  537. return (1);
  538. }
  539. ],[
  540. ac_cv_time_r_type=hpux
  541. ],[
  542. AC_TRY_RUN([
  543. #include <time.h>
  544. main() {
  545. struct tm t, *s;
  546. time_t old = 0;
  547. char buf[27], *p;
  548. s = gmtime_r(&old, &t);
  549. p = asctime_r(&t, buf, 26);
  550. if (p == buf && s == &t) return (0);
  551. return (1);
  552. }
  553. ],[
  554. ac_cv_time_r_type=irix
  555. ],[
  556. ac_cv_time_r_type=POSIX
  557. ])
  558. ],[
  559. ac_cv_time_r_type=POSIX
  560. ])
  561. ])
  562. case $ac_cv_time_r_type in
  563. hpux) AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
  564. irix) AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
  565. esac
  566. ])
  567. AC_DEFUN(PHP_SUBST,[
  568. PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
  569. ])
  570. AC_DEFUN(PHP_SUBST_OLD,[
  571. PHP_SUBST($1)
  572. AC_SUBST($1)
  573. ])
  574. AC_DEFUN(PHP_MKDIR_P_CHECK,[
  575. AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
  576. test -d conftestdir && rm -rf conftestdir
  577. mkdir -p conftestdir/somedir >/dev/null 2>&1
  578. dnl `mkdir -p' must be quiet about creating existing directories
  579. mkdir -p conftestdir/somedir >/dev/null 2>&1
  580. if test "$?" = "0" && test -d conftestdir/somedir; then
  581. ac_cv_mkdir_p=yes
  582. else
  583. ac_cv_mkdir_p=no
  584. fi
  585. rm -rf conftestdir
  586. ])
  587. ])
  588. AC_DEFUN(PHP_TM_GMTOFF,[
  589. AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
  590. [AC_TRY_COMPILE([#include <sys/types.h>
  591. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  592. ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
  593. if test "$ac_cv_struct_tm_gmtoff" = yes; then
  594. AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
  595. fi
  596. ])
  597. dnl PHP_CONFIGURE_PART(MESSAGE)
  598. dnl Idea borrowed from mm
  599. AC_DEFUN(PHP_CONFIGURE_PART,[
  600. AC_MSG_RESULT()
  601. AC_MSG_RESULT([${T_MD}$1${T_ME}])
  602. ])
  603. AC_DEFUN(PHP_PROG_SENDMAIL,[
  604. AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib)
  605. if test -n "$PROG_SENDMAIL"; then
  606. AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail])
  607. fi
  608. ])
  609. AC_DEFUN(PHP_RUNPATH_SWITCH,[
  610. dnl check for -R, etc. switch
  611. AC_MSG_CHECKING([if compiler supports -R])
  612. AC_CACHE_VAL(php_cv_cc_dashr,[
  613. SAVE_LIBS=$LIBS
  614. LIBS="-R /usr/lib $LIBS"
  615. AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
  616. LIBS=$SAVE_LIBS])
  617. AC_MSG_RESULT([$php_cv_cc_dashr])
  618. if test $php_cv_cc_dashr = "yes"; then
  619. ld_runpath_switch=-R
  620. else
  621. AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
  622. AC_CACHE_VAL(php_cv_cc_rpath,[
  623. SAVE_LIBS=$LIBS
  624. LIBS="-Wl,-rpath,/usr/lib $LIBS"
  625. AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
  626. LIBS=$SAVE_LIBS])
  627. AC_MSG_RESULT([$php_cv_cc_rpath])
  628. if test $php_cv_cc_rpath = "yes"; then
  629. ld_runpath_switch=-Wl,-rpath,
  630. else
  631. dnl something innocuous
  632. ld_runpath_switch=-L
  633. fi
  634. fi
  635. ])
  636. AC_DEFUN(PHP_STRUCT_FLOCK,[
  637. AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
  638. AC_TRY_COMPILE([
  639. #include <unistd.h>
  640. #include <fcntl.h>
  641. ],
  642. [struct flock x;],
  643. [
  644. ac_cv_struct_flock=yes
  645. ],[
  646. ac_cv_struct_flock=no
  647. ])
  648. )
  649. if test "$ac_cv_struct_flock" = "yes" ; then
  650. AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
  651. fi
  652. ])
  653. AC_DEFUN(PHP_SOCKLEN_T,[
  654. AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
  655. AC_TRY_COMPILE([
  656. #include <sys/types.h>
  657. #include <sys/socket.h>
  658. ],[
  659. socklen_t x;
  660. ],[
  661. ac_cv_socklen_t=yes
  662. ],[
  663. ac_cv_socklen_t=no
  664. ]))
  665. if test "$ac_cv_socklen_t" = "yes"; then
  666. AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
  667. fi
  668. ])
  669. dnl
  670. dnl PHP_SET_SYM_FILE(path)
  671. dnl
  672. dnl set the path of the file which contains the symbol export list
  673. dnl
  674. AC_DEFUN(PHP_SET_SYM_FILE,
  675. [
  676. PHP_SYM_FILE=$1
  677. ])
  678. dnl
  679. dnl PHP_BUILD_THREAD_SAFE
  680. dnl
  681. AC_DEFUN(PHP_BUILD_THREAD_SAFE,[
  682. enable_experimental_zts=yes
  683. if test "$pthreads_working" != "yes"; then
  684. AC_MSG_ERROR([ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.])
  685. fi
  686. ])
  687. AC_DEFUN(PHP_REQUIRE_CXX,[
  688. if test -z "$php_cxx_done"; then
  689. AC_PROG_CXX
  690. AC_PROG_CXXCPP
  691. php_cxx_done=yes
  692. fi
  693. ])
  694. dnl
  695. dnl PHP_BUILD_SHARED
  696. dnl
  697. AC_DEFUN(PHP_BUILD_SHARED,[
  698. PHP_BUILD_PROGRAM
  699. OVERALL_TARGET=libphp4.la
  700. php_build_target=shared
  701. php_c_pre=$shared_c_pre
  702. php_c_meta=$shared_c_meta
  703. php_c_post=$shared_c_post
  704. php_cxx_pre=$shared_cxx_pre
  705. php_cxx_meta=$shared_cxx_meta
  706. php_cxx_post=$shared_cxx_post
  707. php_lo=$shared_lo
  708. ])
  709. dnl
  710. dnl PHP_BUILD_STATIC
  711. dnl
  712. AC_DEFUN(PHP_BUILD_STATIC,[
  713. PHP_BUILD_PROGRAM
  714. OVERALL_TARGET=libphp4.la
  715. php_build_target=static
  716. ])
  717. dnl
  718. dnl PHP_BUILD_BUNDLE
  719. dnl
  720. AC_DEFUN(PHP_BUILD_BUNDLE,[
  721. PHP_BUILD_PROGRAM
  722. OVERALL_TARGET=libs/libphp4.bundle
  723. php_build_target=static
  724. ])
  725. dnl
  726. dnl PHP_BUILD_PROGRAM
  727. dnl
  728. AC_DEFUN(PHP_BUILD_PROGRAM,[
  729. OVERALL_TARGET=php
  730. php_c_pre='$(CC)'
  731. php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
  732. php_c_post=' && echo > $[@]'
  733. php_cxx_pre='$(CXX)'
  734. php_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS)'
  735. php_cxx_post=' && echo > $[@]'
  736. php_lo=o
  737. shared_c_pre='$(LIBTOOL) --mode=compile $(CC)'
  738. shared_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -prefer-pic'
  739. shared_c_post=
  740. shared_cxx_pre='$(LIBTOOL) --mode=compile $(CXX)'
  741. shared_cxx_meta='$(COMMON_FLAGS) $(CXXFLAGS_CLEAN) $(EXTRA_CXXFLAGS) -prefer-pic'
  742. shared_cxx_post=
  743. shared_lo=lo
  744. php_build_target=program
  745. ])
  746. dnl
  747. dnl AC_PHP_ONCE(namespace, variable, code)
  748. dnl
  749. dnl execute code, if variable is not set in namespace
  750. dnl
  751. AC_DEFUN(AC_PHP_ONCE,[
  752. changequote({,})
  753. unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'`
  754. changequote([,])
  755. cmd="echo $ac_n \"\$$1$unique$ac_c\""
  756. if test -n "$unique" && test "`eval $cmd`" = "" ; then
  757. eval "$1$unique=set"
  758. $3
  759. fi
  760. ])
  761. dnl
  762. dnl PHP_EXPAND_PATH(path, variable)
  763. dnl
  764. dnl expands path to an absolute path and assigns it to variable
  765. dnl
  766. AC_DEFUN(PHP_EXPAND_PATH,[
  767. if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
  768. $2=$1
  769. else
  770. changequote({,})
  771. ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`"
  772. changequote([,])
  773. ep_realdir="`(cd \"$ep_dir\" && pwd)`"
  774. $2="$ep_realdir/`basename \"$1\"`"
  775. fi
  776. ])
  777. dnl
  778. dnl internal, don't use
  779. AC_DEFUN(PHP_ADD_LIBPATH_GLOBAL,[
  780. AC_PHP_ONCE(LIBPATH, $1, [
  781. test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1"
  782. LDFLAGS="$LDFLAGS -L$1"
  783. PHP_RPATHS="$PHP_RPATHS $1"
  784. ])
  785. ])dnl
  786. dnl
  787. dnl
  788. dnl
  789. dnl PHP_ADD_LIBPATH(path[, shared-libadd])
  790. dnl
  791. dnl add a library to linkpath/runpath
  792. dnl
  793. AC_DEFUN(PHP_ADD_LIBPATH,[
  794. if test "$1" != "/usr/lib"; then
  795. PHP_EXPAND_PATH($1, ai_p)
  796. ifelse([$2],,[
  797. PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  798. ],[
  799. if test "$ext_shared" = "yes"; then
  800. $2="-R$ai_p -L$ai_p [$]$2"
  801. else
  802. PHP_ADD_LIBPATH_GLOBAL([$ai_p])
  803. fi
  804. ])
  805. fi
  806. ])
  807. dnl
  808. dnl PHP_BUILD_RPATH()
  809. dnl
  810. dnl builds RPATH from PHP_RPATHS
  811. dnl
  812. AC_DEFUN(PHP_BUILD_RPATH,[
  813. if test "$PHP_RPATH" = "yes" && test -n "$PHP_RPATHS"; then
  814. OLD_RPATHS=$PHP_RPATHS
  815. unset PHP_RPATHS
  816. for i in $OLD_RPATHS; do
  817. PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
  818. PHP_RPATHS="$PHP_RPATHS -R $i"
  819. NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
  820. done
  821. fi
  822. ])
  823. dnl
  824. dnl PHP_ADD_INCLUDE(path [,before])
  825. dnl
  826. dnl add an include path.
  827. dnl if before is 1, add in the beginning of INCLUDES.
  828. dnl
  829. AC_DEFUN(PHP_ADD_INCLUDE,[
  830. if test "$1" != "/usr/include"; then
  831. PHP_EXPAND_PATH($1, ai_p)
  832. AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
  833. if test "$2"; then
  834. INCLUDES="-I$ai_p $INCLUDES"
  835. else
  836. INCLUDES="$INCLUDES -I$ai_p"
  837. fi
  838. ])
  839. fi
  840. ])
  841. dnl
  842. dnl internal, don't use
  843. AC_DEFUN(PHP_X_ADD_LIBRARY,[dnl
  844. ifelse([$2],,$3="-l$1 [$]$3", $3="[$]$3 -l$1") dnl
  845. ])dnl
  846. dnl
  847. dnl internal, don't use
  848. AC_DEFUN(PHP_ADD_LIBRARY_SKELETON,[
  849. case $1 in
  850. c|c_r|pthread*) ;;
  851. *) ifelse($3,,[
  852. PHP_X_ADD_LIBRARY($1,$2,$5)
  853. ],[
  854. if test "$ext_shared" = "yes"; then
  855. PHP_X_ADD_LIBRARY($1,$2,$3)
  856. else
  857. $4($1,$2)
  858. fi
  859. ]) ;;
  860. esac
  861. ])dnl
  862. dnl
  863. dnl
  864. dnl
  865. dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
  866. dnl
  867. dnl add a library to the link line
  868. dnl
  869. AC_DEFUN(PHP_ADD_LIBRARY,[
  870. PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY],[LIBS])
  871. ])
  872. dnl
  873. dnl PHP_ADD_LIBRARY_DEFER(library[, append[, shared-libadd]])
  874. dnl
  875. dnl add a library to the link line (deferred)
  876. dnl
  877. AC_DEFUN(PHP_ADD_LIBRARY_DEFER,[
  878. PHP_ADD_LIBRARY_SKELETON([$1],[$2],[$3],[PHP_ADD_LIBRARY_DEFER],[DLIBS])
  879. ])
  880. dnl
  881. dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
  882. dnl
  883. dnl add a library to the link line and path to linkpath/runpath.
  884. dnl if shared-libadd is not empty and $ext_shared is yes,
  885. dnl shared-libadd will be assigned the library information
  886. dnl
  887. AC_DEFUN(PHP_ADD_LIBRARY_WITH_PATH,[
  888. ifelse($3,,[
  889. if test -n "$2"; then
  890. PHP_ADD_LIBPATH($2)
  891. fi
  892. PHP_ADD_LIBRARY($1)
  893. ],[
  894. if test "$ext_shared" = "yes"; then
  895. $3="-l$1 [$]$3"
  896. if test -n "$2"; then
  897. PHP_ADD_LIBPATH($2,$3)
  898. fi
  899. else
  900. PHP_ADD_LIBRARY_WITH_PATH($1,$2)
  901. fi
  902. ])
  903. ])
  904. dnl
  905. dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path[, shared-libadd])
  906. dnl
  907. dnl add a library to the link line (deferred)
  908. dnl and path to linkpath/runpath (not deferred)
  909. dnl if shared-libadd is not empty and $ext_shared is yes,
  910. dnl shared-libadd will be assigned the library information
  911. dnl
  912. AC_DEFUN(PHP_ADD_LIBRARY_DEFER_WITH_PATH,[
  913. ifelse($3,,[
  914. if test -n "$2"; then
  915. PHP_ADD_LIBPATH($2)
  916. fi
  917. PHP_ADD_LIBRARY_DEFER($1)
  918. ],[
  919. if test "$ext_shared" = "yes"; then
  920. $3="-l$1 [$]$3"
  921. if test -n "$2"; then
  922. PHP_ADD_LIBPATH($2,$3)
  923. fi
  924. else
  925. PHP_ADD_LIBRARY_DEFER_WITH_PATH($1,$2)
  926. fi
  927. ])
  928. ])
  929. dnl
  930. dnl Set libtool variable
  931. dnl
  932. AC_DEFUN(PHP_SET_LIBTOOL_VARIABLE,[
  933. LIBTOOL='$(SHELL) libtool $1'
  934. ])
  935. dnl
  936. dnl Check for cc option
  937. dnl
  938. AC_DEFUN(PHP_CHECK_CC_OPTION,[
  939. echo "main(){return 0;}" > conftest.$ac_ext
  940. opt=$1
  941. changequote({,})
  942. var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'`
  943. changequote([,])
  944. AC_MSG_CHECKING([if compiler supports -$1 really])
  945. ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1"
  946. if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then
  947. eval php_cc_$var=no
  948. AC_MSG_RESULT([no])
  949. else
  950. if eval ./conftest 2>/dev/null ; then
  951. eval php_cc_$var=yes
  952. AC_MSG_RESULT([yes])
  953. else
  954. eval php_cc_$var=no
  955. AC_MSG_RESULT([no])
  956. fi
  957. fi
  958. ])
  959. AC_DEFUN(PHP_REGEX,[
  960. if test "$REGEX_TYPE" = "php"; then
  961. AC_DEFINE(HSREGEX,1,[ ])
  962. AC_DEFINE(REGEX,1,[ ])
  963. PHP_ADD_SOURCES(regex, regcomp.c regexec.c regerror.c regfree.c)
  964. elif test "$REGEX_TYPE" = "system"; then
  965. AC_DEFINE(REGEX,0,[ ])
  966. fi
  967. AC_MSG_CHECKING([which regex library to use])
  968. AC_MSG_RESULT([$REGEX_TYPE])
  969. ])
  970. dnl
  971. dnl See if we have broken header files like SunOS has.
  972. dnl
  973. AC_DEFUN(PHP_MISSING_FCLOSE_DECL,[
  974. AC_MSG_CHECKING([for fclose declaration])
  975. AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
  976. AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
  977. AC_MSG_RESULT([ok])
  978. ],[
  979. AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
  980. AC_MSG_RESULT([missing])
  981. ])
  982. ])
  983. dnl
  984. dnl Check for broken sprintf()
  985. dnl
  986. AC_DEFUN(PHP_AC_BROKEN_SPRINTF,[
  987. AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
  988. AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
  989. ac_cv_broken_sprintf=no
  990. ],[
  991. ac_cv_broken_sprintf=yes
  992. ],[
  993. ac_cv_broken_sprintf=no
  994. ])
  995. ])
  996. if test "$ac_cv_broken_sprintf" = "yes"; then
  997. AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [ ])
  998. else
  999. AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [ ])
  1000. fi
  1001. ])
  1002. dnl PHP_SHARED_MODULE(module-name, object-var, build-dir)
  1003. dnl
  1004. dnl Basically sets up the link-stage for building module-name
  1005. dnl from object_var in build-dir.
  1006. dnl
  1007. AC_DEFUN(PHP_SHARED_MODULE,[
  1008. PHP_MODULES="$PHP_MODULES \$(phplibdir)/$1.la"
  1009. PHP_SUBST($2)
  1010. cat >>Makefile.objects<<EOF
  1011. \$(phplibdir)/$1.la: $3/$1.la
  1012. \$(LIBTOOL) --mode=install cp $3/$1.la \$(phplibdir)
  1013. $3/$1.la: \$($2) \$(translit($1,a-z-,A-Z_)_SHARED_DEPENDENCIES)
  1014. \$(LIBTOOL) --mode=link \$(CC) \$(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)
  1015. EOF
  1016. ])
  1017. dnl
  1018. dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags]])
  1019. dnl
  1020. dnl Selects the SAPI name and type (static, shared, programm)
  1021. dnl and optionally also the source-files for the SAPI-specific
  1022. dnl objects.
  1023. dnl
  1024. AC_DEFUN(PHP_SELECT_SAPI,[
  1025. PHP_SAPI=$1
  1026. case "$2" in
  1027. static) PHP_BUILD_STATIC;;
  1028. shared) PHP_BUILD_SHARED;;
  1029. bundle) PHP_BUILD_BUNDLE;;
  1030. program) PHP_BUILD_PROGRAM;;
  1031. esac
  1032. ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
  1033. ])
  1034. dnl deprecated
  1035. AC_DEFUN(PHP_EXTENSION,[
  1036. sources=`awk -f $abs_srcdir/scan_makefile_in.awk < []PHP_EXT_SRCDIR($1)[]/Makefile.in`
  1037. PHP_NEW_EXTENSION($1, $sources, $2, $3)
  1038. if test -r "$ext_srcdir/Makefile.frag"; then
  1039. PHP_ADD_MAKEFILE_FRAGMENT
  1040. fi
  1041. ])
  1042. AC_DEFUN(PHP_ADD_BUILD_DIR,[
  1043. BUILD_DIR="$BUILD_DIR $1"
  1044. ])
  1045. AC_DEFUN(PHP_GEN_BUILD_DIRS,[
  1046. PHP_MKDIR_P_CHECK
  1047. if test "$ac_cv_mkdir_p" = "yes"; then
  1048. mkdir -p $BUILD_DIR
  1049. fi
  1050. ])
  1051. dnl
  1052. dnl PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])
  1053. dnl
  1054. dnl Includes an extension in the build.
  1055. dnl
  1056. dnl "extname" is the name of the ext/ subdir where the extension resides.
  1057. dnl "sources" is a list of files relative to the subdir which are used
  1058. dnl to build the extension.
  1059. dnl "shared" can be set to "shared" or "yes" to build the extension as
  1060. dnl a dynamically loadable library. Optional parameter "sapi_class" can
  1061. dnl be set to "cli" to mark extension build only with CLI or CGI sapi's.
  1062. dnl extra-cflags are passed to the compiler, with @ext_srcdir@ being
  1063. dnl substituted.
  1064. AC_DEFUN(PHP_NEW_EXTENSION,[
  1065. ext_builddir=[]PHP_EXT_BUILDDIR($1)
  1066. ext_srcdir=[]PHP_EXT_SRCDIR($1)
  1067. ifelse($5,,ac_extra=,[ac_extra=`echo $ac_n "$5$ac_c"|sed s#@ext_srcdir@#$ext_srcdir#g`])
  1068. if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then
  1069. dnl ---------------------------------------------- Static module
  1070. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
  1071. EXT_STATIC="$EXT_STATIC $1"
  1072. if test "$3" != "nocli"; then
  1073. EXT_CLI_LTLIBS="$EXT_CLI_LTLIBS $abs_builddir/$ext_builddir/lib$1.la"
  1074. EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
  1075. fi
  1076. else
  1077. if test "$3" = "shared" || test "$3" = "yes"; then
  1078. dnl ---------------------------------------------- Shared module
  1079. PHP_ADD_SOURCES_X(PHP_EXT_DIR($1),$2,$ac_extra,shared_objects_$1,yes)
  1080. PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir)
  1081. AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z-,A-Z_), 1, Whether to build $1 as dynamic module)
  1082. fi
  1083. fi
  1084. if test "$3" != "shared" && test "$3" != "yes" && test "$4" = "cli"; then
  1085. dnl ---------------------------------------------- CLI static module
  1086. if test "$PHP_SAPI" = "cgi"; then
  1087. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,)
  1088. EXT_STATIC="$EXT_STATIC $1"
  1089. else
  1090. PHP_ADD_SOURCES(PHP_EXT_DIR($1),$2,$ac_extra,cli)
  1091. fi
  1092. EXT_CLI_LTLIBS="$EXT_CLI_LTLIBS $abs_builddir/$ext_builddir/lib$1.la"
  1093. EXT_CLI_STATIC="$EXT_CLI_STATIC $1"
  1094. fi
  1095. PHP_ADD_BUILD_DIR($ext_builddir)
  1096. ])
  1097. dnl
  1098. dnl Solaris requires main code to be position independent in order
  1099. dnl to let shared objects find symbols. Weird. Ugly.
  1100. dnl
  1101. dnl Must be run after all --with-NN options that let the user
  1102. dnl choose dynamic extensions, and after the gcc test.
  1103. dnl
  1104. AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[
  1105. AC_MSG_CHECKING([whether -fPIC is required])
  1106. if test -n "$EXT_SHARED"; then
  1107. os=`uname -sr 2>/dev/null`
  1108. case $os in
  1109. "SunOS 5.6"|"SunOS 5.7")
  1110. case $CC in
  1111. gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
  1112. *) CFLAGS="$CFLAGS -fpic";;
  1113. esac
  1114. AC_MSG_RESULT([yes]);;
  1115. *)
  1116. AC_MSG_RESULT([no]);;
  1117. esac
  1118. else
  1119. AC_MSG_RESULT([no])
  1120. fi
  1121. ])
  1122. dnl
  1123. dnl Checks whether $withval is "shared" or starts with "shared,XXX"
  1124. dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
  1125. dnl from $withval.
  1126. dnl
  1127. AC_DEFUN(PHP_WITH_SHARED,[
  1128. PHP_ARG_ANALYZE_EX(withval)
  1129. shared=$ext_shared
  1130. unset ext_shared ext_output
  1131. ])
  1132. dnl The problem is that the default compilation flags in Solaris 2.6 won't
  1133. dnl let programs access large files; you need to tell the compiler that
  1134. dnl you actually want your programs to work on large files. For more
  1135. dnl details about this brain damage please see:
  1136. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  1137. dnl Written by Paul Eggert <eggert@twinsun.com>.
  1138. AC_DEFUN(PHP_SYS_LFS,
  1139. [dnl
  1140. # If available, prefer support for large files unless the user specified
  1141. # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
  1142. AC_MSG_CHECKING([whether large file support needs explicit enabling])
  1143. ac_getconfs=''
  1144. ac_result=yes
  1145. ac_set=''
  1146. ac_shellvars='CPPFLAGS LDFLAGS LIBS'
  1147. for ac_shellvar in $ac_shellvars; do
  1148. case $ac_shellvar in
  1149. CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
  1150. *) ac_lfsvar=LFS_$ac_shellvar ;;
  1151. esac
  1152. eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
  1153. (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
  1154. ac_getconf=`getconf $ac_lfsvar`
  1155. ac_getconfs=$ac_getconfs$ac_getconf
  1156. eval ac_test_$ac_shellvar=\$ac_getconf
  1157. done
  1158. case "$ac_result$ac_getconfs" in
  1159. yes) ac_result=no ;;
  1160. esac
  1161. case "$ac_result$ac_set" in
  1162. yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
  1163. esac
  1164. AC_MSG_RESULT([$ac_result])
  1165. case $ac_result in
  1166. yes)
  1167. for ac_shellvar in $ac_shellvars; do
  1168. eval $ac_shellvar=\$ac_test_$ac_shellvar
  1169. done ;;
  1170. esac
  1171. ])
  1172. AC_DEFUN(PHP_SOCKADDR_SA_LEN,[
  1173. AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  1174. AC_TRY_COMPILE([#include <sys/types.h>
  1175. #include <sys/socket.h>],
  1176. [struct sockaddr s; s.sa_len;],
  1177. [ac_cv_sockaddr_sa_len=yes
  1178. AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[ ])],
  1179. [ac_cv_sockaddr_sa_len=no])
  1180. ])
  1181. ])
  1182. dnl ## PHP_OUTPUT(file)
  1183. dnl ## adds "file" to the list of files generated by AC_OUTPUT
  1184. dnl ## This macro can be used several times.
  1185. AC_DEFUN(PHP_OUTPUT,[
  1186. PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  1187. ])
  1188. AC_DEFUN(PHP_DECLARED_TIMEZONE,[
  1189. AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
  1190. AC_TRY_COMPILE([
  1191. #include <sys/types.h>
  1192. #include <time.h>
  1193. #ifdef HAVE_SYS_TIME_H
  1194. #include <sys/time.h>
  1195. #endif
  1196. ],[
  1197. time_t foo = (time_t) timezone;
  1198. ],[
  1199. ac_cv_declared_timezone=yes
  1200. ],[
  1201. ac_cv_declared_timezone=no
  1202. ])])
  1203. if test "$ac_cv_declared_timezone" = "yes"; then
  1204. AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
  1205. fi
  1206. ])
  1207. AC_DEFUN(PHP_EBCDIC,[
  1208. AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
  1209. AC_TRY_RUN( [
  1210. int main(void) {
  1211. return (unsigned char)'A' != (unsigned char)0xC1;
  1212. }
  1213. ],[
  1214. ac_cv_ebcdic=yes
  1215. ],[
  1216. ac_cv_ebcdic=no
  1217. ],[
  1218. ac_cv_ebcdic=no
  1219. ])])
  1220. if test "$ac_cv_ebcdic" = "yes"; then
  1221. AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
  1222. fi
  1223. ])
  1224. AC_DEFUN(PHP_FOPENCOOKIE,[
  1225. AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ])
  1226. if test "$have_glibc_fopencookie" = "yes" ; then
  1227. dnl this comes in two flavors:
  1228. dnl newer glibcs (since 2.1.2 ? )
  1229. dnl have a type called cookie_io_functions_t
  1230. AC_TRY_COMPILE([ #define _GNU_SOURCE
  1231. #include <stdio.h>
  1232. ],
  1233. [ cookie_io_functions_t cookie; ],
  1234. [ have_cookie_io_functions_t=yes ],
  1235. [] )
  1236. if test "$have_cookie_io_functions_t" = "yes" ; then
  1237. cookie_io_functions_t=cookie_io_functions_t
  1238. have_fopen_cookie=yes
  1239. else
  1240. dnl older glibc versions (up to 2.1.2 ?)
  1241. dnl call it _IO_cookie_io_functions_t
  1242. AC_TRY_COMPILE([ #define _GNU_SOURCE
  1243. #include <stdio.h>
  1244. ],
  1245. [ _IO_cookie_io_functions_t cookie; ],
  1246. [ have_IO_cookie_io_functions_t=yes ],
  1247. [] )
  1248. if test "$have_cookie_io_functions_t" = "yes" ; then
  1249. cookie_io_functions_t=_IO_cookie_io_functions_t
  1250. have_fopen_cookie=yes
  1251. fi
  1252. fi
  1253. if test "$have_fopen_cookie" = "yes" ; then
  1254. AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
  1255. AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
  1256. fi
  1257. fi
  1258. ])
  1259. dnl
  1260. dnl PHP_CHECK_LIBRARY(library, function [, action-found [, action-not-found [, extra-libs]]])
  1261. dnl
  1262. dnl Wrapper for AC_CHECK_LIB
  1263. dnl
  1264. AC_DEFUN(PHP_CHECK_LIBRARY, [
  1265. save_old_LDFLAGS=$LDFLAGS
  1266. LDFLAGS="$5 $LDFLAGS"
  1267. AC_CHECK_LIB([$1],[$2],[
  1268. LDFLAGS=$save_old_LDFLAGS
  1269. $3
  1270. ],[
  1271. LDFLAGS=$save_old_LDFLAGS
  1272. $4
  1273. ])dnl
  1274. ])
  1275. dnl
  1276. dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
  1277. dnl
  1278. dnl Common setup macro for iconv
  1279. dnl
  1280. AC_DEFUN(PHP_SETUP_ICONV, [
  1281. found_iconv=no
  1282. unset ICONV_DIR
  1283. dnl
  1284. dnl Check libc first if no path is provided in --with-iconv
  1285. dnl
  1286. if test "$PHP_ICONV" = "yes"; then
  1287. AC_CHECK_FUNC(iconv, [
  1288. PHP_DEFINE(HAVE_ICONV)
  1289. found_iconv=yes
  1290. ],[
  1291. AC_CHECK_FUNC(libiconv,[
  1292. PHP_DEFINE(HAVE_LIBICONV)
  1293. found_iconv=yes
  1294. ])
  1295. ])
  1296. fi
  1297. dnl
  1298. dnl Check external libs for iconv funcs
  1299. dnl
  1300. if test "$found_iconv" = "no"; then
  1301. for i in $PHP_ICONV /usr/local /usr; do
  1302. if test -r $i/include/giconv.h; then
  1303. AC_DEFINE(HAVE_GICONV_H, 1, [ ])
  1304. ICONV_DIR=$i
  1305. iconv_lib_name=giconv
  1306. break
  1307. elif test -r $i/include/iconv.h; then
  1308. ICONV_DIR=$i
  1309. iconv_lib_name=iconv
  1310. break
  1311. fi
  1312. done
  1313. if test -z "$ICONV_DIR"; then
  1314. AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
  1315. fi
  1316. if test -f $ICONV_DIR/lib/lib$iconv_lib_name.a ||
  1317. test -f $ICONV_DIR/lib/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
  1318. then
  1319. PHP_CHECK_LIBRARY($iconv_lib_name, libiconv, [
  1320. found_iconv=yes
  1321. PHP_DEFINE(HAVE_LIBICONV)
  1322. ], [
  1323. PHP_CHECK_LIBRARY($iconv_lib_name, iconv, [
  1324. found_iconv=yes
  1325. PHP_DEFINE(HAVE_ICONV)
  1326. ], [], [
  1327. -L$ICONV_DIR/lib
  1328. ])
  1329. ], [
  1330. -L$ICONV_DIR/lib
  1331. ])
  1332. fi
  1333. fi
  1334. if test "$found_iconv" = "yes"; then
  1335. if test -n "$ICONV_DIR"; then
  1336. AC_DEFINE(HAVE_ICONV, 1, [ ])
  1337. PHP_ADD_LIBRARY_WITH_PATH($iconv_lib_name, $ICONV_DIR/lib, $1)
  1338. PHP_ADD_INCLUDE($ICONV_DIR/include)
  1339. fi
  1340. $2
  1341. ifelse([$3],[],,[else $3])
  1342. fi
  1343. ])