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.

210 lines
4.8 KiB

19 years ago
23 years ago
21 years ago
  1. dnl This file becomes configure.in for self-contained extensions.
  2. divert(1)
  3. AC_PREREQ(2.13)
  4. AC_INIT(config.m4)
  5. PHP_CONFIG_NICE(config.nice)
  6. dnl
  7. AC_DEFUN([PHP_EXT_BUILDDIR],[.])dnl
  8. AC_DEFUN([PHP_EXT_DIR],[""])dnl
  9. AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir])dnl
  10. AC_DEFUN([PHP_ALWAYS_SHARED],[
  11. ext_output="yes, shared"
  12. ext_shared=yes
  13. test "[$]$1" = "no" && $1=yes
  14. ])dnl
  15. dnl
  16. test -z "$CFLAGS" && auto_cflags=1
  17. abs_srcdir=`(cd $srcdir && pwd)`
  18. abs_builddir=`pwd`
  19. AC_PROG_CC([cc gcc])
  20. PHP_DETECT_ICC
  21. PHP_DETECT_SUNCC
  22. AC_PROG_CC_C_O
  23. dnl Support systems with system libraries in e.g. /usr/lib64
  24. PHP_ARG_WITH(libdir, for system library directory,
  25. [ --with-libdir=NAME Look for libraries in .../NAME rather than .../lib], lib, no)
  26. PHP_RUNPATH_SWITCH
  27. PHP_SHLIB_SUFFIX_NAMES
  28. dnl Find php-config script
  29. PHP_ARG_WITH(php-config,,
  30. [ --with-php-config=PATH Path to php-config [php-config]], php-config, no)
  31. dnl For BC
  32. PHP_CONFIG=$PHP_PHP_CONFIG
  33. prefix=`$PHP_CONFIG --prefix 2>/dev/null`
  34. phpincludedir=`$PHP_CONFIG --include-dir 2>/dev/null`
  35. INCLUDES=`$PHP_CONFIG --includes 2>/dev/null`
  36. EXTENSION_DIR=`$PHP_CONFIG --extension-dir 2>/dev/null`
  37. PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null`
  38. if test -z "$prefix"; then
  39. AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH])
  40. fi
  41. php_shtool=$srcdir/build/shtool
  42. PHP_INIT_BUILD_SYSTEM
  43. AC_MSG_CHECKING([for PHP prefix])
  44. AC_MSG_RESULT([$prefix])
  45. AC_MSG_CHECKING([for PHP includes])
  46. AC_MSG_RESULT([$INCLUDES])
  47. AC_MSG_CHECKING([for PHP extension directory])
  48. AC_MSG_RESULT([$EXTENSION_DIR])
  49. AC_MSG_CHECKING([for PHP installed headers prefix])
  50. AC_MSG_RESULT([$phpincludedir])
  51. dnl Checks for PHP_DEBUG / ZEND_DEBUG / ZTS
  52. AC_MSG_CHECKING([if debug is enabled])
  53. old_CPPFLAGS=$CPPFLAGS
  54. CPPFLAGS="-I$phpincludedir"
  55. AC_EGREP_CPP(php_debug_is_enabled,[
  56. #include <main/php_config.h>
  57. #if ZEND_DEBUG
  58. php_debug_is_enabled
  59. #endif
  60. ],[
  61. PHP_DEBUG=yes
  62. ],[
  63. PHP_DEBUG=no
  64. ])
  65. AC_MSG_RESULT([$PHP_DEBUG])
  66. AC_MSG_CHECKING([if zts is enabled])
  67. old_CPPFLAGS=$CPPFLAGS
  68. CPPFLAGS="-I$phpincludedir"
  69. AC_EGREP_CPP(php_zts_is_enabled,[
  70. #include <main/php_config.h>
  71. #if ZTS
  72. php_zts_is_enabled
  73. #endif
  74. ],[
  75. PHP_THREAD_SAFETY=yes
  76. ],[
  77. PHP_THREAD_SAFETY=no
  78. ])
  79. CPPFLAGS=$old_CPPFLAGS
  80. AC_MSG_RESULT([$PHP_DEBUG])
  81. dnl Support for building and testing Zend extensions
  82. if test "$PHP_DEBUG" = "yes" && test "$PHP_THREAD_SAFETY" = "yes; then
  83. ZEND_EXT_TYPE="zend_extension_debug_ts"
  84. elif test "$PHP_DEBUG" = "yes"; then
  85. ZEND_EXT_TYPE="zend_extension_debug"
  86. elif test "$PHP_THREAD_SAFETY" = "yes; then
  87. ZEND_EXT_TYPE="zend_extension_ts"
  88. else
  89. ZEND_EXT_TYPE="zend_extension"
  90. fi
  91. PHP_SUBST(ZEND_EXT_TYPE)
  92. dnl Discard optimization flags when debugging is enabled
  93. if test "$PHP_DEBUG" = "yes"; then
  94. PHP_DEBUG=1
  95. ZEND_DEBUG=yes
  96. changequote({,})
  97. CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
  98. CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
  99. changequote([,])
  100. dnl add -O0 only if GCC or ICC is used
  101. if test "$GCC" = "yes" || test "$ICC" = "yes"; then
  102. CFLAGS="$CFLAGS -O0"
  103. CXXFLAGS="$CXXFLAGS -O0"
  104. fi
  105. if test "$SUNCC" = "yes"; then
  106. if test -n "$auto_cflags"; then
  107. CFLAGS="-g"
  108. CXXFLAGS="-g"
  109. else
  110. CFLAGS="$CFLAGS -g"
  111. CXXFLAGS="$CFLAGS -g"
  112. fi
  113. fi
  114. else
  115. PHP_DEBUG=0
  116. ZEND_DEBUG=no
  117. fi
  118. dnl Always shared
  119. PHP_BUILD_SHARED
  120. dnl Required programs
  121. PHP_PROG_RE2C
  122. PHP_PROG_AWK
  123. sinclude(config.m4)
  124. enable_static=no
  125. enable_shared=yes
  126. dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by PHP_REQUIRE_CXX).
  127. dnl Otherwise AC_PROG_LIBTOOL fails if there is no working C++ compiler.
  128. AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [
  129. undefine([AC_PROG_CXX])
  130. AC_DEFUN([AC_PROG_CXX], [])
  131. undefine([AC_PROG_CXXCPP])
  132. AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled])
  133. ])
  134. AC_PROG_LIBTOOL
  135. all_targets='$(PHP_MODULES) $(PHP_ZEND_EX)'
  136. install_targets="install-modules install-headers"
  137. phplibdir="`pwd`/modules"
  138. CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H"
  139. CFLAGS_CLEAN='$(CFLAGS)'
  140. CXXFLAGS_CLEAN='$(CXXFLAGS)'
  141. test "$prefix" = "NONE" && prefix="/usr/local"
  142. test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
  143. PHP_SUBST(PHP_MODULES)
  144. PHP_SUBST(PHP_ZEND_EX)
  145. PHP_SUBST(all_targets)
  146. PHP_SUBST(install_targets)
  147. PHP_SUBST(prefix)
  148. PHP_SUBST(exec_prefix)
  149. PHP_SUBST(libdir)
  150. PHP_SUBST(prefix)
  151. PHP_SUBST(phplibdir)
  152. PHP_SUBST(phpincludedir)
  153. PHP_SUBST(CC)
  154. PHP_SUBST(CFLAGS)
  155. PHP_SUBST(CFLAGS_CLEAN)
  156. PHP_SUBST(CPP)
  157. PHP_SUBST(CPPFLAGS)
  158. PHP_SUBST(CXX)
  159. PHP_SUBST(CXXFLAGS)
  160. PHP_SUBST(CXXFLAGS_CLEAN)
  161. PHP_SUBST(EXTENSION_DIR)
  162. PHP_SUBST(PHP_EXECUTABLE)
  163. PHP_SUBST(EXTRA_LDFLAGS)
  164. PHP_SUBST(EXTRA_LIBS)
  165. PHP_SUBST(INCLUDES)
  166. PHP_SUBST(LFLAGS)
  167. PHP_SUBST(LDFLAGS)
  168. PHP_SUBST(SHARED_LIBTOOL)
  169. PHP_SUBST(LIBTOOL)
  170. PHP_SUBST(SHELL)
  171. PHP_SUBST(INSTALL_HEADERS)
  172. PHP_GEN_BUILD_DIRS
  173. PHP_GEN_GLOBAL_MAKEFILE
  174. test -d modules || $php_shtool mkdir modules
  175. touch .deps
  176. AC_CONFIG_HEADER(config.h)
  177. AC_OUTPUT()