summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2021-12-24 12:01:56 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2021-12-30 02:12:50 +0100
commit299349ed74bae9cad9bbac9a62c4465b0972bd01 (patch)
tree75a904e897ac4aa4fa6875ea2bc740db691703a1 /m4
parent9749cabf7222dfcc74fa951e88a74dd4b301d97a (diff)
Further refine libo_CHECK_SYSTEM_MODULE
Adds the possibility to have default-disabled externals and various fixed variants. The reorganized option handling is also easier to follow. Can't use the newer m4_case, so this uses m4_if with multiple compares, but the code difference is minimal. This also swaps the 4th and 5th argument to reflect the precedence of "enabled" over the "system" handling. And since these now have multiple values, TRUE was replaces with more sensible strings. These and the other arguments are now checked, as possible. I've also thought about dropping the 2nd argument for m4_toupper, but that changes to much for just a minimal gain. Change-Id: I22e835d81f9288f22d42be36e939374f7a455599 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127424 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'm4')
-rw-r--r--m4/libo_externals.m490
1 files changed, 72 insertions, 18 deletions
diff --git a/m4/libo_externals.m4 b/m4/libo_externals.m4
index 64851d3541e2..19ad2bae532f 100644
--- a/m4/libo_externals.m4
+++ b/m4/libo_externals.m4
@@ -6,32 +6,76 @@ 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>,
-# <prefer external (default: FALSE)>,
-# <can be disabled (default: FALSE)>
+# <$1 lowercase variable part - used for variables and configure switches>
+# <$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)]
#
-# FALSE is actually a blank value, so TRUE matches any not-blank value.
+# fixed == fixed-enabled, as fixed-disabled makes no sense.
#
# Used configure.ac variables:
# - $2_(CFLAGS|LIBS)_internal: must be filled to match the internal build
# - enable_$1: should normally not be set manually; use test_$1 instead
+# - found_$1: other tests already provided external $2_CFLAGS and $2_LIBS
# - test_$1: set to no, if the feature shouldn't be tested at all
# - test_system_$1: set to no, if the system library should not be used
#
+# There is currently the AC_SUBST redundancy of
+# (SYSTEM_$2,TRUE) == (,$(filter $2,$(BUILD_TYPE)))
+#
+
+m4_define([csm_default_with], [
+ if test "${with_system_$1+set}" != set -a "${with_system_libs+set}" = set; then
+ with_system_$1="$with_system_libs";
+ else
+ with_system_$1="$2"
+ fi
+])
+
+m4_define([csm_check_required], [
+ m4_ifblank([$2],[m4_fatal([$][$1 ($2) must not be blank and $4])])
+ m4_if([$2],[$3],,[m4_fatal([$][$1 ($2) $3 must be $4])])
+])
+
AC_DEFUN([libo_CHECK_SYSTEM_MODULE], [
-AC_ARG_WITH(system-$1,
- AS_HELP_STRING([m4_ifnblank([$4],[--without-system-$1],[--with-system-$1])],
- m4_ifnblank([$4],
- [Build and bundle the internal $1.],
- [Use $1 from the operating system.])),
-,[m4_ifnblank([$4],[with_system_$1="yes"],[with_system_$1="$with_system_libs"])])
-m4_ifnblank([$5],[
- AC_ARG_ENABLE([$1],
- AS_HELP_STRING([--disable-$1],[Disable $1 support.]),
- ,[enable_$1="yes"])
+# validate arguments as possible
+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(
+ [$4],[enabled],[
+ AC_ARG_ENABLE([$1],
+ AS_HELP_STRING([--disable-$1],[Disable $1 support.]),
+ ,[enable_$1="yes"])
+ ],[$4],[disabled],[
+ AC_ARG_ENABLE([$1],
+ AS_HELP_STRING([--enable-$1],[Enable $1 support.]),
+ ,[enable_$1="no"])
+ ],[
+ m4_if([$4],[fixed],,[m4_ifnblank([$4],
+ [m4_fatal([$$4 ($4) must be "enabled", "disabled", "fixed" or empty (=fixed)])])])
+ enable_$1="yes";
+])
+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)])
+ ],[$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)])])])
+ AC_ARG_WITH(system-$1,
+ AS_HELP_STRING([--with-system-$1],[Use $1 from the operating system.]),
+ ,[csm_default_with($1,no)])
])
+
AC_MSG_CHECKING([which $1 to use])
-if test "$test_$1" != no -a "$enable_$1" != no; then
+if test "$test_$1" != no -a "$found_$1" != yes -a "$enable_$1" != no; then
ENABLE_$2=TRUE
if test "$with_system_$1" = yes -a "$test_system_$1" != no; then
AC_MSG_RESULT([external])
@@ -48,10 +92,20 @@ if test "$test_$1" != no -a "$enable_$1" != no; then
BUILD_TYPE="$BUILD_TYPE $2"
fi
else
- if test "$test_$1" != no -a "$enable_$1" = no; then
- AC_MSG_RESULT([disabled])
+ if test "$found_$1" = yes -a "$enable_$1" != no -a "$with_system_$1" = yes; then
+ AC_MSG_RESULT([external])
+ ENABLE_$2=TRUE
+ SYSTEM_$2=TRUE
else
- AC_MSG_RESULT([ignored / not supported by OS])
+ ENABLE_$2=
+ SYSTEM_$2=
+ $2_CFLAGS=
+ $2_LIBS=
+ if test "$test_$1" != no -a "$enable_$1" = no; then
+ AC_MSG_RESULT([disabled])
+ else
+ AC_MSG_RESULT([ignored / not supported by OS])
+ fi
fi
fi
AC_SUBST([ENABLE_$2])