Commit 852144d1 authored by Evgeny Kotkov's avatar Evgeny Kotkov
Browse files

Create a backport branch with r1761824, r1771789, r1771827 and r1779111

applied to 2.4.x.

These are the mod_brotli related Makefile changes that didn't make it
into the original backport proposal merged in r1791231.  The lack of these
changes causes a failing Unix build in my environment if mod_brotli is not
being built.  Another issue is that by default the CMakeLists.txt file
refers to invalid library filenames.

Shortlog of the changes:

    r1761824: Unbreak building other filter modules without libbrotlienc.

    r1771789: Rewrite the autoconf script in a, hopefully, less convoluted way.
    This lays the groundwork to simplify the switch to the official Brotli
    library.

    r1771827: Update makefiles to use the library layout of the official
    Brotli repository.

    r1779111: Update makefile to cope with the pkg-config layout change
    in https://github.com/google/brotli/commit/fe9f9a9

Also see https://lists.apache.org/thread.html/a83741642c3d20f383efdf2c427829b2f37cb81e98c0a1756a2c19ce@%3Cdev.httpd.apache.org%3E


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x-r1761824-group@1792805 13f79535-47bb-0310-9956-ffa450edef68
parent 9550ca92
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -58,8 +58,8 @@ ELSE()
  SET(default_nghttp2_libraries "${CMAKE_INSTALL_PREFIX}/lib/nghttp2.lib")
  SET(default_nghttp2_libraries "${CMAKE_INSTALL_PREFIX}/lib/nghttp2.lib")
ENDIF()
ENDIF()


IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/brotli_enc.lib")
IF(EXISTS "${CMAKE_INSTALL_PREFIX}/lib/brotlienc.lib")
  SET(default_brotli_libraries "${CMAKE_INSTALL_PREFIX}/lib/brotli_enc.lib" "${CMAKE_INSTALL_PREFIX}/lib/brotli_common.lib")
  SET(default_brotli_libraries "${CMAKE_INSTALL_PREFIX}/lib/brotlienc.lib" "${CMAKE_INSTALL_PREFIX}/lib/brotlicommon.lib")
ELSE()
ELSE()
  SET(default_brotli_libraries)
  SET(default_brotli_libraries)
ENDIF()
ENDIF()
+43 −113
Original line number Original line Diff line number Diff line
@@ -140,125 +140,55 @@ APACHE_MODULE(proxy_html, Fix HTML Links in a Reverse Proxy, , , , [
]
]
)
)


