18f9fac4aSmrg# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
28f9fac4aSmrg#
38f9fac4aSmrg# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2024 Free Software
48f9fac4aSmrg# Foundation, Inc.
58f9fac4aSmrg# Written by Gary V. Vaughan, 2004
68f9fac4aSmrg#
78f9fac4aSmrg# This file is free software; the Free Software Foundation gives
88f9fac4aSmrg# unlimited permission to copy and/or distribute it, with or without
98f9fac4aSmrg# modifications, as long as this notice is preserved.
108f9fac4aSmrg
118f9fac4aSmrg# serial 6 ltsugar.m4
128f9fac4aSmrg
138f9fac4aSmrg# This is to help aclocal find these macros, as it can't see m4_define.
148f9fac4aSmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
158f9fac4aSmrg
168f9fac4aSmrg
178f9fac4aSmrg# lt_join(SEP, ARG1, [ARG2...])
188f9fac4aSmrg# -----------------------------
198f9fac4aSmrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
208f9fac4aSmrg# associated separator.
218f9fac4aSmrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
228f9fac4aSmrg# versions in m4sugar had bugs.
238f9fac4aSmrgm4_define([lt_join],
248f9fac4aSmrg[m4_if([$#], [1], [],
258f9fac4aSmrg       [$#], [2], [[$2]],
268f9fac4aSmrg       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
278f9fac4aSmrgm4_define([_lt_join],
288f9fac4aSmrg[m4_if([$#$2], [2], [],
298f9fac4aSmrg       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
308f9fac4aSmrg
318f9fac4aSmrg
328f9fac4aSmrg# lt_car(LIST)
338f9fac4aSmrg# lt_cdr(LIST)
348f9fac4aSmrg# ------------
358f9fac4aSmrg# Manipulate m4 lists.
368f9fac4aSmrg# These macros are necessary as long as will still need to support
378f9fac4aSmrg# Autoconf-2.59, which quotes differently.
388f9fac4aSmrgm4_define([lt_car], [[$1]])
398f9fac4aSmrgm4_define([lt_cdr],
408f9fac4aSmrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
418f9fac4aSmrg       [$#], 1, [],
428f9fac4aSmrg       [m4_dquote(m4_shift($@))])])
438f9fac4aSmrgm4_define([lt_unquote], $1)
448f9fac4aSmrg
458f9fac4aSmrg
468f9fac4aSmrg# lt_append(MACRO-NAME, STRING, [SEPARATOR])
478f9fac4aSmrg# ------------------------------------------
488f9fac4aSmrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
498f9fac4aSmrg# Note that neither SEPARATOR nor STRING are expanded; they are appended
508f9fac4aSmrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
518f9fac4aSmrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different
528f9fac4aSmrg# than defined and empty).
538f9fac4aSmrg#
548f9fac4aSmrg# This macro is needed until we can rely on Autoconf 2.62, since earlier
558f9fac4aSmrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
568f9fac4aSmrgm4_define([lt_append],
578f9fac4aSmrg[m4_define([$1],
588f9fac4aSmrg	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
598f9fac4aSmrg
608f9fac4aSmrg
618f9fac4aSmrg
628f9fac4aSmrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
638f9fac4aSmrg# ----------------------------------------------------------
648f9fac4aSmrg# Produce a SEP delimited list of all paired combinations of elements of
658f9fac4aSmrg# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
668f9fac4aSmrg# has the form PREFIXmINFIXSUFFIXn.
678f9fac4aSmrg# Needed until we can rely on m4_combine added in Autoconf 2.62.
688f9fac4aSmrgm4_define([lt_combine],
698f9fac4aSmrg[m4_if(m4_eval([$# > 3]), [1],
708f9fac4aSmrg       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
718f9fac4aSmrg[[m4_foreach([_Lt_prefix], [$2],
728f9fac4aSmrg	     [m4_foreach([_Lt_suffix],
738f9fac4aSmrg		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
748f9fac4aSmrg	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
758f9fac4aSmrg
768f9fac4aSmrg
778f9fac4aSmrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
788f9fac4aSmrg# -----------------------------------------------------------------------
798f9fac4aSmrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
808f9fac4aSmrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
818f9fac4aSmrgm4_define([lt_if_append_uniq],
828f9fac4aSmrg[m4_ifdef([$1],
838f9fac4aSmrg	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
848f9fac4aSmrg		 [lt_append([$1], [$2], [$3])$4],
858f9fac4aSmrg		 [$5])],
868f9fac4aSmrg	  [lt_append([$1], [$2], [$3])$4])])
878f9fac4aSmrg
888f9fac4aSmrg
898f9fac4aSmrg# lt_dict_add(DICT, KEY, VALUE)
908f9fac4aSmrg# -----------------------------
918f9fac4aSmrgm4_define([lt_dict_add],
928f9fac4aSmrg[m4_define([$1($2)], [$3])])
938f9fac4aSmrg
948f9fac4aSmrg
958f9fac4aSmrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
968f9fac4aSmrg# --------------------------------------------
978f9fac4aSmrgm4_define([lt_dict_add_subkey],
988f9fac4aSmrg[m4_define([$1($2:$3)], [$4])])
998f9fac4aSmrg
1008f9fac4aSmrg
1018f9fac4aSmrg# lt_dict_fetch(DICT, KEY, [SUBKEY])
1028f9fac4aSmrg# ----------------------------------
1038f9fac4aSmrgm4_define([lt_dict_fetch],
1048f9fac4aSmrg[m4_ifval([$3],
1058f9fac4aSmrg	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
1068f9fac4aSmrg    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
1078f9fac4aSmrg
1088f9fac4aSmrg
1098f9fac4aSmrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
1108f9fac4aSmrg# -----------------------------------------------------------------
1118f9fac4aSmrgm4_define([lt_if_dict_fetch],
1128f9fac4aSmrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
1138f9fac4aSmrg	[$5],
1148f9fac4aSmrg    [$6])])
1158f9fac4aSmrg
1168f9fac4aSmrg
1178f9fac4aSmrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
1188f9fac4aSmrg# --------------------------------------------------------------
1198f9fac4aSmrgm4_define([lt_dict_filter],
1208f9fac4aSmrg[m4_if([$5], [], [],
1218f9fac4aSmrg  [lt_join(m4_quote(m4_default([$4], [[, ]])),
1228f9fac4aSmrg           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
1238f9fac4aSmrg		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
1248f9fac4aSmrg])
125