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.

315 lines
7.2 KiB

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