add missing regexp support to pbd/wscript
[ardour.git] / libs / pbd / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 from waflib import Options
4 from waflib import TaskGen
5 import os
6 import sys
7 import re
8
9 # Version of this package (even if built as a child)
10 MAJOR = '4'
11 MINOR = '1'
12 MICRO = '0'
13 LIBPBD_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
14
15 # Library version (UNIX style major, minor, micro)
16 # major increment <=> incompatible changes
17 # minor increment <=> compatible changes (additions)
18 # micro increment <=> no interface changes
19 LIBPBD_LIB_VERSION = '4.1.0'
20
21 # Variables for 'waf dist'
22 APPNAME = 'libpbd'
23 VERSION = LIBPBD_VERSION
24 I18N_PACKAGE = 'libpbd4'
25
26 # Mandatory variables
27 top = '.'
28 out = 'build'
29
30 path_prefix = 'libs/pbd/'
31
32 libpbd_sources = [
33     'basename.cc',
34     'base_ui.cc',
35     'boost_debug.cc',
36     'cartesian.cc',
37     'command.cc',
38     'configuration_variable.cc',
39     'convert.cc',
40     'controllable.cc',
41     'controllable_descriptor.cc',
42     'crossthread.cc',
43     'cpus.cc',
44     'debug.cc',
45     'enumwriter.cc',
46     'event_loop.cc',
47     'enums.cc',
48     'epa.cc',
49     'error.cc',
50     'ffs.cc',
51     'file_utils.cc',
52     'fpu.cc',
53     'glib_semaphore.cc',
54     'id.cc',
55     'locale_guard.cc',
56     'localtime_r.cc',
57     'malign.cc',
58     'md5.cc',
59     'mountpoint.cc',
60     'openuri.cc',
61     'pathexpand.cc',
62     'pbd.cc',
63     'pool.cc',
64     'property_list.cc',
65     'pthread_utils.cc',
66     'receiver.cc',
67     'resource.cc',
68     'search_path.cc',
69     'semutils.cc',
70     'shortpath.cc',
71     'signals.cc',
72     'stacktrace.cc',
73     'stateful_diff_command.cc',
74     'stateful.cc',
75     'strreplace.cc',
76     'strsplit.cc',
77     'system_exec.cc',
78     'textreceiver.cc',
79     'timer.cc',
80     'timing.cc',
81     'transmitter.cc',
82     'undo.cc',
83     'uuid.cc',
84     'whitespace.cc',
85     'xml++.cc',
86 ]
87
88 def options(opt):
89     autowaf.set_options(opt)
90
91 def configure(conf):
92     conf.load('compiler_cxx')
93     autowaf.configure(conf)
94     autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
95     autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
96
97     conf.check(function_name='getmntent', header_name='mntent.h', define_name='HAVE_GETMNTENT',mandatory=False)
98     conf.check(header_name='execinfo.h', define_name='HAVE_EXECINFO',mandatory=False)
99     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False)
100     conf.check_cc(function_name='posix_memalign', header_name='stdlib.h', cflags='-D_XOPEN_SOURCE=600', define_name='HAVE_POSIX_MEMALIGN', mandatory=False)
101     conf.check(function_name='localtime_r', header_name='time.h', define_name='HAVE_LOCALTIME_R',mandatory=False)
102
103     conf.write_config_header('libpbd-config.h', remove=False)
104
105     # Boost headers
106     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
107     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
108     if Options.options.dist_target == 'mingw':
109         conf.check(compiler='cxx',
110                    lib='ole32',
111                    mandatory=True,
112                    uselib_store='OLE')
113
114 def build(bld):
115
116     # Make signals_generated.h using signals.py
117     bld(rule = 'python ${SRC} ${TGT}', source = 'pbd/signals.py', target = 'pbd/signals_generated.h')
118
119     # Library
120     if bld.is_defined ('INTERNAL_SHARED_LIBS'):
121         obj              = bld.shlib(features = 'cxx cxxshlib', source=libpbd_sources)
122         obj.defines = [ 'LIBPBD_DLL_EXPORTS=1' ]
123     else:
124         obj              = bld.stlib(features = 'cxx cxxstlib', source=libpbd_sources)
125         obj.cxxflags     = [ '-fPIC' ]
126         obj.cflags     = [ '-fPIC' ]
127         obj.defines      = []
128
129     if bld.is_defined('DEBUG_RT_ALLOC'):
130         obj.source += 'debug_rt_alloc.c'
131
132     obj.export_includes = ['.']
133     obj.includes     = ['.']
134     obj.name         = 'libpbd'
135     obj.target       = 'pbd'
136     obj.uselib       = 'GLIBMM SIGCPP XML UUID SNDFILE GIOMM'
137     if sys.platform == 'darwin':
138         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
139         if 'cocoa_open_uri.mm' not in obj.source:
140             obj.source += [ 'cocoa_open_uri.mm' ]
141         obj.uselib += ' OSX'
142     obj.vnum         = LIBPBD_LIB_VERSION
143     obj.install_path = bld.env['LIBDIR']
144     obj.defines     += [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
145
146     if bld.env['build_target'] == 'x86_64':
147         obj.defines += [ 'USE_X86_64_ASM' ]
148     if bld.env['build_target'] == 'mingw':
149         if re.search ('/^x86_64/', str(bld.env['CC'])):
150             obj.defines += [ 'USE_X86_64_ASM' ]
151             obj.defines += ['NO_POSIX_MEMALIGN' ]
152         obj.source += [ 'windows_special_dirs.cc' ]
153         obj.uselib += ' OLE'
154
155     if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
156         # Unit tests
157         testobj              = bld(features = 'cxx cxxprogram')
158         testobj.source       = '''
159                 test/testrunner.cc
160                 test/xpath.cc
161                 test/mutex_test.cc
162                 test/scalar_properties.cc
163                 test/signals_test.cc
164                 test/timer_test.cc
165                 test/convert_test.cc
166                 test/filesystem_test.cc
167                 test/test_common.cc
168         '''.split()
169         testobj.target       = 'run-tests'
170         testobj.includes     = obj.includes + ['test', '../pbd']
171         testobj.uselib       = 'CPPUNIT XML SNDFILE'
172         testobj.use          = 'libpbd'
173         testobj.name         = 'libpbd-tests'
174         testobj.defines      = [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
175         if sys.platform != 'darwin' and bld.env['build_target'] != 'mingw':
176             testobj.linkflags    = ['-lrt']
177             
178 def shutdown():
179     autowaf.shutdown()