trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject [trafficserver] branch 7.1.x updated: allow for specifying of brotli via --enable-brotli= or pkg-config
Date Wed, 28 Mar 2018 14:33:15 GMT
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/7.1.x by this push:
     new c066529  allow for specifying of brotli via --enable-brotli= or pkg-config
c066529 is described below

commit c0665292b1e4f5c41d0f8b51b33f9e59953d97b3
Author: Randall Meyer <randallmeyer@yahoo.com>
AuthorDate: Thu Mar 8 10:18:13 2018 -0800

    allow for specifying of brotli via --enable-brotli= or pkg-config
    
    Addresses issue #2946
    
    (cherry picked from commit de6e9f917fa007a582853fb46dc2234fac63b000)
---
 build/brotli.m4           | 95 +++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac              | 10 ++---
 plugins/gzip/Makefile.inc |  1 +
 3 files changed, 100 insertions(+), 6 deletions(-)

diff --git a/build/brotli.m4 b/build/brotli.m4
new file mode 100644
index 0000000..1984552
--- /dev/null
+++ b/build/brotli.m4
@@ -0,0 +1,95 @@
+dnl -------------------------------------------------------- -*- autoconf -*-
+dnl Licensed to the Apache Software Foundation (ASF) under one or more
+dnl contributor license agreements.  See the NOTICE file distributed with
+dnl this work for additional information regarding copyright ownership.
+dnl The ASF licenses this file to You under the Apache License, Version 2.0
+dnl (the "License"); you may not use this file except in compliance with
+dnl the License.  You may obtain a copy of the License at
+dnl
+dnl     http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+
+dnl
+dnl brotli.m4: Trafficserver's brotli autoconf macros
+dnl
+
+dnl
+dnl TS_CHECK_BROTLI: look for brotli libraries and headers
+dnl
+AC_DEFUN([TS_CHECK_BROTLI], [
+has_brotli=0
+AC_ARG_WITH(brotli, [AC_HELP_STRING([--with-brotli=DIR],[use a specific brotli library])],
+[
+  if test "x$withval" != "xyes" && test "x$withval" != "x"; then
+    brotli_base_dir="$withval"
+    if test "$withval" != "no"; then
+      has_brotli=1
+      case "$withval" in
+      *":"*)
+        brotli_include="`echo $withval |sed -e 's/:.*$//'`"
+        brotli_ldflags="`echo $withval |sed -e 's/^.*://'`"
+        AC_MSG_CHECKING(checking for brotli includes in $brotli_include libs in $brotli_ldflags
)
+        ;;
+      *)
+        brotli_include="$withval/include"
+        brotli_ldflags="$withval/lib"
+        AC_MSG_CHECKING(checking for brotli includes in $withval)
+        ;;
+      esac
+    fi
+  fi
+
+  if test -d $brotli_include && test -d $brotli_ldflags && test -f $brotli_include/brotli/encode.h;
then
+    AC_MSG_RESULT([ok])
+  else
+    AC_MSG_RESULT([not found])
+  fi
+
+if test "$has_brotli" != "0"; then
+  saved_ldflags=$LDFLAGS
+  saved_cppflags=$CPPFLAGS
+  brotli_have_headers=0
+  brotli_have_libs=0
+  if test "$brotli_base_dir" != "/usr"; then
+    TS_ADDTO(CPPFLAGS, [-I${brotli_include}])
+    TS_ADDTO(LDFLAGS, [-L${brotli_ldflags}])
+    TS_ADDTO_RPATH(${brotli_ldflags})
+  fi
+
+  AC_CHECK_LIB([brotlienc], BrotliEncoderCreateInstance, [brotli_have_libs=1])
+  if test "$brotli_have_libs" != "0"; then
+    AC_CHECK_HEADERS(brotli/encode.h, [brotli_have_headers=1])
+  fi
+  if test "$brotli_have_headers" != "0"; then
+    AC_SUBST([LIB_BROTLIENC], [-lbrotlienc])
+    AC_SUBST([CFLAGS_BROTLIENC], [-I${brotli_include}])
+  else
+    has_brotli=0
+    CPPFLAGS=$saved_cppflags
+    LDFLAGS=$saved_ldflags
+  fi
+fi
+],
+[
+AC_CHECK_HEADER([brotli/encode.h], [], [has_brotli=0])
+AC_CHECK_LIB([brotlienc], BrotliEncoderCreateInstance, [], [has_brotli=0])
+
+if test "x$has_brotli" == "x0"; then
+    PKG_CHECK_EXISTS([libbrotlienc],
+    [
+      PKG_CHECK_MODULES([libbrotlienc], [libbrotlienc >= 0.6.0], [
+        AC_SUBST([LIB_BROTLIENC], [$libbrotlienc_LIBS])
+        AC_SUBST([CFLAGS_BROTLIENC], [$libbrotlienc_CFLAGS])
+      ], [])
+    ], [])
+else
+    AC_SUBST([LIB_BROTLIENC], [-lbrotlienc])
+fi
+])
+
+])
diff --git a/configure.ac b/configure.ac
index d74ddec..9e1364a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1221,11 +1221,8 @@ if test "x${enable_pcre}" != "xyes"; then
   AC_MSG_ERROR([Cannot find pcre library. Configure --with-pcre=DIR])
 fi
 
