xref: /PHP-8.4/sapi/apache2handler/config.m4 (revision 16e218a5)
1PHP_ARG_WITH([apxs2],
2  [whether to build Apache 2 handler module support via DSO through APXS],
3  [AS_HELP_STRING([[--with-apxs2[=FILE]]],
4    [Build shared Apache 2 handler module. FILE is the optional pathname to
5    the Apache apxs tool [apxs]])],
6  [no],
7  [no])
8
9if test "$PHP_APXS2" != "no"; then
10  AS_VAR_IF([PHP_APXS2], [yes], [
11    APXS=apxs
12    $APXS -q CFLAGS >/dev/null 2>&1
13    if test "$?" != "0" && test -x /usr/sbin/apxs; then
14      APXS=/usr/sbin/apxs
15    fi
16  ],
17  [PHP_EXPAND_PATH([$PHP_APXS2], [APXS])])
18
19  $APXS -q CFLAGS >/dev/null 2>&1
20  if test "$?" != "0"; then
21    AC_MSG_RESULT()
22    AC_MSG_RESULT()
23    AC_MSG_RESULT([Sorry, I cannot run apxs.  Possible reasons follow:])
24    AC_MSG_RESULT()
25    AC_MSG_RESULT([1. Perl is not installed])
26    AC_MSG_RESULT([2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs])
27    AC_MSG_RESULT([3. Apache was not built using --enable-so (the apxs usage page is displayed)])
28    AC_MSG_RESULT()
29    AC_MSG_RESULT([The output of $APXS follows:])
30    $APXS -q CFLAGS
31    AC_MSG_ERROR([Aborting])
32  fi
33
34  APXS_INCLUDEDIR=$($APXS -q INCLUDEDIR)
35  APXS_HTTPD=$($APXS -q SBINDIR)/$($APXS -q TARGET)
36  AS_IF([test ! -x "$APXS_HTTPD"], [AC_MSG_ERROR(m4_text_wrap([
37    $APXS_HTTPD executable not found. Please, install Apache HTTP Server
38    command-line utility.
39  ]))])
40
41  APXS_CFLAGS=$($APXS -q CFLAGS)
42  APU_BINDIR=$($APXS -q APU_BINDIR)
43  APR_BINDIR=$($APXS -q APR_BINDIR)
44
45  dnl Pick up ap[ru]-N-config.
46  APR_CONFIG=$($APXS -q APR_CONFIG 2>/dev/null || echo $APR_BINDIR/apr-config)
47  APU_CONFIG=$($APXS -q APU_CONFIG 2>/dev/null || 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    AS_CASE([$flag], [-D*], [APACHE_CPPFLAGS="$APACHE_CPPFLAGS $flag"])
54  done
55
56  dnl Check Apache version. The HTTPD_VERSION was added in Apache 2.4.17.
57  dnl Earlier versions can use the Apache HTTP Server command-line utility.
58  APACHE_VERSION=$($APXS -q HTTPD_VERSION 2>/dev/null)
59  AS_VAR_IF([APACHE_VERSION],, [
60    ac_output=$($APXS_HTTPD -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//')
61    ac_IFS=$IFS
62    IFS="- /.
63"
64    set $ac_output
65    IFS=$ac_IFS
66    APACHE_VERSION="$4.$5.$6"
67  ])
68  AS_VERSION_COMPARE([$APACHE_VERSION], [2.4.0],
69    [AC_MSG_ERROR([Please note that Apache version >= 2.4 is required])])
70
71  APXS_LIBEXECDIR='$(INSTALL_ROOT)'$($APXS -q LIBEXECDIR)
72  if test -z $($APXS -q SYSCONFDIR); then
73    INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
74                 $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
75                       -i -n php"
76  else
77    APXS_SYSCONFDIR='$(INSTALL_ROOT)'$($APXS -q SYSCONFDIR)
78    INSTALL_IT="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \
79                \$(mkinstalldirs) '$APXS_SYSCONFDIR' && \
80                 $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \
81                       -S SYSCONFDIR='$APXS_SYSCONFDIR' \
82                       -i -a -n php"
83  fi
84
85  LIBPHP_CFLAGS="-shared"
86  PHP_SUBST([LIBPHP_CFLAGS])
87
88  php_sapi_apache2handler_type=shared
89  AS_CASE([$host_alias],
90    [*aix*], [
91      EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
92      INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
93    ],
94    [*darwin*], [
95      dnl When using bundles on Darwin, we must resolve all symbols. However,
96      dnl the linker does not recursively look at the bundle loader and pull in
97      dnl its dependencies. Therefore, we must pull in the APR and APR-util
98      dnl libraries.
99      if test -x "$APR_CONFIG"; then
100        MH_BUNDLE_FLAGS="$($APR_CONFIG --ldflags --link-ld --libs)"
101      fi
102      if test -x "$APU_CONFIG"; then
103        MH_BUNDLE_FLAGS="$($APU_CONFIG --ldflags --link-ld --libs) $MH_BUNDLE_FLAGS"
104      fi
105      MH_BUNDLE_FLAGS="-bundle -bundle_loader $APXS_HTTPD $MH_BUNDLE_FLAGS"
106      PHP_SUBST([MH_BUNDLE_FLAGS])
107      php_sapi_apache2handler_type=bundle
108      INSTALL_IT="$INSTALL_IT $SAPI_SHARED"
109    ],
110    [INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"])
111
112  PHP_SELECT_SAPI([apache2handler],
113    [$php_sapi_apache2handler_type],
114    [mod_php.c sapi_apache2.c apache_config.c php_functions.c],
115    [
116      $APACHE_CPPFLAGS
117      -I$APXS_INCLUDEDIR
118      $APR_CFLAGS
119      $APU_CFLAGS
120      -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1
121    ])
122
123  AS_IF([$APXS_HTTPD -V 2>/dev/null | grep 'threaded:.*yes' >/dev/null 2>&1], [
124    APACHE_THREADED_MPM=yes
125    enable_zts=yes
126  ], [APACHE_THREADED_MPM=no])
127
128AC_CONFIG_COMMANDS([apache2handler], [AS_VAR_IF([enable_zts], [yes],,
129  [AS_VAR_IF([APACHE_THREADED_MPM], [no],
130    [AC_MSG_WARN([
131+--------------------------------------------------------------------+
132|                        *** WARNING ***                             |
133|                                                                    |
134| You have built PHP for Apache's current non-threaded MPM.          |
135| If you change Apache to use a threaded MPM you must reconfigure    |
136| PHP with --enable-zts                                              |
137+--------------------------------------------------------------------+
138  ])])])],
139  [APACHE_THREADED_MPM="$APACHE_THREADED_MPM"; enable_zts="$enable_zts"])
140fi
141