Commit e80dc40503c17559930c881df993dce410d67494

Authored by Stéphane Raimbault
1 parent 795d1fd7

Rename modbus/ to src/

- upgrade to WAF 1.5.3
- smaller WAF scripts
- fix using of modbus.h with WAF
- updated configure.ac and Makefile.am files
- change include paths in test files
Makefile.am
1 1 EXTRA_DIST = MIGRATION libmodbus.spec
2   -SUBDIRS = modbus tests
  2 +SUBDIRS = src tests
3 3  
4 4 pkgconfigdir = $(libdir)/pkgconfig
5 5 pkgconfig_DATA = modbus.pc
... ...
configure.ac
... ... @@ -3,7 +3,7 @@
3 3  
4 4 AC_PREREQ(2.59)
5 5 AC_INIT(libmodbus, 2.0.3, stephane.raimbault@gmail.com)
6   -AC_CONFIG_SRCDIR([modbus/modbus.c])
  6 +AC_CONFIG_SRCDIR([src/modbus.c])
7 7 AM_INIT_AUTOMAKE
8 8 AM_DISABLE_STATIC
9 9  
... ... @@ -28,7 +28,7 @@ AC_CHECK_FUNCS([inet_ntoa memset select socket])
28 28  
29 29 AC_OUTPUT([
30 30 Makefile
31   - modbus/Makefile
  31 + src/Makefile
32 32 tests/Makefile
33 33 modbus.pc
34 34 ])
... ...
modbus/wscript deleted
1   -def build(bld):
2   - obj = bld.create_obj('cc', 'shlib')
3   - obj.source = 'modbus.c'
4   - obj.includes = '.'
5   - obj.target = 'modbus'
6   - obj.vnum = '2.0.1'
7   -
8   - install_files('PREFIX', 'include/modbus', 'modbus.h')
modbus/Makefile.am renamed to src/Makefile.am
modbus/modbus.c renamed to src/modbus.c
modbus/modbus.h renamed to src/modbus.h
src/wscript 0 → 100644
  1 +def build(bld):
  2 + obj = bld.new_task_gen(
  3 + features='cc cshlib',
  4 + source='modbus.c',
  5 + target = 'modbus',
  6 + vnum='2.2.0')
  7 +
  8 + bld.install_files('${PREFIX}/include/modbus', 'modbus.h')
... ...
tests/Makefile.am
... ... @@ -10,7 +10,7 @@ noinst_PROGRAMS = \
10 10 bandwidth-master
11 11  
12 12 common_ldflags = \
13   - $(top_builddir)/modbus/libmodbus.la
  13 + $(top_builddir)/src/libmodbus.la
14 14  
15 15 random_test_slave_SOURCES = random-test-slave.c
16 16 random_test_slave_LDADD = $(common_ldflags)
... ... @@ -33,5 +33,5 @@ bandwidth_slave_many_up_LDADD = $(common_ldflags)
33 33 bandwidth_master_SOURCES = bandwidth-master.c
34 34 bandwidth_master_LDADD = $(common_ldflags)
35 35  
36   -INCLUDES = -I$(top_srcdir)
  36 +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
37 37 CLEANFILES = *~
... ...
tests/bandwidth-master.c
... ... @@ -22,7 +22,7 @@
22 22 #include <time.h>
23 23 #include <sys/time.h>
24 24  
25   -#include <modbus/modbus.h>
  25 +#include "modbus.h"
26 26  
27 27 /* Tests based on PI-MBUS-300 documentation */
28 28 #define SLAVE 0x11
... ...
tests/bandwidth-slave-many-up.c
... ... @@ -22,7 +22,7 @@
22 22 #include <errno.h>
23 23 #include <signal.h>
24 24  
25   -#include <modbus/modbus.h>
  25 +#include "modbus.h"
26 26  
27 27 #define NB_CONNECTION 5
28 28 int slave_socket;
... ...
tests/bandwidth-slave-one.c
... ... @@ -20,7 +20,7 @@
20 20 #include <string.h>
21 21 #include <stdlib.h>
22 22  
23   -#include <modbus/modbus.h>
  23 +#include "modbus.h"
