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.

202 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. 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. ZEND_EXT_TYPE="zend_extension"
  83. PHP_SUBST(ZEND_EXT_TYPE)
  84. dnl Discard optimization flags when debugging is enabled
  85. if test "$PHP_DEBUG" = "yes"; then
  86. PHP_DEBUG=1
  87. ZEND_DEBUG=yes
  88. changequote({,})
  89. CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
  90. CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
  91. changequote([,])
  92. dnl add -O0 only if GCC or ICC is used
  93. if test "$GCC" = "yes" || test "$ICC" = "yes"; then
  94. CFLAGS="$CFLAGS -O0"
  95. CXXFLAGS="$CXXFLAGS -O0"
  96. fi
  97. if test "$SUNCC" = "yes"; then
  98. if test -n "$auto_cflags"; then
  99. CFLAGS="-g"
  100. CXXFLAGS="-g"
  101. else
  102. CFLAGS="$CFLAGS -g"
  103. CXXFLAGS="$CFLAGS -g"
  104. fi
  105. fi
  106. else
  107. PHP_DEBUG=0
  108. ZEND_DEBUG=no
  109. fi
  110. dnl Always shared
  111. PHP_BUILD_SHARED
  112. dnl Required programs
  113. PHP_PROG_RE2C
  114. PHP_PROG_AWK
  115. sinclude(config.m4)
  116. enable_static=no
  117. enable_shared=yes
  118. dnl Only allow AC_PROG_CXX and AC_PROG_CXXCPP if they are explicitly called (by PHP_REQUIRE_CXX).
  119. dnl Otherwise AC_PROG_LIBTOOL fails if there is no working C++ compiler.
  120. AC_PROVIDE_IFELSE([PHP_REQUIRE_CXX], [], [
  121. undefine([AC_PROG_CXX])
  122. AC_DEFUN([AC_PROG_CXX], [])
  123. undefine([AC_PROG_CXXCPP])
  124. AC_DEFUN([AC_PROG_CXXCPP], [php_prog_cxxcpp=disabled])
  125. ])
  126. AC_PROG_LIBTOOL
  127. all_targets='$(PHP_MODULES) $(PHP_ZEND_EX)'
  128. install_targets="install-modules install-headers"
  129. phplibdir="`pwd`/modules"
  130. CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H"
  131. CFLAGS_CLEAN='$(CFLAGS)'
  132. CXXFLAGS_CLEAN='$(CXXFLAGS)'
  133. test "$prefix" = "NONE" && prefix="/usr/local"
  134. test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
  135. PHP_SUBST(PHP_MODULES)
  136. PHP_SUBST(PHP_ZEND_EX)
  137. PHP_SUBST(all_targets)
  138. PHP_SUBST(install_targets)
  139. PHP_SUBST(prefix)
  140. PHP_SUBST(exec_prefix)
  141. PHP_SUBST(libdir)
  142. PHP_SUBST(prefix)
  143. PHP_SUBST(phplibdir)
  144. PHP_SUBST(phpincludedir)
  145. PHP_SUBST(CC)
  146. PHP_SUBST(CFLAGS)
  147. PHP_SUBST(CFLAGS_CLEAN)
  148. PHP_SUBST(CPP)
  149. PHP_SUBST(CPPFLAGS)
  150. PHP_SUBST(CXX)
  151. PHP_SUBST(CXXFLAGS)
  152. PHP_SUBST(CXXFLAGS_CLEAN)
  153. PHP_SUBST(EXTENSION_DIR)
  154. PHP_SUBST(PHP_EXECUTABLE)
  155. PHP_SUBST(EXTRA_LDFLAGS)
  156. PHP_SUBST(EXTRA_LIBS)
  157. PHP_SUBST(INCLUDES)
  158. PHP_SUBST(LFLAGS)
  159. PHP_SUBST(LDFLAGS)
  160. PHP_SUBST(SHARED_LIBTOOL)
  161. PHP_SUBST(LIBTOOL)
  162. PHP_SUBST(SHELL)
  163. PHP_SUBST(INSTALL_HEADERS)
  164. PHP_GEN_BUILD_DIRS
  165. PHP_GEN_GLOBAL_MAKEFILE
  166. test -d modules || $php_shtool mkdir modules
  167. touch .deps
  168. AC_CONFIG_HEADER(config.h)
  169. AC_OUTPUT()