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