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