configure.ac         |   62 ++++++++++++++-------------------------------------
 m4/libo_externals.m4 |   12 ++++++---
 2 files changed, 26 insertions(+), 48 deletions(-)

New commits:
commit be7a238c33dc02dfba40b2ad60485a56f4685d26
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Tue Dec 7 05:19:01 2021 +0100
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Mon Sep 26 20:54:56 2022 +0200

    Simplify FONTCONFIG and FREETYPE tests
    
    Add an additional option to libo_CHECK_SYSTEM_MODULE to select
    the default external lookup.
    
    Don't "if" the libo_CHECK_SYSTEM_MODULE, so the AC_SUBST are
    always run, but set the test_* flags instead.
    
    Change-Id: Ie0a1204b34d596fdd57a7ee770418f91bf8c5d00
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126464
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140050
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tor Lillqvist <t...@collabora.com>

diff --git a/configure.ac b/configure.ac
index 910c6f6655b9..c4de07a897b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1171,6 +1171,9 @@ if test "$using_freetype_fontconfig" = yes; then
         AC_DEFINE(ENABLE_HEADLESS)
         ENABLE_HEADLESS=TRUE
     fi
+else
+    test_fontconfig=no
+    test_freetype=no
 fi
 
 AC_SUBST(ENABLE_HEADLESS)
@@ -5863,23 +5866,7 @@ fi
 
 AC_SUBST(ENABLE_CUPS)
 
-# fontconfig checks
-if test "$using_freetype_fontconfig" = yes; then
-    AC_MSG_CHECKING([which fontconfig to use])
-fi
-if test "$using_freetype_fontconfig" = yes -a "$test_system_fontconfig" != no; 
then
-    AC_MSG_RESULT([external])
-    PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.4.1])
-    SYSTEM_FONTCONFIG=TRUE
-    FilterLibs "${FONTCONFIG_LIBS}"
-    FONTCONFIG_LIBS="${filteredlibs}"
-elif test "$using_freetype_fontconfig" = yes; then
-    AC_MSG_RESULT([internal])
-    BUILD_TYPE="$BUILD_TYPE FONTCONFIG"
-fi
-AC_SUBST(FONTCONFIG_CFLAGS)
-AC_SUBST(FONTCONFIG_LIBS)
-AC_SUBST([SYSTEM_FONTCONFIG])
+libo_CHECK_SYSTEM_MODULE([fontconfig],[FONTCONFIG],[fontconfig >= 
2.4.1],,,TRUE)
 
 dnl whether to find & fetch external tarballs?
 dnl ===================================================================
@@ -9511,38 +9498,25 @@ fi
 
 dnl ===================================================================
 dnl Check whether freetype is available
+dnl
+dnl FreeType has 3 different kinds of versions
+dnl * release, like 2.4.10
+dnl * libtool, like 13.0.7 (this what pkg-config returns)
+dnl * soname
+dnl FreeType's docs/VERSION.DLL provides a table mapping between the three
+dnl
+dnl 9.9.3 is 2.2.0
+dnl When the minimal version is at least 2.8.1, remove Skia's check down below.
 dnl ===================================================================
-if test "$using_freetype_fontconfig" = yes; then
-    AC_MSG_CHECKING([which freetype to use])
-fi
-if test "$using_freetype_fontconfig" = yes -a "$test_system_freetype" != no; 
then
-    AC_MSG_RESULT([external])
-    # FreeType has 3 different kinds of versions
-    # * release, like 2.4.10
-    # * libtool, like 13.0.7 (this what pkg-config returns)
-    # * soname
-    # FreeType's docs/VERSION.DLL provides a table mapping between the three
-    #
-    # 9.9.3 is 2.2.0
-    # When the minimal version is at least 2.8.1, remove Skia's check down 
below.
-    PKG_CHECK_MODULES(FREETYPE, freetype2 >= 9.9.3)
-    FREETYPE_CFLAGS=$(printf '%s' "$FREETYPE_CFLAGS" | sed -e 
"s/-I/${ISYSTEM?}/g")
-    FilterLibs "${FREETYPE_LIBS}"
-    FREETYPE_LIBS="${filteredlibs}"
-    SYSTEM_FREETYPE=TRUE
-elif test "$using_freetype_fontconfig" = yes; then
-    AC_MSG_RESULT([internal])
-    FREETYPE_CFLAGS="${ISYSTEM}${WORKDIR}/UnpackedTarball/freetype/include"
+if test "$test_freetype" != no; then
     if test "x$ac_config_site_64bit_host" = xYES; then
-        FREETYPE_LIBS="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib64 
-lfreetype"
+        
FREETYPE_LIBS_INTERNAL="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib64 
-lfreetype"
     else
-        FREETYPE_LIBS="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib 
-lfreetype"
+        
FREETYPE_LIBS_INTERNAL="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib 
-lfreetype"
     fi
-    BUILD_TYPE="$BUILD_TYPE FREETYPE"
 fi
-AC_SUBST(FREETYPE_CFLAGS)
-AC_SUBST(FREETYPE_LIBS)
-AC_SUBST([SYSTEM_FREETYPE])
+libo_CHECK_SYSTEM_MODULE([freetype],[FREETYPE],[freetype2 >= 9.9.3],
+    
["${ISYSTEM}${WORKDIR}/UnpackedTarball/freetype/include"],["$FREETYPE_LIBS_INTERNAL"],TRUE)
 
 # ===================================================================
 # Check for system libxslt
diff --git a/m4/libo_externals.m4 b/m4/libo_externals.m4
index d19178ab8250..b2b314fec933 100644
--- a/m4/libo_externals.m4
+++ b/m4/libo_externals.m4
@@ -6,15 +6,19 @@ dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; 
fill-column: 102 -*
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
+# <lowercase check>,<variable prefix>,<pkg-config query>,
+#     <internal CFLAGS>,<internal LIBS>,<external (default: FALSE)>
 AC_DEFUN([libo_CHECK_SYSTEM_MODULE], [
 AC_ARG_WITH(system-$1,
-    AS_HELP_STRING([--with-system-$1],
-        [Use $1 from operating system instead of building and bundling it.]),,
-    [with_system_$1="$with_system_libs"])
+    
AS_HELP_STRING([m4_ifnblank([$6],[--without-system-$1],[--with-system-$1])],
+        [m4_ifnblank([$6],
+            Build and bundle the internal $1 instead of using the operating 
system one.,
+            Use $1 from the operating system instead of building and bundling 
it.)]),
+,[m4_ifnblank([$6],[with_system_$1="yes"],[with_system_$1="$with_system_libs"])])
 AC_MSG_CHECKING([which $1 to use])
 if test "$test_$1" != "no"; then
     ENABLE_$2=TRUE
-    if test "$with_system_$1" = "yes"; then
+    if test "$with_system_$1" = yes -a "$test_system_$1" != no; then
         AC_MSG_RESULT([external])
         SYSTEM_$2=TRUE
         PKG_CHECK_MODULES([$2], [$3])

Reply via email to