configure.ac | 8 ++-- m4/libo_externals.m4 | 90 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 76 insertions(+), 22 deletions(-)
New commits: commit 299349ed74bae9cad9bbac9a62c4465b0972bd01 Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Fri Dec 24 12:01:56 2021 +0100 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Thu Dec 30 02:12:50 2021 +0100 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 <glo...@fbihome.de> diff --git a/configure.ac b/configure.ac index 8238d6d3210a..d07ced70939f 100644 --- a/configure.ac +++ b/configure.ac @@ -5849,7 +5849,7 @@ fi AC_SUBST(ENABLE_CUPS) -libo_CHECK_SYSTEM_MODULE([fontconfig],[FONTCONFIG],[fontconfig >= 2.4.1],TRUE) +libo_CHECK_SYSTEM_MODULE([fontconfig],[FONTCONFIG],[fontconfig >= 2.4.1],,system) dnl whether to find & fetch external tarballs? dnl =================================================================== @@ -7303,7 +7303,7 @@ AC_SUBST(GPERF) dnl =================================================================== dnl Check for system libcmis dnl =================================================================== -libo_CHECK_SYSTEM_MODULE([libcmis],[LIBCMIS],[libcmis-0.5 >= 0.5.2],,TRUE) +libo_CHECK_SYSTEM_MODULE([libcmis],[LIBCMIS],[libcmis-0.5 >= 0.5.2],enabled) dnl =================================================================== dnl C++11 @@ -9470,7 +9470,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],TRUE) +libo_CHECK_SYSTEM_MODULE([freetype],[FREETYPE],[freetype2 >= 9.9.3],,system) # =================================================================== # Check for system libxslt @@ -10315,7 +10315,7 @@ AC_SUBST(LIBTOMMATH_LIBS) dnl =================================================================== dnl Check for system curl dnl =================================================================== -libo_CHECK_SYSTEM_MODULE([curl],[CURL],[libcurl >= 7.68.0],,TRUE) +libo_CHECK_SYSTEM_MODULE([curl],[CURL],[libcurl >= 7.68.0],enabled) dnl =================================================================== dnl Check for system boost 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])