| 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
|
|---|
| 2 | #
|
|---|
| 3 | # Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
|---|
| 4 | # Written by Gary V. Vaughan.
|
|---|
| 5 | #
|
|---|
| 6 | # This file is free software; the Free Software Foundation gives
|
|---|
| 7 | # unlimited permission to copy and/or distribute it, with or without
|
|---|
| 8 | # modifications, as long as this notice is preserved.
|
|---|
| 9 |
|
|---|
| 10 | # serial 3 ltsugar.m4
|
|---|
| 11 |
|
|---|
| 12 | # This is to help aclocal find these macros, as it can't see m4_define.
|
|---|
| 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | # lt_join(SEP, ARG1, [ARG2...])
|
|---|
| 17 | # -----------------------------
|
|---|
| 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
|
|---|
| 19 | # associated separator.
|
|---|
| 20 | m4_define([lt_join],
|
|---|
| 21 | [m4_case([$#],
|
|---|
| 22 | [0], [m4_fatal([$0: too few arguments: $#])],
|
|---|
| 23 | [1], [],
|
|---|
| 24 | [2], [[$2]],
|
|---|
| 25 | [m4_ifval([$2],
|
|---|
| 26 | [[$2][]m4_foreach(_lt_Arg, lt_car([m4_shiftn(2, $@)]),
|
|---|
| 27 | [_$0([$1], _lt_Arg)])],
|
|---|
| 28 | [$0([$1], m4_shiftn(2, $@))])])[]dnl
|
|---|
| 29 | ])
|
|---|
| 30 | m4_define([_lt_join],
|
|---|
| 31 | [m4_ifval([$2],[$1][$2])[]dnl
|
|---|
| 32 | ])
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | # lt_car(LIST)
|
|---|
| 36 | # lt_cdr(LIST)
|
|---|
| 37 | # ------------
|
|---|
| 38 | # Manipulate m4 lists.
|
|---|
| 39 | # These macros are necessary as long as will still need to support
|
|---|
| 40 | # Autoconf-2.59 which quotes differently.
|
|---|
| 41 | m4_define([lt_car], [[$1]])
|
|---|
| 42 | m4_define([lt_cdr],
|
|---|
| 43 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
|
|---|
| 44 | [$#], 1, [],
|
|---|
| 45 | [m4_dquote(m4_shift($@))])])
|
|---|
| 46 | m4_define([lt_unquote], $1)
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
|
|---|
| 50 | # ----------------------------------------------------------
|
|---|
| 51 | # Produce a SEP delimited list of all paired combinations of elements of
|
|---|
| 52 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
|
|---|
| 53 | # has the form PREFIXmINFIXSUFFIXn.
|
|---|
| 54 | m4_define([lt_combine],
|
|---|
| 55 | [m4_if([$2], [], [],
|
|---|
| 56 | [m4_if([$4], [], [],
|
|---|
| 57 | [lt_join(m4_quote(m4_default([$1], [[, ]])),
|
|---|
| 58 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_prefix, [$2],
|
|---|
| 59 | [m4_foreach(_Lt_suffix, lt_car([m4_shiftn(3, $@)]),
|
|---|
| 60 | [_Lt_prefix[]$3[]_Lt_suffix ])])))))])])dnl
|
|---|
| 61 | ])
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
|
|---|
| 65 | # -----------------------------------------------------------------------
|
|---|
| 66 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
|
|---|
| 67 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
|
|---|
| 68 | m4_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 | # -----------------------------
|
|---|
| 78 | m4_define([lt_dict_add],
|
|---|
| 79 | [m4_define([$1($2)], [$4])])
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
|
|---|
| 83 | # --------------------------------------------
|
|---|
| 84 | m4_define([lt_dict_add_subkey],
|
|---|
| 85 | [m4_define([$1($2:$3)], [$4])])
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 | # lt_dict_fetch(DICT, KEY, [SUBKEY])
|
|---|
| 89 | # ----------------------------------
|
|---|
| 90 | m4_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 | # -----------------------------------------------------------------
|
|---|
| 98 | m4_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 | # --------------------------------------------------------------
|
|---|
| 106 | m4_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 | ])
|
|---|