]> Savannah Git Hosting - gnulib.git/commitdiff
libtextstyle[-optional]: Allow requesting a minimum version.
authorBruno Haible <bruno@clisp.org>
Sat, 1 Aug 2020 13:04:52 +0000 (15:04 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 1 Aug 2020 13:04:52 +0000 (15:04 +0200)
* m4/libtextstyle.m4 (gl_LIBTEXTSTYLE): Allow an optional argument.
(gl_LIBTEXTSTYLE_NEWEST_VERSION, gl_LIBTEXTSTYLE_INITIALIZE,
gl_LIBTEXTSTYLE_SEARCH): New macros.
* modules/libtextstyle (configure.ac): Don't invoke gl_LIBTEXTSTYLE.
* m4/libtextstyle-optional.m4 (gl_LIBTEXTSTYLE_OPTIONAL): Allow an
optional argument. Invoke, not require, gl_LIBTEXTSTYLE.
* modules/libtextstyle-optional (configure.ac): Don't invoke
gl_LIBTEXTSTYLE_OPTIONAL.
* NEWS: Mention the changes.

ChangeLog
NEWS
m4/libtextstyle-optional.m4
m4/libtextstyle.m4
modules/libtextstyle
modules/libtextstyle-optional

index 654c52bdde4b30dd37ca4970f1d55013b7e13fcf..b951c6a1724a594e551b5029ce0c0ee871fa4de7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2020-08-01  Bruno Haible  <bruno@clisp.org>
+
+       libtextstyle[-optional]: Allow requesting a minimum version.
+       * m4/libtextstyle.m4 (gl_LIBTEXTSTYLE): Allow an optional argument.
+       (gl_LIBTEXTSTYLE_NEWEST_VERSION, gl_LIBTEXTSTYLE_INITIALIZE,
+       gl_LIBTEXTSTYLE_SEARCH): New macros.
+       * modules/libtextstyle (configure.ac): Don't invoke gl_LIBTEXTSTYLE.
+       * m4/libtextstyle-optional.m4 (gl_LIBTEXTSTYLE_OPTIONAL): Allow an
+       optional argument. Invoke, not require, gl_LIBTEXTSTYLE.
+       * modules/libtextstyle-optional (configure.ac): Don't invoke
+       gl_LIBTEXTSTYLE_OPTIONAL.
+       * NEWS: Mention the changes.
+
 2020-07-31  Bruno Haible  <bruno@clisp.org>
 
        _GL_CMP: Improve documentation.
diff --git a/NEWS b/NEWS
index 668f2d60c0eacc37f2a51c01c72b4bd5a50524cf..89477472bacb547714c7b462bd935f65ab2c3ca5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,15 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2020-08-01  libtextstyle-optional  You now need to invoke
+                                   gl_LIBTEXTSTYLE_OPTIONAL explicitly, because
+                                   this macro now takes an optional
+                                   MINIMUM-VERSION argument.
+
+2020-08-01  libtextstyle    You now need to invoke gl_LIBTEXTSTYLE explicitly,
+                            because this macro now takes an optional
+                            MINIMUM-VERSION argument.
+
 2020-06-27  clean-temp      The functions open_temp, fopen_temp now take a
                             'bool delete_on_close' argument. If in doubt, pass
                             false.
index 38a7ace873425f2f4289743b23a2c9480fe53763..2c41bbf8d3251e40cbecfa0601c72955bd5aecb0 100644 (file)
@@ -1,4 +1,4 @@
-# libtextstyle-optional.m4 serial 1
+# libtextstyle-optional.m4 serial 2
 dnl Copyright (C) 2019-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,9 +6,13 @@ dnl with or without modifications, as long as this notice is preserved.
 
 dnl From Bruno Haible.
 
-dnl gl_LIBTEXTSTYLE_OPTIONAL
-dnl Searches for an installed libtextstyle or uses the included source code
-dnl parts that define only part of the API and does not do any styling.
+dnl gl_LIBTEXTSTYLE_OPTIONAL([MINIMUM-VERSION])
+dnl Searches for an installed libtextstyle with version >= MINIMUM-VERSION
+dnl   MINIMUM-VERSION = 0.20      - the first release in 2019
+dnl   MINIMUM-VERSION = 0.20.5    - adds hyperlink support and ostream_printf
+dnl   MINIMUM-VERSION unspecified - the newest release
+dnl or uses the included source code parts that define only part of the API
+dnl and do not do any styling.
 dnl If found, it sets and AC_SUBSTs HAVE_LIBTEXTSTYLE=yes and the LIBTEXTSTYLE
 dnl and LTLIBTEXTSTYLE variables, and augments the CPPFLAGS variable, and
 dnl #defines HAVE_LIBTEXTSTYLE to 1.
@@ -17,7 +21,7 @@ dnl LTLIBTEXTSTYLE to empty.
 
 AC_DEFUN([gl_LIBTEXTSTYLE_OPTIONAL],
 [
-  AC_REQUIRE([gl_LIBTEXTSTYLE])
+  gl_LIBTEXTSTYLE([$1])
   if test $HAVE_LIBTEXTSTYLE = yes; then
     TEXTSTYLE_H=
   else
index 23b4a6959c586d128591da6edbe49ec32cede8b6..0b1b1d2d431649bcc69d56b6ca53b460a9ee9f40 100644 (file)
@@ -1,4 +1,4 @@
-# libtextstyle.m4 serial 1
+# libtextstyle.m4 serial 2
 dnl Copyright (C) 2019-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,8 +6,11 @@ dnl with or without modifications, as long as this notice is preserved.
 
 dnl From Bruno Haible.
 
-dnl gl_LIBTEXTSTYLE
-dnl Searches for an installed libtextstyle.
+dnl gl_LIBTEXTSTYLE([MINIMUM-VERSION])
+dnl Searches for an installed libtextstyle with version >= MINIMUM-VERSION.
+dnl   MINIMUM-VERSION = 0.20      - the first release in 2019
+dnl   MINIMUM-VERSION = 0.20.5    - adds hyperlink support and ostream_printf
+dnl   MINIMUM-VERSION unspecified - the newest release
 dnl If found, it sets and AC_SUBSTs HAVE_LIBTEXTSTYLE=yes and the LIBTEXTSTYLE
 dnl and LTLIBTEXTSTYLE variables, and augments the CPPFLAGS variable, and
 dnl #defines HAVE_LIBTEXTSTYLE to 1.
@@ -16,7 +19,41 @@ dnl LTLIBTEXTSTYLE to empty.
 
 AC_DEFUN([gl_LIBTEXTSTYLE],
 [
+  AC_REQUIRE([gl_LIBTEXTSTYLE_INITIALIZE])
+  AC_REQUIRE([gl_LIBTEXTSTYLE_SEARCH])
+  pushdef([MINVERSION], ifelse([$1], [], [gl_LIBTEXTSTYLE_NEWEST_VERSION], [$1]))
+  dnl Signal a fatal error if MINVERSION is not among the allowed values.
+  ifelse(ifelse(MINVERSION, [0.20], [x], [])ifelse(MINVERSION, [0.20.5], [x], []), [],
+    [m4_fatal([The argument to gl_LIBTEXTSTYLE or gl_LIBTEXTSTYLE_OPTIONAL is not one of the expected values.])])
+  dnl Store the specified minimum version in gl_libtextstyle_minversion.
+  dnl (This needs to be outside the ifelse. m4_divert_text inside ifelse does
+  dnl not work reliably in Autoconf 2.69.)
+  m4_divert_text([INIT_PREPARE],
+    [gl_libtextstyle_minversion="$gl_libtextstyle_minversion MINVERSION "])
+  popdef([MINVERSION])
+])
+
+AC_DEFUN([gl_LIBTEXTSTYLE_NEWEST_VERSION], [0.20.5])
+
+AC_DEFUN([gl_LIBTEXTSTYLE_INITIALIZE],
+[
+  m4_divert_text([DEFAULTS], [gl_libtextstyle_minversion=' 0.20 '])
+])
+
+AC_DEFUN([gl_LIBTEXTSTYLE_SEARCH],
+[
+  dnl $gl_libtextstyle_minversion evaluates to a space-separated list of
+  dnl specified minimum versions. The maximum of these requirement matters.
+  case "$gl_libtextstyle_minversion" in
+    *" 0.20.5 "*)
+      snippet='styled_ostream_t s = term_styled_ostream_create(1,"",TTYCTL_AUTO,"");
+               ostream_printf(s,"%d",42);'
+      ;;
+    *" 0.20 "*)
+      snippet='term_styled_ostream_create(1,"",TTYCTL_AUTO,"");'
+      ;;
+  esac
   AC_LIB_HAVE_LINKFLAGS([textstyle], [],
-    [#include <textstyle.h>], [term_styled_ostream_create(1,"",TTYCTL_AUTO,"");],
+    [#include <textstyle.h>], [$snippet],
     [no])
 ])
index e086c41724cce9f4b67766d81816c530245abed0..4c3a4686ac12ad0c8772cf8d4c41c7dcbecdc06f 100644 (file)
@@ -8,7 +8,7 @@ Depends-on:
 havelib
 
 configure.ac:
-gl_LIBTEXTSTYLE
+# You need to invoke gl_LIBTEXTSTYLE yourself, possibly with arguments.
 
 Makefile.am:
 
index 2d55b3d76f258b7f8258763763a3baf9b3d46e5d..1ee82707f1355a796936cabca55e30cf071734bb 100644 (file)
@@ -13,7 +13,7 @@ fsync
 vasprintf-posix
 
 configure.ac:
-gl_LIBTEXTSTYLE_OPTIONAL
+# You need to invoke gl_LIBTEXTSTYLE_OPTIONAL yourself, possibly with arguments.
 
 Makefile.am:
 BUILT_SOURCES += $(TEXTSTYLE_H)