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