1 | ## $Id: my_version.m4 2853 2012-09-23 23:56:38Z peter $ |
---|
2 | # |
---|
3 | # Copyright (C) 2012 Peter Johansson |
---|
4 | # |
---|
5 | # This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
6 | # |
---|
7 | # The yat library is free software; you can redistribute it |
---|
8 | # and/or modify it under the terms of the GNU General Public License as |
---|
9 | # published by the Free Software Foundation; either version 3 of the |
---|
10 | # License, or (at your option) any later version. |
---|
11 | # |
---|
12 | # The yat library is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | # General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | # |
---|
20 | |
---|
21 | # serial 0 |
---|
22 | |
---|
23 | # How to use this file |
---|
24 | # ==================== |
---|
25 | # In 'configure.ac', include this file and call 'MY_VERSION_early' |
---|
26 | # before 'AC_INIT'. After AC_INIT you can call MY_VERSION in order to |
---|
27 | # AC_SUBST and AC_DEFINE variables MAJOR_VERSION, MINOR_VERSION etc. |
---|
28 | # m4_include([m4/version.m4]) |
---|
29 | # MY_VERSION_early([3],[1],[4],[true]) |
---|
30 | # AC_INIT([foo], [my_VERSION]) |
---|
31 | # MY_VERSION |
---|
32 | |
---|
33 | |
---|
34 | # MY_VERSION_early(major, minor, patch, dev) |
---|
35 | # ========== |
---|
36 | m4_define([MY_VERSION_early], |
---|
37 | [ |
---|
38 | m4_define([my_MAJOR_VERSION], [$1]) |
---|
39 | m4_define([my_MINOR_VERSION], [$2]) |
---|
40 | m4_define([my_PATCH_VERSION], [$3]) |
---|
41 | m4_define([my_DEV_BUILD], [$4]) |
---|
42 | m4_define([my_VERSION],[$1.$2m4_if([$3],[0],,[.$3])m4_if([$4],[true],[pre])]) |
---|
43 | ]) # my_version |
---|
44 | |
---|
45 | |
---|
46 | # MY_VERSION |
---|
47 | # ========== |
---|
48 | # AC_SUBST and AC_DEFINE variables set in MY_VERSION_early |
---|
49 | m4_define([MY_VERSION], |
---|
50 | [ |
---|
51 | m4_ifndef([my_VERSION], |
---|
52 | [m4_fatal([MY_VERSION_early must be expanded before MY_VERSION])]) |
---|
53 | AC_SUBST(m4_toupper(AC_PACKAGE_NAME)[_MAJOR_VERSION], [my_MAJOR_VERSION]) |
---|
54 | AC_SUBST(m4_toupper(AC_PACKAGE_NAME)[_MINOR_VERSION], [my_MINOR_VERSION]) |
---|
55 | AC_SUBST(m4_toupper(AC_PACKAGE_NAME)[_PATCH_VERSION], [my_PATCH_VERSION]) |
---|
56 | |
---|
57 | AC_DEFINE([DEV_BUILD],[my_DEV_BUILD], |
---|
58 | [true if dev build (version ends with pre)]) |
---|
59 | AC_DEFINE(m4_toupper(AC_PACKAGE_NAME)[_MAJOR_VERSION], [my_MAJOR_VERSION], |
---|
60 | [Define to major version]) |
---|
61 | AC_DEFINE(m4_toupper(AC_PACKAGE_NAME)[_MINOR_VERSION], [my_MINOR_VERSION], |
---|
62 | [Define to minor version]) |
---|
63 | AC_DEFINE(m4_toupper(AC_PACKAGE_NAME)[_PATCH_VERSION], [my_PATCH_VERSION], |
---|
64 | [Define to patch version]) |
---|
65 | ]) # MY_VERSION |
---|