1290001Sglebius# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
2290001Sglebius#
3290001Sglebius# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
4290001Sglebius# Written by Gary V. Vaughan, 2004
5290001Sglebius#
6290001Sglebius# This file is free software; the Free Software Foundation gives
7290001Sglebius# unlimited permission to copy and/or distribute it, with or without
8290001Sglebius# modifications, as long as this notice is preserved.
9290001Sglebius
10290001Sglebius# serial 6 ltsugar.m4
11290001Sglebius
12290001Sglebius# This is to help aclocal find these macros, as it can't see m4_define.
13290001SglebiusAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
14290001Sglebius
15290001Sglebius
16290001Sglebius# lt_join(SEP, ARG1, [ARG2...])
17290001Sglebius# -----------------------------
18290001Sglebius# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
19290001Sglebius# associated separator.
20290001Sglebius# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
21290001Sglebius# versions in m4sugar had bugs.
22290001Sglebiusm4_define([lt_join],
23290001Sglebius[m4_if([$#], [1], [],
24290001Sglebius       [$#], [2], [[$2]],
25290001Sglebius       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
26290001Sglebiusm4_define([_lt_join],
27290001Sglebius[m4_if([$#$2], [2], [],
28290001Sglebius       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
29290001Sglebius
30290001Sglebius
31290001Sglebius# lt_car(LIST)
32290001Sglebius# lt_cdr(LIST)
33290001Sglebius# ------------
34290001Sglebius# Manipulate m4 lists.
35290001Sglebius# These macros are necessary as long as will still need to support
36290001Sglebius# Autoconf-2.59 which quotes differently.
37290001Sglebiusm4_define([lt_car], [[$1]])
38290001Sglebiusm4_define([lt_cdr],
39290001Sglebius[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
40290001Sglebius       [$#], 1, [],
41290001Sglebius       [m4_dquote(m4_shift($@))])])
42290001Sglebiusm4_define([lt_unquote], $1)
43290001Sglebius
44290001Sglebius
45290001Sglebius# lt_append(MACRO-NAME, STRING, [SEPARATOR])
46290001Sglebius# ------------------------------------------
47290001Sglebius# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
48290001Sglebius# Note that neither SEPARATOR nor STRING are expanded; they are appended
49290001Sglebius# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
50290001Sglebius# No SEPARATOR is output if MACRO-NAME was previously undefined (different
51290001Sglebius# than defined and empty).
52290001Sglebius#
53290001Sglebius# This macro is needed until we can rely on Autoconf 2.62, since earlier
54290001Sglebius# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
55290001Sglebiusm4_define([lt_append],
56290001Sglebius[m4_define([$1],
57290001Sglebius	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
58290001Sglebius
59290001Sglebius
60290001Sglebius
61290001Sglebius# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
62290001Sglebius# ----------------------------------------------------------
63290001Sglebius# Produce a SEP delimited list of all paired combinations of elements of
64290001Sglebius# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
65290001Sglebius# has the form PREFIXmINFIXSUFFIXn.
66290001Sglebius# Needed until we can rely on m4_combine added in Autoconf 2.62.
67290001Sglebiusm4_define([lt_combine],
68290001Sglebius[m4_if(m4_eval([$# > 3]), [1],
69290001Sglebius       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
70290001Sglebius[[m4_foreach([_Lt_prefix], [$2],
71290001Sglebius	     [m4_foreach([_Lt_suffix],
72290001Sglebius		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
73290001Sglebius	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
74290001Sglebius
75290001Sglebius
76290001Sglebius# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
77290001Sglebius# -----------------------------------------------------------------------
78290001Sglebius# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
79290001Sglebius# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
80290001Sglebiusm4_define([lt_if_append_uniq],
81290001Sglebius[m4_ifdef([$1],
82290001Sglebius	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
83290001Sglebius		 [lt_append([$1], [$2], [$3])$4],
84290001Sglebius		 [$5])],
85290001Sglebius	  [lt_append([$1], [$2], [$3])$4])])
86290001Sglebius
87290001Sglebius
88290001Sglebius# lt_dict_add(DICT, KEY, VALUE)
89290001Sglebius# -----------------------------
90290001Sglebiusm4_define([lt_dict_add],
91290001Sglebius[m4_define([$1($2)], [$3])])
92290001Sglebius
93290001Sglebius
94290001Sglebius# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
95290001Sglebius# --------------------------------------------
96290001Sglebiusm4_define([lt_dict_add_subkey],
97290001Sglebius[m4_define([$1($2:$3)], [$4])])
98290001Sglebius
99290001Sglebius
100290001Sglebius# lt_dict_fetch(DICT, KEY, [SUBKEY])
101290001Sglebius# ----------------------------------
102290001Sglebiusm4_define([lt_dict_fetch],
103290001Sglebius[m4_ifval([$3],
104290001Sglebius	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
105290001Sglebius    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
106290001Sglebius
107290001Sglebius
108290001Sglebius# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
109290001Sglebius# -----------------------------------------------------------------
110290001Sglebiusm4_define([lt_if_dict_fetch],
111290001Sglebius[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
112290001Sglebius	[$5],
113290001Sglebius    [$6])])
114290001Sglebius
115290001Sglebius
116290001Sglebius# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
117290001Sglebius# --------------------------------------------------------------
118290001Sglebiusm4_define([lt_dict_filter],
119290001Sglebius[m4_if([$5], [], [],
120290001Sglebius  [lt_join(m4_quote(m4_default([$4], [[, ]])),
121290001Sglebius           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
122290001Sglebius		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
123290001Sglebius])
124