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