1706f2543Smrg# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2706f2543Smrg# 3706f2543Smrg# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4706f2543Smrg# Written by Gary V. Vaughan, 2004 5706f2543Smrg# 6706f2543Smrg# This file is free software; the Free Software Foundation gives 7706f2543Smrg# unlimited permission to copy and/or distribute it, with or without 8706f2543Smrg# modifications, as long as this notice is preserved. 9706f2543Smrg 10706f2543Smrg# serial 6 ltsugar.m4 11706f2543Smrg 12706f2543Smrg# This is to help aclocal find these macros, as it can't see m4_define. 13706f2543SmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14706f2543Smrg 15706f2543Smrg 16706f2543Smrg# lt_join(SEP, ARG1, [ARG2...]) 17706f2543Smrg# ----------------------------- 18706f2543Smrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19706f2543Smrg# associated separator. 20706f2543Smrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21706f2543Smrg# versions in m4sugar had bugs. 22706f2543Smrgm4_define([lt_join], 23706f2543Smrg[m4_if([$#], [1], [], 24706f2543Smrg [$#], [2], [[$2]], 25706f2543Smrg [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26706f2543Smrgm4_define([_lt_join], 27706f2543Smrg[m4_if([$#$2], [2], [], 28706f2543Smrg [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29706f2543Smrg 30706f2543Smrg 31706f2543Smrg# lt_car(LIST) 32706f2543Smrg# lt_cdr(LIST) 33706f2543Smrg# ------------ 34706f2543Smrg# Manipulate m4 lists. 35706f2543Smrg# These macros are necessary as long as will still need to support 36706f2543Smrg# Autoconf-2.59 which quotes differently. 37706f2543Smrgm4_define([lt_car], [[$1]]) 38706f2543Smrgm4_define([lt_cdr], 39706f2543Smrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40706f2543Smrg [$#], 1, [], 41706f2543Smrg [m4_dquote(m4_shift($@))])]) 42706f2543Smrgm4_define([lt_unquote], $1) 43706f2543Smrg 44706f2543Smrg 45706f2543Smrg# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46706f2543Smrg# ------------------------------------------ 47706f2543Smrg# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48706f2543Smrg# Note that neither SEPARATOR nor STRING are expanded; they are appended 49706f2543Smrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50706f2543Smrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different 51706f2543Smrg# than defined and empty). 52706f2543Smrg# 53706f2543Smrg# This macro is needed until we can rely on Autoconf 2.62, since earlier 54706f2543Smrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55706f2543Smrgm4_define([lt_append], 56706f2543Smrg[m4_define([$1], 57706f2543Smrg m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58706f2543Smrg 59706f2543Smrg 60706f2543Smrg 61706f2543Smrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62706f2543Smrg# ---------------------------------------------------------- 63706f2543Smrg# Produce a SEP delimited list of all paired combinations of elements of 64706f2543Smrg# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65706f2543Smrg# has the form PREFIXmINFIXSUFFIXn. 66706f2543Smrg# Needed until we can rely on m4_combine added in Autoconf 2.62. 67706f2543Smrgm4_define([lt_combine], 68706f2543Smrg[m4_if(m4_eval([$# > 3]), [1], 69706f2543Smrg [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70706f2543Smrg[[m4_foreach([_Lt_prefix], [$2], 71706f2543Smrg [m4_foreach([_Lt_suffix], 72706f2543Smrg ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73706f2543Smrg [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74706f2543Smrg 75706f2543Smrg 76706f2543Smrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77706f2543Smrg# ----------------------------------------------------------------------- 78706f2543Smrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79706f2543Smrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80706f2543Smrgm4_define([lt_if_append_uniq], 81706f2543Smrg[m4_ifdef([$1], 82706f2543Smrg [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83706f2543Smrg [lt_append([$1], [$2], [$3])$4], 84706f2543Smrg [$5])], 85706f2543Smrg [lt_append([$1], [$2], [$3])$4])]) 86706f2543Smrg 87706f2543Smrg 88706f2543Smrg# lt_dict_add(DICT, KEY, VALUE) 89706f2543Smrg# ----------------------------- 90706f2543Smrgm4_define([lt_dict_add], 91706f2543Smrg[m4_define([$1($2)], [$3])]) 92706f2543Smrg 93706f2543Smrg 94706f2543Smrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95706f2543Smrg# -------------------------------------------- 96706f2543Smrgm4_define([lt_dict_add_subkey], 97706f2543Smrg[m4_define([$1($2:$3)], [$4])]) 98706f2543Smrg 99706f2543Smrg 100706f2543Smrg# lt_dict_fetch(DICT, KEY, [SUBKEY]) 101706f2543Smrg# ---------------------------------- 102706f2543Smrgm4_define([lt_dict_fetch], 103706f2543Smrg[m4_ifval([$3], 104706f2543Smrg m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105706f2543Smrg m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106706f2543Smrg 107706f2543Smrg 108706f2543Smrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109706f2543Smrg# ----------------------------------------------------------------- 110706f2543Smrgm4_define([lt_if_dict_fetch], 111706f2543Smrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112706f2543Smrg [$5], 113706f2543Smrg [$6])]) 114706f2543Smrg 115706f2543Smrg 116706f2543Smrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117706f2543Smrg# -------------------------------------------------------------- 118706f2543Smrgm4_define([lt_dict_filter], 119706f2543Smrg[m4_if([$5], [], [], 120706f2543Smrg [lt_join(m4_quote(m4_default([$4], [[, ]])), 121706f2543Smrg lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122706f2543Smrg [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123706f2543Smrg]) 124