Commit fe9f97ec fe9f97ecaa25c605b8192c97b3946c038b6fed57 by Sergey Poznyakoff

Improve AM_GNU_MAILUTILS autoconf macro

* mu-aux/mailutils.m4: Don't use packed version representation, because of
eventual numerical overflows.  Compare versions number by number.
Define the following additional constants: MAILUTILS_VERSION_MAJOR,
MAILUTILS_VERSION_MINOR, and MAILUTILS_VERSION_PATCH.
* NEWS: Document changes.
1 parent 9c6c1cd0
1 GNU mailutils NEWS -- history of user-visible changes. 2017-03-18 1 GNU mailutils NEWS -- history of user-visible changes. 2017-04-06
2 Copyright (C) 2002-2017 Free Software Foundation, Inc. 2 Copyright (C) 2002-2017 Free Software Foundation, Inc.
3 See the end of file for copying conditions. 3 See the end of file for copying conditions.
4 4
...@@ -75,6 +75,17 @@ value is anything but "no", the settings from the global "tls" section ...@@ -75,6 +75,17 @@ value is anything but "no", the settings from the global "tls" section
75 will be used. In this case, it is an error if the global "tls" 75 will be used. In this case, it is an error if the global "tls"
76 section is not defined. 76 section is not defined.
77 77
78 * AM_GNU_MAILUTILS autoconf macro
79
80 Required version must be literal string.
81
82 The packed version number (MAILUTILS_VERSION_NUMBER) is no longer
83 defined. Instead, the following constants are defined in config.h:
84
85 MAILUTILS_VERSION_MAJOR Major version number
86 MAILUTILS_VERSION_MINOR Minor version number
87 MAILUTILS_VERSION_PATCH Patchlevel number (or 0, for stable releases).
88
78 89
79 Version 3.2 - 2017-03-11 90 Version 3.2 - 2017-03-11
80 91
......
...@@ -14,6 +14,16 @@ dnl ...@@ -14,6 +14,16 @@ dnl
14 dnl You should have received a copy of the GNU General Public License 14 dnl You should have received a copy of the GNU General Public License
15 dnl along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. 15 dnl along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16 16
17 m4_define([am_mu_vercmp],[
18 m4_pushdef([_ver_A_],m4_car($1))dnl
19 m4_pushdef([_ver_B_],m4_car($2))dnl
20 m4_if(_ver_B_,,,[if test m4_if(_ver_A_,,0,_ver_A_) -lt _ver_B_; then
21 $3
22 fi
23 m4_popdef([_ver_A_])dnl
24 m4_popdef([_ver_B_])dnl
25 am_mu_vercmp(m4_cdr($1),m4_cdr($2),[$3])])])
26
17 dnl AM_GNU_MAILUTILS(minversion, link-req, [act-if-found], [ac-if-not-found]) 27 dnl AM_GNU_MAILUTILS(minversion, link-req, [act-if-found], [ac-if-not-found])
18 dnl $1 $2 $3 $4 28 dnl $1 $2 $3 $4
19 dnl Verify if GNU Mailutils is installed and if its version is `minversion' 29 dnl Verify if GNU Mailutils is installed and if its version is `minversion'
...@@ -23,8 +33,10 @@ dnl ...@@ -23,8 +33,10 @@ dnl
23 dnl If Mailutils is found, set: 33 dnl If Mailutils is found, set:
24 dnl MAILUTILS_CONFIG to the full name of the mailutils-config program; 34 dnl MAILUTILS_CONFIG to the full name of the mailutils-config program;
25 dnl MAILUTILS_VERSION to the Mailutils version (string); 35 dnl MAILUTILS_VERSION to the Mailutils version (string);
26 dnl MAILUTILS_VERSION_NUMBER to the packed numeric representation of the 36 dnl MAILUTILS_VERSION_MAJOR Mailutils version: major number
27 dnl GNU Mailutils version (major * 1000 + minor * 100 + patch); 37 dnl MAILUTILS_VERSION_MINOR Mailutils version: minor number
38 dnl MAILUTILS_VERSION_PATCH Mailutils version: patchlevel number (or 0,
39 dnl if not defined)
28 dnl MAILUTILS_LIBS to the list of cc(1) flags needed to link in the 40 dnl MAILUTILS_LIBS to the list of cc(1) flags needed to link in the
29 dnl libraries requested by `link-req'; 41 dnl libraries requested by `link-req';
30 dnl MAILUTILS_INCLUDES to the list of cc(1) flags needed to set include 42 dnl MAILUTILS_INCLUDES to the list of cc(1) flags needed to set include
...@@ -36,25 +48,34 @@ dnl ...@@ -36,25 +48,34 @@ dnl
36 AC_DEFUN([AM_GNU_MAILUTILS], 48 AC_DEFUN([AM_GNU_MAILUTILS],
37 [AC_PATH_PROG(MAILUTILS_CONFIG, mailutils-config, none, $PATH) 49 [AC_PATH_PROG(MAILUTILS_CONFIG, mailutils-config, none, $PATH)
38 if test "$MAILUTILS_CONFIG" = "none"; then 50 if test "$MAILUTILS_CONFIG" = "none"; then
39 ifelse($4,,[AC_MSG_ERROR(cannot find GNU Mailutils)], [$4]) 51 m4_if($4,,[AC_MSG_ERROR(cannot find GNU Mailutils)], [$4])
40 fi 52 fi
41 AC_SUBST(MAILUTILS_CONFIG) 53 AC_SUBST(MAILUTILS_CONFIG)
42 AC_SUBST(MAILUTILS_VERSION) 54 AC_SUBST(MAILUTILS_VERSION)
43 AC_SUBST(MAILUTILS_INCLUDES) 55 AC_SUBST(MAILUTILS_INCLUDES)
44 AC_SUBST(MAILUTILS_LIBS) 56 AC_SUBST(MAILUTILS_LIBS)
57
58 m4_ifndef([MU_VERSION_PARSE_DEFINED],[[
59 mu_version_parse() {
60 set -- `echo "@S|@1" | sed 's/^\([0-9\.][0-9\.]*\).*/\1/;s/\./ /g'`
61 major=@S|@{1:-0}
62 minor=@S|@{2:-0}
63 patch=@S|@{3:-0}
64 }]
65 m4_pushdef([MU_VERSION_PARSE_DEFINED])])
66
45 MAILUTILS_VERSION=`$MAILUTILS_CONFIG --info version|sed 's/VERSION=//'` 67 MAILUTILS_VERSION=`$MAILUTILS_CONFIG --info version|sed 's/VERSION=//'`
46 VEX=`echo $MAILUTILS_VERSION | sed 's/\./ \\\\* 1000 + /;s/\./ \\\\* 100 + /'` 68 mu_version_parse $MAILUTILS_VERSION
47 MAILUTILS_VERSION_NUMBER=`eval expr "$VEX"` 69 AC_DEFINE_UNQUOTED([MAILUTILS_VERSION_MAJOR], $major, [Mailutils version major number])
48 AC_SUBST(MAILUTILS_VERSION_NUMBER) 70 AC_DEFINE_UNQUOTED([MAILUTILS_VERSION_MINOR], $minor, [Mailutils version minor number])
71 AC_DEFINE_UNQUOTED([MAILUTILS_VERSION_PATCH], $patch, [Mailutils version patchlevel number])
72
49 AC_DEFINE_UNQUOTED(MAILUTILS_VERSION, "$MAILUTILS_VERSION", [Mailutils version number]) 73 AC_DEFINE_UNQUOTED(MAILUTILS_VERSION, "$MAILUTILS_VERSION", [Mailutils version number])
50 AC_DEFINE_UNQUOTED(MAILUTILS_VERSION_NUMBER, $MAILUTILS_VERSION_NUMBER, 74 m4_if($1,,,[
51 [Packed Mailutils version number]) 75 am_mu_vercmp(m4_quote($major, $minor, $patch),
52 ifelse($1,,,[ 76 m4_dquote(m4_bpatsubst($1, [\.],[,])),
53 VEX=`echo $1 | sed 's/\./ \\\\* 1000 + /;s/\./ \\\\* 100 + /'` 77 [AC_MSG_ERROR([Mailutils v. $MAILUTILS_VERSION is too old; required is at least ]$1)])
54 min=`eval expr "$VEX"` 78 ])
55 if test $MAILUTILS_VERSION_NUMBER -lt $min; then
56 AC_MSG_ERROR([Mailutils version too old; required is at least ]$1)
57 fi])
58 req="" 79 req=""
59 for x in $2 80 for x in $2
60 do 81 do
...@@ -65,6 +86,6 @@ AC_DEFUN([AM_GNU_MAILUTILS], ...@@ -65,6 +86,6 @@ AC_DEFUN([AM_GNU_MAILUTILS],
65 done 86 done
66 MAILUTILS_LIBS=`$MAILUTILS_CONFIG --link $req` 87 MAILUTILS_LIBS=`$MAILUTILS_CONFIG --link $req`
67 MAILUTILS_INCLUDES=`$MAILUTILS_CONFIG --compile` 88 MAILUTILS_INCLUDES=`$MAILUTILS_CONFIG --compile`
68 ifelse($3,,[LIBS="$LIBS $MAILUTILS_LIBS"], [$3]) 89 m4_if($3,,[LIBS="$LIBS $MAILUTILS_LIBS"], [$3])
69 ]) 90 ])
70 91
......