diff --git a/.gitignore b/.gitignore index 081bddb..332146d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ libtool ltmain.sh missing libmodbus.pc -modbus.h +modbus-version.h .deps .libs *.la diff --git a/configure.ac b/configure.ac index c06830f..3b458f5 100644 --- a/configure.ac +++ b/configure.ac @@ -76,7 +76,7 @@ AC_CHECK_FUNCS([gettimeofday inet_ntoa memset select socket strerror]) AC_CONFIG_FILES([ Makefile src/Makefile - src/modbus.h + src/modbus-version.h tests/Makefile libmodbus.pc ]) diff --git a/src/Makefile.am b/src/Makefile.am index 0f1a558..4260250 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,11 +1,14 @@ lib_LTLIBRARIES = libmodbus.la -libmodbus_la_SOURCES = modbus.c modbus.h +libmodbus_la_SOURCES = \ + modbus.c \ + modbus.h \ + modbus-version.h libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBMODBUS_LT_VERSION_INFO) -# Include files to install -libmodbusincludedir = $(includedir) -libmodbusinclude_HEADERS = modbus.h +# Header files to install +libmodbusincludedir = $(includedir)/modbus +libmodbusinclude_HEADERS = modbus.h modbus-version.h -DISTCLEANFILES = modbus.h -EXTRA_DIST = modbus.h.in +DISTCLEANFILES = modbus-version.h +EXTRA_DIST = modbus-version.h.in CLEANFILES = *~ diff --git a/src/modbus-version.h.in b/src/modbus-version.h.in new file mode 100644 index 0000000..a5be00f --- /dev/null +++ b/src/modbus-version.h.in @@ -0,0 +1,52 @@ +/* + * Copyright © 2010 Stéphane Raimbault + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser Public License for more details. + * + * You should have received a copy of the GNU Lesser Public License + * along with this program. If not, see . + */ + +#ifndef _MODBUS_VERSION_H_ +#define _MODBUS_VERSION_H_ + +/* The major version, (1, if %LIBMODBUS_VERSION is 1.2.3) */ +#define LIBMODBUS_VERSION_MAJOR (@LIBMODBUS_VERSION_MAJOR@) + +/* The minor version (2, if %LIBMODBUS_VERSION is 1.2.3) */ +#define LIBMODBUS_VERSION_MINOR (@LIBMODBUS_VERSION_MINOR@) + +/* The micro version (3, if %LIBMODBUS_VERSION is 1.2.3) */ +#define LIBMODBUS_VERSION_MICRO (@LIBMODBUS_VERSION_MICRO@) + +/* The full version, like 1.2.3 */ +#define LIBMODBUS_VERSION @LIBMODBUS_VERSION@ + +/* The full version, in string form (suited for string concatenation) + */ +#define LIBMODBUS_VERSION_STRING "@LIBMODBUS_VERSION@" + +/* Numerically encoded version, like 0x010203 */ +#define LIBMODBUS_VERSION_HEX ((LIBMODBUS_MAJOR_VERSION << 24) | \ + (LIBMODBUS_MINOR_VERSION << 16) | \ + (LIBMODBUS_MICRO_VERSION << 8)) + +/* Evaluates to True if the version is greater than @major, @minor and @micro + */ +#define LIBMODBUS_VERSION_CHECK(major,minor,micro) \ + (LIBMODBUS_VERSION_MAJOR > (major) || \ + (LIBMODBUS_VERSION_MAJOR == (major) && \ + LIBMODBUS_VERSION_MINOR > (minor)) || \ + (LIBMODBUS_VERSION_MAJOR == (major) && \ + LIBMODBUS_VERSION_MINOR == (minor) && \ + LIBMODBUS_VERSION_MICRO >= (micro))) + +#endif /* _MODBUS_VERSION_H_ */ diff --git a/src/modbus.h.in b/src/modbus.h index 4470eb5..367d973 100644 --- a/src/modbus.h.in +++ b/src/modbus.h @@ -38,6 +38,8 @@ #include #include +#include "modbus-version.h" + #ifdef __cplusplus # define MODBUS_BEGIN_DECLS extern "C" { # define MODBUS_END_DECLS } @@ -122,37 +124,6 @@ enum { #define EMBUNKEXC (EMBXGTAR + 4) #define EMBMDATA (EMBXGTAR + 5) -/* The major version, (1, if %LIBMODBUS_VERSION is 1.2.3) */ -#define LIBMODBUS_VERSION_MAJOR (@LIBMODBUS_VERSION_MAJOR@) - -/* The minor version (2, if %LIBMODBUS_VERSION is 1.2.3) */ -#define LIBMODBUS_VERSION_MINOR (@LIBMODBUS_VERSION_MINOR@) - -/* The micro version (3, if %LIBMODBUS_VERSION is 1.2.3) */ -#define LIBMODBUS_VERSION_MICRO (@LIBMODBUS_VERSION_MICRO@) - -/* The full version, like 1.2.3 */ -#define LIBMODBUS_VERSION @LIBMODBUS_VERSION@ - -/* The full version, in string form (suited for string concatenation) - */ -#define LIBMODBUS_VERSION_STRING "@LIBMODBUS_VERSION@" - -/* Numerically encoded version, like 0x010203 */ -#define LIBMODBUS_VERSION_HEX ((LIBMODBUS_MAJOR_VERSION << 24) | \ - (LIBMODBUS_MINOR_VERSION << 16) | \ - (LIBMODBUS_MICRO_VERSION << 8)) - -/* Evaluates to True if the version is greater than @major, @minor and @micro - */ -#define LIBMODBUS_VERSION_CHECK(major,minor,micro) \ - (LIBMODBUS_VERSION_MAJOR > (major) || \ - (LIBMODBUS_VERSION_MAJOR == (major) && \ - LIBMODBUS_VERSION_MINOR > (minor)) || \ - (LIBMODBUS_VERSION_MAJOR == (major) && \ - LIBMODBUS_VERSION_MINOR == (minor) && \ - LIBMODBUS_VERSION_MICRO >= (micro))) - extern const unsigned int libmodbus_version_major; extern const unsigned int libmodbus_version_minor; extern const unsigned int libmodbus_version_micro;