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.

197 lines
4.5 KiB

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