-# Check Brotli
-AC_CHECK_HEADERS([brotli/encode.h], [has_brotli=1],[has_brotli=0])
-AC_CHECK_LIB([brotlienc],[BrotliEncoderCreateInstance],[AC_SUBST([LIB_BROTLIENC],["-lbrotlienc"])],[has_brotli=0])
-AC_SUBST(has_brotli)
-AM_CONDITIONAL([HAS_BROTLI], [ test "x${has_brotli}" = "x1" ])
+# Check for optional brotli library
+TS_CHECK_BROTLI
 
 # Check for backtrace() support
 has_backtrace=0
@@ -1994,6 +1991,7 @@ AC_MSG_NOTICE([Build option summary:
     CC:                 $CC
     CXX:                $CXX
     CPP:                $CPP
+    CPPFLAGS:           $CPPFLAGS
     AM@&t@_CFLAGS:          $AM_CFLAGS
     AM@&t@_CXXFLAGS:        $AM_CXXFLAGS
     AM@&t@_CPPFLAGS:        $AM_CPPFLAGS
@@ -2005,6 +2003,6 @@ AC_MSG_NOTICE([Build option summary:
     OPENSSL_LDFLAGS:    $OPENSSL_LDFLAGS
     OPENSSL_INCLUDES:   $OPENSSL_INCLUDES
     LUAJIT_CFLAGS:      $LUAJIT_CFLAGS
-    LUAJIT_CPPFLAGS:	$LUAJIT_CPPFLAGS
+    LUAJIT_CPPFLAGS:    $LUAJIT_CPPFLAGS
     LUAJIT_LDFLAGS:     $LUAJIT_LDFLAGS
 ])
diff --git a/plugins/gzip/Makefile.inc b/plugins/gzip/Makefile.inc
index 8762e21..019e37f 100644
--- a/plugins/gzip/Makefile.inc
+++ b/plugins/gzip/Makefile.inc
@@ -20,3 +20,4 @@ gzip_gzip_la_SOURCES = gzip/gzip.cc gzip/configuration.cc gzip/misc.cc
 gzip_gzip_la_LDFLAGS = \
   $(AM_LDFLAGS) $(LIB_BROTLIENC)
 
+gzip_gzip_la_CFLAGS = $(AM_CFLAGS) $(CFLAGS_BROTLIENC)

-- 
To stop receiving notification emails like this one, please contact
zwoop@apache.org.

Mime
View raw message