ltsugar.m4 revision 1016ad83
11016ad83Smrg# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
21016ad83Smrg#
31016ad83Smrg# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
41016ad83Smrg# Written by Gary V. Vaughan, 2004
51016ad83Smrg#
61016ad83Smrg# This file is free software; the Free Software Foundation gives
71016ad83Smrg# unlimited permission to copy and/or distribute it, with or without
81016ad83Smrg# modifications, as long as this notice is preserved.
91016ad83Smrg
101016ad83Smrg# serial 6 ltsugar.m4
111016ad83Smrg
121016ad83Smrg# This is to help aclocal find these macros, as it can't see m4_define.
131016ad83SmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
141016ad83Smrg
151016ad83Smrg
161016ad83Smrg# lt_join(SEP, ARG1, [ARG2...])
171016ad83Smrg# -----------------------------
181016ad83Smrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
191016ad83Smrg# associated separator.
201016ad83Smrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
211016ad83Smrg# versions in m4sugar had bugs.
221016ad83Smrgm4_define([lt_join],
231016ad83Smrg[m4_if([$#], [1], [],
241016ad83Smrg       [$#], [2], [[$2]],
251016ad83Smrg       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
261016ad83Smrgm4_define([_lt_join],
271016ad83Smrg[m4_if([$#$2], [2], [],
281016ad83Smrg       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
291016ad83Smrg
301016ad83Smrg
311016ad83Smrg# lt_car(LIST)
321016ad83Smrg# lt_cdr(LIST)
331016ad83Smrg# ------------
341016ad83Smrg# Manipulate m4 lists.
351016ad83Smrg# These macros are necessary as long as will still need to support
361016ad83Smrg# Autoconf-2.59 which quotes differently.
371016ad83Smrgm4_define([lt_car], [[$1]])
381016ad83Smrgm4_define([lt_cdr],
391016ad83Smrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
401016ad83Smrg       [$#], 1, [],
411016ad83Smrg       [m4_dquote(m4_shift($@))])])
421016ad83Smrgm4_define([lt_unquote], $1)
431016ad83Smrg
441016ad83Smrg
451016ad83Smrg# lt_append(MACRO-NAME, STRING, [SEPARATOR])
461016ad83Smrg# ------------------------------------------
471016ad83Smrg# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
481016ad83Smrg# Note that neither SEPARATOR nor STRING are expanded; they are appended
491016ad83Smrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
501016ad83Smrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different
511016ad83Smrg# than defined and empty).
521016ad83Smrg#
531016ad83Smrg# This macro is needed until we can rely on Autoconf 2.62, since earlier
541016ad83Smrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
551016ad83Smrgm4_define([lt_append],
561016ad83Smrg[m4_define([$1],
571016ad83Smrg	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
581016ad83Smrg
591016ad83Smrg
601016ad83Smrg
611016ad83Smrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
621016ad83Smrg# ----------------------------------------------------------
631016ad83Smrg# Produce a SEP delimited list of all paired combinations of elements of
641016ad83Smrg# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
651016ad83Smrg# has the form PREFIXmINFIXSUFFIXn.
661016ad83Smrg# Needed until we can rely on m4_combine added in Autoconf 2.62.
671016ad83Smrgm4_define([lt_combine],
681016ad83Smrg[m4_if(m4_eval([$# > 3]), [1],
691016ad83Smrg       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
701016ad83Smrg[[m4_foreach([_Lt_prefix], [$2],
711016ad83Smrg	     [m4_foreach([_Lt_suffix],
721016ad83Smrg		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
731016ad83Smrg	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
741016ad83Smrg
751016ad83Smrg
761016ad83Smrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
771016ad83Smrg# -----------------------------------------------------------------------
781016ad83Smrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
791016ad83Smrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
801016ad83Smrgm4_define([lt_if_append_uniq],
811016ad83Smrg[m4_ifdef([$1],
821016ad83Smrg	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
831016ad83Smrg		 [lt_append([$1], [$2], [$3])$4],
841016ad83Smrg		 [$5])],
851016ad83Smrg	  [lt_append([$1], [$2], [$3])$4])])
861016ad83Smrg
871016ad83Smrg
881016ad83Smrg# lt_dict_add(DICT, KEY, VALUE)
891016ad83Smrg# -----------------------------
901016ad83Smrgm4_define([lt_dict_add],
911016ad83Smrg[m4_define([$1($2)], [$3])])
921016ad83Smrg
931016ad83Smrg
941016ad83Smrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
951016ad83Smrg# --------------------------------------------
961016ad83Smrgm4_define([lt_dict_add_subkey],
971016ad83Smrg[m4_define([$1($2:$3)], [$4])])
981016ad83Smrg
991016ad83Smrg
1001016ad83Smrg# lt_dict_fetch(DICT, KEY, [SUBKEY])
1011016ad83Smrg# ----------------------------------
1021016ad83Smrgm4_define([lt_dict_fetch],
1031016ad83Smrg[m4_ifval([$3],
1041016ad83Smrg	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
1051016ad83Smrg    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
1061016ad83Smrg
1071016ad83Smrg
1081016ad83Smrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
1091016ad83Smrg# -----------------------------------------------------------------
1101016ad83Smrgm4_define([lt_if_dict_fetch],
1111016ad83Smrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
1121016ad83Smrg	[$5],
1131016ad83Smrg    [$6])])
1141016ad83Smrg
1151016ad83Smrg
1161016ad83Smrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
1171016ad83Smrg# --------------------------------------------------------------
1181016ad83Smrgm4_define([lt_dict_filter],
1191016ad83Smrg[m4_if([$5], [], [],
1201016ad83Smrg  [lt_join(m4_quote(m4_default([$4], [[, ]])),
1211016ad83Smrg           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
1221016ad83Smrg		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
1231016ad83Smrg])
124