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