config.m4 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. dnl
  2. dnl $Id$
  3. dnl
  4. AC_DEFUN([PHP_APACHE_FD_CHECK], [
  5. AC_CACHE_CHECK([for member fd in BUFF *],ac_cv_php_fd_in_buff,[
  6. save=$CPPFLAGS
  7. if test -n "$APXS_INCLUDEDIR"; then
  8. CPPFLAGS="$CPPFLAGS -I$APXS_INCLUDEDIR"
  9. else
  10. CPPFLAGS="$CPPFLAGS $APACHE_INCLUDE"
  11. fi
  12. AC_TRY_COMPILE([#include <httpd.h>],[conn_rec *c; int fd = c->client->fd;],[
  13. ac_cv_php_fd_in_buff=yes],[ac_cv_php_fd_in_buff=no],[ac_cv_php_fd_in_buff=no])
  14. CPPFLAGS=$save
  15. ])
  16. if test "$ac_cv_php_fd_in_buff" = "yes"; then
  17. AC_DEFINE(PHP_APACHE_HAVE_CLIENT_FD,1,[ ])
  18. fi
  19. ])
  20. dnl Apache 1.x shared module
  21. PHP_ARG_WITH(apxs,,
  22. [ --with-apxs[=FILE] Build shared Apache 1.x module. FILE is the optional
  23. pathname to the Apache apxs tool [apxs]], no, no)
  24. AC_MSG_CHECKING([for Apache 1.x module support via DSO through APXS])
  25. if test "$PHP_APXS" != "no"; then
  26. if test "$PHP_APXS" = "yes"; then
  27. APXS=apxs
  28. $APXS -q CFLAGS >/dev/null 2>&1
  29. if test "$?" != "0" && test -x /usr/sbin/apxs; then #SUSE 6.x
  30. APXS=/usr/sbin/apxs
  31. fi
  32. else
  33. PHP_EXPAND_PATH($PHP_APXS, APXS)
  34. fi
  35. $APXS -q CFLAGS >/dev/null 2>&1
  36. if test "$?" != "0"; then
  37. AC_MSG_RESULT()
  38. AC_MSG_RESULT()
  39. AC_MSG_RESULT([Sorry, I was not able to successfully run APXS. Possible reasons:])
  40. AC_MSG_RESULT()
  41. AC_MSG_RESULT([1. Perl is not installed;])
  42. AC_MSG_RESULT([2. Apache was not compiled with DSO support (--enable-module=so);])
  43. AC_MSG_RESULT([3. 'apxs' is not in your path. Try to use --with-apxs=/path/to/apxs])
  44. AC_MSG_RESULT([The output of $APXS follows])
  45. $APXS -q CFLAGS
  46. AC_MSG_ERROR([Aborting])
  47. fi
  48. APXS_LDFLAGS="@SYBASE_LFLAGS@ @SYBASE_LIBS@ @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@"
  49. APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR`
  50. APXS_CFLAGS=`$APXS -q CFLAGS`
  51. APXS_HTTPD=`$APXS -q SBINDIR`/`$APXS -q TARGET`
  52. APACHE_INCLUDE=-I$APXS_INCLUDEDIR
  53. # Test that we're trying to configure with apache 1.x
  54. PHP_AP_EXTRACT_VERSION($APXS_HTTPD)
  55. if test "$APACHE_VERSION" -ge 2000000; then
  56. AC_MSG_ERROR([You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropriate switch --with-apxs2])
  57. fi
  58. for flag in $APXS_CFLAGS; do
  59. case $flag in
  60. -D*) APACHE_CPPFLAGS="$APACHE_CPPFLAGS $flag";;
  61. esac
  62. done
  63. case $host_alias in
  64. *aix*)
  65. APXS_LIBEXECDIR=`$APXS -q LIBEXECDIR`
  66. EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
  67. PHP_AIX_LDFLAGS="-Wl,-brtl"
  68. build_type=shared
  69. ;;
  70. *darwin*)
  71. MH_BUNDLE_FLAGS="-dynamic -twolevel_namespace -bundle -bundle_loader $APXS_HTTPD"
  72. PHP_SUBST(MH_BUNDLE_FLAGS)
  73. SAPI_SHARED=libs/libphp5.so
  74. build_type=bundle
  75. ;;
  76. *)
  77. build_type=shared
  78. ;;
  79. esac
  80. PHP_SELECT_SAPI(apache, $build_type, sapi_apache.c mod_php5.c php_apache.c, $APACHE_CPPFLAGS -I$APXS_INCLUDEDIR)
  81. # Test whether apxs support -S option
  82. $APXS -q -S CFLAGS="$APXS_CFLAGS" CFLAGS >/dev/null 2>&1
  83. if test "$?" != "0"; then
  84. APACHE_INSTALL="$APXS -i -a -n php5 $SAPI_SHARED" # Old apxs does not have -S option
  85. else
  86. APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`
  87. if test -z `$APXS -q SYSCONFDIR`; then
  88. APACHE_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
  89. $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
  90. -i -n php5 $SAPI_SHARED"
  91. else
  92. APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR`
  93. APACHE_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
  94. \$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
  95. $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
  96. -S SYSCONFDIR='$APXS_SYSCONFDIR' \
  97. -i -a -n php5 $SAPI_SHARED"
  98. fi
  99. fi
  100. if test -z "`$APXS -q LD_SHLIB`" || test "`$APXS -q LIBEXECDIR`" = "modules"; then
  101. PHP_APXS_BROKEN=yes
  102. fi
  103. STRONGHOLD=
  104. AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ])
  105. AC_DEFINE(HAVE_AP_COMPAT_H,1,[ ])
  106. AC_DEFINE(HAVE_APACHE,1,[ ])
  107. AC_MSG_RESULT(yes)
  108. else
  109. AC_MSG_RESULT(no)
  110. fi
  111. dnl Apache 1.x static module
  112. PHP_ARG_WITH(apache,,
  113. [ --with-apache[=DIR] Build Apache 1.x module. DIR is the top-level Apache
  114. build directory [/usr/local/apache]], no, no)
  115. AC_MSG_CHECKING([for Apache 1.x module support])
  116. if test "$PHP_SAPI" != "apache" && test "$PHP_APACHE" != "no"; then
  117. if test "$PHP_APACHE" = "yes"; then
  118. # Apache's default directory
  119. PHP_APACHE=/usr/local/apache
  120. fi
  121. APACHE_INSTALL_FILES="\$(srcdir)/sapi/apache/mod_php5.* sapi/apache/libphp5.module"
  122. AC_DEFINE(HAVE_APACHE,1,[ ])
  123. APACHE_MODULE=yes
  124. PHP_EXPAND_PATH($PHP_APACHE, PHP_APACHE)
  125. # For Apache 1.2.x
  126. if test -f $PHP_APACHE/src/httpd.h; then
  127. APACHE_INCLUDE=-I$PHP_APACHE/src
  128. APACHE_TARGET=$PHP_APACHE/src
  129. PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
  130. APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_INSTALL_FILES $APACHE_TARGET"
  131. PHP_LIBS="-L. -lphp3"
  132. AC_MSG_RESULT([yes - Apache 1.2.x])
  133. STRONGHOLD=
  134. if test -f $PHP_APACHE/src/ap_config.h; then
  135. AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ])
  136. fi
  137. # For Apache 2.0.x
  138. elif test -f $PHP_APACHE/include/httpd.h && test -f $PHP_APACHE/srclib/apr/include/apr_general.h ; then
  139. AC_MSG_ERROR([Use --with-apxs2 with Apache 2.x!])
  140. # For Apache 1.3.x
  141. elif test -f $PHP_APACHE/src/main/httpd.h; then
  142. APACHE_HAS_REGEX=1
  143. APACHE_INCLUDE="-I$PHP_APACHE/src/main -I$PHP_APACHE/src/os/unix -I$PHP_APACHE/src/ap"
  144. APACHE_TARGET=$PHP_APACHE/src/modules/php5
  145. if test ! -d $APACHE_TARGET; then
  146. mkdir $APACHE_TARGET
  147. fi
  148. PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
  149. APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
  150. PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5"
  151. AC_MSG_RESULT([yes - Apache 1.3.x])
  152. STRONGHOLD=
  153. if test -f $PHP_APACHE/src/include/ap_config.h; then
  154. AC_DEFINE(HAVE_AP_CONFIG_H, 1, [ ])
  155. fi
  156. if test -f $PHP_APACHE/src/include/ap_compat.h; then
  157. AC_DEFINE(HAVE_AP_COMPAT_H, 1, [ ])
  158. if test ! -f $PHP_APACHE/src/include/ap_config_auto.h; then
  159. AC_MSG_ERROR([Please run Apache\'s configure or src/Configure program once and try again])
  160. fi
  161. elif test -f $PHP_APACHE/src/include/compat.h; then
  162. AC_DEFINE(HAVE_OLD_COMPAT_H, 1, [ ])
  163. fi
  164. # Also for Apache 1.3.x
  165. elif test -f $PHP_APACHE/src/include/httpd.h; then
  166. APACHE_HAS_REGEX=1
  167. APACHE_INCLUDE="-I$PHP_APACHE/src/include -I$PHP_APACHE/src/os/unix"
  168. APACHE_TARGET=$PHP_APACHE/src/modules/php5
  169. if test ! -d $APACHE_TARGET; then
  170. mkdir $APACHE_TARGET
  171. fi
  172. PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
  173. PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5"
  174. APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir"
  175. AC_MSG_RESULT([yes - Apache 1.3.x])
  176. STRONGHOLD=
  177. if test -f $PHP_APACHE/src/include/ap_config.h; then
  178. AC_DEFINE(HAVE_AP_CONFIG_H, 1, [ ])
  179. fi
  180. if test -f $PHP_APACHE/src/include/ap_compat.h; then
  181. AC_DEFINE(HAVE_AP_COMPAT_H, 1, [ ])
  182. if test ! -f $PHP_APACHE/src/include/ap_config_auto.h; then
  183. AC_MSG_ERROR([Please run Apache\'s configure or src/Configure program once and try again])
  184. fi
  185. elif test -f $PHP_APACHE/src/include/compat.h; then
  186. AC_DEFINE(HAVE_OLD_COMPAT_H, 1, [ ])
  187. fi
  188. # For StrongHold 2.2
  189. elif test -f $PHP_APACHE/apache/httpd.h; then
  190. APACHE_INCLUDE="-I$PHP_APACHE/apache -I$PHP_APACHE/ssl/include"
  191. APACHE_TARGET=$PHP_APACHE/apache
  192. PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE)
  193. PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5"
  194. APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET"
  195. STRONGHOLD=-DSTRONGHOLD=1
  196. AC_MSG_RESULT([yes - StrongHold])
  197. if test -f $PHP_APACHE/apache/ap_config.h; then
  198. AC_DEFINE(HAVE_AP_CONFIG_H, 1, [ ])
  199. fi
  200. if test -f $PHP_APACHE/src/ap_compat.h; then
  201. AC_DEFINE(HAVE_AP_COMPAT_H, 1, [ ])
  202. if test ! -f $PHP_APACHE/src/include/ap_config_auto.h; then
  203. AC_MSG_ERROR([Please run Apache\'s configure or src/Configure program once and try again])
  204. fi
  205. elif test -f $PHP_APACHE/src/compat.h; then
  206. AC_DEFINE(HAVE_OLD_COMPAT_H, 1, [ ])
  207. fi
  208. else
  209. AC_MSG_RESULT(no)
  210. AC_MSG_ERROR([Invalid Apache directory - unable to find httpd.h under $PHP_APACHE])
  211. fi
  212. else
  213. AC_MSG_RESULT(no)
  214. fi
  215. # compatibility
  216. if test -z "$enable_mod_charset" && test "$with_mod_charset"; then
  217. enable_mod_charset=$with_mod_charset
  218. fi
  219. PHP_ARG_ENABLE(mod-charset, whether to enable Apache charset compatibility option,
  220. [ --enable-mod-charset APACHE: Enable transfer tables for mod_charset (Rus Apache)], no, no)
  221. if test "$PHP_MOD_CHARSET" = "yes"; then
  222. AC_DEFINE(USE_TRANSFER_TABLES, 1, [ ])
  223. fi
  224. dnl Build as static module
  225. if test "$APACHE_MODULE" = "yes"; then
  226. PHP_TARGET_RDYNAMIC
  227. $php_shtool mkdir -p sapi/apache
  228. PHP_OUTPUT(sapi/apache/libphp5.module)
  229. fi
  230. dnl General
  231. if test -n "$APACHE_INSTALL"; then
  232. if test "x$APXS" != "x" -a "`uname -sv`" = "AIX 4" -a "$GCC" != "yes"; then
  233. APXS_EXP=-bE:sapi/apache/mod_php5.exp
  234. fi
  235. PHP_APACHE_FD_CHECK
  236. INSTALL_IT=$APACHE_INSTALL
  237. PHP_SUBST(APXS_EXP)
  238. PHP_SUBST(APACHE_INCLUDE)
  239. PHP_SUBST(APACHE_TARGET)
  240. PHP_SUBST(APXS)
  241. PHP_SUBST(APXS_LDFLAGS)
  242. PHP_SUBST(APACHE_INSTALL)
  243. PHP_SUBST(STRONGHOLD)
  244. fi
  245. dnl ## Local Variables:
  246. dnl ## tab-width: 4
  247. dnl ## End: