acinclude/ltsugar.m4
changeset 3342 3da232c5980a
child 6442 2d3caa191dc4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/acinclude/ltsugar.m4	Sun Oct 04 20:44:04 2009 +0000
     1.3 @@ -0,0 +1,125 @@
     1.4 +##############################################################################
     1.5 +# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
     1.6 +#
     1.7 +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
     1.8 +# Written by Gary V. Vaughan, 2004
     1.9 +#
    1.10 +# This file is free software; the Free Software Foundation gives
    1.11 +# unlimited permission to copy and/or distribute it, with or without
    1.12 +# modifications, as long as this notice is preserved.
    1.13 +
    1.14 +# serial 6 ltsugar.m4
    1.15 +
    1.16 +# This is to help aclocal find these macros, as it can't see m4_define.
    1.17 +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
    1.18 +
    1.19 +
    1.20 +# lt_join(SEP, ARG1, [ARG2...])
    1.21 +# -----------------------------
    1.22 +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
    1.23 +# associated separator.
    1.24 +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
    1.25 +# versions in m4sugar had bugs.
    1.26 +m4_define([lt_join],
    1.27 +[m4_if([$#], [1], [],
    1.28 +       [$#], [2], [[$2]],
    1.29 +       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
    1.30 +m4_define([_lt_join],
    1.31 +[m4_if([$#$2], [2], [],
    1.32 +       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
    1.33 +
    1.34 +
    1.35 +# lt_car(LIST)
    1.36 +# lt_cdr(LIST)
    1.37 +# ------------
    1.38 +# Manipulate m4 lists.
    1.39 +# These macros are necessary as long as will still need to support
    1.40 +# Autoconf-2.59 which quotes differently.
    1.41 +m4_define([lt_car], [[$1]])
    1.42 +m4_define([lt_cdr],
    1.43 +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
    1.44 +       [$#], 1, [],
    1.45 +       [m4_dquote(m4_shift($@))])])
    1.46 +m4_define([lt_unquote], $1)
    1.47 +
    1.48 +
    1.49 +# lt_append(MACRO-NAME, STRING, [SEPARATOR])
    1.50 +# ------------------------------------------
    1.51 +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
    1.52 +# Note that neither SEPARATOR nor STRING are expanded; they are appended
    1.53 +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
    1.54 +# No SEPARATOR is output if MACRO-NAME was previously undefined (different
    1.55 +# than defined and empty).
    1.56 +#
    1.57 +# This macro is needed until we can rely on Autoconf 2.62, since earlier
    1.58 +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
    1.59 +m4_define([lt_append],
    1.60 +[m4_define([$1],
    1.61 +	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
    1.62 +
    1.63 +
    1.64 +
    1.65 +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
    1.66 +# ----------------------------------------------------------
    1.67 +# Produce a SEP delimited list of all paired combinations of elements of
    1.68 +# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
    1.69 +# has the form PREFIXmINFIXSUFFIXn.
    1.70 +# Needed until we can rely on m4_combine added in Autoconf 2.62.
    1.71 +m4_define([lt_combine],
    1.72 +[m4_if(m4_eval([$# > 3]), [1],
    1.73 +       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
    1.74 +[[m4_foreach([_Lt_prefix], [$2],
    1.75 +	     [m4_foreach([_Lt_suffix],
    1.76 +		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
    1.77 +	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
    1.78 +
    1.79 +
    1.80 +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
    1.81 +# -----------------------------------------------------------------------
    1.82 +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
    1.83 +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
    1.84 +m4_define([lt_if_append_uniq],
    1.85 +[m4_ifdef([$1],
    1.86 +	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
    1.87 +		 [lt_append([$1], [$2], [$3])$4],
    1.88 +		 [$5])],
    1.89 +	  [lt_append([$1], [$2], [$3])$4])])
    1.90 +
    1.91 +
    1.92 +# lt_dict_add(DICT, KEY, VALUE)
    1.93 +# -----------------------------
    1.94 +m4_define([lt_dict_add],
    1.95 +[m4_define([$1($2)], [$3])])
    1.96 +
    1.97 +
    1.98 +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
    1.99 +# --------------------------------------------
   1.100 +m4_define([lt_dict_add_subkey],
   1.101 +[m4_define([$1($2:$3)], [$4])])
   1.102 +
   1.103 +
   1.104 +# lt_dict_fetch(DICT, KEY, [SUBKEY])
   1.105 +# ----------------------------------
   1.106 +m4_define([lt_dict_fetch],
   1.107 +[m4_ifval([$3],
   1.108 +	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
   1.109 +    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
   1.110 +
   1.111 +
   1.112 +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
   1.113 +# -----------------------------------------------------------------
   1.114 +m4_define([lt_if_dict_fetch],
   1.115 +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
   1.116 +	[$5],
   1.117 +    [$6])])
   1.118 +
   1.119 +
   1.120 +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
   1.121 +# --------------------------------------------------------------
   1.122 +m4_define([lt_dict_filter],
   1.123 +[m4_if([$5], [], [],
   1.124 +  [lt_join(m4_quote(m4_default([$4], [[, ]])),
   1.125 +           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
   1.126 +		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
   1.127 +])
   1.128 +