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