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