10c674dbdSmrg# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
20c674dbdSmrg#
30c674dbdSmrg# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2022 Free Software
40c674dbdSmrg# Foundation, Inc.
50c674dbdSmrg# Written by Gary V. Vaughan, 2004
60c674dbdSmrg#
70c674dbdSmrg# This file is free software; the Free Software Foundation gives
80c674dbdSmrg# unlimited permission to copy and/or distribute it, with or without
90c674dbdSmrg# modifications, as long as this notice is preserved.
100c674dbdSmrg
110c674dbdSmrg# serial 6 ltsugar.m4
120c674dbdSmrg
130c674dbdSmrg# This is to help aclocal find these macros, as it can't see m4_define.
140c674dbdSmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
150c674dbdSmrg
160c674dbdSmrg
170c674dbdSmrg# lt_join(SEP, ARG1, [ARG2...])
180c674dbdSmrg# -----------------------------
190c674dbdSmrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
200c674dbdSmrg# associated separator.
210c674dbdSmrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
220c674dbdSmrg# versions in m4sugar had bugs.
230c674dbdSmrgm4_define([lt_join],
240c674dbdSmrg[m4_if([$#], [1], [],
250c674dbdSmrg       [$#], [2], [[$2]],
260c674dbdSmrg       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
270c674dbdSmrgm4_define([_lt_join],
280c674dbdSmrg[m4_if([$#$2], [2], [],
290c674dbdSmrg       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
300c674dbdSmrg
310c674dbdSmrg
320c674dbdSmrg# lt_car(LIST)
330c674dbdSmrg# lt_cdr(LIST)
340c674dbdSmrg# ------------
350c674dbdSmrg# Manipulate m4 lists.
360c674dbdSmrg# These macros are necessary as long as will still need to support
370c674dbdSmrg# Autoconf-2.59, which quotes differently.
380c674dbdSmrgm4_define([lt_car], [[$1]])
390c674dbdSmrgm4_define([lt_cdr],
400c674dbdSmrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
410c674dbdSmrg       [$#], 1, [],
420c674dbdSmrg       [m4_dquote(m4_shift($@))])])
430c674dbdSmrgm4_define([lt_unquote], $1)
440c674dbdSmrg
450c674dbdSmrg
460c674dbdSmrg# lt_append(MACRO-NAME, STRING, [SEPARATOR])
470c674dbdSmrg# ------------------------------------------
480c674dbdSmrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
490c674dbdSmrg# Note that neither SEPARATOR nor STRING are expanded; they are appended
500c674dbdSmrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
510c674dbdSmrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different
520c674dbdSmrg# than defined and empty).
530c674dbdSmrg#
540c674dbdSmrg# This macro is needed until we can rely on Autoconf 2.62, since earlier
550c674dbdSmrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
560c674dbdSmrgm4_define([lt_append],
570c674dbdSmrg[m4_define([$1],
580c674dbdSmrg	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
590c674dbdSmrg
600c674dbdSmrg
610c674dbdSmrg
620c674dbdSmrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
630c674dbdSmrg# ----------------------------------------------------------
640c674dbdSmrg# Produce a SEP delimited list of all paired combinations of elements of
650c674dbdSmrg# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
660c674dbdSmrg# has the form PREFIXmINFIXSUFFIXn.
670c674dbdSmrg# Needed until we can rely on m4_combine added in Autoconf 2.62.
680c674dbdSmrgm4_define([lt_combine],
690c674dbdSmrg[m4_if(m4_eval([$# > 3]), [1],
700c674dbdSmrg       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
710c674dbdSmrg[[m4_foreach([_Lt_prefix], [$2],
720c674dbdSmrg	     [m4_foreach([_Lt_suffix],
730c674dbdSmrg		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
740c674dbdSmrg	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
750c674dbdSmrg
760c674dbdSmrg
770c674dbdSmrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
780c674dbdSmrg# -----------------------------------------------------------------------
790c674dbdSmrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
800c674dbdSmrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
810c674dbdSmrgm4_define([lt_if_append_uniq],
820c674dbdSmrg[m4_ifdef([$1],
830c674dbdSmrg	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
840c674dbdSmrg		 [lt_append([$1], [$2], [$3])$4],
850c674dbdSmrg		 [$5])],
860c674dbdSmrg	  [lt_append([$1], [$2], [$3])$4])])
870c674dbdSmrg
880c674dbdSmrg
890c674dbdSmrg# lt_dict_add(DICT, KEY, VALUE)
900c674dbdSmrg# -----------------------------
910c674dbdSmrgm4_define([lt_dict_add],
920c674dbdSmrg[m4_define([$1($2)], [$3])])
930c674dbdSmrg
940c674dbdSmrg
950c674dbdSmrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
960c674dbdSmrg# --------------------------------------------
970c674dbdSmrgm4_define([lt_dict_add_subkey],
980c674dbdSmrg[m4_define([$1($2:$3)], [$4])])
990c674dbdSmrg
1000c674dbdSmrg
1010c674dbdSmrg# lt_dict_fetch(DICT, KEY, [SUBKEY])
1020c674dbdSmrg# ----------------------------------
1030c674dbdSmrgm4_define([lt_dict_fetch],
1040c674dbdSmrg[m4_ifval([$3],
1050c674dbdSmrg	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
1060c674dbdSmrg    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
1070c674dbdSmrg
1080c674dbdSmrg
1090c674dbdSmrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
1100c674dbdSmrg# -----------------------------------------------------------------
1110c674dbdSmrgm4_define([lt_if_dict_fetch],
1120c674dbdSmrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
1130c674dbdSmrg	[$5],
1140c674dbdSmrg    [$6])])
1150c674dbdSmrg
1160c674dbdSmrg
1170c674dbdSmrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
1180c674dbdSmrg# --------------------------------------------------------------
1190c674dbdSmrgm4_define([lt_dict_filter],
1200c674dbdSmrg[m4_if([$5], [], [],
1210c674dbdSmrg  [lt_join(m4_quote(m4_default([$4], [[, ]])),
1220c674dbdSmrg           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
1230c674dbdSmrg		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
1240c674dbdSmrg])
125