Add Brotli dependency and required checks.

Brotli is required for decompressing WOFF2 font directory streams.
The library is thus being added as an optional dependency for FreeType.

* builds/unix/configure.raw: Add checks for `libbrotlidec'.

* devel/ftoption.h, include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_BROTLI): New macro.
This commit is contained in:
Nikhil Ramakrishnan 2019-06-28 01:01:17 +05:30
parent 47f009d703
commit 8e05ab3e2e
3 changed files with 88 additions and 1 deletions

View File

@ -543,6 +543,50 @@ if test x"$with_harfbuzz" = xyes -a "$have_harfbuzz" = no; then
fi
# check for system libbrotlidec
AC_ARG_WITH([libbrotlidec],
[AS_HELP_STRING([--with-brotli=@<:@yes|no|auto@:>@],
[Support decompression of WOFF2 streams @<:@default=auto@:>@])],
[], [with_brotli=auto])
have_brotli=no
if test x"$with_brotli" = xyes -o x"$with_brotli" = xauto; then
brotli_pkg="libbrotlidec"
have_brotli_pkg=no
if test x"$BROTLI_CFLAGS" = x -a x"$BROTLI_LIBS" = x; then
PKG_CHECK_EXISTS([$brotli_pkg], [have_brotli_pkg=yes])
fi
PKG_CHECK_MODULES([BROTLI], [$brotli_pkg],
[have_brotli="yes (pkg-config)"], [:])
if test $have_brotli_pkg = yes; then
# we have libbrotlidec.pc
brotli_reqpriv="$brotli_pkg"
brotli_libspriv=
brotli_libsstaticconf=`$PKG_CONFIG --static --libs "$brotli_pkg"`
else
brotli_reqpriv=
if test "$have_brotli" != no; then
# BROTLI_CFLAGS and BROTLI_LIBS are set by the user
brotli_libspriv="$BROTLI_LIBS"
brotli_libsstaticconf="$BROTLI_LIBS"
have_brotli="yes (BROTLI_CFLAGS and BROTLI_LIBS)"
else
# since Brotli is quite a new library we don't fall back to a
# different test;
:
fi
fi
fi
if test x"$with_brotli" = xyes -a "$have_brotli" = no; then
AC_MSG_ERROR([brotli support requested but library not found])
fi
# check for librt
#
# We need `clock_gettime' for the `ftbench' demo program.
@ -992,7 +1036,8 @@ fi
REQUIRES_PRIVATE="$zlib_reqpriv, \
$bzip2_reqpriv, \
$libpng_reqpriv, \
$harfbuzz_reqpriv"
$harfbuzz_reqpriv, \
$brotli_reqpriv"
# beautify
REQUIRES_PRIVATE=`echo "$REQUIRES_PRIVATE" \
| sed -e 's/^ *//' \
@ -1007,6 +1052,7 @@ LIBS_PRIVATE="$zlib_libspriv \
$bzip2_libspriv \
$libpng_libspriv \
$harfbuzz_libspriv \
$brotli_libspriv \
$ft2_extra_libs"
# beautify
LIBS_PRIVATE=`echo "$LIBS_PRIVATE" \
@ -1019,6 +1065,7 @@ LIBSSTATIC_CONFIG="-lfreetype \
$bzip2_libsstaticconf \
$libpng_libsstaticconf \
$harfbuzz_libsstaticconf \
$brotli_libsstaticconf \
$ft2_extra_libs"
# remove -L/usr/lib and -L/usr/lib64 since `freetype-config' adds them later
# on if necessary; also beautify
@ -1083,6 +1130,13 @@ if test "$have_harfbuzz" != no; then
else
ftoption_unset FT_CONFIG_OPTION_USE_HARFBUZZ
fi
if test "$have_brotli" != no; then
CFLAGS="$CFLAGS $BROTLI_CFLAGS"
LDFLAGS="$LDFLAGS $BROTLI_LIBS"
ftoption_set FT_CONFIG_OPTION_USE_BROTLI
else
ftoption_unset FT_CONFIG_OPTION_USE_BROTLI
fi
AC_SUBST([CFLAGS])
AC_SUBST([LDFLAGS])
@ -1129,6 +1183,7 @@ Library configuration:
bzip2: $have_bzip2
libpng: $have_libpng
harfbuzz: $have_harfbuzz
brotli: $have_brotli
])
# Warn if docwriter is not installed

View File

@ -292,6 +292,22 @@ FT_BEGIN_HEADER
#define FT_CONFIG_OPTION_USE_HARFBUZZ
/**************************************************************************
*
* Brotli support.
*
* FreeType uses the Brotli library to provide support for decompressing
* WOFF2 streams.
*
* Define this macro if you want to enable this 'feature'.
*
* If you use a build system like cmake or the `configure` script,
* options set by those programs have precedence, overwriting the value
* here with the configured one.
*/
#define FT_CONFIG_OPTION_USE_BROTLI
/**************************************************************************
*
* Glyph Postscript Names handling

View File

@ -292,6 +292,22 @@ FT_BEGIN_HEADER
/* #define FT_CONFIG_OPTION_USE_HARFBUZZ */
/**************************************************************************
*
* Brotli support.
*
* FreeType uses the Brotli library to provide support for decompressing
* WOFF2 streams.
*
* Define this macro if you want to enable this 'feature'.
*
* If you use a build system like cmake or the `configure` script,
* options set by those programs have precedence, overwriting the value
* here with the configured one.
*/
#define FT_CONFIG_OPTION_USE_BROTLI
/**************************************************************************
*
* Glyph Postscript Names handling