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