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.

188 lines
4.2 KiB

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. AC_EXPAND_PATH($1, ai_p)
  36. AC_PHP_ONCE(LIBPATH, $ai_p, [
  37. EXTRA_LIBS="$EXTRA_LIBS -L$ai_p"
  38. if test -n "$APXS" ; then
  39. RPATHS="$RPATHS ${apxs_runpath_switch}$ai_p'"
  40. else
  41. RPATHS="$RPATHS ${ld_runpath_switch}$ai_p"
  42. fi
  43. ])
  44. ])
  45. dnl
  46. dnl AC_ADD_INCLUDE(path)
  47. dnl
  48. dnl add a include path
  49. dnl
  50. AC_DEFUN(AC_ADD_INCLUDE,[
  51. AC_EXPAND_PATH($1, ai_p)
  52. AC_PHP_ONCE(INCLUDEPATH, $ai_p, [
  53. INCLUDES="$INCLUDES -I$ai_p"
  54. ])
  55. ])
  56. dnl
  57. dnl AC_ADD_LIBRARY(library)
  58. dnl
  59. dnl add a library to the link line
  60. dnl
  61. AC_DEFUN(AC_ADD_LIBRARY,[
  62. AC_PHP_ONCE(LIBRARY, $1, [
  63. EXTRA_LIBS="$EXTRA_LIBS -l$1"
  64. ])
  65. ])
  66. dnl
  67. dnl AC_ADD_LIBRARY_WITH_PATH(library, path)
  68. dnl
  69. dnl add a library to the link line and path to linkpath/runpath
  70. dnl
  71. AC_DEFUN(AC_ADD_LIBRARY_WITH_PATH,[
  72. AC_ADD_LIBPATH($2)
  73. AC_ADD_LIBRARY($1)
  74. ])
  75. dnl
  76. dnl Check for cc option
  77. dnl
  78. AC_DEFUN(AC_CHECK_CC_OPTION,[
  79. echo "main(){return 0;}" > conftest.$ac_ext
  80. opt="$1"
  81. var=`echo $ac_n "$opt$ac_c"|tr -c a-zA-Z0-9 _`
  82. AC_MSG_CHECKING([if compiler supports -$1 really])
  83. ac_php_compile="${CC-cc} -$opt -o conftest $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1"
  84. if eval $ac_php_compile 2>&1 | egrep "$opt" > /dev/null 2>&1 ; then
  85. eval php_cc_$var=no
  86. AC_MSG_RESULT(no)
  87. else
  88. if eval ./conftest 2>/dev/null ; then
  89. eval php_cc_$var=yes
  90. AC_MSG_RESULT(yes)
  91. else
  92. eval php_cc_$var=no
  93. AC_MSG_RESULT(no)
  94. fi
  95. fi
  96. ])
  97. dnl
  98. dnl See if we have broken header files like SunOS has.
  99. dnl
  100. AC_DEFUN(AC_MISSING_FCLOSE_DECL,[
  101. AC_MSG_CHECKING([for fclose declaration])
  102. AC_TRY_COMPILE([#include <stdio.h>],[int (*func)() = fclose],[
  103. AC_DEFINE(MISSING_FCLOSE_DECL,0)
  104. AC_MSG_RESULT(ok)
  105. ],[
  106. AC_DEFINE(MISSING_FCLOSE_DECL,1)
  107. AC_MSG_RESULT(missing)
  108. ])
  109. ])
  110. dnl
  111. dnl Check for broken sprintf()
  112. dnl
  113. AC_DEFUN(AC_BROKEN_SPRINTF,[
  114. AC_MSG_CHECKING([for broken sprintf])
  115. AC_TRY_RUN([main() { char buf[20]; exit (sprintf(buf,"testing 123")!=11); }],[
  116. AC_DEFINE(BROKEN_SPRINTF,0)
  117. AC_MSG_RESULT(ok)
  118. ],[
  119. AC_DEFINE(BROKEN_SPRINTF,1)
  120. AC_MSG_RESULT(broken)
  121. ],[
  122. AC_DEFINE(BROKEN_SPRINTF,0)
  123. AC_MSG_RESULT(cannot check, guessing ok)
  124. ])
  125. ])
  126. dnl
  127. dnl Stuff to do when setting up a new extension.
  128. dnl XXX have to change the hardcoding of ".a" when we want to be able
  129. dnl to make dynamic libraries as well.
  130. dnl
  131. AC_DEFUN(PHP_EXTENSION,[
  132. EXT_SUBDIRS="$EXT_SUBDIRS $1"
  133. if test "$2" != "shared" -a "$2" != "yes"; then
  134. _extlib="libphpext_$1.a"
  135. EXT_LIBS="$EXT_LIBS $1/$_extlib"
  136. EXTINFO_DEPS="$EXTINFO_DEPS ../ext/$1/extinfo.c.stub"
  137. EXT_STATIC="$EXT_STATIC $1"
  138. else
  139. EXT_SHARED="$EXT_SHARED $1"
  140. fi
  141. dnl EXT_INCLUDE_CODE="\#include \"ext/$1/php3_$1.h\"\\n$EXT_INCLUDE_CODE"
  142. dnl EXT_MODULE_PTRS="phpext_$1_ptr, $EXT_MODULE_PTRS"
  143. dnl "
  144. ])
  145. AC_SUBST(EXT_SUBDIRS)
  146. AC_SUBST(EXT_STATIC)
  147. AC_SUBST(EXT_SHARED)
  148. AC_SUBST(EXT_LIBS)
  149. AC_SUBST(EXTINFO_DEPS)
  150. dnl AC_SUBST(EXT_INCLUDE_CODE)
  151. dnl AC_SUBST(EXT_MODULES_PTRS)
  152. dnl
  153. dnl Solaris requires main code to be position independent in order
  154. dnl to let shared objects find symbols. Weird. Ugly.
  155. dnl
  156. dnl Must be run after all --with-NN options that let the user
  157. dnl choose dynamic extensions, and after the gcc test.
  158. dnl
  159. AC_DEFUN(PHP_SOLARIS_PIC_WEIRDNESS,[
  160. AC_MSG_CHECKING(whether -fPIC is required)
  161. if test "$EXT_SHARED" != ""; then
  162. os=`uname -sr 2>/dev/null`
  163. case "$os" in
  164. "SunOS 5.6"|"SunOS 5.7")
  165. case "$CC" in
  166. gcc*|egcs*) CFLAGS="$CFLAGS -fPIC";;
  167. *) CFLAGS="$CFLAGS -fpic";;
  168. esac
  169. AC_MSG_RESULT(yes);;
  170. *)
  171. AC_MSG_RESULT(no);;
  172. esac
  173. fi
  174. ])