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