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