1275970Scy# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
2275970Scy#
3316069Sdelphij# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
4316069Sdelphij# Foundation, Inc.
5275970Scy# Written by Gary V. Vaughan, 2004
6275970Scy#
7275970Scy# This file is free software; the Free Software Foundation gives
8275970Scy# unlimited permission to copy and/or distribute it, with or without
9275970Scy# modifications, as long as this notice is preserved.
10275970Scy
11275970Scy# serial 6 ltsugar.m4
12275970Scy
13275970Scy# This is to help aclocal find these macros, as it can't see m4_define.
14275970ScyAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
15275970Scy
16275970Scy
17275970Scy# lt_join(SEP, ARG1, [ARG2...])
18275970Scy# -----------------------------
19275970Scy# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
20275970Scy# associated separator.
21275970Scy# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
22275970Scy# versions in m4sugar had bugs.
23275970Scym4_define([lt_join],
24275970Scy[m4_if([$#], [1], [],
25275970Scy       [$#], [2], [[$2]],
26275970Scy       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
27275970Scym4_define([_lt_join],
28275970Scy[m4_if([$#$2], [2], [],
29275970Scy       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
30275970Scy
31275970Scy
32275970Scy# lt_car(LIST)
33275970Scy# lt_cdr(LIST)
34275970Scy# ------------
35275970Scy# Manipulate m4 lists.
36275970Scy# These macros are necessary as long as will still need to support
37316069Sdelphij# Autoconf-2.59, which quotes differently.
38275970Scym4_define([lt_car], [[$1]])
39275970Scym4_define([lt_cdr],
40275970Scy[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
41275970Scy       [$#], 1, [],
42275970Scy       [m4_dquote(m4_shift($@))])])
43275970Scym4_define([lt_unquote], $1)
44275970Scy
45275970Scy
46275970Scy# lt_append(MACRO-NAME, STRING, [SEPARATOR])
47275970Scy# ------------------------------------------
48316069Sdelphij# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
49275970Scy# Note that neither SEPARATOR nor STRING are expanded; they are appended
50275970Scy# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
51275970Scy# No SEPARATOR is output if MACRO-NAME was previously undefined (different
52275970Scy# than defined and empty).
53275970Scy#
54275970Scy# This macro is needed until we can rely on Autoconf 2.62, since earlier
55275970Scy# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
56275970Scym4_define([lt_append],
57275970Scy[m4_define([$1],
58275970Scy	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
59275970Scy
60275970Scy
61275970Scy
62275970Scy# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
63275970Scy# ----------------------------------------------------------
64275970Scy# Produce a SEP delimited list of all paired combinations of elements of
65275970Scy# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
66275970Scy# has the form PREFIXmINFIXSUFFIXn.
67275970Scy# Needed until we can rely on m4_combine added in Autoconf 2.62.
68275970Scym4_define([lt_combine],
69275970Scy[m4_if(m4_eval([$# > 3]), [1],
70275970Scy       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
71275970Scy[[m4_foreach([_Lt_prefix], [$2],
72275970Scy	     [m4_foreach([_Lt_suffix],
73275970Scy		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
74275970Scy	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
75275970Scy
76275970Scy
77275970Scy# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
78275970Scy# -----------------------------------------------------------------------
79275970Scy# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
80275970Scy# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
81275970Scym4_define([lt_if_append_uniq],
82275970Scy[m4_ifdef([$1],
83275970Scy	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
84275970Scy		 [lt_append([$1], [$2], [$3])$4],
85275970Scy		 [$5])],
86275970Scy	  [lt_append([$1], [$2], [$3])$4])])
87275970Scy
88275970Scy
89275970Scy# lt_dict_add(DICT, KEY, VALUE)
90275970Scy# -----------------------------
91275970Scym4_define([lt_dict_add],
92275970Scy[m4_define([$1($2)], [$3])])
93275970Scy
94275970Scy
95275970Scy# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
96275970Scy# --------------------------------------------
97275970Scym4_define([lt_dict_add_subkey],
98275970Scy[m4_define([$1($2:$3)], [$4])])
99275970Scy
100275970Scy
101275970Scy# lt_dict_fetch(DICT, KEY, [SUBKEY])
102275970Scy# ----------------------------------
103275970Scym4_define([lt_dict_fetch],
104275970Scy[m4_ifval([$3],
105275970Scy	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
106275970Scy    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
107275970Scy
108275970Scy
109275970Scy# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
110275970Scy# -----------------------------------------------------------------
111275970Scym4_define([lt_if_dict_fetch],
112275970Scy[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
113275970Scy	[$5],
114275970Scy    [$6])])
115275970Scy
116275970Scy
117275970Scy# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
118275970Scy# --------------------------------------------------------------
119275970Scym4_define([lt_dict_filter],
120275970Scy[m4_if([$5], [], [],
121275970Scy  [lt_join(m4_quote(m4_default([$4], [[, ]])),
122275970Scy           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
123275970Scy		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
124275970Scy])
125