dnl
APACHE_MODULE(brotli, Brotli compression support, , , most, [
dnl APACHE_CHECK_BROTLI
dnl
dnl Configure for Brotli, giving preference to
dnl "--with-brotli=<path>" if it was specified.
dnl
AC_DEFUN([APACHE_CHECK_BROTLI],[
  AC_CACHE_CHECK([for Brotli], [ac_cv_brotli], [
    dnl initialise the variables we use
    ac_cv_brotli=no
    ac_brotli_found=""
    ac_brotli_base=""
    ac_brotli_libs=""
    ac_brotli_mod_cflags=""
    ac_brotli_mod_ldflags=""

    dnl Determine the Brotli base directory, if any
    AC_MSG_CHECKING([for user-provided Brotli base directory])
  AC_ARG_WITH(brotli, APACHE_HELP_STRING(--with-brotli=PATH,Brotli installation directory),[
  AC_ARG_WITH(brotli, APACHE_HELP_STRING(--with-brotli=PATH,Brotli installation directory),[
      dnl If --with-brotli specifies a directory, we use that directory
    if test "$withval" != "yes" -a "x$withval" != "x"; then
      if test "x$withval" != "xyes" -a "x$withval" != "x"; then
      ap_brotli_base="$withval"
        dnl This ensures $withval is actually a directory and that it is absolute
      ap_brotli_with=yes
        ac_brotli_base="`cd $withval ; pwd`"
    fi
    fi
  ])
  ])
    if test "x$ac_brotli_base" = "x"; then
  ap_brotli_found=no
      AC_MSG_RESULT(none)
  if test -n "$ap_brotli_base"; then
    ap_save_cppflags=$CPPFLAGS
    APR_ADDTO(CPPFLAGS, [-I${ap_brotli_base}/include])
    AC_MSG_CHECKING([for Brotli library >= 0.6.0 via prefix])
    AC_TRY_COMPILE(
      [#include <brotli/encode.h>],[
const uint8_t *o = BrotliEncoderTakeOutput((BrotliEncoderState*)0, (size_t*)0);
if (o) return *o;],
      [AC_MSG_RESULT(yes)
       ap_brotli_found=yes
       ap_brotli_cflags="-I${ap_brotli_base}/include"
       ap_brotli_libs="-L${ap_brotli_base}/lib -lbrotlienc -lbrotlicommon"],
      [AC_MSG_RESULT(no)]
    )
    CPPFLAGS=$ap_save_cppflags
  else
  else
      AC_MSG_RESULT($ac_brotli_base)
    fi

    dnl Run header and version checks
    saved_CPPFLAGS="$CPPFLAGS"
    saved_LIBS="$LIBS"
    saved_LDFLAGS="$LDFLAGS"

    dnl Before doing anything else, load in pkg-config variables
    if test -n "$PKGCONFIG"; then
    if test -n "$PKGCONFIG"; then
      saved_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
      AC_MSG_CHECKING([for Brotli library >= 0.6.0 via pkg-config])
      if test "x$ac_brotli_base" != "x" -a \
      if $PKGCONFIG --exists "libbrotlienc >= 0.6.0"; then
              -f "${ac_brotli_base}/lib/pkgconfig/libbrotlienc.pc"; then
        AC_MSG_RESULT(yes)
        dnl Ensure that the given path is used by pkg-config too, otherwise
        ap_brotli_found=yes
        dnl the system libbrotlienc.pc might be picked up instead.
        ap_brotli_cflags=`$PKGCONFIG libbrotlienc --cflags`
        PKG_CONFIG_PATH="${ac_brotli_base}/lib/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
        ap_brotli_libs=`$PKGCONFIG libbrotlienc --libs`
        export PKG_CONFIG_PATH
      else
      fi
        AC_MSG_RESULT(no)
      ac_brotli_libs="`$PKGCONFIG --libs-only-l --silence-errors libbrotlienc`"
      if test $? -eq 0; then
        ac_brotli_found="yes"
        pkglookup="`$PKGCONFIG --cflags-only-I libbrotlienc`"
        APR_ADDTO(CPPFLAGS, [$pkglookup])
        APR_ADDTO(MOD_CFLAGS, [$pkglookup])
        pkglookup="`$PKGCONFIG --libs-only-L libbrotlienc`"
        APR_ADDTO(LDFLAGS, [$pkglookup])
        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
        pkglookup="`$PKGCONFIG --libs-only-other libbrotlienc`"
        APR_ADDTO(LDFLAGS, [$pkglookup])
        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
      fi
      PKG_CONFIG_PATH="$saved_PKG_CONFIG_PATH"
    fi

    dnl fall back to the user-supplied directory if not found via pkg-config
    if test "x$ac_brotli_base" != "x" -a "x$ac_brotli_found" = "x"; then
      APR_ADDTO(CPPFLAGS, [-I$ac_brotli_base/include])
      APR_ADDTO(MOD_CFLAGS, [-I$ac_brotli_base/include])
      APR_ADDTO(LDFLAGS, [-L$ac_brotli_base/lib])
      APR_ADDTO(MOD_LDFLAGS, [-L$ac_brotli_base/lib])
      if test "x$ap_platform_runtime_link_flag" != "x"; then
        APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ac_brotli_base/lib])
        APR_ADDTO(MOD_LDFLAGS, [$ap_platform_runtime_link_flag$ac_brotli_base/lib])
      fi
      fi
    fi
    fi

    ac_brotli_libs="${ac_brotli_libs:--lbrotlienc `$apr_config --libs`} "
    APR_ADDTO(MOD_LDFLAGS, [$ac_brotli_libs])
    APR_ADDTO(LIBS, [$ac_brotli_libs])

    dnl Run library and function checks
    liberrors=""
    AC_CHECK_HEADERS([brotli/encode.h])
    AC_MSG_CHECKING([for Brotli version >= 0.6.0])
    AC_TRY_COMPILE([#include <brotli/encode.h>],[
const uint8_t *o = BrotliEncoderTakeOutput((BrotliEncoderState*)0, (size_t*)0);
if (o) return *o;],
      [AC_MSG_RESULT(OK)
       ac_cv_brotli="yes"],
      [AC_MSG_RESULT(FAILED)])

    dnl restore
    CPPFLAGS="$saved_CPPFLAGS"
    LIBS="$saved_LIBS"
    LDFLAGS="$saved_LDFLAGS"

    dnl cache MOD_LDFLAGS, MOD_CFLAGS
    ac_brotli_mod_cflags=$MOD_CFLAGS
    ac_brotli_mod_ldflags=$MOD_LDFLAGS
  ])
  if test "x$ac_cv_brotli" = "xyes"; then
    APR_ADDTO(MOD_LDFLAGS, [$ac_brotli_mod_ldflags])

    dnl Ouch!  libbrotlienc.1.so doesn't link against libm.so (-lm),
    dnl although it should.  Workaround that in our LDFLAGS:

    APR_ADDTO(MOD_LDFLAGS, ["-lm"])
    APR_ADDTO(MOD_CFLAGS, [$ac_brotli_mod_cflags])
  fi
  fi
])
  if test "$ap_brotli_found" = "yes"; then

    APR_ADDTO(MOD_CFLAGS, [$ap_brotli_cflags])
APACHE_MODULE(brotli, Brotli compression support, , , most, [
    APR_ADDTO(MOD_BROTLI_LDADD, [$ap_brotli_libs])
  APACHE_CHECK_BROTLI
    if test "$enable_brotli" = "shared"; then
  if test "$ac_cv_brotli" = "yes" ; then
      dnl The only symbol which needs to be exported is the module
      if test "x$enable_brotli" = "xshared"; then
      dnl structure, so ask libtool to hide everything else:
         # The only symbol which needs to be exported is the module
         # structure, so ask libtool to hide everything else:
      APR_ADDTO(MOD_BROTLI_LDADD, [-export-symbols-regex brotli_module])
      APR_ADDTO(MOD_BROTLI_LDADD, [-export-symbols-regex brotli_module])
    fi
    fi
  else
  else
    enable_brotli=no
    enable_brotli=no
    if test "$ap_brotli_with" = "yes"; then
      AC_MSG_ERROR([Brotli library was missing or unusable])
    fi
  fi
  fi
])
])