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.

1017 lines
23 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
26 years ago
26 years ago
26 years ago
25 years ago
27 years ago
27 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. sinclude(dynlib.m4)
  5. AC_DEFUN(PHP_REMOVE_USR_LIB,[
  6. unset ac_new_flags
  7. for i in [$]$1; do
  8. case [$]i in
  9. -L/usr/lib|-L/usr/lib/) ;;
  10. *) ac_new_flags="[$]ac_new_flags [$]i" ;;
  11. esac
  12. done
  13. $1=[$]ac_new_flags
  14. ])
  15. AC_DEFUN(PHP_SETUP_OPENSSL,[
  16. if test "$PHP_OPENSSL" = "no"; then
  17. PHP_OPENSSL="/usr/local/ssl /usr/local /usr /usr/local/openssl"
  18. fi
  19. for i in $PHP_OPENSSL; do
  20. if test -r $i/include/openssl/evp.h; then
  21. OPENSSL_DIR=$i
  22. OPENSSL_INC=$i/include
  23. fi
  24. done
  25. if test -z "$OPENSSL_DIR"; then
  26. AC_MSG_ERROR(Cannot find OpenSSL's <evp.h>)
  27. fi
  28. old_CPPFLAGS=$CPPFLAGS
  29. CPPFLAGS=-I$OPENSSL_INC
  30. AC_MSG_CHECKING(for OpenSSL version)
  31. AC_EGREP_CPP(yes,[
  32. #include <openssl/opensslv.h>
  33. #if OPENSSL_VERSION_NUMBER >= 0x0090500fL
  34. yes
  35. #endif
  36. ],[
  37. AC_MSG_RESULT(>= 0.9.5)
  38. ],[
  39. AC_MSG_ERROR(OpenSSL version 0.9.5 or greater required.)
  40. ])
  41. CPPFLAGS=$old_CPPFLAGS
  42. PHP_ADD_LIBPATH($OPENSSL_DIR/lib)
  43. AC_CHECK_LIB(crypto, CRYPTO_free, [
  44. PHP_ADD_LIBRARY(crypto)
  45. ],[
  46. AC_MSG_ERROR(libcrypto not found!)
  47. ])
  48. AC_CHECK_LIB(ssl, SSL_CTX_set_ssl_version, [
  49. PHP_ADD_LIBRARY(ssl)
  50. ],[
  51. AC_MSG_ERROR(libssl not found!)
  52. ])
  53. PHP_ADD_INCLUDE($OPENSSL_INC)
  54. ])
  55. dnl PHP_EVAL_LIBLINE(LINE, SHARED-LIBADD)
  56. dnl
  57. dnl Use this macro, if you need to add libraries and or library search
  58. dnl paths to the PHP build system which are only given in compiler
  59. dnl notation.
  60. dnl
  61. AC_DEFUN(PHP_EVAL_LIBLINE,[
  62. for ac_i in $1; do
  63. case $ac_i in
  64. -l*)
  65. ac_ii=`echo $ac_i|cut -c 3-`
  66. PHP_ADD_LIBRARY($ac_ii,,$2)
  67. ;;
  68. -L*)
  69. ac_ii=`echo $ac_i|cut -c 3-`
  70. PHP_ADD_LIBPATH($ac_ii,$2)
  71. ;;
  72. esac
  73. done
  74. ])
  75. dnl PHP_EVAL_INCLINE(LINE)
  76. dnl
  77. dnl Use this macro, if you need to add header search paths to the PHP
  78. dnl build system which are only given in compiler notation.
  79. dnl
  80. AC_DEFUN(PHP_EVAL_INCLINE,[
  81. for ac_i in $1; do
  82. case $ac_i in
  83. -I*)
  84. ac_ii=`echo $ac_i|cut -c 3-`
  85. PHP_ADD_INCLUDE($ac_ii)
  86. ;;
  87. esac
  88. done
  89. ])
  90. AC_DEFUN(PHP_READDIR_R_TYPE,[
  91. dnl HAVE_READDIR_R is also defined by libmysql
  92. AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
  93. if test "$ac_cv_func_readdir_r" = "yes"; then
  94. AC_CACHE_CHECK(for type of readdir_r, ac_cv_what_readdir_r,[
  95. AC_TRY_RUN([
  96. #define _REENTRANT
  97. #include <sys/types.h>
  98. #include <dirent.h>
  99. #ifndef PATH_MAX
  100. #define PATH_MAX 1024
  101. #endif
  102. main() {
  103. DIR *dir;
  104. char entry[sizeof(struct dirent)+PATH_MAX];
  105. struct dirent *pentry = (struct dirent *) &entry;
  106. dir = opendir("/");
  107. if (!dir)
  108. exit(1);
  109. if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0)
  110. exit(0);
  111. exit(1);
  112. }
  113. ],[
  114. ac_cv_what_readdir_r=POSIX
  115. ],[
  116. AC_TRY_CPP([
  117. #define _REENTRANT
  118. #include <sys/types.h>
  119. #include <dirent.h>
  120. int readdir_r(DIR *, struct dirent *);
  121. ],[
  122. ac_cv_what_readdir_r=old-style
  123. ],[
  124. ac_cv_what_readdir_r=none
  125. ])
  126. ],[
  127. ac_cv_what_readdir_r=none
  128. ])
  129. ])
  130. case $ac_cv_what_readdir_r in
  131. POSIX)
  132. AC_DEFINE(HAVE_POSIX_READDIR_R,1,[whether you have POSIX readdir_r]);;
  133. old-style)
  134. AC_DEFINE(HAVE_OLD_READDIR_R,1,[whether you have old-style readdir_r]);;
  135. esac
  136. fi
  137. ])
  138. AC_DEFUN(PHP_SHLIB_SUFFIX_NAME,[
  139. PHP_SUBST(SHLIB_SUFFIX_NAME)
  140. SHLIB_SUFFIX_NAME=so
  141. case $host_alias in
  142. *hpux*)
  143. SHLIB_SUFFIX_NAME=sl
  144. ;;
  145. esac
  146. ])
  147. AC_DEFUN(PHP_DEBUG_MACRO,[
  148. DEBUG_LOG=$1
  149. cat >$1 <<X
  150. CONFIGURE: $CONFIGURE_COMMAND
  151. CC: $CC
  152. CFLAGS: $CFLAGS
  153. CPPFLAGS: $CPPFLAGS
  154. CXX: $CXX
  155. CXXFLAGS: $CXXFLAGS
  156. INCLUDES: $INCLUDES
  157. LDFLAGS: $LDFLAGS
  158. LIBS: $LIBS
  159. DLIBS: $DLIBS
  160. SAPI: $PHP_SAPI
  161. PHP_RPATHS: $PHP_RPATHS
  162. uname -a: `uname -a`
  163. X
  164. cat >conftest.$ac_ext <<X
  165. main()
  166. {
  167. exit(0);
  168. }
  169. X
  170. (eval echo \"$ac_link\"; eval $ac_link && ./conftest) >>$1 2>&1
  171. rm -fr conftest*
  172. ])
  173. AC_DEFUN(PHP_MISSING_TIME_R_DECL,[
  174. AC_MSG_CHECKING(for missing declarations of reentrant functions)
  175. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = localtime_r],[
  176. :
  177. ],[
  178. AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
  179. ])
  180. AC_TRY_COMPILE([#include <time.h>],[struct tm *(*func)() = gmtime_r],[
  181. :
  182. ],[
  183. AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
  184. ])
  185. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = asctime_r],[
  186. :
  187. ],[
  188. AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
  189. ])
  190. AC_TRY_COMPILE([#include <time.h>],[char *(*func)() = ctime_r],[
  191. :
  192. ],[
  193. AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
  194. ])
  195. AC_TRY_COMPILE([#include <string.h>],[char *(*func)() = strtok_r],[
  196. :
  197. ],[
  198. AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
  199. ])
  200. AC_MSG_RESULT(done)
  201. ])
  202. dnl
  203. dnl PHP_LIBGCC_LIBPATH(gcc)
  204. dnl Stores the location of libgcc in libgcc_libpath
  205. dnl
  206. AC_DEFUN(PHP_LIBGCC_LIBPATH,[
  207. changequote({,})
  208. libgcc_libpath=`$1 --print-libgcc-file-name|sed 's%/*[^/][^/]*$%%'`
  209. changequote([,])
  210. ])
  211. AC_DEFUN(PHP_ARG_ANALYZE,[
  212. case [$]$1 in
  213. shared,*)
  214. ext_output="yes, shared"
  215. ext_shared=yes
  216. $1=`echo "[$]$1"|sed 's/^shared,//'`
  217. ;;
  218. shared)
  219. ext_output="yes, shared"
  220. ext_shared=yes
  221. $1=yes
  222. ;;
  223. no)
  224. ext_output=no
  225. ext_shared=no
  226. ;;
  227. *)
  228. ext_output=yes
  229. ext_shared=no
  230. ;;
  231. esac
  232. if test "$php_always_shared" = "yes"; then
  233. ext_output="yes, shared"
  234. ext_shared=yes
  235. test "[$]$1" = "no" && $1=yes
  236. fi
  237. AC_MSG_RESULT($ext_output)
  238. ])
  239. dnl
  240. dnl PHP_ARG_WITH(arg-name, check message, help text[, default-val])
  241. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  242. dnl default-val defaults to no. This will also set the variable ext_shared,
  243. dnl and will overwrite any previous variable of that name.
  244. dnl
  245. AC_DEFUN(PHP_ARG_WITH,[
  246. PHP_REAL_ARG_WITH([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_))
  247. ])
  248. AC_DEFUN(PHP_REAL_ARG_WITH,[
  249. AC_MSG_CHECKING($2)
  250. AC_ARG_WITH($1,[$3],$5=[$]withval,$5=ifelse($4,,no,$4))
  251. PHP_ARG_ANALYZE($5)
  252. ])
  253. dnl
  254. dnl PHP_ARG_ENABLE(arg-name, check message, help text[, default-val])
  255. dnl Sets PHP_ARG_NAME either to the user value or to the default value.
  256. dnl default-val defaults to no. This will also set the variable ext_shared,
  257. dnl and will overwrite any previous variable of that name.
  258. dnl
  259. AC_DEFUN(PHP_ARG_ENABLE,[
  260. PHP_REAL_ARG_ENABLE([$1],[$2],[$3],[$4],PHP_[]translit($1,a-z-,A-Z_))
  261. ])
  262. AC_DEFUN(PHP_REAL_ARG_ENABLE,[
  263. AC_MSG_CHECKING($2)
  264. AC_ARG_ENABLE($1,[$3],$5=[$]enableval,$5=ifelse($4,,no,$4))
  265. PHP_ARG_ANALYZE($5)
  266. ])
  267. AC_DEFUN(PHP_MODULE_PTR,[
  268. EXTRA_MODULE_PTRS="$EXTRA_MODULE_PTRS $1,"
  269. ])
  270. AC_DEFUN(PHP_CONFIG_NICE,[
  271. rm -f $1
  272. cat >$1<<EOF
  273. #! /bin/sh
  274. #
  275. # Created by configure
  276. EOF
  277. for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS CC CXX; do
  278. eval val=\$$var
  279. if test -n "$val"; then
  280. echo "$var='$val' \\" >> $1
  281. fi
  282. done
  283. for arg in [$]0 "[$]@"; do
  284. echo "'[$]arg' \\" >> $1
  285. done
  286. echo '"[$]@"' >> $1
  287. chmod +x $1
  288. ])
  289. AC_DEFUN(PHP_TIME_R_TYPE,[
  290. AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
  291. AC_TRY_RUN([
  292. #include <time.h>
  293. main() {
  294. char buf[27];
  295. struct tm t;
  296. time_t old = 0;
  297. int r, s;
  298. s = gmtime_r(&old, &t);
  299. r = (int) asctime_r(&t, buf, 26);
  300. if (r == s && s == 0) return (0);
  301. return (1);
  302. }
  303. ],[
  304. ac_cv_time_r_type=hpux
  305. ],[
  306. AC_TRY_RUN([
  307. #include <time.h>
  308. main() {
  309. struct tm t, *s;
  310. time_t old = 0;
  311. char buf[27], *p;
  312. s = gmtime_r(&old, &t);
  313. p = asctime_r(&t, buf, 26);
  314. if (p == buf && s == t) return (0);
  315. return (1);
  316. }
  317. ],[
  318. ac_cv_time_r_type=irix
  319. ],[
  320. ac_cv_time_r_type=POSIX
  321. ])
  322. ],[
  323. ac_cv_time_r_type=POSIX
  324. ])
  325. ])
  326. case $ac_cv_time_r_type in
  327. hpux) AC_DEFINE(PHP_HPUX_TIME_R,1,[Whether you have HP-UX 10.x]) ;;
  328. irix) AC_DEFINE(PHP_IRIX_TIME_R,1,[Whether you have IRIX-style functions]) ;;
  329. esac
  330. fi
  331. ])
  332. AC_DEFUN(PHP_SUBST,[
  333. PHP_VAR_SUBST="$PHP_VAR_SUBST $1"
  334. ])
  335. AC_DEFUN(PHP_SUBST_OLD,[
  336. PHP_SUBST($1)
  337. AC_SUBST($1)
  338. ])
  339. AC_DEFUN(PHP_FAST_OUTPUT,[
  340. PHP_FAST_OUTPUT_FILES="$PHP_FAST_OUTPUT_FILES $1"
  341. ])
  342. AC_DEFUN(PHP_MKDIR_P_CHECK,[
  343. AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
  344. test -d conftestdir && rm -rf conftestdir
  345. mkdir -p conftestdir/somedir >/dev/null 2>&1
  346. dnl `mkdir -p' must be quiet about creating existing directories
  347. mkdir -p conftestdir/somedir >/dev/null 2>&1
  348. if test "$?" = "0" && test -d conftestdir/somedir; then
  349. ac_cv_mkdir_p=yes
  350. else
  351. ac_cv_mkdir_p=no
  352. fi
  353. rm -rf conftestdir
  354. ])
  355. ])
  356. AC_DEFUN(PHP_GEN_CONFIG_VARS,[
  357. PHP_MKDIR_P_CHECK
  358. echo creating config_vars.mk
  359. > config_vars.mk
  360. for i in $PHP_VAR_SUBST; do
  361. eval echo "$i = \$$i" >> config_vars.mk
  362. done
  363. ])
  364. AC_DEFUN(PHP_GEN_MAKEFILES,[
  365. $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $1
  366. ])
  367. AC_DEFUN(PHP_TM_GMTOFF,[
  368. AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
  369. [AC_TRY_COMPILE([#include <sys/types.h>
  370. #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
  371. ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
  372. if test "$ac_cv_struct_tm_gmtoff" = yes; then
  373. AC_DEFINE(HAVE_TM_GMTOFF,1,[whether you have tm_gmtoff in struct tm])
  374. fi
  375. ])
  376. dnl PHP_CONFIGURE_PART(MESSAGE)
  377. dnl Idea borrowed from mm
  378. AC_DEFUN(PHP_CONFIGURE_PART,[
  379. AC_MSG_RESULT()
  380. AC_MSG_RESULT(${T_MD}$1${T_ME})
  381. ])
  382. AC_DEFUN(PHP_PROG_SENDMAIL,[
  383. AC_PATH_PROG(PROG_SENDMAIL, sendmail,[], $PATH:/usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib)
  384. if test -n "$PROG_SENDMAIL"; then
  385. AC_DEFINE(HAVE_SENDMAIL,1,[whether you have sendmail])
  386. fi
  387. ])
  388. AC_DEFUN(PHP_RUNPATH_SWITCH,[
  389. dnl check for -R, etc. switch
  390. AC_MSG_CHECKING(if compiler supports -R)
  391. AC_CACHE_VAL(php_cv_cc_dashr,[
  392. SAVE_LIBS=$LIBS
  393. LIBS="-R /usr/lib $LIBS"
  394. AC_TRY_LINK([], [], php_cv_cc_dashr=yes, php_cv_cc_dashr=no)
  395. LIBS=$SAVE_LIBS])
  396. AC_MSG_RESULT($php_cv_cc_dashr)
  397. if test $php_cv_cc_dashr = "yes"; then
  398. ld_runpath_switch=-R
  399. else
  400. AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
  401. AC_CACHE_VAL(php_cv_cc_rpath,[
  402. SAVE_LIBS=$LIBS
  403. LIBS="-Wl,-rpath,/usr/lib $LIBS"
  404. AC_TRY_LINK([], [], php_cv_cc_rpath=yes, php_cv_cc_rpath=no)
  405. LIBS=$SAVE_LIBS])
  406. AC_MSG_RESULT($php_cv_cc_rpath)
  407. if test $php_cv_cc_rpath = "yes"; then
  408. ld_runpath_switch=-Wl,-rpath,
  409. else
  410. dnl something innocuous
  411. ld_runpath_switch=-L
  412. fi
  413. fi
  414. ])
  415. AC_DEFUN(PHP_STRUCT_FLOCK,[
  416. AC_CACHE_CHECK(for struct flock,ac_cv_struct_flock,
  417. AC_TRY_COMPILE([
  418. #include <unistd.h>
  419. #include <fcntl.h>
  420. ],
  421. [struct flock x;],
  422. [
  423. ac_cv_struct_flock=yes
  424. ],[
  425. ac_cv_struct_flock=no
  426. ])
  427. )
  428. if test "$ac_cv_struct_flock" = "yes" ; then
  429. AC_DEFINE(HAVE_STRUCT_FLOCK, 1,[whether you have struct flock])
  430. fi
  431. ])
  432. AC_DEFUN(PHP_SOCKLEN_T,[
  433. AC_CACHE_CHECK(for socklen_t,ac_cv_socklen_t,
  434. AC_TRY_COMPILE([
  435. #include <sys/types.h>
  436. #include <sys/socket.h>
  437. ],[
  438. socklen_t x;
  439. ],[
  440. ac_cv_socklen_t=yes
  441. ],[
  442. ac_cv_socklen_t=no
  443. ]))
  444. if test "$ac_cv_socklen_t" = "yes"; then
  445. AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
  446. fi
  447. ])
  448. dnl
  449. dnl PHP_SET_SYM_FILE(path)
  450. dnl
  451. dnl set the path of the file which contains the symbol export list
  452. dnl
  453. AC_DEFUN(PHP_SET_SYM_FILE,
  454. [
  455. PHP_SYM_FILE=$1
  456. ])
  457. dnl
  458. dnl PHP_BUILD_THREAD_SAFE
  459. dnl
  460. AC_DEFUN(PHP_BUILD_THREAD_SAFE,[
  461. enable_experimental_zts=yes
  462. if test "$pthreads_working" != "yes"; then
  463. AC_MSG_ERROR(ZTS currently requires working POSIX threads. We were unable to verify that your system supports Pthreads.)
  464. fi
  465. ])
  466. AC_DEFUN(PHP_REQUIRE_CXX,[
  467. if test -z "$php_cxx_done"; then
  468. AC_PROG_CXX
  469. AC_PROG_CXXCPP
  470. php_cxx_done=yes
  471. fi
  472. ])
  473. dnl
  474. dnl PHP_BUILD_SHARED
  475. dnl
  476. AC_DEFUN(PHP_BUILD_SHARED,[
  477. php_build_target=shared
  478. ])
  479. dnl
  480. dnl PHP_BUILD_STATIC
  481. dnl
  482. AC_DEFUN(PHP_BUILD_STATIC,[
  483. php_build_target=static
  484. ])
  485. dnl
  486. dnl PHP_BUILD_PROGRAM
  487. dnl
  488. AC_DEFUN(PHP_BUILD_PROGRAM,[
  489. php_build_target=program
  490. ])
  491. dnl
  492. dnl AC_PHP_ONCE(namespace, variable, code)
  493. dnl
  494. dnl execute code, if variable is not set in namespace
  495. dnl
  496. AC_DEFUN(AC_PHP_ONCE,[
  497. changequote({,})
  498. unique=`echo $2|sed 's/[^a-zA-Z0-9]/_/g'`
  499. changequote([,])
  500. cmd="echo $ac_n \"\$$1$unique$ac_c\""
  501. if test -n "$unique" && test "`eval $cmd`" = "" ; then
  502. eval "$1$unique=set"
  503. $3
  504. fi
  505. ])
  506. dnl
  507. dnl PHP_EXPAND_PATH(path, variable)
  508. dnl
  509. dnl expands path to an absolute path and assigns it to variable
  510. dnl
  511. AC_DEFUN(PHP_EXPAND_PATH,[
  512. if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
  513. $2=$1
  514. else
  515. changequote({,})
  516. ep_dir="`echo $1|sed 's%/*[^/][^/]*/*$%%'`"
  517. changequote([,])
  518. ep_realdir="`(cd \"$ep_dir\" && pwd)`"
  519. $2="$ep_realdir/`basename \"$1\"`"
  520. fi
  521. ])
  522. dnl
  523. dnl PHP_ADD_LIBPATH(path[, shared-libadd])
  524. dnl
  525. dnl add a library to linkpath/runpath
  526. dnl
  527. AC_DEFUN(PHP_ADD_LIBPATH,[
  528. if test "$1" != "/usr/lib"; then
  529. PHP_EXPAND_PATH($1, ai_p)
  530. if test "$ext_shared" = "yes" && test -n "$2"; then
  531. $2="-R$1 -L$1 [$]$2"
  532. else
  533. AC_PHP_ONCE(LIBPATH, $ai_p, [
  534. test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$ai_p"
  535. LDFLAGS="$LDFLAGS -L$ai_p"
  536. PHP_RPATHS="$PHP_RPATHS $ai_p"
  537. ])
  538. fi
  539. fi
  540. ])
  541. dnl
  542. dnl PHP_BUILD_RPATH()
  543. dnl
  544. dnl builds RPATH from PHP_RPATHS
  545. dnl
  546. AC_DEFUN(PHP_BUILD_RPATH,[
  547. if test "$PHP_RPATH" = "yes" && test -n "$PHP_RPATHS"; then
  548. OLD_RPATHS="$PHP_RPATHS"
  549. unset PHP_RPATHS
  550. for i in $OLD_RPATHS; do
  551. PHP_LDFLAGS="$PHP_LDFLAGS -L$i"
  552. PHP_RPATHS="$PHP_RPATHS -R $i"
  553. NATIVE_RPATHS="$NATIVE_RPATHS $ld_runpath_switch$i"
  554. done
  555. fi
  556. ])
  557. dnl
  558. dnl PHP_ADD_INCLUDE(path)
  559. dnl
  560. dnl add a include path
  561. dnl
  562. AC_DEFUN(PHP_ADD_INCLUDE,[
  563. if test "$1" != "/usr/include"; then
  564. PHP_EXPAND_PATH($1, ai_p)
  565. AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
  566. INCLUDES="$INCLUDES -I$ai_p"
  567. ])
  568. fi
  569. ])
  570. AC_DEFUN(PHP_X_ADD_LIBRARY,[
  571. ifelse($2,,$3="-l$1 [$]$3", $3="[$]$3 -l$1")
  572. ])
  573. dnl
  574. dnl PHP_ADD_LIBRARY(library[, append[, shared-libadd]])
  575. dnl
  576. dnl add a library to the link line
  577. dnl
  578. AC_DEFUN(PHP_ADD_LIBRARY,[
  579. case $1 in
  580. c|c_r|pthread*) ;;
  581. *)
  582. ifelse($3,,[
  583. PHP_X_ADD_LIBRARY($1,$2,LIBS)
  584. ],[
  585. if test "$ext_shared" = "yes"; then
  586. PHP_X_ADD_LIBRARY($1,$2,$3)
  587. else
  588. PHP_ADD_LIBRARY($1,$2)
  589. fi
  590. ])
  591. ;;
  592. esac
  593. ])
  594. dnl
  595. dnl PHP_ADD_LIBRARY_DEFER(library[, append])
  596. dnl
  597. dnl add a library to the link line (deferred)
  598. AC_DEFUN(PHP_ADD_LIBRARY_DEFER,[
  599. ifelse($#, 1, DLIBS="-l$1 $DLIBS", DLIBS="$DLIBS -l$1")
  600. ])
  601. dnl
  602. dnl PHP_ADD_LIBRARY_WITH_PATH(library, path[, shared-libadd])
  603. dnl
  604. dnl add a library to the link line and path to linkpath/runpath.
  605. dnl if shared-libadd is not empty and $ext_shared is yes,
  606. dnl shared-libadd will be assigned the library information
  607. dnl
  608. AC_DEFUN(PHP_ADD_LIBRARY_WITH_PATH,[
  609. ifelse($3,,[
  610. if test -n "$2"; then
  611. PHP_ADD_LIBPATH($2)
  612. fi
  613. PHP_ADD_LIBRARY($1)
  614. ],[
  615. if test "$ext_shared" = "yes"; then
  616. $3="-l$1 [$]$3"
  617. if test -n "$2"; then
  618. PHP_ADD_LIBPATH($2,$3)
  619. fi
  620. else
  621. PHP_ADD_LIBRARY_WITH_PATH($1,$2)
  622. fi
  623. ])
  624. ])
  625. dnl
  626. dnl PHP_ADD_LIBRARY_DEFER_WITH_PATH(library, path)
  627. dnl
  628. dnl add a library to the link line (deferred)
  629. dnl and path to linkpath/runpath (not deferred)
  630. dnl
  631. AC_DEFUN(PHP_ADD_LIBRARY_DEFER_WITH_PATH,[
  632. PHP_ADD_LIBPATH($2)
  633. PHP_ADD_LIBRARY_DEFER($1)
  634. ])
  635. dnl
  636. dnl Set libtool variable
  637. dnl
  638. AC_DEFUN(AM_SET_LIBTOOL_VARIABLE,[
  639. LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
  640. ])
  641. dnl
  642. dnl Check for cc option
  643. dnl
  644. AC_DEFUN(PHP_CHECK_CC_OPTION,[
  645. echo "main(){return 0;}" > conftest.$ac_ext
  646. opt=$1
  647. changequote({,})
  648. var=`echo $opt|sed 's/[^a-zA-Z0-9]/_/g'`
  649. changequote([,])
  650. AC_MSG_CHECKING([if compiler supports -$1 really])
  651. ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1"
  652. if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then
  653. eval php_cc_$var=no
  654. AC_MSG_RESULT(no)
  655. else
  656. if eval ./conftest 2>/dev/null ; then
  657. eval php_cc_$var=yes
  658. AC_MSG_RESULT(yes)
  659. else
  660. eval php_cc_$var=no
  661. AC_MSG_RESULT(no)
  662. fi
  663. fi
  664. ])
  665. AC_DEFUN(PHP_REGEX,[
  666. if test "$REGEX_TYPE" = "php"; then
  667. REGEX_LIB=regex/libregex.la
  668. REGEX_DIR=regex
  669. AC_DEFINE(HSREGEX,1,[ ])
  670. AC_DEFINE(REGEX,1,[ ])
  671. PHP_FAST_OUTPUT(regex/Makefile)
  672. elif test "$REGEX_TYPE" = "system"; then
  673. AC_DEFINE(REGEX,0,[ ])
  674. fi
  675. AC_MSG_CHECKING(which regex library to use)
  676. AC_MSG_RESULT($REGEX_TYPE)
  677. PHP_SUBST(REGEX_DIR)
  678. PHP_SUBST(REGEX_LIB)
  679. PHP_SUBST(HSREGEX)
  680. ])
  681. dnl
  682. dnl See if we have broken header files like SunOS has.
  683. dnl
  684. AC_DEFUN(PHP_MISSING_FCLOSE_DECL,[
  685. AC_MSG_CHECKING([for fclose declaration])
  686. AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
  687. AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
  688. AC_MSG_RESULT(ok)
  689. ],[
  690. AC_DEFINE(MISSING_FCLOSE_DECL,1,[ ])
  691. AC_MSG_RESULT(missing)
  692. ])
  693. ])
  694. dnl
  695. dnl Check for broken sprintf()
  696. dnl
  697. AC_DEFUN(PHP_AC_BROKEN_SPRINTF,[
  698. AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[
  699. AC_TRY_RUN([main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }],[
  700. ac_cv_broken_sprintf=no
  701. ],[
  702. ac_cv_broken_sprintf=yes
  703. ],[
  704. ac_cv_broken_sprintf=no
  705. ])
  706. ])
  707. if test "$ac_cv_broken_sprintf" = "yes"; then
  708. AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [ ])
  709. else
  710. AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [ ])
  711. fi
  712. ])
  713. dnl
  714. dnl PHP_EXTENSION(extname [, shared])
  715. dnl
  716. dnl Includes an extension in the build.
  717. dnl
  718. dnl "extname" is the name of the ext/ subdir where the extension resides
  719. dnl "shared" can be set to "shared" or "yes" to build the extension as
  720. dnl a dynamically loadable library.
  721. dnl
  722. AC_DEFUN(PHP_EXTENSION,[
  723. EXT_SUBDIRS="$EXT_SUBDIRS $1"
  724. if test -d "$abs_srcdir/ext/$1"; then
  725. dnl ---------------------------------------------- Internal Module
  726. ext_builddir=ext/$1
  727. ext_srcdir=$abs_srcdir/ext/$1
  728. else
  729. dnl ---------------------------------------------- External Module
  730. ext_builddir=.
  731. ext_srcdir=$abs_srcdir
  732. fi
  733. if test "$2" != "shared" && test "$2" != "yes"; then
  734. dnl ---------------------------------------------- Static module
  735. LIB_BUILD($ext_builddir)
  736. EXT_LTLIBS="$EXT_LTLIBS $ext_builddir/lib$1.la"
  737. EXT_STATIC="$EXT_STATIC $1"
  738. else
  739. dnl ---------------------------------------------- Shared module
  740. LIB_BUILD($ext_builddir,yes)
  741. AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z-,A-Z_), 1, Whether to build $1 as dynamic module)
  742. fi
  743. PHP_FAST_OUTPUT($ext_builddir/Makefile)
  744. ])
  745. PHP_SUBST(EXT_SUBDIRS)
  746. PHP_SUBST(EXT_STATIC)
  747. PHP_SUBST(EXT_SHARED)
  748. PHP_SUBST(EXT_LIBS)
  749. PHP_SUBST(EXT_LTLIBS)
  750. dnl
  751. dnl Solaris requires main code to be position independent in order
  752. dnl to let shared objects find symbols. Weird. Ugly.
  753. dnl
  754. dnl Must be run after all --with-NN options that let the user
  755. dnl choose dynamic extensions, and after the gcc test.
  756. dnl
  757. AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[
  758. AC_MSG_CHECKING(whether -fPIC is required)
  759. if test -n "$EXT_SHARED"; then
  760. os=`uname -sr 2>/dev/null`
  761. case $os in
  762. "SunOS 5.6"|"SunOS 5.7")
  763. case $CC in
  764. gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
  765. *) CFLAGS="$CFLAGS -fpic";;
  766. esac
  767. AC_MSG_RESULT(yes);;
  768. *)
  769. AC_MSG_RESULT(no);;
  770. esac
  771. else
  772. AC_MSG_RESULT(no)
  773. fi
  774. ])
  775. dnl
  776. dnl Checks whether $withval is "shared" or starts with "shared,XXX"
  777. dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
  778. dnl from $withval.
  779. dnl
  780. AC_DEFUN(PHP_WITH_SHARED,[
  781. case $withval in
  782. shared)
  783. shared=yes
  784. withval=yes
  785. ;;
  786. shared,*)
  787. shared=yes
  788. withval=`echo $withval | sed -e 's/^shared,//'`
  789. ;;
  790. *)
  791. shared=no
  792. ;;
  793. esac
  794. if test -n "$php_always_shared"; then
  795. shared=yes
  796. fi
  797. ])
  798. dnl The problem is that the default compilation flags in Solaris 2.6 won't
  799. dnl let programs access large files; you need to tell the compiler that
  800. dnl you actually want your programs to work on large files. For more
  801. dnl details about this brain damage please see:
  802. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  803. dnl Written by Paul Eggert <eggert@twinsun.com>.
  804. AC_DEFUN(PHP_SYS_LFS,
  805. [dnl
  806. # If available, prefer support for large files unless the user specified
  807. # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
  808. AC_MSG_CHECKING(whether large file support needs explicit enabling)
  809. ac_getconfs=''
  810. ac_result=yes
  811. ac_set=''
  812. ac_shellvars='CPPFLAGS LDFLAGS LIBS'
  813. for ac_shellvar in $ac_shellvars; do
  814. case $ac_shellvar in
  815. CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
  816. *) ac_lfsvar=LFS_$ac_shellvar ;;
  817. esac
  818. eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
  819. (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
  820. ac_getconf=`getconf $ac_lfsvar`
  821. ac_getconfs=$ac_getconfs$ac_getconf
  822. eval ac_test_$ac_shellvar=\$ac_getconf
  823. done
  824. case "$ac_result$ac_getconfs" in
  825. yes) ac_result=no ;;
  826. esac
  827. case "$ac_result$ac_set" in
  828. yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
  829. esac
  830. AC_MSG_RESULT($ac_result)
  831. case $ac_result in
  832. yes)
  833. for ac_shellvar in $ac_shellvars; do
  834. eval $ac_shellvar=\$ac_test_$ac_shellvar
  835. done ;;
  836. esac
  837. ])
  838. AC_DEFUN(PHP_SOCKADDR_SA_LEN,[
  839. AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  840. AC_TRY_COMPILE([#include <sys/types.h>
  841. #include <sys/socket.h>],
  842. [struct sockaddr s; s.sa_len;],
  843. [ac_cv_sockaddr_sa_len=yes
  844. AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[ ])],
  845. [ac_cv_sockaddr_sa_len=no])
  846. ])
  847. ])
  848. dnl ## PHP_OUTPUT(file)
  849. dnl ## adds "file" to the list of files generated by AC_OUTPUT
  850. dnl ## This macro can be used several times.
  851. AC_DEFUN(PHP_OUTPUT,[
  852. PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  853. ])
  854. AC_DEFUN(PHP_DECLARED_TIMEZONE,[
  855. AC_CACHE_CHECK(for declared timezone, ac_cv_declared_timezone,[
  856. AC_TRY_COMPILE([
  857. #include <sys/types.h>
  858. #include <time.h>
  859. #ifdef HAVE_SYS_TIME_H
  860. #include <sys/time.h>
  861. #endif
  862. ],[
  863. time_t foo = (time_t) timezone;
  864. ],[
  865. ac_cv_declared_timezone=yes
  866. ],[
  867. ac_cv_declared_timezone=no
  868. ])])
  869. if test "$ac_cv_declared_timezone" = "yes"; then
  870. AC_DEFINE(HAVE_DECLARED_TIMEZONE, 1, [Whether system headers declare timezone])
  871. fi
  872. ])
  873. AC_DEFUN(PHP_EBCDIC,[
  874. AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
  875. AC_TRY_RUN( [
  876. int main(void) {
  877. return (unsigned char)'A' != (unsigned char)0xC1;
  878. }
  879. ],[
  880. ac_cv_ebcdic=yes
  881. ],[
  882. ac_cv_ebcdic=no
  883. ],[
  884. ac_cv_ebcdic=no
  885. ])])
  886. if test "$ac_cv_ebcdic" = "yes"; then
  887. AC_DEFINE(CHARSET_EBCDIC,1, [Define if system uses EBCDIC])
  888. fi
  889. ])
  890. AC_DEFUN(PHP_FOPENCOOKIE,[
  891. AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ])
  892. if test "$have_glibc_fopencookie" = "yes" ; then
  893. dnl this comes in two flavors:
  894. dnl newer glibcs (since 2.1.2 ? )
  895. dnl have a type called cookie_io_functions_t
  896. AC_TRY_COMPILE([ #define _GNU_SOURCE
  897. #include <stdio.h>
  898. ],
  899. [ cookie_io_functions_t cookie; ],
  900. [ have_cookie_io_functions_t=yes ],
  901. [ ] )
  902. if test "$have_cookie_io_functions_t" = "yes" ; then
  903. cookie_io_functions_t=cookie_io_functions_t
  904. have_fopen_cookie=yes
  905. else
  906. dnl older glibc versions (up to 2.1.2 ?)
  907. dnl call it _IO_cookie_io_functions_t
  908. AC_TRY_COMPILE([ #define _GNU_SOURCE
  909. #include <stdio.h>
  910. ],
  911. [ _IO_cookie_io_functions_t cookie; ],
  912. [ have_IO_cookie_io_functions_t=yes ],
  913. [] )
  914. if test "$have_cookie_io_functions_t" = "yes" ; then
  915. cookie_io_functions_t=_IO_cookie_io_functions_t
  916. have_fopen_cookie=yes
  917. fi
  918. fi
  919. if test "$have_fopen_cookie" = "yes" ; then
  920. AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
  921. AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
  922. fi
  923. fi
  924. ])