Эх сурвалжийг харах

Finished waf script (almost)

Stéphane Raimbault 17 жил өмнө
parent
commit
6d093b6a42
1 өөрчлөгдсөн 38 нэмэгдсэн , 13 устгасан
  1. 38 13
      wscript

+ 38 - 13
wscript

@@ -6,7 +6,7 @@ APPNAME='libmodbus'
 
 # these variables are mandatory ('/' are converted automatically)
 srcdir = '.'
-blddir = '_build_'
+blddir = 'build'
 
 def init():
      print "A groovy libmodbus for Linux!"
@@ -18,27 +18,52 @@ def set_options(opt):
 def configure(conf):
      conf.check_tool('compiler_cc')
      conf.check_pkg('glib-2.0', destvar='GLIB', mandatory=True)
+     conf.check_tool('misc')
 
-     e = conf.create_header_enumerator()
-     e.mandatory = 1
-     # Add AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h termio.h termios.h unistd.h])
-     e.name = 'arpa/inet.h'
-     e.run()
+     headers = 'arpa/inet.h fcntl.h netinet/in.h stdlib.h \
+                string.h sys/ioctl.h sys/socket.h sys/time.h \
+                termio.h termios.h unistd.h'
 
-     # Add AC_CHECK_FUNCS([inet_ntoa memset select socket])
+     # 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):
+               headers_found.append(header)
+
+     functions_defines = (
+          ('inet_ntoa', 'HAVE_INET_NTOA'),
+          ('memset', 'HAVE_MEMSET'),
+          ('select', 'HAVE_SELECT'),
+          ('socket', 'HAVE_SOCKET'))
+
+     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()
+ 
      conf.define('VERSION', VERSION)
      conf.define('PACKAGE', 'libmodbus')
 
      conf.write_config_header()
 
 def build(bld):
-     bld.add_subdirs('src');  
+     import misc
+
+     bld.add_subdirs('src')  
 
-#    Doesn't work I need some help from the WAF project
-#      obj = bld.create_obj('subst')
-#      obj.source = 'modbus.pc.in'
-#      obj.target = 'modbus.pc'
-#      obj.dict = {'VERSION' : VERSION }
+     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',
+                 'modbus_pkgdeps' : 'glib-2.0'}
 
 def shutdown():
      import UnitTest