xref: /PHP-5.5/sapi/apache2filter/config.m4 (revision 8d86597d)
1dnl
2dnl $Id$
3dnl
4
5PHP_ARG_WITH(apxs2filter,,
6[  --with-apxs2filter[=FILE]
7                          EXPERIMENTAL: Build shared Apache 2.0 Filter module. FILE is the optional
8                          pathname to the Apache apxs tool [apxs]], no, no)
9
10AC_MSG_CHECKING([for Apache 2.0 filter-module support via DSO through APXS])
11
12if test "$PHP_APXS2FILTER" != "no"; then
13  if test "$PHP_APXS2FILTER" = "yes"; then
14    APXS=apxs
15    $APXS -q CFLAGS >/dev/null 2>&1
16    if test "$?" != "0" && test -x /usr/sbin/apxs; then
17      APXS=/usr/sbin/apxs
18    fi
19  else
20    PHP_EXPAND_PATH($PHP_APXS2FILTER, APXS)
21  fi
22
23  $APXS -q CFLAGS >/dev/null 2>&1
24  if test "$?" != "0"; then
25    AC_MSG_RESULT()
26    AC_MSG_RESULT()
27    AC_MSG_RESULT([Sorry, I cannot run apxs.  Possible reasons follow:])
28    AC_MSG_RESULT()
29    AC_MSG_RESULT([1. Perl is not installed])
30    AC_MSG_RESULT([2. apxs was not found. Try to pass the path using --with-apxs2filter=/path/to/apxs])
31    AC_MSG_RESULT([3. Apache was not built using --enable-so (the apxs usage page is displayed)])
32    AC_MSG_RESULT()
33    AC_MSG_RESULT([The output of $APXS follows:])
34    $APXS -q CFLAGS
35    AC_MSG_ERROR([Aborting])
36  fi
37
38  APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR`
39  APXS_BINDIR=`$APXS -q BINDIR`
40  APXS_HTTPD=`$APXS -q SBINDIR`/`$APXS -q TARGET`
41  APXS_CFLAGS=`$APXS -q CFLAGS`
42  APU_BINDIR=`$APXS -q APU_BINDIR`
43  APR_BINDIR=`$APXS -q APR_BINDIR`
44
45  # Pick up ap[ru]-N-config if using httpd >=2.1
46  APR_CONFIG=`$APXS -q APR_CONFIG 2>/dev/null ||
47    echo $APR_BINDIR/apr-config`
48  APU_CONFIG=`$APXS -q APU_CONFIG 2>/dev/null ||
49    echo $APU_BINDIR/apu-config`
50
51  APR_CFLAGS="`$APR_CONFIG --cppflags --includes`"
52  APU_CFLAGS="`$APU_CONFIG --includes`"
53
54  for flag in $APXS_CFLAGS; do
55    case $flag in
56    -D*) APACHE_CPPFLAGS="$APACHE_CPPFLAGS $flag";;
57    esac
58  done
59
60  APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS"
61
62  # Test that we're trying to configure with apache 2.x
63  PHP_AP_EXTRACT_VERSION($APXS_HTTPD)
64  if test "$APACHE_VERSION" -le 2000000; then
65    AC_MSG_ERROR([You have enabled Apache 2 support while your server is Apache 1.3.  Please use the appropriate switch --with-apxs (without the 2)])
66  elif test "$APACHE_VERSION" -lt 2000040; then
67    AC_MSG_ERROR([Please note that Apache version >= 2.0.40 is required])
68  fi
69
70  APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR`
71  if test -z `$APXS -q SYSCONFDIR`; then
72    INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
73                 $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
74                       -i -n php5"
75  else
76    APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR`
77    INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
78                \$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
79                 $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
80                       -S SYSCONFDIR='$APXS_SYSCONFDIR' \
81                       -i -a -n php5"
82  fi
83
84  case $host_alias in
85  *aix*)
86    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
87    PHP_SELECT_SAPI(apache2filter, shared, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
88    INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
89    ;;
90  *darwin*)
91    dnl When using bundles on Darwin, we must resolve all symbols.  However,
92    dnl the linker does not recursively look at the bundle loader and
93    dnl pull in its dependencies.  Therefore, we must pull in the APR
94    dnl and APR-util libraries.
95    if test -x "$APR_CONFIG"; then
96        MH_BUNDLE_FLAGS="`$APR_CONFIG --ldflags --link-ld --libs`"
97    fi
98    if test -x "$APU_CONFIG"; then
99        MH_BUNDLE_FLAGS="`$APU_CONFIG --ldflags --link-ld --libs` $MH_BUNDLE_FLAGS"
100    fi
101    MH_BUNDLE_FLAGS="-bundle -bundle_loader $APXS_HTTPD $MH_BUNDLE_FLAGS"
102    PHP_SUBST(MH_BUNDLE_FLAGS)
103    PHP_SELECT_SAPI(apache2filter, bundle, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
104    SAPI_SHARED=libs/libphp5.so
105    INSTALL_IT="$INSTALL_IT $SAPI_SHARED"
106    ;;
107  *beos*)
108    if test -f _APP_; then `rm _APP_`; fi
109    `ln -s $APXS_BINDIR/httpd _APP_`
110    EXTRA_LIBS="$EXTRA_LIBS _APP_"
111    PHP_SELECT_SAPI(apache2filter, shared, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
112    INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
113    ;;
114  *)
115    PHP_SELECT_SAPI(apache2filter, shared, sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
116    INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
117    ;;
118  esac
119
120  if test "$APACHE_VERSION" -lt 2004001; then
121    APXS_MPM=`$APXS -q MPM_NAME`
122    if test "$APXS_MPM" != "prefork" && test "$APXS_MPM" != "peruser" && test "$APXS_MPM" != "itk"; then
123      PHP_BUILD_THREAD_SAFE
124    fi
125  else
126    APACHE_THREADED_MPM=`$APXS_HTTPD -V | grep 'threaded:.*yes'`
127    if test -n "$APACHE_THREADED_MPM"; then
128      PHP_BUILD_THREAD_SAFE
129    fi
130  fi
131  AC_MSG_RESULT(yes)
132  PHP_SUBST(APXS)
133else
134  AC_MSG_RESULT(no)
135fi
136
137dnl ## Local Variables:
138dnl ## tab-width: 4
139dnl ## End:
140