24 24  
25 25 int main(void)
26 26 {
... ...
tests/random-test-master.c
... ... @@ -20,7 +20,7 @@
20 20 #include <string.h>
21 21 #include <stdlib.h>
22 22  
23   -#include <modbus/modbus.h>
  23 +#include "modbus.h"
24 24  
25 25 /* The goal of this program is to check all major functions of
26 26 libmodbus:
... ...
tests/random-test-slave.c
... ... @@ -19,7 +19,7 @@
19 19 #include <unistd.h>
20 20 #include <stdlib.h>
21 21  
22   -#include <modbus/modbus.h>
  22 +#include "modbus.h"
23 23  
24 24 int main(void)
25 25 {
... ...
tests/unit-test-master.c
... ... @@ -20,8 +20,7 @@
20 20 #include <string.h>
21 21 #include <stdlib.h>
22 22  
23   -#include <modbus/modbus.h>
24   -
  23 +#include "modbus.h"
25 24 #include "unit-test.h"
26 25  
27 26 /* Tests based on PI-MBUS-300 documentation */
... ...
tests/unit-test-slave.c
... ... @@ -20,8 +20,7 @@
20 20 #include <string.h>
21 21 #include <stdlib.h>
22 22  
23   -#include <modbus/modbus.h>
24   -
  23 +#include "modbus.h"
25 24 #include "unit-test.h"
26 25  
27 26 int main(void)
... ...
tests/wscript
1 1 def build(bld):
2   - obj = bld.create_obj('cc', 'program')
3   - obj.source = 'random-test-slave.c'
4   - obj.includes = '. ..'
5   - obj.uselib_local = 'modbus'
6   - obj.target = 'random-test-slave'
7   - obj.inst_var = 0
  2 + programs = ('random-test-slave',
  3 + 'unit-test-slave',
  4 + 'unit-test-master',
  5 + 'bandwidth-slave-one',
  6 + 'bandwidth-slave-many-up',
  7 + 'bandwidth-master')
8 8  
9   - obj = bld.create_obj('cc', 'program')
10   - obj.source = 'random-test-master.c'
11   - obj.includes = '. ..'
12   - obj.uselib_local = 'modbus'
13   - obj.target = 'random-test-master'
14   - obj.inst_var = 0
15   -
16   - obj = bld.create_obj('cc', 'program')
17   - obj.source = 'unit-test-slave.c'
18   - obj.includes = '. ..'
19   - obj.uselib_local = 'modbus'
20   - obj.target = 'unit-test-slave'
21   - obj.inst_var = 0
22   -
23   - obj = bld.create_obj('cc', 'program')
24   - obj.source = 'unit-test-master.c'
25   - obj.includes = '. ..'
26   - obj.uselib_local = 'modbus'
27   - obj.target = 'unit-test-master'
28   - obj.inst_var = 0
29   -
30   - obj = bld.create_obj('cc', 'program')
31   - obj.source = 'bandwidth-slave-one.c'
32   - obj.includes = '. ..'
33   - obj.uselib_local = 'modbus'
34   - obj.target = 'bandwidth-slave-one'
35   - obj.inst_var = 0
36   -
37   - obj = bld.create_obj('cc', 'program')
38   - obj.source = 'bandwidth-slave-many-up.c'
39   - obj.includes = '. ..'
40   - obj.uselib_local = 'modbus'
41   - obj.target = 'bandwidth-slave-many-up'
42   - obj.inst_var = 0
43   -
44   - obj = bld.create_obj('cc', 'program')
45   - obj.source = 'bandwidth-master.c'
46   - obj.includes = '. ..'
47   - obj.uselib_local = 'modbus'
48   - obj.target = 'bandwidth-master'
49   - obj.inst_var = 0
  9 + for program in programs:
  10 + obj = bld.new_task_gen(
  11 + features = 'cc cprogram',
  12 + source = program + '.c',
  13 + target = program,
  14 + includes = '. ../src',
  15 + uselib_local = 'modbus',
  16 + install_path='')
... ...
No preview for this file type
... ... @@ -24,23 +24,19 @@ def configure(conf):
24 24 # check for headers and append found headers to headers_found for later use
25 25 headers_found = []
26 26 for header in headers.split():
27   - if conf.check_header(header):
  27 + if conf.check_cc(header_name=header):
28 28 headers_found.append(header)
29 29  
30   - functions_defines = (
31   - ('setsockopt', 'HAVE_SETSOCKOPT'),
32   - ('inet_ntoa', 'HAVE_INET_NTOA'),
33   - ('memset', 'HAVE_MEMSET'),
34   - ('select', 'HAVE_SELECT'),
35   - ('socket', 'HAVE_SOCKET'))
  30 + functions_headers = (
  31 + ('setsockopt', 'sys/socket.h'),
  32 + ('inet_ntoa', 'arpa/inet.h'),
  33 + ('memset', 'string.h'),
  34 + ('select', 'sys/select.h'),
  35 + ('socket', 'sys/socket.h'),
  36 + )
36 37  
37   - for (function, define) in functions_defines:
38   - e = conf.create_function_enumerator()
39   - e.mandatory = True
40   - e.function = function
41   - e.headers = headers_found
42   - e.define = define
43   - e.run()
  38 + for (function, headers) in functions_headers:
  39 + conf.check_cc(function_name=function, header_name=headers, mandatory=1)
44 40  
45 41 conf.define('VERSION', VERSION)
46 42 conf.define('PACKAGE', 'libmodbus')
... ... @@ -50,18 +46,19 @@ def configure(conf):
50 46 def build(bld):
51 47 import misc
52 48  
53   - bld.add_subdirs('modbus tests')
  49 + bld.add_subdirs('src tests')
54 50  
55   - obj = bld.create_obj('subst')
56   - obj.source = 'modbus.pc.in'
57   - obj.target = 'modbus.pc'
58   - obj.dict = {'VERSION' : VERSION,
59   - 'prefix': bld.env()['PREFIX'],
60   - 'exec_prefix': bld.env()['PREFIX'],
61   - 'libdir': bld.env()['PREFIX'] + 'lib',
62   - 'includedir': bld.env()['PREFIX'] + 'include'}
  51 + obj = bld.new_task_gen(features='subst',
  52 + source='modbus.pc.in',
  53 + target='modbus.pc',
  54 + dict = {'VERSION' : VERSION,
  55 + 'prefix': bld.env['PREFIX'],
  56 + 'exec_prefix': bld.env['PREFIX'],
  57 + 'libdir': bld.env['PREFIX'] + 'lib',
  58 + 'includedir': bld.env['PREFIX'] + 'include'}
  59 + )
63 60  
64   - install_files('PREFIX', 'lib/pkgconfig', 'modbus.pc')
  61 + bld.install_files('${PREFIX}/lib/pkgconfig', 'modbus.pc')
65 62  
66 63 def shutdown():
67 64 import UnitTest
... ...