1*0a6a1f1dSLionel Sambuc# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2*0a6a1f1dSLionel Sambuc# 3*0a6a1f1dSLionel Sambuc# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4*0a6a1f1dSLionel Sambuc# Written by Gary V. Vaughan, 2004 5*0a6a1f1dSLionel Sambuc# 6*0a6a1f1dSLionel Sambuc# This file is free software; the Free Software Foundation gives 7*0a6a1f1dSLionel Sambuc# unlimited permission to copy and/or distribute it, with or without 8*0a6a1f1dSLionel Sambuc# modifications, as long as this notice is preserved. 9*0a6a1f1dSLionel Sambuc 10*0a6a1f1dSLionel Sambuc# serial 6 ltsugar.m4 11*0a6a1f1dSLionel Sambuc 12*0a6a1f1dSLionel Sambuc# This is to help aclocal find these macros, as it can't see m4_define. 13*0a6a1f1dSLionel SambucAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14*0a6a1f1dSLionel Sambuc 15*0a6a1f1dSLionel Sambuc 16*0a6a1f1dSLionel Sambuc# lt_join(SEP, ARG1, [ARG2...]) 17*0a6a1f1dSLionel Sambuc# ----------------------------- 18*0a6a1f1dSLionel Sambuc# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19*0a6a1f1dSLionel Sambuc# associated separator. 20*0a6a1f1dSLionel Sambuc# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21*0a6a1f1dSLionel Sambuc# versions in m4sugar had bugs. 22*0a6a1f1dSLionel Sambucm4_define([lt_join], 23*0a6a1f1dSLionel Sambuc[m4_if([$#], [1], [], 24*0a6a1f1dSLionel Sambuc [$#], [2], [[$2]], 25*0a6a1f1dSLionel Sambuc [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26*0a6a1f1dSLionel Sambucm4_define([_lt_join], 27*0a6a1f1dSLionel Sambuc[m4_if([$#$2], [2], [], 28*0a6a1f1dSLionel Sambuc [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29*0a6a1f1dSLionel Sambuc 30*0a6a1f1dSLionel Sambuc 31*0a6a1f1dSLionel Sambuc# lt_car(LIST) 32*0a6a1f1dSLionel Sambuc# lt_cdr(LIST) 33*0a6a1f1dSLionel Sambuc# ------------ 34*0a6a1f1dSLionel Sambuc# Manipulate m4 lists. 35*0a6a1f1dSLionel Sambuc# These macros are necessary as long as will still need to support 36*0a6a1f1dSLionel Sambuc# Autoconf-2.59 which quotes differently. 37*0a6a1f1dSLionel Sambucm4_define([lt_car], [[$1]]) 38*0a6a1f1dSLionel Sambucm4_define([lt_cdr], 39*0a6a1f1dSLionel Sambuc[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40*0a6a1f1dSLionel Sambuc [$#], 1, [], 41*0a6a1f1dSLionel Sambuc [m4_dquote(m4_shift($@))])]) 42*0a6a1f1dSLionel Sambucm4_define([lt_unquote], $1) 43*0a6a1f1dSLionel Sambuc 44*0a6a1f1dSLionel Sambuc 45*0a6a1f1dSLionel Sambuc# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46*0a6a1f1dSLionel Sambuc# ------------------------------------------ 47*0a6a1f1dSLionel Sambuc# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48*0a6a1f1dSLionel Sambuc# Note that neither SEPARATOR nor STRING are expanded; they are appended 49*0a6a1f1dSLionel Sambuc# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50*0a6a1f1dSLionel Sambuc# No SEPARATOR is output if MACRO-NAME was previously undefined (different 51*0a6a1f1dSLionel Sambuc# than defined and empty). 52*0a6a1f1dSLionel Sambuc# 53*0a6a1f1dSLionel Sambuc# This macro is needed until we can rely on Autoconf 2.62, since earlier 54*0a6a1f1dSLionel Sambuc# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55*0a6a1f1dSLionel Sambucm4_define([lt_append], 56*0a6a1f1dSLionel Sambuc[m4_define([$1], 57*0a6a1f1dSLionel Sambuc m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58*0a6a1f1dSLionel Sambuc 59*0a6a1f1dSLionel Sambuc 60*0a6a1f1dSLionel Sambuc 61*0a6a1f1dSLionel Sambuc# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62*0a6a1f1dSLionel Sambuc# ---------------------------------------------------------- 63*0a6a1f1dSLionel Sambuc# Produce a SEP delimited list of all paired combinations of elements of 64*0a6a1f1dSLionel Sambuc# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65*0a6a1f1dSLionel Sambuc# has the form PREFIXmINFIXSUFFIXn. 66*0a6a1f1dSLionel Sambuc# Needed until we can rely on m4_combine added in Autoconf 2.62. 67*0a6a1f1dSLionel Sambucm4_define([lt_combine], 68*0a6a1f1dSLionel Sambuc[m4_if(m4_eval([$# > 3]), [1], 69*0a6a1f1dSLionel Sambuc [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70*0a6a1f1dSLionel Sambuc[[m4_foreach([_Lt_prefix], [$2], 71*0a6a1f1dSLionel Sambuc [m4_foreach([_Lt_suffix], 72*0a6a1f1dSLionel Sambuc ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73*0a6a1f1dSLionel Sambuc [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74*0a6a1f1dSLionel Sambuc 75*0a6a1f1dSLionel Sambuc 76*0a6a1f1dSLionel Sambuc# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77*0a6a1f1dSLionel Sambuc# ----------------------------------------------------------------------- 78*0a6a1f1dSLionel Sambuc# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79*0a6a1f1dSLionel Sambuc# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80*0a6a1f1dSLionel Sambucm4_define([lt_if_append_uniq], 81*0a6a1f1dSLionel Sambuc[m4_ifdef([$1], 82*0a6a1f1dSLionel Sambuc [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83*0a6a1f1dSLionel Sambuc [lt_append([$1], [$2], [$3])$4], 84*0a6a1f1dSLionel Sambuc [$5])], 85*0a6a1f1dSLionel Sambuc [lt_append([$1], [$2], [$3])$4])]) 86*0a6a1f1dSLionel Sambuc 87*0a6a1f1dSLionel Sambuc 88*0a6a1f1dSLionel Sambuc# lt_dict_add(DICT, KEY, VALUE) 89*0a6a1f1dSLionel Sambuc# ----------------------------- 90*0a6a1f1dSLionel Sambucm4_define([lt_dict_add], 91*0a6a1f1dSLionel Sambuc[m4_define([$1($2)], [$3])]) 92*0a6a1f1dSLionel Sambuc 93*0a6a1f1dSLionel Sambuc 94*0a6a1f1dSLionel Sambuc# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95*0a6a1f1dSLionel Sambuc# -------------------------------------------- 96*0a6a1f1dSLionel Sambucm4_define([lt_dict_add_subkey], 97*0a6a1f1dSLionel Sambuc[m4_define([$1($2:$3)], [$4])]) 98*0a6a1f1dSLionel Sambuc 99*0a6a1f1dSLionel Sambuc 100*0a6a1f1dSLionel Sambuc# lt_dict_fetch(DICT, KEY, [SUBKEY]) 101*0a6a1f1dSLionel Sambuc# ---------------------------------- 102*0a6a1f1dSLionel Sambucm4_define([lt_dict_fetch], 103*0a6a1f1dSLionel Sambuc[m4_ifval([$3], 104*0a6a1f1dSLionel Sambuc m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105*0a6a1f1dSLionel Sambuc m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106*0a6a1f1dSLionel Sambuc 107*0a6a1f1dSLionel Sambuc 108*0a6a1f1dSLionel Sambuc# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109*0a6a1f1dSLionel Sambuc# ----------------------------------------------------------------- 110*0a6a1f1dSLionel Sambucm4_define([lt_if_dict_fetch], 111*0a6a1f1dSLionel Sambuc[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112*0a6a1f1dSLionel Sambuc [$5], 113*0a6a1f1dSLionel Sambuc [$6])]) 114*0a6a1f1dSLionel Sambuc 115*0a6a1f1dSLionel Sambuc 116*0a6a1f1dSLionel Sambuc# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117*0a6a1f1dSLionel Sambuc# -------------------------------------------------------------- 118*0a6a1f1dSLionel Sambucm4_define([lt_dict_filter], 119*0a6a1f1dSLionel Sambuc[m4_if([$5], [], [], 120*0a6a1f1dSLionel Sambuc [lt_join(m4_quote(m4_default([$4], [[, ]])), 121*0a6a1f1dSLionel Sambuc lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122*0a6a1f1dSLionel Sambuc [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123*0a6a1f1dSLionel Sambuc]) 124