diff --git a/Makefile.am b/Makefile.am index 99c2a71..e5a2d6c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ EXTRA_DIST = MIGRATION libmodbus.spec -SUBDIRS = modbus tests +SUBDIRS = src tests pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = modbus.pc diff --git a/configure.ac b/configure.ac index 090c8d6..827e308 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ(2.59) AC_INIT(libmodbus, 2.0.3, stephane.raimbault@gmail.com) -AC_CONFIG_SRCDIR([modbus/modbus.c]) +AC_CONFIG_SRCDIR([src/modbus.c]) AM_INIT_AUTOMAKE AM_DISABLE_STATIC @@ -28,7 +28,7 @@ AC_CHECK_FUNCS([inet_ntoa memset select socket]) AC_OUTPUT([ Makefile - modbus/Makefile + src/Makefile tests/Makefile modbus.pc ]) diff --git a/modbus/wscript b/modbus/wscript deleted file mode 100644 index da2c0c6..0000000 --- a/modbus/wscript +++ /dev/null @@ -1,8 +0,0 @@ -def build(bld): - obj = bld.create_obj('cc', 'shlib') - obj.source = 'modbus.c' - obj.includes = '.' - obj.target = 'modbus' - obj.vnum = '2.0.1' - - install_files('PREFIX', 'include/modbus', 'modbus.h') diff --git a/modbus/Makefile.am b/src/Makefile.am index 7469c0a..7469c0a 100644 --- a/modbus/Makefile.am +++ b/src/Makefile.am diff --git a/modbus/modbus.c b/src/modbus.c index da838fb..da838fb 100644 --- a/modbus/modbus.c +++ b/src/modbus.c diff --git a/modbus/modbus.h b/src/modbus.h index 96b61f1..96b61f1 100644 --- a/modbus/modbus.h +++ b/src/modbus.h diff --git a/src/wscript b/src/wscript new file mode 100644 index 0000000..0dd98be --- /dev/null +++ b/src/wscript @@ -0,0 +1,8 @@ +def build(bld): + obj = bld.new_task_gen( + features='cc cshlib', + source='modbus.c', + target = 'modbus', + vnum='2.2.0') + + bld.install_files('${PREFIX}/include/modbus', 'modbus.h') diff --git a/tests/Makefile.am b/tests/Makefile.am index 46185e4..73f37a5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,7 +10,7 @@ noinst_PROGRAMS = \ bandwidth-master common_ldflags = \ - $(top_builddir)/modbus/libmodbus.la + $(top_builddir)/src/libmodbus.la random_test_slave_SOURCES = random-test-slave.c random_test_slave_LDADD = $(common_ldflags) @@ -33,5 +33,5 @@ bandwidth_slave_many_up_LDADD = $(common_ldflags) bandwidth_master_SOURCES = bandwidth-master.c bandwidth_master_LDADD = $(common_ldflags) -INCLUDES = -I$(top_srcdir) +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src CLEANFILES = *~ diff --git a/tests/bandwidth-master.c b/tests/bandwidth-master.c index 1f455ef..3110f38 100644 --- a/tests/bandwidth-master.c +++ b/tests/bandwidth-master.c @@ -22,7 +22,7 @@ #include #include -#include +#include "modbus.h" /* Tests based on PI-MBUS-300 documentation */ #define SLAVE 0x11 diff --git a/tests/bandwidth-slave-many-up.c b/tests/bandwidth-slave-many-up.c index c458895..fd8c379 100644 --- a/tests/bandwidth-slave-many-up.c +++ b/tests/bandwidth-slave-many-up.c @@ -22,7 +22,7 @@ #include #include -#include +#include "modbus.h" #define NB_CONNECTION 5 int slave_socket; diff --git a/tests/bandwidth-slave-one.c b/tests/bandwidth-slave-one.c index e3d80ce..57a39d2 100644 --- a/tests/bandwidth-slave-one.c +++ b/tests/bandwidth-slave-one.c @@ -20,7 +20,7 @@ #include #include -#include +#include "modbus.h" int main(void) { diff --git a/tests/random-test-master.c b/tests/random-test-master.c index 77ff406..bb0a59c 100644 --- a/tests/random-test-master.c +++ b/tests/random-test-master.c @@ -20,7 +20,7 @@ #include #include -#include +#include "modbus.h" /* The goal of this program is to check all major functions of libmodbus: diff --git a/tests/random-test-slave.c b/tests/random-test-slave.c index d1a5441..9668943 100644 --- a/tests/random-test-slave.c +++ b/tests/random-test-slave.c @@ -19,7 +19,7 @@ #include #include -#include +#include "modbus.h" int main(void) { diff --git a/tests/unit-test-master.c b/tests/unit-test-master.c index af74028..b70a132 100644 --- a/tests/unit-test-master.c +++ b/tests/unit-test-master.c @@ -20,8 +20,7 @@ #include #include -#include - +#include "modbus.h" #include "unit-test.h" /* Tests based on PI-MBUS-300 documentation */ diff --git a/tests/unit-test-slave.c b/tests/unit-test-slave.c index a7615a3..8a51adb 100644 --- a/tests/unit-test-slave.c +++ b/tests/unit-test-slave.c @@ -20,8 +20,7 @@ #include #include -#include - +#include "modbus.h" #include "unit-test.h" int main(void) diff --git a/tests/wscript b/tests/wscript index 959fd8d..b21a64d 100644 --- a/tests/wscript +++ b/tests/wscript @@ -1,49 +1,16 @@ def build(bld): - obj = bld.create_obj('cc', 'program') - obj.source = 'random-test-slave.c' - obj.includes = '. ..' - obj.uselib_local = 'modbus' - obj.target = 'random-test-slave' - obj.inst_var = 0 + programs = ('random-test-slave', + 'unit-test-slave', + 'unit-test-master', + 'bandwidth-slave-one', + 'bandwidth-slave-many-up', + 'bandwidth-master') - obj = bld.create_obj('cc', 'program') - obj.source = 'random-test-master.c' - obj.includes = '. ..' - obj.uselib_local = 'modbus' - obj.target = 'random-test-master' - obj.inst_var = 0 - - obj = bld.create_obj('cc', 'program') - obj.source = 'unit-test-slave.c' - obj.includes = '. ..' - obj.uselib_local = 'modbus' - obj.target = 'unit-test-slave' - obj.inst_var = 0 - - obj = bld.create_obj('cc', 'program') - obj.source = 'unit-test-master.c' - obj.includes = '. ..' - obj.uselib_local = 'modbus' - obj.target = 'unit-test-master' - obj.inst_var = 0 - - obj = bld.create_obj('cc', 'program') - obj.source = 'bandwidth-slave-one.c' - obj.includes = '. ..' - obj.uselib_local = 'modbus' - obj.target = 'bandwidth-slave-one' - obj.inst_var = 0 - - obj = bld.create_obj('cc', 'program') - obj.source = 'bandwidth-slave-many-up.c' - obj.includes = '. ..' - obj.uselib_local = 'modbus' - obj.target = 'bandwidth-slave-many-up' - obj.inst_var = 0 - - obj = bld.create_obj('cc', 'program') - obj.source = 'bandwidth-master.c' - obj.includes = '. ..' - obj.uselib_local = 'modbus' - obj.target = 'bandwidth-master' - obj.inst_var = 0 + for program in programs: + obj = bld.new_task_gen( + features = 'cc cprogram', + source = program + '.c', + target = program, + includes = '. ../src', + uselib_local = 'modbus', + install_path='') diff --git a/waf b/waf index ca7e812..a8c8129 100755 --- a/waf +++ b/waf diff --git a/wscript b/wscript index b3d660e..b141387 100644 --- a/wscript +++ b/wscript @@ -24,23 +24,19 @@ def configure(conf): # check for headers and append found headers to headers_found for later use headers_found = [] for header in headers.split(): - if conf.check_header(header): + if conf.check_cc(header_name=header): headers_found.append(header) - functions_defines = ( - ('setsockopt', 'HAVE_SETSOCKOPT'), - ('inet_ntoa', 'HAVE_INET_NTOA'), - ('memset', 'HAVE_MEMSET'), - ('select', 'HAVE_SELECT'), - ('socket', 'HAVE_SOCKET')) + functions_headers = ( + ('setsockopt', 'sys/socket.h'), + ('inet_ntoa', 'arpa/inet.h'), + ('memset', 'string.h'), + ('select', 'sys/select.h'), + ('socket', 'sys/socket.h'), + ) - for (function, define) in functions_defines: - e = conf.create_function_enumerator() - e.mandatory = True - e.function = function - e.headers = headers_found - e.define = define - e.run() + for (function, headers) in functions_headers: + conf.check_cc(function_name=function, header_name=headers, mandatory=1) conf.define('VERSION', VERSION) conf.define('PACKAGE', 'libmodbus') @@ -50,18 +46,19 @@ def configure(conf): def build(bld): import misc - bld.add_subdirs('modbus tests') + bld.add_subdirs('src tests') - obj = bld.create_obj('subst') - obj.source = 'modbus.pc.in' - obj.target = 'modbus.pc' - obj.dict = {'VERSION' : VERSION, - 'prefix': bld.env()['PREFIX'], - 'exec_prefix': bld.env()['PREFIX'], - 'libdir': bld.env()['PREFIX'] + 'lib', - 'includedir': bld.env()['PREFIX'] + 'include'} + obj = bld.new_task_gen(features='subst', + source='modbus.pc.in', + target='modbus.pc', + dict = {'VERSION' : VERSION, + 'prefix': bld.env['PREFIX'], + 'exec_prefix': bld.env['PREFIX'], + 'libdir': bld.env['PREFIX'] + 'lib', + 'includedir': bld.env['PREFIX'] + 'include'} + ) - install_files('PREFIX', 'lib/pkgconfig', 'modbus.pc') + bld.install_files('${PREFIX}/lib/pkgconfig', 'modbus.pc') def shutdown(): import UnitTest