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.

356 lines
8.1 KiB

27 years ago
27 years ago
27 years ago
27 years ago
  1. dnl $Id$
  2. dnl
  3. dnl This file contains local autoconf functions.
  4. dnl
  5. dnl PHP_SET_SYM_FILE(path)
  6. dnl
  7. dnl set the path of the file which contains the symbol export list
  8. dnl
  9. AC_DEFUN(PHP_SET_SYM_FILE,
  10. [
  11. PHP_SYM_FILE="$1"
  12. ])
  13. dnl
  14. dnl PHP_BUILD_THREAD_SAFE
  15. dnl
  16. AC_DEFUN(PHP_BUILD_THREAD_SAFE,[
  17. PHP_THREAD_SAFETY=yes
  18. ])
  19. dnl
  20. dnl PHP_BUILD_SHARED
  21. dnl
  22. AC_DEFUN(PHP_BUILD_SHARED,[
  23. php_build_target=shared
  24. ])
  25. dnl
  26. dnl PHP_BUILD_STATIC
  27. dnl
  28. AC_DEFUN(PHP_BUILD_STATIC,[
  29. php_build_target=static
  30. ])
  31. dnl
  32. dnl PHP_BUILD_PROGRAM
  33. dnl
  34. AC_DEFUN(PHP_BUILD_PROGRAM,[
  35. php_build_target=program
  36. ])
  37. dnl
  38. dnl AC_PHP_ONCE(namespace, variable, code)
  39. dnl
  40. dnl execute code, if variable is not set in namespace
  41. dnl
  42. AC_DEFUN(AC_PHP_ONCE,[
  43. unique=`echo $ac_n "$2$ac_c" | tr -c -d a-zA-Z0-9`
  44. cmd="echo $ac_n \"\$$1$unique$ac_c\""
  45. if test -n "$unique" && test "`eval $cmd`" = "" ; then
  46. eval "$1$unique=set"
  47. $3
  48. fi
  49. ])
  50. dnl
  51. dnl AC_EXPAND_PATH(path, variable)
  52. dnl
  53. dnl expands path to an absolute path and assigns it to variable
  54. dnl
  55. AC_DEFUN(AC_EXPAND_PATH,[
  56. if test -z "$1" || echo "$1" | grep '^/' >/dev/null ; then
  57. $2="$1"
  58. else
  59. ep_dir="`dirname \"$1\"`"
  60. ep_realdir="`(cd \"$ep_dir\" && pwd)`"
  61. $2="$ep_realdir/`basename \"$1\"`"
  62. fi
  63. ])
  64. dnl
  65. dnl AC_ADD_LIBPATH(path)
  66. dnl
  67. dnl add a library to linkpath/runpath
  68. dnl
  69. AC_DEFUN(AC_ADD_LIBPATH,[
  70. if test "$1" != "/usr/lib"; then
  71. AC_EXPAND_PATH($1, ai_p)
  72. AC_PHP_ONCE(LIBPATH, $ai_p, [
  73. EXTRA_LIBS="$EXTRA_LIBS -L$ai_p"
  74. PHP_RPATHS="$PHP_RPATHS $ai_p"
  75. ])
  76. fi
  77. ])
  78. dnl
  79. dnl AC_BUILD_RPATH()
  80. dnl
  81. dnl builds RPATH from PHP_RPATHS
  82. dnl
  83. AC_DEFUN(AC_BUILD_RPATH,[
  84. if test "$enable_rpath" = "yes" && test -n "$PHP_RPATHS"; then
  85. OLD_RPATHS="$PHP_RPATHS"
  86. PHP_RPATHS=""
  87. for i in $OLD_RPATHS; do
  88. PHP_RPATHS="$PHP_RPATHS -R $i"
  89. NATIVE_RPATHS="$NATIVE_RPATHS ${ld_runpath_switch}$i"
  90. done
  91. fi
  92. ])
  93. dnl
  94. dnl AC_ADD_INCLUDE(path)
  95. dnl
  96. dnl add a include path
  97. dnl
  98. AC_DEFUN(AC_ADD_INCLUDE,[
  99. if test "$1" != "/usr/include"; then
  100. AC_EXPAND_PATH($1, ai_p)
  101. AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
  102. INCLUDES="$INCLUDES -I$ai_p"
  103. ])
  104. fi
  105. ])
  106. dnl
  107. dnl AC_ADD_LIBRARY(library)
  108. dnl
  109. dnl add a library to the link line
  110. dnl
  111. AC_DEFUN(AC_ADD_LIBRARY,[
  112. AC_PHP_ONCE(LIBRARY, $1, [
  113. EXTRA_LIBS="$EXTRA_LIBS -l$1"
  114. ])
  115. ])
  116. dnl
  117. dnl AC_ADD_LIBRARY_WITH_PATH(library, path)
  118. dnl
  119. dnl add a library to the link line and path to linkpath/runpath
  120. dnl
  121. AC_DEFUN(AC_ADD_LIBRARY_WITH_PATH,[
  122. AC_ADD_LIBPATH($2)
  123. AC_ADD_LIBRARY($1)
  124. ])
  125. AC_DEFUN(AM_SET_LIBTOOL_VARIABLE,[
  126. LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
  127. ])
  128. dnl
  129. dnl Check for cc option
  130. dnl
  131. AC_DEFUN(AC_CHECK_CC_OPTION,[
  132. echo "main(){return 0;}" > conftest.$ac_ext
  133. opt="$1"
  134. var=`echo $ac_n "$opt$ac_c"|tr -c a-zA-Z0-9 _`
  135. AC_MSG_CHECKING([if compiler supports -$1 really])
  136. ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1"
  137. if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then
  138. eval php_cc_$var=no
  139. AC_MSG_RESULT(no)
  140. else
  141. if eval ./conftest 2>/dev/null ; then
  142. eval php_cc_$var=yes
  143. AC_MSG_RESULT(yes)
  144. else
  145. eval php_cc_$var=no
  146. AC_MSG_RESULT(no)
  147. fi
  148. fi
  149. ])
  150. AC_DEFUN(PHP_REGEX,[
  151. if test "$REGEX_TYPE" = "php"; then
  152. REGEX_LIB=regex/libregex.la
  153. REGEX_DIR=regex
  154. AC_DEFINE(HSREGEX)
  155. AC_DEFINE(REGEX,1)
  156. PHP_OUTPUT(regex/Makefile)
  157. elif test "$REGEX_TYPE" = "system"; then
  158. AC_DEFINE(REGEX,0)
  159. elif test "$REGEX_TYPE" = "apache"; then
  160. AC_DEFINE(REGEX,2)
  161. fi
  162. AC_MSG_CHECKING(which regex library to use)
  163. AC_MSG_RESULT($REGEX_TYPE)
  164. AC_SUBST(REGEX_DIR)
  165. AC_SUBST(REGEX_LIB)
  166. AC_SUBST(HSREGEX)
  167. ])
  168. dnl
  169. dnl See if we have broken header files like SunOS has.
  170. dnl
  171. AC_DEFUN(AC_MISSING_FCLOSE_DECL,[
  172. AC_MSG_CHECKING([for fclose declaration])
  173. AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
  174. AC_DEFINE(MISSING_FCLOSE_DECL,0)
  175. AC_MSG_RESULT(ok)
  176. ],[
  177. AC_DEFINE(MISSING_FCLOSE_DECL,1)
  178. AC_MSG_RESULT(missing)
  179. ])
  180. ])
  181. dnl
  182. dnl Check for broken sprintf()
  183. dnl
  184. AC_DEFUN(AC_BROKEN_SPRINTF,[
  185. AC_MSG_CHECKING([for broken sprintf])
  186. AC_TRY_RUN([main() { char buf[20]; exit (sprintf(buf,"testing 123")!=11); }],[
  187. AC_DEFINE(BROKEN_SPRINTF,0)
  188. AC_MSG_RESULT(ok)
  189. ],[
  190. AC_DEFINE(BROKEN_SPRINTF,1)
  191. AC_MSG_RESULT(broken)
  192. ],[
  193. AC_DEFINE(BROKEN_SPRINTF,0)
  194. AC_MSG_RESULT(cannot check, guessing ok)
  195. ])
  196. ])
  197. dnl
  198. dnl PHP_EXTENSION(extname [, shared])
  199. dnl
  200. dnl Includes an extension in the build.
  201. dnl
  202. dnl "extname" is the name of the ext/ subdir where the extension resides
  203. dnl "shared" can be set to "shared" or "yes" to build the extension as
  204. dnl a dynamically loadable library.
  205. dnl
  206. AC_DEFUN(PHP_EXTENSION,[
  207. if test -d "$cwd/$srcdir/ext/$1" ; then
  208. EXT_SUBDIRS="$EXT_SUBDIRS $1"
  209. if test "$2" != "shared" -a "$2" != "yes"; then
  210. _extlib="libphpext_$1.a"
  211. EXT_LTLIBS="$EXT_LTLIBS ext/$1/libphpext_$1.la"
  212. EXT_LIBS="$EXT_LIBS $1/$_extlib"
  213. EXT_STATIC="$EXT_STATIC $1"
  214. else
  215. AC_DEFINE_UNQUOTED("COMPILE_DL_`echo $1|tr a-z A-Z`", 1, Whether to build $1 as dynamic module)
  216. EXT_SHARED="$EXT_SHARED $1"
  217. fi
  218. PHP_OUTPUT(ext/$1/Makefile)
  219. fi
  220. ])
  221. AC_SUBST(EXT_SUBDIRS)
  222. AC_SUBST(EXT_STATIC)
  223. AC_SUBST(EXT_SHARED)
  224. AC_SUBST(EXT_LIBS)
  225. AC_SUBST(EXT_LTLIBS)
  226. dnl
  227. dnl Solaris requires main code to be position independent in order
  228. dnl to let shared objects find symbols. Weird. Ugly.
  229. dnl
  230. dnl Must be run after all --with-NN options that let the user
  231. dnl choose dynamic extensions, and after the gcc test.
  232. dnl
  233. AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[
  234. AC_MSG_CHECKING(whether -fPIC is required)
  235. if test "$EXT_SHARED" != ""; then
  236. os=`uname -sr 2>/dev/null`
  237. case "$os" in
  238. "SunOS 5.6"|"SunOS 5.7")
  239. case "$CC" in
  240. gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
  241. *) CFLAGS="$CFLAGS -fpic";;
  242. esac
  243. AC_MSG_RESULT(yes);;
  244. *)
  245. AC_MSG_RESULT(no);;
  246. esac
  247. else
  248. AC_MSG_RESULT(no)
  249. fi
  250. ])
  251. dnl
  252. dnl Checks whether $withval is "shared" or starts with "shared,XXX"
  253. dnl and sets $shared to "yes" or "no", and removes "shared,?" stuff
  254. dnl from $withval.
  255. dnl
  256. AC_DEFUN(PHP_WITH_SHARED,[
  257. case $withval in
  258. shared)
  259. shared=yes
  260. withval=yes
  261. ;;
  262. shared,*)
  263. shared=yes
  264. withval=`echo $withval | sed -e 's/^shared,//'`
  265. ;;
  266. *)
  267. shared=no
  268. ;;
  269. esac
  270. ])
  271. dnl The problem is that the default compilation flags in Solaris 2.6 won't
  272. dnl let programs access large files; you need to tell the compiler that
  273. dnl you actually want your programs to work on large files. For more
  274. dnl details about this brain damage please see:
  275. dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
  276. dnl Written by Paul Eggert <eggert@twinsun.com>.
  277. AC_DEFUN(AC_SYS_LFS,
  278. [dnl
  279. # If available, prefer support for large files unless the user specified
  280. # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
  281. AC_MSG_CHECKING(whether large file support needs explicit enabling)
  282. ac_getconfs=''
  283. ac_result=yes
  284. ac_set=''
  285. ac_shellvars='CPPFLAGS LDFLAGS LIBS'
  286. for ac_shellvar in $ac_shellvars; do
  287. case $ac_shellvar in
  288. CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
  289. *) ac_lfsvar=LFS_$ac_shellvar ;;
  290. esac
  291. eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
  292. (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
  293. ac_getconf=`getconf $ac_lfsvar`
  294. ac_getconfs=$ac_getconfs$ac_getconf
  295. eval ac_test_$ac_shellvar=\$ac_getconf
  296. done
  297. case "$ac_result$ac_getconfs" in
  298. yes) ac_result=no ;;
  299. esac
  300. case "$ac_result$ac_set" in
  301. yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
  302. esac
  303. AC_MSG_RESULT($ac_result)
  304. case $ac_result in
  305. yes)
  306. for ac_shellvar in $ac_shellvars; do
  307. eval $ac_shellvar=\$ac_test_$ac_shellvar
  308. done ;;
  309. esac
  310. ])
  311. AC_DEFUN(AC_SOCKADDR_SA_LEN,[
  312. AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
  313. AC_TRY_COMPILE([#include <sys/types.h>
  314. #include <sys/socket.h>],
  315. [struct sockaddr s; s.sa_len;],
  316. [ac_cv_sockaddr_sa_len=yes
  317. AC_DEFINE(HAVE_SOCKADDR_SA_LEN)],
  318. [ac_cv_sockaddr_sa_len=no])
  319. ])
  320. ])
  321. dnl ## PHP_AC_OUTPUT(file)
  322. dnl ## adds "file" to the list of files generated by AC_OUTPUT
  323. dnl ## This macro can be used several times.
  324. AC_DEFUN(PHP_OUTPUT,[
  325. PHP_OUTPUT_FILES="$PHP_OUTPUT_FILES $1"
  326. ])