immutable: Add tests.
[gnulib.git] / m4 / libtextstyle.m4
blob6ae52619291ae1cc0933bec05f4a20367c181d48
1 # libtextstyle.m4 serial 3
2 dnl Copyright (C) 2019-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl From Bruno Haible.
9 dnl gl_LIBTEXTSTYLE([MINIMUM-VERSION])
10 dnl Searches for an installed libtextstyle with version >= MINIMUM-VERSION.
11 dnl   MINIMUM-VERSION = 0.20      - the first release in 2019
12 dnl   MINIMUM-VERSION = 0.20.5    - adds hyperlink support and ostream_printf
13 dnl   MINIMUM-VERSION unspecified - the newest release
14 dnl If found, it sets and AC_SUBSTs HAVE_LIBTEXTSTYLE=yes and the LIBTEXTSTYLE
15 dnl and LTLIBTEXTSTYLE variables, and augments the CPPFLAGS variable, and
16 dnl #defines HAVE_LIBTEXTSTYLE to 1.
17 dnl Otherwise, it sets and AC_SUBSTs HAVE_LIBTEXTSTYLE=no and LIBTEXTSTYLE and
18 dnl LTLIBTEXTSTYLE to empty.
20 AC_DEFUN([gl_LIBTEXTSTYLE],
22   AC_REQUIRE([gl_LIBTEXTSTYLE_INITIALIZE])
23   AC_REQUIRE([gl_LIBTEXTSTYLE_SEARCH])
24   pushdef([MINVERSION], m4_if([$1], [], [gl_LIBTEXTSTYLE_NEWEST_VERSION], [$1]))
25   dnl Signal a fatal error if MINVERSION is not among the allowed values.
26   m4_if(m4_if(MINVERSION, [0.20], [x], [])m4_if(MINVERSION, [0.20.5], [x], []), [],
27     [m4_fatal([The argument to gl_LIBTEXTSTYLE or gl_LIBTEXTSTYLE_OPTIONAL is not one of the expected values.])])
28   dnl Store the specified minimum version in gl_libtextstyle_minversion.
29   dnl (This needs to be outside the m4_if. m4_divert_text inside m4_if does
30   dnl not work reliably in Autoconf 2.69.)
31   m4_divert_text([INIT_PREPARE],
32     [gl_libtextstyle_minversion="$gl_libtextstyle_minversion MINVERSION "])
33   popdef([MINVERSION])
36 AC_DEFUN([gl_LIBTEXTSTYLE_NEWEST_VERSION], [0.20.5])
38 AC_DEFUN([gl_LIBTEXTSTYLE_INITIALIZE],
40   m4_divert_text([DEFAULTS], [gl_libtextstyle_minversion=' 0.20 '])
43 AC_DEFUN([gl_LIBTEXTSTYLE_SEARCH],
45   dnl $gl_libtextstyle_minversion evaluates to a space-separated list of
46   dnl specified minimum versions. The maximum of these requirement matters.
47   case "$gl_libtextstyle_minversion" in
48     *" 0.20.5 "*)
49       snippet='styled_ostream_t s = term_styled_ostream_create(1,"",TTYCTL_AUTO,"");
50                ostream_printf(s,"%d",42);'
51       ;;
52     *" 0.20 "*)
53       snippet='term_styled_ostream_create(1,"",TTYCTL_AUTO,"");'
54       ;;
55   esac
56   AC_LIB_HAVE_LINKFLAGS([textstyle], [],
57     [#include <textstyle.h>], [$snippet],
58     [no])