phpize.m4 5.2 KB

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