ltsugar.m4 revision 7204935c
11016ad83Smrg# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 21016ad83Smrg# 37204935cSmrg# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software 47204935cSmrg# Foundation, Inc. 51016ad83Smrg# Written by Gary V. Vaughan, 2004 61016ad83Smrg# 71016ad83Smrg# This file is free software; the Free Software Foundation gives 81016ad83Smrg# unlimited permission to copy and/or distribute it, with or without 91016ad83Smrg# modifications, as long as this notice is preserved. 101016ad83Smrg 111016ad83Smrg# serial 6 ltsugar.m4 121016ad83Smrg 131016ad83Smrg# This is to help aclocal find these macros, as it can't see m4_define. 141016ad83SmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 151016ad83Smrg 161016ad83Smrg 171016ad83Smrg# lt_join(SEP, ARG1, [ARG2...]) 181016ad83Smrg# ----------------------------- 191016ad83Smrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 201016ad83Smrg# associated separator. 211016ad83Smrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 221016ad83Smrg# versions in m4sugar had bugs. 231016ad83Smrgm4_define([lt_join], 241016ad83Smrg[m4_if([$#], [1], [], 251016ad83Smrg [$#], [2], [[$2]], 261016ad83Smrg [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 271016ad83Smrgm4_define([_lt_join], 281016ad83Smrg[m4_if([$#$2], [2], [], 291016ad83Smrg [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 301016ad83Smrg 311016ad83Smrg 321016ad83Smrg# lt_car(LIST) 331016ad83Smrg# lt_cdr(LIST) 341016ad83Smrg# ------------ 351016ad83Smrg# Manipulate m4 lists. 361016ad83Smrg# These macros are necessary as long as will still need to support 377204935cSmrg# Autoconf-2.59, which quotes differently. 381016ad83Smrgm4_define([lt_car], [[$1]]) 391016ad83Smrgm4_define([lt_cdr], 401016ad83Smrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 411016ad83Smrg [$#], 1, [], 421016ad83Smrg [m4_dquote(m4_shift($@))])]) 431016ad83Smrgm4_define([lt_unquote], $1) 441016ad83Smrg 451016ad83Smrg 461016ad83Smrg# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 471016ad83Smrg# ------------------------------------------ 487204935cSmrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. 491016ad83Smrg# Note that neither SEPARATOR nor STRING are expanded; they are appended 501016ad83Smrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 511016ad83Smrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different 521016ad83Smrg# than defined and empty). 531016ad83Smrg# 541016ad83Smrg# This macro is needed until we can rely on Autoconf 2.62, since earlier 551016ad83Smrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 561016ad83Smrgm4_define([lt_append], 571016ad83Smrg[m4_define([$1], 581016ad83Smrg m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 591016ad83Smrg 601016ad83Smrg 611016ad83Smrg 621016ad83Smrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 631016ad83Smrg# ---------------------------------------------------------- 641016ad83Smrg# Produce a SEP delimited list of all paired combinations of elements of 651016ad83Smrg# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 661016ad83Smrg# has the form PREFIXmINFIXSUFFIXn. 671016ad83Smrg# Needed until we can rely on m4_combine added in Autoconf 2.62. 681016ad83Smrgm4_define([lt_combine], 691016ad83Smrg[m4_if(m4_eval([$# > 3]), [1], 701016ad83Smrg [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 711016ad83Smrg[[m4_foreach([_Lt_prefix], [$2], 721016ad83Smrg [m4_foreach([_Lt_suffix], 731016ad83Smrg ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 741016ad83Smrg [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 751016ad83Smrg 761016ad83Smrg 771016ad83Smrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 781016ad83Smrg# ----------------------------------------------------------------------- 791016ad83Smrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 801016ad83Smrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 811016ad83Smrgm4_define([lt_if_append_uniq], 821016ad83Smrg[m4_ifdef([$1], 831016ad83Smrg [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 841016ad83Smrg [lt_append([$1], [$2], [$3])$4], 851016ad83Smrg [$5])], 861016ad83Smrg [lt_append([$1], [$2], [$3])$4])]) 871016ad83Smrg 881016ad83Smrg 891016ad83Smrg# lt_dict_add(DICT, KEY, VALUE) 901016ad83Smrg# ----------------------------- 911016ad83Smrgm4_define([lt_dict_add], 921016ad83Smrg[m4_define([$1($2)], [$3])]) 931016ad83Smrg 941016ad83Smrg 951016ad83Smrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 961016ad83Smrg# -------------------------------------------- 971016ad83Smrgm4_define([lt_dict_add_subkey], 981016ad83Smrg[m4_define([$1($2:$3)], [$4])]) 991016ad83Smrg 1001016ad83Smrg 1011016ad83Smrg# lt_dict_fetch(DICT, KEY, [SUBKEY]) 1021016ad83Smrg# ---------------------------------- 1031016ad83Smrgm4_define([lt_dict_fetch], 1041016ad83Smrg[m4_ifval([$3], 1051016ad83Smrg m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 1061016ad83Smrg m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 1071016ad83Smrg 1081016ad83Smrg 1091016ad83Smrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 1101016ad83Smrg# ----------------------------------------------------------------- 1111016ad83Smrgm4_define([lt_if_dict_fetch], 1121016ad83Smrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 1131016ad83Smrg [$5], 1141016ad83Smrg [$6])]) 1151016ad83Smrg 1161016ad83Smrg 1171016ad83Smrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 1181016ad83Smrg# -------------------------------------------------------------- 1191016ad83Smrgm4_define([lt_dict_filter], 1201016ad83Smrg[m4_if([$5], [], [], 1211016ad83Smrg [lt_join(m4_quote(m4_default([$4], [[, ]])), 1221016ad83Smrg lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 1231016ad83Smrg [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 1241016ad83Smrg]) 125