124b90cf4Smrg# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 224b90cf4Smrg# 346845023Smrg# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software 424b90cf4Smrg# Foundation, Inc. 524b90cf4Smrg# Written by Gary V. Vaughan, 2004 624b90cf4Smrg# 724b90cf4Smrg# This file is free software; the Free Software Foundation gives 824b90cf4Smrg# unlimited permission to copy and/or distribute it, with or without 924b90cf4Smrg# modifications, as long as this notice is preserved. 1024b90cf4Smrg 1124b90cf4Smrg# serial 6 ltsugar.m4 1224b90cf4Smrg 1324b90cf4Smrg# This is to help aclocal find these macros, as it can't see m4_define. 1424b90cf4SmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 1524b90cf4Smrg 1624b90cf4Smrg 1724b90cf4Smrg# lt_join(SEP, ARG1, [ARG2...]) 1824b90cf4Smrg# ----------------------------- 1924b90cf4Smrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 2024b90cf4Smrg# associated separator. 2124b90cf4Smrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 2224b90cf4Smrg# versions in m4sugar had bugs. 2324b90cf4Smrgm4_define([lt_join], 2424b90cf4Smrg[m4_if([$#], [1], [], 2524b90cf4Smrg [$#], [2], [[$2]], 2624b90cf4Smrg [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 2724b90cf4Smrgm4_define([_lt_join], 2824b90cf4Smrg[m4_if([$#$2], [2], [], 2924b90cf4Smrg [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 3024b90cf4Smrg 3124b90cf4Smrg 3224b90cf4Smrg# lt_car(LIST) 3324b90cf4Smrg# lt_cdr(LIST) 3424b90cf4Smrg# ------------ 3524b90cf4Smrg# Manipulate m4 lists. 3624b90cf4Smrg# These macros are necessary as long as will still need to support 3724b90cf4Smrg# Autoconf-2.59, which quotes differently. 3824b90cf4Smrgm4_define([lt_car], [[$1]]) 3924b90cf4Smrgm4_define([lt_cdr], 4024b90cf4Smrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 4124b90cf4Smrg [$#], 1, [], 4224b90cf4Smrg [m4_dquote(m4_shift($@))])]) 4324b90cf4Smrgm4_define([lt_unquote], $1) 4424b90cf4Smrg 4524b90cf4Smrg 4624b90cf4Smrg# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 4724b90cf4Smrg# ------------------------------------------ 4824b90cf4Smrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. 4924b90cf4Smrg# Note that neither SEPARATOR nor STRING are expanded; they are appended 5024b90cf4Smrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 5124b90cf4Smrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different 5224b90cf4Smrg# than defined and empty). 5324b90cf4Smrg# 5424b90cf4Smrg# This macro is needed until we can rely on Autoconf 2.62, since earlier 5524b90cf4Smrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 5624b90cf4Smrgm4_define([lt_append], 5724b90cf4Smrg[m4_define([$1], 5824b90cf4Smrg m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 5924b90cf4Smrg 6024b90cf4Smrg 6124b90cf4Smrg 6224b90cf4Smrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 6324b90cf4Smrg# ---------------------------------------------------------- 6424b90cf4Smrg# Produce a SEP delimited list of all paired combinations of elements of 6524b90cf4Smrg# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 6624b90cf4Smrg# has the form PREFIXmINFIXSUFFIXn. 6724b90cf4Smrg# Needed until we can rely on m4_combine added in Autoconf 2.62. 6824b90cf4Smrgm4_define([lt_combine], 6924b90cf4Smrg[m4_if(m4_eval([$# > 3]), [1], 7024b90cf4Smrg [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 7124b90cf4Smrg[[m4_foreach([_Lt_prefix], [$2], 7224b90cf4Smrg [m4_foreach([_Lt_suffix], 7324b90cf4Smrg ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 7424b90cf4Smrg [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 7524b90cf4Smrg 7624b90cf4Smrg 7724b90cf4Smrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 7824b90cf4Smrg# ----------------------------------------------------------------------- 7924b90cf4Smrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 8024b90cf4Smrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 8124b90cf4Smrgm4_define([lt_if_append_uniq], 8224b90cf4Smrg[m4_ifdef([$1], 8324b90cf4Smrg [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 8424b90cf4Smrg [lt_append([$1], [$2], [$3])$4], 8524b90cf4Smrg [$5])], 8624b90cf4Smrg [lt_append([$1], [$2], [$3])$4])]) 8724b90cf4Smrg 8824b90cf4Smrg 8924b90cf4Smrg# lt_dict_add(DICT, KEY, VALUE) 9024b90cf4Smrg# ----------------------------- 9124b90cf4Smrgm4_define([lt_dict_add], 9224b90cf4Smrg[m4_define([$1($2)], [$3])]) 9324b90cf4Smrg 9424b90cf4Smrg 9524b90cf4Smrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 9624b90cf4Smrg# -------------------------------------------- 9724b90cf4Smrgm4_define([lt_dict_add_subkey], 9824b90cf4Smrg[m4_define([$1($2:$3)], [$4])]) 9924b90cf4Smrg 10024b90cf4Smrg 10124b90cf4Smrg# lt_dict_fetch(DICT, KEY, [SUBKEY]) 10224b90cf4Smrg# ---------------------------------- 10324b90cf4Smrgm4_define([lt_dict_fetch], 10424b90cf4Smrg[m4_ifval([$3], 10524b90cf4Smrg m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 10624b90cf4Smrg m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 10724b90cf4Smrg 10824b90cf4Smrg 10924b90cf4Smrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 11024b90cf4Smrg# ----------------------------------------------------------------- 11124b90cf4Smrgm4_define([lt_if_dict_fetch], 11224b90cf4Smrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 11324b90cf4Smrg [$5], 11424b90cf4Smrg [$6])]) 11524b90cf4Smrg 11624b90cf4Smrg 11724b90cf4Smrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 11824b90cf4Smrg# -------------------------------------------------------------- 11924b90cf4Smrgm4_define([lt_dict_filter], 12024b90cf4Smrg[m4_if([$5], [], [], 12124b90cf4Smrg [lt_join(m4_quote(m4_default([$4], [[, ]])), 12224b90cf4Smrg lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 12324b90cf4Smrg [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 12424b90cf4Smrg]) 125