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.

295 lines
6.9 KiB

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