1 | ## $Id: my_version.m4 3229 2014-05-20 07:00:16Z peter $ |
---|
2 | # |
---|
3 | # Copyright (C) 2012, 2014 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 1 (yat 0.13) |
---|
22 | |
---|
23 | # How to use this file |
---|
24 | # ==================== |
---|
25 | # |
---|
26 | # Copy this file to your project, e.g. directory 'm4/'. Aclocal will |
---|
27 | # not do that du to limitations. In 'configure.ac', include this file |
---|
28 | # and call 'MY_VERSION_early' before 'AC_INIT'. After AC_INIT you can |
---|
29 | # call MY_VERSION in order to AC_SUBST and AC_DEFINE variables |
---|
30 | # FOO_MAJOR_VERSION, FOO_MINOR_VERSION etc., where FOO has been |
---|
31 | # replaced with PACKAGE_NAME after appropriate translation (to suit a |
---|
32 | # Make variable or PP #define): |
---|
33 | # |
---|
34 | # m4_include([m4/my_version.m4]) |
---|
35 | # MY_VERSION_early([3],[1],[4],[true]) |
---|
36 | # AC_INIT([foo], [my_VERSION]) |
---|
37 | # MY_VERSION |
---|
38 | |
---|
39 | |
---|
40 | # MY_VERSION_early(major, minor, patch, dev) |
---|
41 | # ========== |
---|
42 | m4_define([MY_VERSION_early], |
---|
43 | [ |
---|
44 | m4_define([my_MAJOR_VERSION], [$1]) |
---|
45 | m4_define([my_MINOR_VERSION], [$2]) |
---|
46 | m4_define([my_PATCH_VERSION], [$3]) |
---|
47 | m4_define([my_DEV_BUILD], [$4]) |
---|
48 | m4_define([my_VERSION],[$1.$2m4_if([$3],[0],,[.$3])m4_if([$4],[true],[pre])]) |
---|
49 | ]) # my_version |
---|
50 | |
---|
51 | |
---|
52 | # MY_VERSION |
---|
53 | # ========== |
---|
54 | # AC_SUBST and AC_DEFINE variables set in MY_VERSION_early |
---|
55 | m4_define([MY_VERSION], |
---|
56 | [ |
---|
57 | m4_ifndef([my_VERSION], |
---|
58 | [m4_fatal([MY_VERSION_early must be expanded before MY_VERSION])]) |
---|
59 | |
---|
60 | AS_VAR_PUSHDEF([my_PACKAGE_SH], [m4_toupper(AC_PACKAGE_NAME)]) |
---|
61 | AC_SUBST(my_PACKAGE_SH[_MAJOR_VERSION], [my_MAJOR_VERSION]) |
---|
62 | AC_SUBST(my_PACKAGE_SH[_MINOR_VERSION], [my_MINOR_VERSION]) |
---|
63 | AC_SUBST(my_PACKAGE_SH[_PATCH_VERSION], [my_PATCH_VERSION]) |
---|
64 | AS_VAR_POPDEF([my_PACKAGE_SH]) |
---|
65 | |
---|
66 | m4_pushdef([my_PACKAGE_CPP], [AS_TR_CPP([m4_toupper(AC_PACKAGE_NAME)])]) |
---|
67 | AC_DEFINE([DEV_BUILD],[my_DEV_BUILD], |
---|
68 | [true if dev build (version ends with pre)]) |
---|
69 | AC_DEFINE(my_PACKAGE_CPP[_MAJOR_VERSION], [my_MAJOR_VERSION], |
---|
70 | [Define to major version]) |
---|
71 | AC_DEFINE(my_PACKAGE_CPP[_MINOR_VERSION], [my_MINOR_VERSION], |
---|
72 | [Define to minor version]) |
---|
73 | AC_DEFINE(my_PACKAGE_CPP[_PATCH_VERSION], [my_PATCH_VERSION], |
---|
74 | [Define to patch version]) |
---|
75 | m4_popdef([my_PACKAGE_CPP]) |
---|
76 | ]) # MY_VERSION |
---|