Explorar o código

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
Stéphane Raimbault %!s(int64=16) %!d(string=hai) anos
pai
achega
e80dc40503

+ 1 - 1
Makefile.am

@@ -1,5 +1,5 @@
 EXTRA_DIST = MIGRATION libmodbus.spec
-SUBDIRS = modbus tests
+SUBDIRS = src tests
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = modbus.pc

+ 2 - 2
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
 ])

+ 0 - 8
modbus/wscript

@@ -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')

+ 0 - 0
modbus/Makefile.am → src/Makefile.am


+ 0 - 0
modbus/modbus.c → src/modbus.c


+ 0 - 0
modbus/modbus.h → src/modbus.h


+ 8 - 0
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')

+ 2 - 2
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 = *~

+ 1 - 1
tests/bandwidth-master.c

@@ -22,7 +22,7 @@
 #include <time.h>
 #include <sys/time.h>
 
-#include <modbus/modbus.h>
+#include "modbus.h"
 
 /* Tests based on PI-MBUS-300 documentation */
 #define SLAVE     0x11

+ 1 - 1
tests/bandwidth-slave-many-up.c

@@ -22,7 +22,7 @@
 #include <errno.h>
 #include <signal.h>
 
-#include <modbus/modbus.h>
+#include "modbus.h"
 
 #define NB_CONNECTION 5
 int slave_socket;

+ 1 - 1
tests/bandwidth-slave-one.c

@@ -20,7 +20,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <modbus/modbus.h>
+#include "modbus.h"
 
 int main(void)
 {

+ 1 - 1
tests/random-test-master.c

@@ -20,7 +20,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <modbus/modbus.h>
+#include "modbus.h"
 
 /* The goal of this program is to check all major functions of
    libmodbus:

+ 1 - 1
tests/random-test-slave.c

@@ -19,7 +19,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 
-#include <modbus/modbus.h>
+#include "modbus.h"
 
 int main(void)
 {

+ 1 - 2
tests/unit-test-master.c

@@ -20,8 +20,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <modbus/modbus.h>
-
+#include "modbus.h"
 #include "unit-test.h"
 
 /* Tests based on PI-MBUS-300 documentation */

+ 1 - 2
tests/unit-test-slave.c

@@ -20,8 +20,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <modbus/modbus.h>
-
+#include "modbus.h"
 #include "unit-test.h"
 
 int main(void)

+ 14 - 47
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='')

BIN=BIN
waf


+ 21 - 24
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