13bf3b463Smrg# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 23bf3b463Smrg# 33bf3b463Smrg# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2024 Free Software 43bf3b463Smrg# Foundation, Inc. 53bf3b463Smrg# Written by Gary V. Vaughan, 2004 63bf3b463Smrg# 73bf3b463Smrg# This file is free software; the Free Software Foundation gives 83bf3b463Smrg# unlimited permission to copy and/or distribute it, with or without 93bf3b463Smrg# modifications, as long as this notice is preserved. 103bf3b463Smrg 113bf3b463Smrg# serial 6 ltsugar.m4 123bf3b463Smrg 133bf3b463Smrg# This is to help aclocal find these macros, as it can't see m4_define. 143bf3b463SmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 153bf3b463Smrg 163bf3b463Smrg 173bf3b463Smrg# lt_join(SEP, ARG1, [ARG2...]) 183bf3b463Smrg# ----------------------------- 193bf3b463Smrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 203bf3b463Smrg# associated separator. 213bf3b463Smrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 223bf3b463Smrg# versions in m4sugar had bugs. 233bf3b463Smrgm4_define([lt_join], 243bf3b463Smrg[m4_if([$#], [1], [], 253bf3b463Smrg [$#], [2], [[$2]], 263bf3b463Smrg [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 273bf3b463Smrgm4_define([_lt_join], 283bf3b463Smrg[m4_if([$#$2], [2], [], 293bf3b463Smrg [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 303bf3b463Smrg 313bf3b463Smrg 323bf3b463Smrg# lt_car(LIST) 333bf3b463Smrg# lt_cdr(LIST) 343bf3b463Smrg# ------------ 353bf3b463Smrg# Manipulate m4 lists. 363bf3b463Smrg# These macros are necessary as long as will still need to support 373bf3b463Smrg# Autoconf-2.59, which quotes differently. 383bf3b463Smrgm4_define([lt_car], [[$1]]) 393bf3b463Smrgm4_define([lt_cdr], 403bf3b463Smrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 413bf3b463Smrg [$#], 1, [], 423bf3b463Smrg [m4_dquote(m4_shift($@))])]) 433bf3b463Smrgm4_define([lt_unquote], $1) 443bf3b463Smrg 453bf3b463Smrg 463bf3b463Smrg# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 473bf3b463Smrg# ------------------------------------------ 483bf3b463Smrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. 493bf3b463Smrg# Note that neither SEPARATOR nor STRING are expanded; they are appended 503bf3b463Smrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 513bf3b463Smrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different 523bf3b463Smrg# than defined and empty). 533bf3b463Smrg# 543bf3b463Smrg# This macro is needed until we can rely on Autoconf 2.62, since earlier 553bf3b463Smrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 563bf3b463Smrgm4_define([lt_append], 573bf3b463Smrg[m4_define([$1], 583bf3b463Smrg m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 593bf3b463Smrg 603bf3b463Smrg 613bf3b463Smrg 623bf3b463Smrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 633bf3b463Smrg# ---------------------------------------------------------- 643bf3b463Smrg# Produce a SEP delimited list of all paired combinations of elements of 653bf3b463Smrg# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 663bf3b463Smrg# has the form PREFIXmINFIXSUFFIXn. 673bf3b463Smrg# Needed until we can rely on m4_combine added in Autoconf 2.62. 683bf3b463Smrgm4_define([lt_combine], 693bf3b463Smrg[m4_if(m4_eval([$# > 3]), [1], 703bf3b463Smrg [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 713bf3b463Smrg[[m4_foreach([_Lt_prefix], [$2], 723bf3b463Smrg [m4_foreach([_Lt_suffix], 733bf3b463Smrg ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 743bf3b463Smrg [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 753bf3b463Smrg 763bf3b463Smrg 773bf3b463Smrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 783bf3b463Smrg# ----------------------------------------------------------------------- 793bf3b463Smrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 803bf3b463Smrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 813bf3b463Smrgm4_define([lt_if_append_uniq], 823bf3b463Smrg[m4_ifdef([$1], 833bf3b463Smrg [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 843bf3b463Smrg [lt_append([$1], [$2], [$3])$4], 853bf3b463Smrg [$5])], 863bf3b463Smrg [lt_append([$1], [$2], [$3])$4])]) 873bf3b463Smrg 883bf3b463Smrg 893bf3b463Smrg# lt_dict_add(DICT, KEY, VALUE) 903bf3b463Smrg# ----------------------------- 913bf3b463Smrgm4_define([lt_dict_add], 923bf3b463Smrg[m4_define([$1($2)], [$3])]) 933bf3b463Smrg 943bf3b463Smrg 953bf3b463Smrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 963bf3b463Smrg# -------------------------------------------- 973bf3b463Smrgm4_define([lt_dict_add_subkey], 983bf3b463Smrg[m4_define([$1($2:$3)], [$4])]) 993bf3b463Smrg 1003bf3b463Smrg 1013bf3b463Smrg# lt_dict_fetch(DICT, KEY, [SUBKEY]) 1023bf3b463Smrg# ---------------------------------- 1033bf3b463Smrgm4_define([lt_dict_fetch], 1043bf3b463Smrg[m4_ifval([$3], 1053bf3b463Smrg m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 1063bf3b463Smrg m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 1073bf3b463Smrg 1083bf3b463Smrg 1093bf3b463Smrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 1103bf3b463Smrg# ----------------------------------------------------------------- 1113bf3b463Smrgm4_define([lt_if_dict_fetch], 1123bf3b463Smrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 1133bf3b463Smrg [$5], 1143bf3b463Smrg [$6])]) 1153bf3b463Smrg 1163bf3b463Smrg 1173bf3b463Smrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 1183bf3b463Smrg# -------------------------------------------------------------- 1193bf3b463Smrgm4_define([lt_dict_filter], 1203bf3b463Smrg[m4_if([$5], [], [], 1213bf3b463Smrg [lt_join(m4_quote(m4_default([$4], [[, ]])), 1223bf3b463Smrg lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 1233bf3b463Smrg [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 1243bf3b463Smrg]) 125