15b16253fSmrg# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 25b16253fSmrg# 35b16253fSmrg# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2022 Free Software 45b16253fSmrg# Foundation, Inc. 55b16253fSmrg# Written by Gary V. Vaughan, 2004 65b16253fSmrg# 75b16253fSmrg# This file is free software; the Free Software Foundation gives 85b16253fSmrg# unlimited permission to copy and/or distribute it, with or without 95b16253fSmrg# modifications, as long as this notice is preserved. 105b16253fSmrg 115b16253fSmrg# serial 6 ltsugar.m4 125b16253fSmrg 135b16253fSmrg# This is to help aclocal find these macros, as it can't see m4_define. 145b16253fSmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 155b16253fSmrg 165b16253fSmrg 175b16253fSmrg# lt_join(SEP, ARG1, [ARG2...]) 185b16253fSmrg# ----------------------------- 195b16253fSmrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 205b16253fSmrg# associated separator. 215b16253fSmrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 225b16253fSmrg# versions in m4sugar had bugs. 235b16253fSmrgm4_define([lt_join], 245b16253fSmrg[m4_if([$#], [1], [], 255b16253fSmrg [$#], [2], [[$2]], 265b16253fSmrg [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 275b16253fSmrgm4_define([_lt_join], 285b16253fSmrg[m4_if([$#$2], [2], [], 295b16253fSmrg [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 305b16253fSmrg 315b16253fSmrg 325b16253fSmrg# lt_car(LIST) 335b16253fSmrg# lt_cdr(LIST) 345b16253fSmrg# ------------ 355b16253fSmrg# Manipulate m4 lists. 365b16253fSmrg# These macros are necessary as long as will still need to support 375b16253fSmrg# Autoconf-2.59, which quotes differently. 385b16253fSmrgm4_define([lt_car], [[$1]]) 395b16253fSmrgm4_define([lt_cdr], 405b16253fSmrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 415b16253fSmrg [$#], 1, [], 425b16253fSmrg [m4_dquote(m4_shift($@))])]) 435b16253fSmrgm4_define([lt_unquote], $1) 445b16253fSmrg 455b16253fSmrg 465b16253fSmrg# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 475b16253fSmrg# ------------------------------------------ 485b16253fSmrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. 495b16253fSmrg# Note that neither SEPARATOR nor STRING are expanded; they are appended 505b16253fSmrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 515b16253fSmrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different 525b16253fSmrg# than defined and empty). 535b16253fSmrg# 545b16253fSmrg# This macro is needed until we can rely on Autoconf 2.62, since earlier 555b16253fSmrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 565b16253fSmrgm4_define([lt_append], 575b16253fSmrg[m4_define([$1], 585b16253fSmrg m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 595b16253fSmrg 605b16253fSmrg 615b16253fSmrg 625b16253fSmrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 635b16253fSmrg# ---------------------------------------------------------- 645b16253fSmrg# Produce a SEP delimited list of all paired combinations of elements of 655b16253fSmrg# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 665b16253fSmrg# has the form PREFIXmINFIXSUFFIXn. 675b16253fSmrg# Needed until we can rely on m4_combine added in Autoconf 2.62. 685b16253fSmrgm4_define([lt_combine], 695b16253fSmrg[m4_if(m4_eval([$# > 3]), [1], 705b16253fSmrg [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 715b16253fSmrg[[m4_foreach([_Lt_prefix], [$2], 725b16253fSmrg [m4_foreach([_Lt_suffix], 735b16253fSmrg ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 745b16253fSmrg [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 755b16253fSmrg 765b16253fSmrg 775b16253fSmrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 785b16253fSmrg# ----------------------------------------------------------------------- 795b16253fSmrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 805b16253fSmrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 815b16253fSmrgm4_define([lt_if_append_uniq], 825b16253fSmrg[m4_ifdef([$1], 835b16253fSmrg [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 845b16253fSmrg [lt_append([$1], [$2], [$3])$4], 855b16253fSmrg [$5])], 865b16253fSmrg [lt_append([$1], [$2], [$3])$4])]) 875b16253fSmrg 885b16253fSmrg 895b16253fSmrg# lt_dict_add(DICT, KEY, VALUE) 905b16253fSmrg# ----------------------------- 915b16253fSmrgm4_define([lt_dict_add], 925b16253fSmrg[m4_define([$1($2)], [$3])]) 935b16253fSmrg 945b16253fSmrg 955b16253fSmrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 965b16253fSmrg# -------------------------------------------- 975b16253fSmrgm4_define([lt_dict_add_subkey], 985b16253fSmrg[m4_define([$1($2:$3)], [$4])]) 995b16253fSmrg 1005b16253fSmrg 1015b16253fSmrg# lt_dict_fetch(DICT, KEY, [SUBKEY]) 1025b16253fSmrg# ---------------------------------- 1035b16253fSmrgm4_define([lt_dict_fetch], 1045b16253fSmrg[m4_ifval([$3], 1055b16253fSmrg m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 1065b16253fSmrg m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 1075b16253fSmrg 1085b16253fSmrg 1095b16253fSmrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 1105b16253fSmrg# ----------------------------------------------------------------- 1115b16253fSmrgm4_define([lt_if_dict_fetch], 1125b16253fSmrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 1135b16253fSmrg [$5], 1145b16253fSmrg [$6])]) 1155b16253fSmrg 1165b16253fSmrg 1175b16253fSmrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 1185b16253fSmrg# -------------------------------------------------------------- 1195b16253fSmrgm4_define([lt_dict_filter], 1205b16253fSmrg[m4_if([$5], [], [], 1215b16253fSmrg [lt_join(m4_quote(m4_default([$4], [[, ]])), 1225b16253fSmrg lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 1235b16253fSmrg [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 1245b16253fSmrg]) 125