1267843Sdelphij# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2267843Sdelphij# 3267843Sdelphij# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4267843Sdelphij# Written by Gary V. Vaughan, 2004 5267843Sdelphij# 6267843Sdelphij# This file is free software; the Free Software Foundation gives 7267843Sdelphij# unlimited permission to copy and/or distribute it, with or without 8267843Sdelphij# modifications, as long as this notice is preserved. 9267843Sdelphij 10267843Sdelphij# serial 6 ltsugar.m4 11267843Sdelphij 12267843Sdelphij# This is to help aclocal find these macros, as it can't see m4_define. 13267843SdelphijAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14267843Sdelphij 15267843Sdelphij 16267843Sdelphij# lt_join(SEP, ARG1, [ARG2...]) 17267843Sdelphij# ----------------------------- 18267843Sdelphij# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19267843Sdelphij# associated separator. 20267843Sdelphij# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21267843Sdelphij# versions in m4sugar had bugs. 22267843Sdelphijm4_define([lt_join], 23267843Sdelphij[m4_if([$#], [1], [], 24267843Sdelphij [$#], [2], [[$2]], 25267843Sdelphij [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26267843Sdelphijm4_define([_lt_join], 27267843Sdelphij[m4_if([$#$2], [2], [], 28267843Sdelphij [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29267843Sdelphij 30267843Sdelphij 31267843Sdelphij# lt_car(LIST) 32267843Sdelphij# lt_cdr(LIST) 33267843Sdelphij# ------------ 34267843Sdelphij# Manipulate m4 lists. 35267843Sdelphij# These macros are necessary as long as will still need to support 36267843Sdelphij# Autoconf-2.59 which quotes differently. 37267843Sdelphijm4_define([lt_car], [[$1]]) 38267843Sdelphijm4_define([lt_cdr], 39267843Sdelphij[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40267843Sdelphij [$#], 1, [], 41267843Sdelphij [m4_dquote(m4_shift($@))])]) 42267843Sdelphijm4_define([lt_unquote], $1) 43267843Sdelphij 44267843Sdelphij 45267843Sdelphij# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46267843Sdelphij# ------------------------------------------ 47267843Sdelphij# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48267843Sdelphij# Note that neither SEPARATOR nor STRING are expanded; they are appended 49267843Sdelphij# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50267843Sdelphij# No SEPARATOR is output if MACRO-NAME was previously undefined (different 51267843Sdelphij# than defined and empty). 52267843Sdelphij# 53267843Sdelphij# This macro is needed until we can rely on Autoconf 2.62, since earlier 54267843Sdelphij# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55267843Sdelphijm4_define([lt_append], 56267843Sdelphij[m4_define([$1], 57267843Sdelphij m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58267843Sdelphij 59267843Sdelphij 60267843Sdelphij 61267843Sdelphij# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62267843Sdelphij# ---------------------------------------------------------- 63267843Sdelphij# Produce a SEP delimited list of all paired combinations of elements of 64267843Sdelphij# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65267843Sdelphij# has the form PREFIXmINFIXSUFFIXn. 66267843Sdelphij# Needed until we can rely on m4_combine added in Autoconf 2.62. 67267843Sdelphijm4_define([lt_combine], 68267843Sdelphij[m4_if(m4_eval([$# > 3]), [1], 69267843Sdelphij [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70267843Sdelphij[[m4_foreach([_Lt_prefix], [$2], 71267843Sdelphij [m4_foreach([_Lt_suffix], 72267843Sdelphij ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73267843Sdelphij [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74267843Sdelphij 75267843Sdelphij 76267843Sdelphij# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77267843Sdelphij# ----------------------------------------------------------------------- 78267843Sdelphij# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79267843Sdelphij# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80267843Sdelphijm4_define([lt_if_append_uniq], 81267843Sdelphij[m4_ifdef([$1], 82267843Sdelphij [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83267843Sdelphij [lt_append([$1], [$2], [$3])$4], 84267843Sdelphij [$5])], 85267843Sdelphij [lt_append([$1], [$2], [$3])$4])]) 86267843Sdelphij 87267843Sdelphij 88267843Sdelphij# lt_dict_add(DICT, KEY, VALUE) 89267843Sdelphij# ----------------------------- 90267843Sdelphijm4_define([lt_dict_add], 91267843Sdelphij[m4_define([$1($2)], [$3])]) 92267843Sdelphij 93267843Sdelphij 94267843Sdelphij# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95267843Sdelphij# -------------------------------------------- 96267843Sdelphijm4_define([lt_dict_add_subkey], 97267843Sdelphij[m4_define([$1($2:$3)], [$4])]) 98267843Sdelphij 99267843Sdelphij 100267843Sdelphij# lt_dict_fetch(DICT, KEY, [SUBKEY]) 101267843Sdelphij# ---------------------------------- 102267843Sdelphijm4_define([lt_dict_fetch], 103267843Sdelphij[m4_ifval([$3], 104267843Sdelphij m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105267843Sdelphij m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106267843Sdelphij 107267843Sdelphij 108267843Sdelphij# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109267843Sdelphij# ----------------------------------------------------------------- 110267843Sdelphijm4_define([lt_if_dict_fetch], 111267843Sdelphij[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112267843Sdelphij [$5], 113267843Sdelphij [$6])]) 114267843Sdelphij 115267843Sdelphij 116267843Sdelphij# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117267843Sdelphij# -------------------------------------------------------------- 118267843Sdelphijm4_define([lt_dict_filter], 119267843Sdelphij[m4_if([$5], [], [], 120267843Sdelphij [lt_join(m4_quote(m4_default([$4], [[, ]])), 121267843Sdelphij lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122267843Sdelphij [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123267843Sdelphij]) 124