Commit 15d042e22769bd8c8aeb394277981960984b4f0a

Authored by Stéphane Raimbault
1 parent fdc7521f

Major changes to the build system

- move modbus.h => include/modbus/
- create a pkgconfig file (module.pc)
- install modbus.h in $(includedir)
- new path to reach modbus.h
Makefile.am
1   -SUBDIRS=src
  1 +SUBDIRS = include src
  2 +
  3 +pkgconfigdir = $(libdir)/pkgconfig
  4 +pkgconfig_DATA = modbus.pc
... ...
configure.ac
... ... @@ -12,6 +12,9 @@ AC_PROG_LIBTOOL
12 12  
13 13 # Checks for libraries.
14 14 AM_PATH_GLIB_2_0(2.0.0,,AC_MSG_ERROR(libmodbus needs GLib 2.X))
  15 +PKG_CHECK_MODULES(GLIB, glib-2.0)
  16 +AC_SUBST(GLIB_CFLAGS)
  17 +AC_SUBST(GLIB_LIBS)
15 18  
16 19 # Checks for header files.
17 20 AC_HEADER_STDC
... ... @@ -27,8 +30,11 @@ AC_FUNC_MALLOC
27 30 AC_FUNC_SELECT_ARGTYPES
28 31 AC_CHECK_FUNCS([inet_ntoa memset select socket])
29 32  
30   -AC_CONFIG_FILES([
31   - Makefile
32   - src/Makefile
33   - ])
34   -AC_OUTPUT
  33 +AC_OUTPUT([
  34 +Makefile
  35 +src/Makefile
  36 +include/Makefile
  37 +include/modbus/Makefile
  38 +modbus.pc
  39 +])
  40 +
... ...
include/Makefile.am 0 → 100644
  1 +## Process this file with automake to produce Makefile.in
  2 +
  3 +SUBDIRS = modbus
... ...
include/modbus/Makefile.am 0 → 100644
  1 +## Process this file with automake to produce Makefile.in
  2 +
  3 +# Include files to install
  4 +libmodbusincludedir = $(includedir)/libmodbus
  5 +libmodbusinclude_HEADERS = modbus.h
0 6 \ No newline at end of file
... ...
src/modbus.h renamed to include/modbus/modbus.h
modbus.pc.in 0 → 100644
  1 +prefix=@prefix@
  2 +exec_prefix=@exec_prefix@
  3 +libdir=@libdir@
  4 +includedir=@includedir@
  5 +
  6 +Name: modbus
  7 +Description: Modbus protocol library
  8 +Requires: @modbus_pkgdeps@
  9 +Version: @VERSION@
  10 +Libs: -L${libdir} -lmodbus
  11 +Cflags: -I${includedir}
... ...
src/Makefile.am
... ... @@ -10,10 +10,6 @@ test_modbus_slave_SOURCES = test-modbus-slave.c
10 10 test_modbus_slave_INCLUDES = @GLIB_CFLAGS@
11 11 test_modbus_slave_LDADD = libmodbus.la @GLIB_LIBS@
12 12  
13   -INCLUDES = @GLIB_CFLAGS@
  13 +INCLUDES = @GLIB_CFLAGS@ -I$(top_srcdir)/include
14 14 LDADD = @GLIB_LIBS@
15 15 CLEANFILES = *~
16   -
17   -# Include files to install
18   -libmodbusincludedir = $(includedir)/libmodbus
19   -libmodbusinclude_HEADERS = modbus.h
... ...
src/modbus.c
... ... @@ -41,7 +41,7 @@
41 41 #include <netinet/ip.h>
42 42 #include <netinet/tcp.h>
43 43  
44   -#include "modbus.h"
  44 +#include <modbus/modbus.h>
45 45  
46 46 #define UNKNOWN_ERROR_MSG "Not defined in modbus specification"
47 47  
... ...
src/test-modbus-master.c
... ... @@ -24,7 +24,7 @@
24 24 #include <string.h>
25 25 #include <stdlib.h>
26 26  
27   -#include <modbus.h>
  27 +#include <modbus/modbus.h>
28 28  
29 29 #define LOOP 1
30 30 #define SLAVE 0x11
... ...
src/test-modbus-slave.c
... ... @@ -24,7 +24,7 @@
24 24 #include <string.h>
25 25 #include <stdlib.h>
26 26  
27   -#include <modbus.h>
  27 +#include <modbus/modbus.h>
28 28  
29 29 int main(void)
30 30 {
... ...