1603fc0a3Smrg# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2603fc0a3Smrg# 3603fc0a3Smrg# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software 4603fc0a3Smrg# Foundation, Inc. 5603fc0a3Smrg# Written by Gary V. Vaughan, 2004 6603fc0a3Smrg# 7603fc0a3Smrg# This file is free software; the Free Software Foundation gives 8603fc0a3Smrg# unlimited permission to copy and/or distribute it, with or without 9603fc0a3Smrg# modifications, as long as this notice is preserved. 10603fc0a3Smrg 11603fc0a3Smrg# serial 6 ltsugar.m4 12603fc0a3Smrg 13603fc0a3Smrg# This is to help aclocal find these macros, as it can't see m4_define. 14603fc0a3SmrgAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 15603fc0a3Smrg 16603fc0a3Smrg 17603fc0a3Smrg# lt_join(SEP, ARG1, [ARG2...]) 18603fc0a3Smrg# ----------------------------- 19603fc0a3Smrg# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 20603fc0a3Smrg# associated separator. 21603fc0a3Smrg# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 22603fc0a3Smrg# versions in m4sugar had bugs. 23603fc0a3Smrgm4_define([lt_join], 24603fc0a3Smrg[m4_if([$#], [1], [], 25603fc0a3Smrg [$#], [2], [[$2]], 26603fc0a3Smrg [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 27603fc0a3Smrgm4_define([_lt_join], 28603fc0a3Smrg[m4_if([$#$2], [2], [], 29603fc0a3Smrg [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 30603fc0a3Smrg 31603fc0a3Smrg 32603fc0a3Smrg# lt_car(LIST) 33603fc0a3Smrg# lt_cdr(LIST) 34603fc0a3Smrg# ------------ 35603fc0a3Smrg# Manipulate m4 lists. 36603fc0a3Smrg# These macros are necessary as long as will still need to support 37603fc0a3Smrg# Autoconf-2.59, which quotes differently. 38603fc0a3Smrgm4_define([lt_car], [[$1]]) 39603fc0a3Smrgm4_define([lt_cdr], 40603fc0a3Smrg[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 41603fc0a3Smrg [$#], 1, [], 42603fc0a3Smrg [m4_dquote(m4_shift($@))])]) 43603fc0a3Smrgm4_define([lt_unquote], $1) 44603fc0a3Smrg 45603fc0a3Smrg 46603fc0a3Smrg# lt_append(MACRO-NAME, STRING, [SEPARATOR]) 47603fc0a3Smrg# ------------------------------------------ 48603fc0a3Smrg# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. 49603fc0a3Smrg# Note that neither SEPARATOR nor STRING are expanded; they are appended 50603fc0a3Smrg# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 51603fc0a3Smrg# No SEPARATOR is output if MACRO-NAME was previously undefined (different 52603fc0a3Smrg# than defined and empty). 53603fc0a3Smrg# 54603fc0a3Smrg# This macro is needed until we can rely on Autoconf 2.62, since earlier 55603fc0a3Smrg# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 56603fc0a3Smrgm4_define([lt_append], 57603fc0a3Smrg[m4_define([$1], 58603fc0a3Smrg m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 59603fc0a3Smrg 60603fc0a3Smrg 61603fc0a3Smrg 62603fc0a3Smrg# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 63603fc0a3Smrg# ---------------------------------------------------------- 64603fc0a3Smrg# Produce a SEP delimited list of all paired combinations of elements of 65603fc0a3Smrg# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 66603fc0a3Smrg# has the form PREFIXmINFIXSUFFIXn. 67603fc0a3Smrg# Needed until we can rely on m4_combine added in Autoconf 2.62. 68603fc0a3Smrgm4_define([lt_combine], 69603fc0a3Smrg[m4_if(m4_eval([$# > 3]), [1], 70603fc0a3Smrg [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 71603fc0a3Smrg[[m4_foreach([_Lt_prefix], [$2], 72603fc0a3Smrg [m4_foreach([_Lt_suffix], 73603fc0a3Smrg ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 74603fc0a3Smrg [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 75603fc0a3Smrg 76603fc0a3Smrg 77603fc0a3Smrg# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 78603fc0a3Smrg# ----------------------------------------------------------------------- 79603fc0a3Smrg# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 80603fc0a3Smrg# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 81603fc0a3Smrgm4_define([lt_if_append_uniq], 82603fc0a3Smrg[m4_ifdef([$1], 83603fc0a3Smrg [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 84603fc0a3Smrg [lt_append([$1], [$2], [$3])$4], 85603fc0a3Smrg [$5])], 86603fc0a3Smrg [lt_append([$1], [$2], [$3])$4])]) 87603fc0a3Smrg 88603fc0a3Smrg 89603fc0a3Smrg# lt_dict_add(DICT, KEY, VALUE) 90603fc0a3Smrg# ----------------------------- 91603fc0a3Smrgm4_define([lt_dict_add], 92603fc0a3Smrg[m4_define([$1($2)], [$3])]) 93603fc0a3Smrg 94603fc0a3Smrg 95603fc0a3Smrg# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 96603fc0a3Smrg# -------------------------------------------- 97603fc0a3Smrgm4_define([lt_dict_add_subkey], 98603fc0a3Smrg[m4_define([$1($2:$3)], [$4])]) 99603fc0a3Smrg 100603fc0a3Smrg 101603fc0a3Smrg# lt_dict_fetch(DICT, KEY, [SUBKEY]) 102603fc0a3Smrg# ---------------------------------- 103603fc0a3Smrgm4_define([lt_dict_fetch], 104603fc0a3Smrg[m4_ifval([$3], 105603fc0a3Smrg m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 106603fc0a3Smrg m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 107603fc0a3Smrg 108603fc0a3Smrg 109603fc0a3Smrg# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 110603fc0a3Smrg# ----------------------------------------------------------------- 111603fc0a3Smrgm4_define([lt_if_dict_fetch], 112603fc0a3Smrg[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 113603fc0a3Smrg [$5], 114603fc0a3Smrg [$6])]) 115603fc0a3Smrg 116603fc0a3Smrg 117603fc0a3Smrg# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 118603fc0a3Smrg# -------------------------------------------------------------- 119603fc0a3Smrgm4_define([lt_dict_filter], 120603fc0a3Smrg[m4_if([$5], [], [], 121603fc0a3Smrg [lt_join(m4_quote(m4_default([$4], [[, ]])), 122603fc0a3Smrg lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 123603fc0a3Smrg [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 124603fc0a3Smrg]) 125