16bea0e4fSmrg# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
26bea0e4fSmrg#
36bea0e4fSmrg# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2024 Free Software
46bea0e4fSmrg# Foundation, Inc.
56bea0e4fSmrg# Written by Gary V. Vaughan, 2004
66bea0e4fSmrg#
76bea0e4fSmrg# This file is free software; the Free Software Foundation gives
86bea0e4fSmrg# unlimited permission to copy and/or distribute it, with or without
96bea0e4fSmrg# modifications, as long as this notice is preserved.
106bea0e4fSmrg
116bea0e4fSmrg# serial 6 ltsugar.m4
126bea0e4fSmrg
136bea0e4fSmrg# This is to help aclocal find these macros, as it can't see m4_define.
146bea0e4fSmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
156bea0e4fSmrg
166bea0e4fSmrg
176bea0e4fSmrg# lt_join(SEP, ARG1, [ARG2...])
186bea0e4fSmrg# -----------------------------
196bea0e4fSmrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
206bea0e4fSmrg# associated separator.
216bea0e4fSmrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
226bea0e4fSmrg# versions in m4sugar had bugs.
236bea0e4fSmrgm4_define([lt_join],
246bea0e4fSmrg[m4_if([$#], [1], [],
256bea0e4fSmrg       [$#], [2], [[$2]],
266bea0e4fSmrg       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
276bea0e4fSmrgm4_define([_lt_join],
286bea0e4fSmrg[m4_if([$#$2], [2], [],
296bea0e4fSmrg       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
306bea0e4fSmrg
316bea0e4fSmrg
326bea0e4fSmrg# lt_car(LIST)
336bea0e4fSmrg# lt_cdr(LIST)
346bea0e4fSmrg# ------------
356bea0e4fSmrg# Manipulate m4 lists.
366bea0e4fSmrg# These macros are necessary as long as will still need to support
376bea0e4fSmrg# Autoconf-2.59, which quotes differently.
386bea0e4fSmrgm4_define([lt_car], [[$1]])
396bea0e4fSmrgm4_define([lt_cdr],
406bea0e4fSmrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
416bea0e4fSmrg       [$#], 1, [],
426bea0e4fSmrg       [m4_dquote(m4_shift($@))])])
436bea0e4fSmrgm4_define([lt_unquote], $1)
446bea0e4fSmrg
456bea0e4fSmrg
466bea0e4fSmrg# lt_append(MACRO-NAME, STRING, [SEPARATOR])
476bea0e4fSmrg# ------------------------------------------
486bea0e4fSmrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
496bea0e4fSmrg# Note that neither SEPARATOR nor STRING are expanded; they are appended
506bea0e4fSmrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
516bea0e4fSmrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different
526bea0e4fSmrg# than defined and empty).
536bea0e4fSmrg#
546bea0e4fSmrg# This macro is needed until we can rely on Autoconf 2.62, since earlier
556bea0e4fSmrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
566bea0e4fSmrgm4_define([lt_append],
576bea0e4fSmrg[m4_define([$1],
586bea0e4fSmrg	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
596bea0e4fSmrg
606bea0e4fSmrg
616bea0e4fSmrg
626bea0e4fSmrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
636bea0e4fSmrg# ----------------------------------------------------------
646bea0e4fSmrg# Produce a SEP delimited list of all paired combinations of elements of
656bea0e4fSmrg# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
666bea0e4fSmrg# has the form PREFIXmINFIXSUFFIXn.
676bea0e4fSmrg# Needed until we can rely on m4_combine added in Autoconf 2.62.
686bea0e4fSmrgm4_define([lt_combine],
696bea0e4fSmrg[m4_if(m4_eval([$# > 3]), [1],
706bea0e4fSmrg       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
716bea0e4fSmrg[[m4_foreach([_Lt_prefix], [$2],
726bea0e4fSmrg	     [m4_foreach([_Lt_suffix],
736bea0e4fSmrg		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
746bea0e4fSmrg	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
756bea0e4fSmrg
766bea0e4fSmrg
776bea0e4fSmrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
786bea0e4fSmrg# -----------------------------------------------------------------------
796bea0e4fSmrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
806bea0e4fSmrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
816bea0e4fSmrgm4_define([lt_if_append_uniq],
826bea0e4fSmrg[m4_ifdef([$1],
836bea0e4fSmrg	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
846bea0e4fSmrg		 [lt_append([$1], [$2], [$3])$4],
856bea0e4fSmrg		 [$5])],
866bea0e4fSmrg	  [lt_append([$1], [$2], [$3])$4])])
876bea0e4fSmrg
886bea0e4fSmrg
896bea0e4fSmrg# lt_dict_add(DICT, KEY, VALUE)
906bea0e4fSmrg# -----------------------------
916bea0e4fSmrgm4_define([lt_dict_add],
926bea0e4fSmrg[m4_define([$1($2)], [$3])])
936bea0e4fSmrg
946bea0e4fSmrg
956bea0e4fSmrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
966bea0e4fSmrg# --------------------------------------------
976bea0e4fSmrgm4_define([lt_dict_add_subkey],
986bea0e4fSmrg[m4_define([$1($2:$3)], [$4])])
996bea0e4fSmrg
1006bea0e4fSmrg
1016bea0e4fSmrg# lt_dict_fetch(DICT, KEY, [SUBKEY])
1026bea0e4fSmrg# ----------------------------------
1036bea0e4fSmrgm4_define([lt_dict_fetch],
1046bea0e4fSmrg[m4_ifval([$3],
1056bea0e4fSmrg	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
1066bea0e4fSmrg    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
1076bea0e4fSmrg
1086bea0e4fSmrg
1096bea0e4fSmrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
1106bea0e4fSmrg# -----------------------------------------------------------------
1116bea0e4fSmrgm4_define([lt_if_dict_fetch],
1126bea0e4fSmrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
1136bea0e4fSmrg	[$5],
1146bea0e4fSmrg    [$6])])
1156bea0e4fSmrg
1166bea0e4fSmrg
1176bea0e4fSmrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
1186bea0e4fSmrg# --------------------------------------------------------------
1196bea0e4fSmrgm4_define([lt_dict_filter],
1206bea0e4fSmrg[m4_if([$5], [], [],
1216bea0e4fSmrg  [lt_join(m4_quote(m4_default([$4], [[, ]])),
1226bea0e4fSmrg           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
1236bea0e4fSmrg		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
1246bea0e4fSmrg])
125