ltsugar.m4 revision 214571
1120586Sbms# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
2120586Sbms#
3120586Sbms# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4120586Sbms# Written by Gary V. Vaughan.
5120586Sbms#
6120586Sbms# This file is free software; the Free Software Foundation gives
7120586Sbms# unlimited permission to copy and/or distribute it, with or without
8120586Sbms# modifications, as long as this notice is preserved.
9120586Sbms
10120586Sbms# serial 3 ltsugar.m4
11120586Sbms
12120586Sbms# This is to help aclocal find these macros, as it can't see m4_define.
13120586SbmsAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
14120586Sbms
15120586Sbms
16120586Sbms# lt_join(SEP, ARG1, [ARG2...])
17120586Sbms# -----------------------------
18120586Sbms# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
19120586Sbms# associated separator.
20120586Sbmsm4_define([lt_join],
21120586Sbms[m4_case([$#],
22120586Sbms	 [0], [m4_fatal([$0: too few arguments: $#])],
23120586Sbms	 [1], [],
24120586Sbms	 [2], [[$2]],
25120586Sbms	 [m4_ifval([$2],
26120586Sbms	 	   [[$2][]m4_foreach(_lt_Arg, lt_car([m4_shiftn(2, $@)]),
27120586Sbms	                   [_$0([$1], _lt_Arg)])],
28120586Sbms		   [$0([$1], m4_shiftn(2, $@))])])[]dnl
29131680Sru])
30131681Srum4_define([_lt_join],
31120586Sbms[m4_ifval([$2],[$1][$2])[]dnl
32120586Sbms])
33120586Sbms
34120586Sbms
35120586Sbms# lt_car(LIST)
36120586Sbms# lt_cdr(LIST)
37120586Sbms# ------------
38120586Sbms# Manipulate m4 lists.
39120586Sbms# These macros are necessary as long as will still need to support
40120586Sbms# Autoconf-2.59 which quotes differently.
41120586Sbmsm4_define([lt_car], [[$1]])
42120586Sbmsm4_define([lt_cdr],
43120586Sbms[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
44120586Sbms       [$#], 1, [],
45120586Sbms       [m4_dquote(m4_shift($@))])])
46120586Sbmsm4_define([lt_unquote], $1)
47120586Sbms
48120586Sbms
49120586Sbms# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
50120586Sbms# ----------------------------------------------------------
51120586Sbms# Produce a SEP delimited list of all paired combinations of elements of
52120586Sbms# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
53120586Sbms# has the form PREFIXmINFIXSUFFIXn.
54120586Sbmsm4_define([lt_combine],
55120586Sbms[m4_if([$2], [], [],
56120586Sbms  [m4_if([$4], [], [],
57120586Sbms    [lt_join(m4_quote(m4_default([$1], [[, ]])),
58120586Sbms      lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_prefix, [$2],
59120586Sbms       		   [m4_foreach(_Lt_suffix, lt_car([m4_shiftn(3, $@)]),
60120586Sbms		   	       [_Lt_prefix[]$3[]_Lt_suffix ])])))))])])dnl
61120586Sbms])
62120586Sbms
63120586Sbms
64120586Sbms# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
65147647Shmp# -----------------------------------------------------------------------
66267936Sbapt# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
67# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
68m4_define([lt_if_append_uniq],
69[m4_ifdef([$1],
70	[m4_bmatch($3[]m4_defn([$1])$3, $3[]m4_re_escape([$2])$3,
71		[$5],
72	    [m4_append([$1], [$2], [$3])$4])],
73    [m4_append([$1], [$2], [$3])$4])])
74
75
76# lt_dict_add(DICT, KEY, VALUE)
77# -----------------------------
78m4_define([lt_dict_add],
79[m4_define([$1($2)], [$4])])
80
81
82# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
83# --------------------------------------------
84m4_define([lt_dict_add_subkey],
85[m4_define([$1($2:$3)], [$4])])
86
87
88# lt_dict_fetch(DICT, KEY, [SUBKEY])
89# ----------------------------------
90m4_define([lt_dict_fetch],
91[m4_ifval([$3],
92	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
93    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
94
95
96# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
97# -----------------------------------------------------------------
98m4_define([lt_if_dict_fetch],
99[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
100	[$5],
101    [$6])])
102
103
104# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
105# --------------------------------------------------------------
106m4_define([lt_dict_filter],
107[m4_if([$5], [], [],
108  [lt_join(m4_quote(m4_default([$4], [[, ]])),
109           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
110		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
111])
112