Commit 95fd206f7987ab95135ec8e439e7f29968d44ea3
1 parent
c0de8fed
Add versioning infrastructure
Inspired by the Clutter project and work done by Florian Forster.
Showing
9 changed files
with
160 additions
and
10 deletions
.gitignore
| ... | ... | @@ -20,6 +20,7 @@ libtool |
| 20 | 20 | ltmain.sh |
| 21 | 21 | missing |
| 22 | 22 | modbus.pc |
| 23 | +version.h | |
| 23 | 24 | .deps |
| 24 | 25 | .libs |
| 25 | 26 | *.la |
| ... | ... | @@ -33,3 +34,4 @@ tests/random-test-master |
| 33 | 34 | tests/random-test-slave |
| 34 | 35 | tests/unit-test-master |
| 35 | 36 | tests/unit-test-slave |
| 37 | +tests/version | |
| 36 | 38 | \ No newline at end of file | ... | ... |
NEWS
| 1 | -libmodbus 2.2.0 (2009-XX-01) | |
| 1 | +libmodbus 2.1.1 (2010-XX-XX) | |
| 2 | +============================ | |
| 3 | + | |
| 4 | +- Versioning infrastructure. | |
| 5 | + Inspired by the Clutter project and the work done by Florian Forster. | |
| 6 | +- Renamed src directory to modbus | |
| 7 | + | |
| 8 | +libmodbus 2.1.0 (2010-03-24) | |
| 2 | 9 | ============================ |
| 3 | 10 | |
| 4 | 11 | - New API to read and write float values by Stéphane Raimbault and Florian | ... | ... |
configure.ac
| 1 | -# -*- Autoconf -*- | |
| 2 | -# Process this file with autoconf to produce a configure script. | |
| 1 | +# libmodbus package version number, (as distinct from shared library version) | |
| 2 | +# An odd micro number indicates in-progress development from Git | |
| 3 | +# An even micro number indicates a released version | |
| 4 | +# | |
| 5 | +# Making a point release: | |
| 6 | +# - increase mb_version_micro to the next even number | |
| 7 | +# | |
| 8 | +# After the release: | |
| 9 | +# - increase mb_version_minor to the next odd number | |
| 10 | +# | |
| 11 | +# mb_version_ld increases at each new minor version because minor versions | |
| 12 | +# are used to change API/ABI | |
| 13 | +# | |
| 14 | +m4_define([mb_version_major], [2]) | |
| 15 | +m4_define([mb_version_minor], [1]) | |
| 16 | +m4_define([mb_version_micro], [1]) | |
| 17 | + | |
| 18 | +m4_define([mb_release_status], | |
| 19 | + [m4_if(m4_eval(mb_version_minor % 2), [1], [snapshot], | |
| 20 | + [release])]) | |
| 21 | + | |
| 22 | +m4_define([mb_version], [mb_version_major.mb_version_minor.mb_version_micro]) | |
| 23 | +m4_define([mb_version_ld], [m4_eval(mb_version_major + mb_version_minor)]) | |
| 3 | 24 | |
| 4 | 25 | AC_PREREQ(2.63) |
| 5 | -AC_INIT([libmodbus],[2.1.0],[stephane.raimbault@gmail.com]) | |
| 26 | +AC_INIT([libmodbus],[mb_version],[stephane.raimbault@gmail.com]) | |
| 6 | 27 | AC_CONFIG_SRCDIR([modbus/modbus.c]) |
| 7 | 28 | AC_CONFIG_HEADERS([config.h]) |
| 8 | 29 | AM_INIT_AUTOMAKE([1.11 foreign]) |
| 9 | 30 | # enable nice build output on automake1.11 |
| 10 | 31 | m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) |
| 11 | 32 | |
| 33 | +MB_VERSION_MAJOR=mb_version_major | |
| 34 | +MB_VERSION_MINOR=mb_version_minor | |
| 35 | +MB_VERSION_MICRO=mb_version_micro | |
| 36 | +MB_VERSION=mb_version | |
| 37 | +AC_SUBST(MB_VERSION_MAJOR) | |
| 38 | +AC_SUBST(MB_VERSION_MINOR) | |
| 39 | +AC_SUBST(MB_VERSION_MICRO) | |
| 40 | +AC_SUBST(MB_VERSION) | |
| 41 | + | |
| 42 | +MB_VERSION_LD=mb_version_ld | |
| 43 | +MB_LT_LDFLAGS="-version-info $MB_VERSION_LD:0:0" | |
| 44 | +AC_SUBST(MB_LT_LDFLAGS) | |
| 45 | + | |
| 12 | 46 | # Checks for programs. |
| 13 | 47 | AC_PROG_CC |
| 14 | 48 | AC_PROG_CXX |
| ... | ... | @@ -39,7 +73,8 @@ AC_CHECK_FUNCS([gettimeofday inet_ntoa memset select socket strerror]) |
| 39 | 73 | AC_CONFIG_FILES([ |
| 40 | 74 | Makefile |
| 41 | 75 | modbus/Makefile |
| 76 | + modbus/version.h | |
| 42 | 77 | tests/Makefile |
| 43 | - modbus.pc | |
| 78 | + libmodbus.pc | |
| 44 | 79 | ]) |
| 45 | 80 | AC_OUTPUT | ... | ... |
modbus/Makefile.am
| 1 | 1 | lib_LTLIBRARIES = libmodbus.la |
| 2 | -libmodbus_la_SOURCES = modbus.c modbus.h | |
| 3 | -libmodbus_la_LDFLAGS = -version-info 2:0:0 | |
| 4 | -service_CFLAGS = -I$(top_srcdir)/ | |
| 2 | +libmodbus_la_SOURCES = modbus.c modbus.h version.h | |
| 3 | +libmodbus_la_LDFLAGS = $(MB_LT_LDFLAGS) | |
| 5 | 4 | |
| 6 | 5 | # Include files to install |
| 7 | 6 | libmodbusincludedir = $(includedir)/modbus |
| 8 | -libmodbusinclude_HEADERS = modbus.h | |
| 7 | +libmodbusinclude_HEADERS = modbus.h version.h | |
| 9 | 8 | |
| 9 | +DISTCLEANFILES = version.h | |
| 10 | +EXTRA_DIST = version.h.in | |
| 10 | 11 | CLEANFILES = *~ | ... | ... |
modbus/modbus.c
| ... | ... | @@ -65,6 +65,11 @@ |
| 65 | 65 | |
| 66 | 66 | #define UNKNOWN_ERROR_MSG "Not defined in modbus specification" |
| 67 | 67 | |
| 68 | +/* Exported version */ | |
| 69 | +const unsigned int mb_version_major = MB_VERSION_MAJOR; | |
| 70 | +const unsigned int mb_version_minor = MB_VERSION_MINOR; | |
| 71 | +const unsigned int mb_version_micro = MB_VERSION_MICRO; | |
| 72 | + | |
| 68 | 73 | /* This structure reduces the number of params in functions and so |
| 69 | 74 | * optimizes the speed of execution (~ 37%). */ |
| 70 | 75 | typedef struct { | ... | ... |
modbus/modbus.h
modbus/version.h.in
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright © 2010 Stéphane Raimbault <stephane.raimbault@gmail.com> | |
| 3 | + * | |
| 4 | + * This program is free software: you can redistribute it and/or modify | |
| 5 | + * it under the terms of the GNU Lesser Public License as published by | |
| 6 | + * the Free Software Foundation; either version 3 of the License, or | |
| 7 | + * (at your option) any later version. | |
| 8 | + * | |
| 9 | + * This program is distributed in the hope that it will be useful, | |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + * GNU Lesser Public License for more details. | |
| 13 | + * | |
| 14 | + * You should have received a copy of the GNU Lesser Public License | |
| 15 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#ifndef _MB_VERSION_H_ | |
| 19 | +#define _MB_VERSION_H_ | |
| 20 | + | |
| 21 | +#ifdef __cplusplus | |
| 22 | +extern "C" { | |
| 23 | +#endif | |
| 24 | + | |
| 25 | +/* The major version of libmb, (1, if %MB_VERSION is 1.2.3) */ | |
| 26 | +#define MB_VERSION_MAJOR (@MB_VERSION_MAJOR@) | |
| 27 | + | |
| 28 | +/* The minor version of libmb (2, if %MB_VERSION is 1.2.3) */ | |
| 29 | +#define MB_VERSION_MINOR (@MB_VERSION_MINOR@) | |
| 30 | + | |
| 31 | +/* The micro version of libmb (3, if %MB_VERSION is 1.2.3) */ | |
| 32 | +#define MB_VERSION_MICRO (@MB_VERSION_MICRO@) | |
| 33 | + | |
| 34 | +/* The full version of libmb, like 1.2.3 */ | |
| 35 | +#define MB_VERSION @MB_VERSION@ | |
| 36 | + | |
| 37 | +/* The full version of libmb, in string form (suited for | |
| 38 | + * string concatenation) | |
| 39 | + */ | |
| 40 | +#define MB_VERSION_STRING "@MB_VERSION@" | |
| 41 | + | |
| 42 | +/* Numerically encoded version libmb, like 0x010203 */ | |
| 43 | +#define MB_VERSION_HEX ((MB_MAJOR_VERSION << 24) | \ | |
| 44 | + (MB_MINOR_VERSION << 16) | \ | |
| 45 | + (MB_MICRO_VERSION << 8)) | |
| 46 | + | |
| 47 | +/* Evaluates to True if the version of libmb is greater than @major, @minor | |
| 48 | + * and @micro | |
| 49 | + */ | |
| 50 | +#define MB_VERSION_CHECK(major,minor,micro) \ | |
| 51 | + (MB_VERSION_MAJOR > (major) || \ | |
| 52 | + (MB_VERSION_MAJOR == (major) && MB_VERSION_MINOR > (minor)) || \ | |
| 53 | + (MB_VERSION_MAJOR == (major) && MB_VERSION_MINOR == (minor) && MB_VERSION_MICRO >= (micro))) | |
| 54 | + | |
| 55 | +extern const unsigned int mb_version_major; | |
| 56 | +extern const unsigned int mb_version_minor; | |
| 57 | +extern const unsigned int mb_version_micro; | |
| 58 | + | |
| 59 | +#ifdef __cplusplus | |
| 60 | +} | |
| 61 | +#endif | |
| 62 | + | |
| 63 | +#endif /* _MB_VERSION_H_ */ | ... | ... |
tests/Makefile.am
| ... | ... | @@ -7,7 +7,8 @@ noinst_PROGRAMS = \ |
| 7 | 7 | unit-test-master \ |
| 8 | 8 | bandwidth-slave-one \ |
| 9 | 9 | bandwidth-slave-many-up \ |
| 10 | - bandwidth-master | |
| 10 | + bandwidth-master \ | |
| 11 | + version | |
| 11 | 12 | |
| 12 | 13 | common_ldflags = \ |
| 13 | 14 | $(top_builddir)/modbus/libmodbus.la |
| ... | ... | @@ -33,5 +34,8 @@ bandwidth_slave_many_up_LDADD = $(common_ldflags) |
| 33 | 34 | bandwidth_master_SOURCES = bandwidth-master.c |
| 34 | 35 | bandwidth_master_LDADD = $(common_ldflags) |
| 35 | 36 | |
| 37 | +version_SOURCES = version.c | |
| 38 | +version_LDADD = $(common_ldflags) | |
| 39 | + | |
| 36 | 40 | INCLUDES = -I$(top_srcdir) |
| 37 | 41 | CLEANFILES = *~ | ... | ... |
tests/version.c
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright © 2010 Stéphane Raimbault <stephane.raimbault@gmail.com> | |
| 3 | + * | |
| 4 | + * This program is free software: you can redistribute it and/or modify | |
| 5 | + * it under the terms of the GNU General Public License as published by | |
| 6 | + * the Free Software Foundation; either version 3 of the License, or | |
| 7 | + * (at your option) any later version. | |
| 8 | + * | |
| 9 | + * This program is distributed in the hope that it will be useful, | |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | + * GNU General Public License for more details. | |
| 13 | + * | |
| 14 | + * You should have received a copy of the GNU General Public License | |
| 15 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#include <stdio.h> | |
| 19 | +#include <modbus/modbus.h> | |
| 20 | + | |
| 21 | +int main(void) | |
| 22 | +{ | |
| 23 | + printf("Compiled with libmodbus version %s\n", MB_VERSION_STRING); | |
| 24 | + printf("Linked with libmodbus version %d.%d.%d\n", | |
| 25 | + mb_version_major, mb_version_minor, mb_version_micro); | |
| 26 | + | |
| 27 | + if (MB_VERSION_CHECK(2, 1, 0)) { | |
| 28 | + printf("The functions to read/write float values are available.\n"); | |
| 29 | + } | |
| 30 | + return 0; | |
| 31 | +} | ... | ... |