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