100ca1914Smrg# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 200ca1914Smrg# 300ca1914Smrg# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2022 Free Software 400ca1914Smrg# Foundation, Inc. 500ca1914Smrg# Written by Gary V. Vaughan, 2004 600ca1914Smrg# 700ca1914Smrg# This file is free software; the Free Software Foundation gives 800ca1914Smrg# unlimited permission to copy and/or distribute it, with or without 900ca1914Smrg# modifications, as long as this notice is preserved. 1000ca1914Smrg 1100ca1914Smrg# serial 6 ltsugar.m4 1200ca1914Smrg 1300ca1914Smrg# This is to help aclocal find these macros, as it can't see m4_define. 1400ca1914SmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 1500ca1914Smrg 1600ca1914Smrg 1700ca1914Smrg# lt_join(SEP, ARG1, [ARG2...]) 1800ca1914Smrg# ----------------------------- 1900ca1914Smrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 2000ca1914Smrg# associated separator. 2100ca1914Smrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 2200ca1914Smrg# versions in m4sugar had bugs. 2300ca1914Smrgm4_define([lt_join], 2400ca1914Smrg[m4_if([$#], [1], [], 2500ca1914Smrg [$#], [2], [[$2]], 2600ca1914Smrg [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 2700ca1914Smrgm4_define([_lt_join], 2800ca1914Smrg[m4_if([$#$2], [2], [], 2900ca1914Smrg [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 3000ca1914Smrg 3100ca1914Smrg 3200ca1914Smrg# lt_car(LIST) 3300ca1914Smrg# lt_cdr(LIST) 3400ca1914Smrg# ------------ 3500ca1914Smrg# Manipulate m4 lists. 3600ca1914Smrg# These macros are necessary as long as will still need to support 3700ca1914Smrg# Autoconf-2.59, which quotes differently. 3800ca1914Smrgm4_define([lt_car], [[$1]]) 3900ca1914Smrgm4_define([lt_cdr], 4000ca1914Smrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 4100ca1914Smrg [$#], 1, [], 4200ca1914Smrg [m4_dquote(m4_shift($@))])]) 4300ca1914Smrgm4_define([lt_unquote], $1) 4400ca1914Smrg 4500ca1914Smrg 4600ca1914Smrg# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 4700ca1914Smrg# ------------------------------------------ 4800ca1914Smrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. 4900ca1914Smrg# Note that neither SEPARATOR nor STRING are expanded; they are appended 5000ca1914Smrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 5100ca1914Smrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different 5200ca1914Smrg# than defined and empty). 5300ca1914Smrg# 5400ca1914Smrg# This macro is needed until we can rely on Autoconf 2.62, since earlier 5500ca1914Smrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 5600ca1914Smrgm4_define([lt_append], 5700ca1914Smrg[m4_define([$1], 5800ca1914Smrg m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 5900ca1914Smrg 6000ca1914Smrg 6100ca1914Smrg 6200ca1914Smrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 6300ca1914Smrg# ---------------------------------------------------------- 6400ca1914Smrg# Produce a SEP delimited list of all paired combinations of elements of 6500ca1914Smrg# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 6600ca1914Smrg# has the form PREFIXmINFIXSUFFIXn. 6700ca1914Smrg# Needed until we can rely on m4_combine added in Autoconf 2.62. 6800ca1914Smrgm4_define([lt_combine], 6900ca1914Smrg[m4_if(m4_eval([$# > 3]), [1], 7000ca1914Smrg [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 7100ca1914Smrg[[m4_foreach([_Lt_prefix], [$2], 7200ca1914Smrg [m4_foreach([_Lt_suffix], 7300ca1914Smrg ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 7400ca1914Smrg [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 7500ca1914Smrg 7600ca1914Smrg 7700ca1914Smrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 7800ca1914Smrg# ----------------------------------------------------------------------- 7900ca1914Smrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 8000ca1914Smrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 8100ca1914Smrgm4_define([lt_if_append_uniq], 8200ca1914Smrg[m4_ifdef([$1], 8300ca1914Smrg [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 8400ca1914Smrg [lt_append([$1], [$2], [$3])$4], 8500ca1914Smrg [$5])], 8600ca1914Smrg [lt_append([$1], [$2], [$3])$4])]) 8700ca1914Smrg 8800ca1914Smrg 8900ca1914Smrg# lt_dict_add(DICT, KEY, VALUE) 9000ca1914Smrg# ----------------------------- 9100ca1914Smrgm4_define([lt_dict_add], 9200ca1914Smrg[m4_define([$1($2)], [$3])]) 9300ca1914Smrg 9400ca1914Smrg 9500ca1914Smrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 9600ca1914Smrg# -------------------------------------------- 9700ca1914Smrgm4_define([lt_dict_add_subkey], 9800ca1914Smrg[m4_define([$1($2:$3)], [$4])]) 9900ca1914Smrg 10000ca1914Smrg 10100ca1914Smrg# lt_dict_fetch(DICT, KEY, [SUBKEY]) 10200ca1914Smrg# ---------------------------------- 10300ca1914Smrgm4_define([lt_dict_fetch], 10400ca1914Smrg[m4_ifval([$3], 10500ca1914Smrg m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 10600ca1914Smrg m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 10700ca1914Smrg 10800ca1914Smrg 10900ca1914Smrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 11000ca1914Smrg# ----------------------------------------------------------------- 11100ca1914Smrgm4_define([lt_if_dict_fetch], 11200ca1914Smrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 11300ca1914Smrg [$5], 11400ca1914Smrg [$6])]) 11500ca1914Smrg 11600ca1914Smrg 11700ca1914Smrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 11800ca1914Smrg# -------------------------------------------------------------- 11900ca1914Smrgm4_define([lt_dict_filter], 12000ca1914Smrg[m4_if([$5], [], [], 12100ca1914Smrg [lt_join(m4_quote(m4_default([$4], [[, ]])), 12200ca1914Smrg lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 12300ca1914Smrg [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 12400ca1914Smrg]) 125