10ef0e59aSmrg# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 20ef0e59aSmrg# 3d5e6aabbSmrg# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2024 Free Software 40ef0e59aSmrg# Foundation, Inc. 50ef0e59aSmrg# Written by Gary V. Vaughan, 2004 60ef0e59aSmrg# 70ef0e59aSmrg# This file is free software; the Free Software Foundation gives 80ef0e59aSmrg# unlimited permission to copy and/or distribute it, with or without 90ef0e59aSmrg# modifications, as long as this notice is preserved. 100ef0e59aSmrg 110ef0e59aSmrg# serial 6 ltsugar.m4 120ef0e59aSmrg 130ef0e59aSmrg# This is to help aclocal find these macros, as it can't see m4_define. 140ef0e59aSmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 150ef0e59aSmrg 160ef0e59aSmrg 170ef0e59aSmrg# lt_join(SEP, ARG1, [ARG2...]) 180ef0e59aSmrg# ----------------------------- 190ef0e59aSmrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 200ef0e59aSmrg# associated separator. 210ef0e59aSmrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 220ef0e59aSmrg# versions in m4sugar had bugs. 230ef0e59aSmrgm4_define([lt_join], 240ef0e59aSmrg[m4_if([$#], [1], [], 250ef0e59aSmrg [$#], [2], [[$2]], 260ef0e59aSmrg [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 270ef0e59aSmrgm4_define([_lt_join], 280ef0e59aSmrg[m4_if([$#$2], [2], [], 290ef0e59aSmrg [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 300ef0e59aSmrg 310ef0e59aSmrg 320ef0e59aSmrg# lt_car(LIST) 330ef0e59aSmrg# lt_cdr(LIST) 340ef0e59aSmrg# ------------ 350ef0e59aSmrg# Manipulate m4 lists. 360ef0e59aSmrg# These macros are necessary as long as will still need to support 370ef0e59aSmrg# Autoconf-2.59, which quotes differently. 380ef0e59aSmrgm4_define([lt_car], [[$1]]) 390ef0e59aSmrgm4_define([lt_cdr], 400ef0e59aSmrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 410ef0e59aSmrg [$#], 1, [], 420ef0e59aSmrg [m4_dquote(m4_shift($@))])]) 430ef0e59aSmrgm4_define([lt_unquote], $1) 440ef0e59aSmrg 450ef0e59aSmrg 460ef0e59aSmrg# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 470ef0e59aSmrg# ------------------------------------------ 480ef0e59aSmrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. 490ef0e59aSmrg# Note that neither SEPARATOR nor STRING are expanded; they are appended 500ef0e59aSmrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 510ef0e59aSmrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different 520ef0e59aSmrg# than defined and empty). 530ef0e59aSmrg# 540ef0e59aSmrg# This macro is needed until we can rely on Autoconf 2.62, since earlier 550ef0e59aSmrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 560ef0e59aSmrgm4_define([lt_append], 570ef0e59aSmrg[m4_define([$1], 580ef0e59aSmrg m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 590ef0e59aSmrg 600ef0e59aSmrg 610ef0e59aSmrg 620ef0e59aSmrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 630ef0e59aSmrg# ---------------------------------------------------------- 640ef0e59aSmrg# Produce a SEP delimited list of all paired combinations of elements of 650ef0e59aSmrg# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 660ef0e59aSmrg# has the form PREFIXmINFIXSUFFIXn. 670ef0e59aSmrg# Needed until we can rely on m4_combine added in Autoconf 2.62. 680ef0e59aSmrgm4_define([lt_combine], 690ef0e59aSmrg[m4_if(m4_eval([$# > 3]), [1], 700ef0e59aSmrg [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 710ef0e59aSmrg[[m4_foreach([_Lt_prefix], [$2], 720ef0e59aSmrg [m4_foreach([_Lt_suffix], 730ef0e59aSmrg ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 740ef0e59aSmrg [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 750ef0e59aSmrg 760ef0e59aSmrg 770ef0e59aSmrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 780ef0e59aSmrg# ----------------------------------------------------------------------- 790ef0e59aSmrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 800ef0e59aSmrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 810ef0e59aSmrgm4_define([lt_if_append_uniq], 820ef0e59aSmrg[m4_ifdef([$1], 830ef0e59aSmrg [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 840ef0e59aSmrg [lt_append([$1], [$2], [$3])$4], 850ef0e59aSmrg [$5])], 860ef0e59aSmrg [lt_append([$1], [$2], [$3])$4])]) 870ef0e59aSmrg 880ef0e59aSmrg 890ef0e59aSmrg# lt_dict_add(DICT, KEY, VALUE) 900ef0e59aSmrg# ----------------------------- 910ef0e59aSmrgm4_define([lt_dict_add], 920ef0e59aSmrg[m4_define([$1($2)], [$3])]) 930ef0e59aSmrg 940ef0e59aSmrg 950ef0e59aSmrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 960ef0e59aSmrg# -------------------------------------------- 970ef0e59aSmrgm4_define([lt_dict_add_subkey], 980ef0e59aSmrg[m4_define([$1($2:$3)], [$4])]) 990ef0e59aSmrg 1000ef0e59aSmrg 1010ef0e59aSmrg# lt_dict_fetch(DICT, KEY, [SUBKEY]) 1020ef0e59aSmrg# ---------------------------------- 1030ef0e59aSmrgm4_define([lt_dict_fetch], 1040ef0e59aSmrg[m4_ifval([$3], 1050ef0e59aSmrg m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 1060ef0e59aSmrg m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 1070ef0e59aSmrg 1080ef0e59aSmrg 1090ef0e59aSmrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 1100ef0e59aSmrg# ----------------------------------------------------------------- 1110ef0e59aSmrgm4_define([lt_if_dict_fetch], 1120ef0e59aSmrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 1130ef0e59aSmrg [$5], 1140ef0e59aSmrg [$6])]) 1150ef0e59aSmrg 1160ef0e59aSmrg 1170ef0e59aSmrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 1180ef0e59aSmrg# -------------------------------------------------------------- 1190ef0e59aSmrgm4_define([lt_dict_filter], 1200ef0e59aSmrg[m4_if([$5], [], [], 1210ef0e59aSmrg [lt_join(m4_quote(m4_default([$4], [[, ]])), 1220ef0e59aSmrg lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 1230ef0e59aSmrg [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 1240ef0e59aSmrg]) 125