Commit 0a671c234c1af74d07ee17554d422484069ff8a4

Authored by Stéphane Raimbault
1 parent fb1abdbc

Add modbus-version.h.in

- partial revert of 93ce13656103cbb459ebd630d055a008dbb059f3
- it was a bit confusing to always edit modbus.h.in
- the header inclusion still unchanged (<modbus.h>)
.gitignore
... ... @@ -20,7 +20,7 @@ libtool
20 20 ltmain.sh
21 21 missing
22 22 libmodbus.pc
23   -modbus.h
  23 +modbus-version.h
24 24 .deps
25 25 .libs
26 26 *.la
... ...
configure.ac
... ... @@ -76,7 +76,7 @@ AC_CHECK_FUNCS([gettimeofday inet_ntoa memset select socket strerror])
76 76 AC_CONFIG_FILES([
77 77 Makefile
78 78 src/Makefile
79   - src/modbus.h
  79 + src/modbus-version.h
80 80 tests/Makefile
81 81 libmodbus.pc
82 82 ])
... ...
src/Makefile.am
1 1 lib_LTLIBRARIES = libmodbus.la
2   -libmodbus_la_SOURCES = modbus.c modbus.h
  2 +libmodbus_la_SOURCES = \
  3 + modbus.c \
  4 + modbus.h \
  5 + modbus-version.h
3 6 libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBMODBUS_LT_VERSION_INFO)
4 7  
5   -# Include files to install
6   -libmodbusincludedir = $(includedir)
7   -libmodbusinclude_HEADERS = modbus.h
  8 +# Header files to install
  9 +libmodbusincludedir = $(includedir)/modbus
  10 +libmodbusinclude_HEADERS = modbus.h modbus-version.h
8 11  
9   -DISTCLEANFILES = modbus.h
10   -EXTRA_DIST = modbus.h.in
  12 +DISTCLEANFILES = modbus-version.h
  13 +EXTRA_DIST = modbus-version.h.in
11 14 CLEANFILES = *~
... ...
src/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 _MODBUS_VERSION_H_
  19 +#define _MODBUS_VERSION_H_
  20 +
  21 +/* The major version, (1, if %LIBMODBUS_VERSION is 1.2.3) */
  22 +#define LIBMODBUS_VERSION_MAJOR (@LIBMODBUS_VERSION_MAJOR@)
  23 +
  24 +/* The minor version (2, if %LIBMODBUS_VERSION is 1.2.3) */
  25 +#define LIBMODBUS_VERSION_MINOR (@LIBMODBUS_VERSION_MINOR@)
  26 +
  27 +/* The micro version (3, if %LIBMODBUS_VERSION is 1.2.3) */
  28 +#define LIBMODBUS_VERSION_MICRO (@LIBMODBUS_VERSION_MICRO@)
  29 +
  30 +/* The full version, like 1.2.3 */
  31 +#define LIBMODBUS_VERSION @LIBMODBUS_VERSION@
  32 +
  33 +/* The full version, in string form (suited for string concatenation)
  34 + */
  35 +#define LIBMODBUS_VERSION_STRING "@LIBMODBUS_VERSION@"
  36 +
  37 +/* Numerically encoded version, like 0x010203 */
  38 +#define LIBMODBUS_VERSION_HEX ((LIBMODBUS_MAJOR_VERSION << 24) | \
  39 + (LIBMODBUS_MINOR_VERSION << 16) | \
  40 + (LIBMODBUS_MICRO_VERSION << 8))
  41 +
  42 +/* Evaluates to True if the version is greater than @major, @minor and @micro
  43 + */
  44 +#define LIBMODBUS_VERSION_CHECK(major,minor,micro) \
  45 + (LIBMODBUS_VERSION_MAJOR > (major) || \
  46 + (LIBMODBUS_VERSION_MAJOR == (major) && \
  47 + LIBMODBUS_VERSION_MINOR > (minor)) || \
  48 + (LIBMODBUS_VERSION_MAJOR == (major) && \
  49 + LIBMODBUS_VERSION_MINOR == (minor) && \
  50 + LIBMODBUS_VERSION_MICRO >= (micro)))
  51 +
  52 +#endif /* _MODBUS_VERSION_H_ */
... ...
src/modbus.h.in renamed to src/modbus.h
... ... @@ -38,6 +38,8 @@
38 38 #include <netinet/tcp.h>
39 39 #include <arpa/inet.h>
40 40  
  41 +#include "modbus-version.h"
  42 +
41 43 #ifdef __cplusplus
42 44 # define MODBUS_BEGIN_DECLS extern "C" {
43 45 # define MODBUS_END_DECLS }
... ... @@ -122,37 +124,6 @@ enum {
122 124 #define EMBUNKEXC (EMBXGTAR + 4)
123 125 #define EMBMDATA (EMBXGTAR + 5)
124 126  
125   -/* The major version, (1, if %LIBMODBUS_VERSION is 1.2.3) */
126   -#define LIBMODBUS_VERSION_MAJOR (@LIBMODBUS_VERSION_MAJOR@)
127   -
128   -/* The minor version (2, if %LIBMODBUS_VERSION is 1.2.3) */
129   -#define LIBMODBUS_VERSION_MINOR (@LIBMODBUS_VERSION_MINOR@)
130   -
131   -/* The micro version (3, if %LIBMODBUS_VERSION is 1.2.3) */
132   -#define LIBMODBUS_VERSION_MICRO (@LIBMODBUS_VERSION_MICRO@)
133   -
134   -/* The full version, like 1.2.3 */
135   -#define LIBMODBUS_VERSION @LIBMODBUS_VERSION@
136   -
137   -/* The full version, in string form (suited for string concatenation)
138   - */
139   -#define LIBMODBUS_VERSION_STRING "@LIBMODBUS_VERSION@"
140   -
141   -/* Numerically encoded version, like 0x010203 */
142   -#define LIBMODBUS_VERSION_HEX ((LIBMODBUS_MAJOR_VERSION << 24) | \
143   - (LIBMODBUS_MINOR_VERSION << 16) | \
144   - (LIBMODBUS_MICRO_VERSION << 8))
145   -
146   -/* Evaluates to True if the version is greater than @major, @minor and @micro
147   - */
148   -#define LIBMODBUS_VERSION_CHECK(major,minor,micro) \
149   - (LIBMODBUS_VERSION_MAJOR > (major) || \
150   - (LIBMODBUS_VERSION_MAJOR == (major) && \
151   - LIBMODBUS_VERSION_MINOR > (minor)) || \
152   - (LIBMODBUS_VERSION_MAJOR == (major) && \
153   - LIBMODBUS_VERSION_MINOR == (minor) && \
154   - LIBMODBUS_VERSION_MICRO >= (micro)))
155   -
156 127 extern const unsigned int libmodbus_version_major;
157 128 extern const unsigned int libmodbus_version_minor;
158 129 extern const unsigned int libmodbus_version_micro;
... ...