freetype/fontconfig: ignore --without-system-libs

Since commit 8677e994d37329a28ca8278358a99d18b9cada69 ("Simplify
FONTCONFIG and FREETYPE tests"), these tests adhered to the
${with_system_libs} setting, which might not be desirable.

As a result commit 4e7f3692c9eb42a00797025289782baa69a42cc7
("Make external/freetype use -fPIC") is needed as a linking fix.

This still keeps the possibility to build with internal freetype
and fontconfig. This also adds a new macro option, "test-system",
which follows the $test_system_* variable without additional
configure switches.

Change-Id: Ifed91fdc6e4a77f708a3dbbd784b6069bf2a61b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127878
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
diff --git a/configure.ac b/configure.ac
index 9aa2243..e31f755 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1146,6 +1146,7 @@ test "${test_xrender+set}" = set || test_xrender="$using_x11"
test "${using_headless_plugin+set}" = set || using_headless_plugin="$using_freetype_fontconfig"

test "${test_gtk3_kde5+set}" != set -a "$test_kf5" = yes -a "$test_gtk3" = yes && test_gtk3_kde5="yes"
# Make sure fontconfig and freetype test both either system or not
test "${test_system_fontconfig+set}" != set -a "${test_system_freetype+set}" = set && test_system_fontconfig="$test_system_freetype"
test "${test_system_freetype+set}" != set -a "${test_system_fontconfig+set}" = set && test_system_freetype="$test_system_fontconfig"

@@ -5869,7 +5870,7 @@ fi

AC_SUBST(ENABLE_CUPS)

libo_CHECK_SYSTEM_MODULE([fontconfig],[FONTCONFIG],[fontconfig >= 2.4.1],,system)
libo_CHECK_SYSTEM_MODULE([fontconfig],[FONTCONFIG],[fontconfig >= 2.4.1],,system,TRUE)

dnl whether to find & fetch external tarballs?
dnl ===================================================================
@@ -9458,7 +9459,7 @@ if test "x$ac_config_site_64bit_host" = xYES; then
else
    FREETYPE_LIBS_internal="-L${WORKDIR}/UnpackedTarball/freetype/instdir/lib -lfreetype"
fi
libo_CHECK_SYSTEM_MODULE([freetype],[FREETYPE],[freetype2 >= 9.9.3],,system)
libo_CHECK_SYSTEM_MODULE([freetype],[FREETYPE],[freetype2 >= 9.9.3],,system,TRUE)

# ===================================================================
# Check for system libxslt
diff --git a/m4/libo_externals.m4 b/m4/libo_externals.m4
index 96a4586..07df27f 100644
--- a/m4/libo_externals.m4
+++ b/m4/libo_externals.m4
@@ -10,9 +10,11 @@ dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; fill-column: 102 -*
# <$2 uppercase variable part - used for configure.ac and make variables>
# <$3 pkg-config query string>
# [$4 if optional, default to: enabled, disabled or fixed (default: fixed)]
# [$5 which is preferred: system, fixed-system, internal or fixed-internal (default: internal)]
# [$5 which is preferred: (fixed-|test-)system or (fixed-)internal (default: internal)]
# [$6 ignore $with_system_libs: TRUE or blank (default: blank/false)]
#
# fixed == fixed-enabled, as fixed-disabled makes no sense.
# $4 fixed: fixed-enabled, as fixed-disabled makes no sense.
# $5 test-system: follows $test_system_$1, ignors $with_system_libs; no configure switch
#
# Used configure.ac variables:
#  - $2_(CFLAGS|LIBS)_internal: must be filled to match the internal build
@@ -26,7 +28,7 @@ dnl -*- Mode: Autoconf; tab-width: 4; indent-tabs-mode: nil; fill-column: 102 -*
#

m4_define([csm_default_with], [
    if test "${with_system_$1+set}" != set -a "${with_system_libs+set}" = set; then
    if test "${with_system_$1+set}" != set -a "${with_system_libs+set}" = set -a "$3" != TRUE; then
        with_system_$1="$with_system_libs";
    else
        with_system_$1="$2"
@@ -43,6 +45,7 @@ AC_DEFUN([libo_CHECK_SYSTEM_MODULE], [
csm_check_required([1],[$1],m4_tolower([$1]),[lowercase])
csm_check_required([2],[$2],m4_toupper([$2]),[uppercase])
m4_ifblank([$3],[m4_fatal([$][3 is the pkg-config query and must not be blank])])
m4_if([$6],[TRUE],[],[m4_ifnblank([$6],[m4_fatal([$][6 must be TRUE or blank])])])
m4_if(
    [$4],[enabled],[
        AC_ARG_ENABLE([$1],
@@ -61,17 +64,19 @@ m4_if(
    [$5],[system],[
        AC_ARG_WITH(system-$1,
            AS_HELP_STRING([--without-system-$1],[Build and bundle the internal $1.]),
        ,[csm_default_with($1,yes)])
        ,[csm_default_with($1,yes,$6)])
    ],[$5],[test-system],[
        with_system_$1="$test_system_$1"
    ],[$5],[fixed-system],[
        with_system_$1=yes
    ],[$5],[fixed-internal],[
        with_system_$1=no
    ],[
        m4_if([$5],[internal],,[m4_ifnblank([$5],
              [m4_fatal([$$5 ($5) must be "(fixed-)system", "(fixed-)internal" or empty (=internal)])])])
              [m4_fatal([$$5 ($5) must be "(fixed-|test-)system", "(fixed-)internal" or empty (=internal)])])])
        AC_ARG_WITH(system-$1,
            AS_HELP_STRING([--with-system-$1],[Use $1 from the operating system.]),
        ,[csm_default_with($1,no)])
        ,[csm_default_with($1,no,$6)])
])

AC_MSG_CHECKING([which $1 to use])