time-bound memory-pool
[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
8 # Version of this package (even if built as a child)
9 MAJOR = '4'
10 MINOR = '1'
11 MICRO = '0'
12 LIBPBD_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
13
14 # Library version (UNIX style major, minor, micro)
15 # major increment <=> incompatible changes
16 # minor increment <=> compatible changes (additions)
17 # micro increment <=> no interface changes
18 LIBPBD_LIB_VERSION = '4.1.0'
19
20 # Variables for 'waf dist'
21 APPNAME = 'libpbd'
22 VERSION = LIBPBD_VERSION
23 I18N_PACKAGE = 'libpbd4'
24
25 # Mandatory variables
26 top = '.'
27 out = 'build'
28
29 path_prefix = 'libs/pbd/'
30
31 libpbd_sources = [
32     'basename.cc',
33     'base_ui.cc',
34     'boost_debug.cc',
35     'cartesian.cc',
36     'command.cc',
37     'configuration_variable.cc',
38     'convert.cc',
39     'controllable.cc',
40     'controllable_descriptor.cc',
41     'crossthread.cc',
42     'cpus.cc',
43     'debug.cc',
44     'demangle.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     'id.cc',
54     'locale_guard.cc',
55     'localtime_r.cc',
56     'malign.cc',
57     'md5.cc',
58     'mountpoint.cc',
59     'openuri.cc',
60     'pathexpand.cc',
61     'pbd.cc',
62     'pool.cc',
63     'property_list.cc',
64     'pthread_utils.cc',
65     'reallocpool.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     if not Options.options.ppc:
101         conf.check_cc(function_name='posix_memalign', header_name='stdlib.h', cflags='-D_XOPEN_SOURCE=600', define_name='HAVE_POSIX_MEMALIGN', mandatory=False)
102     conf.check(function_name='localtime_r', header_name='time.h', define_name='HAVE_LOCALTIME_R',mandatory=False)
103
104     conf.write_config_header('libpbd-config.h', remove=False)
105
106     # Boost headers
107     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
108     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
109     if Options.options.dist_target == 'mingw':
110         conf.check(compiler='cxx',
111                    lib='ole32',
112                    mandatory=True,
113                    uselib_store='OLE')
114
115 def build(bld):
116
117     # Make signals_generated.h using signals.py
118     bld(rule = sys.executable + ' ${SRC} ${TGT}', source = 'pbd/signals.py', target = 'pbd/signals_generated.h')
119
120     # Library
121     if bld.is_defined ('INTERNAL_SHARED_LIBS'):
122         obj              = bld.shlib(features = 'cxx cxxshlib', source=libpbd_sources)
123         obj.defines = [ 'LIBPBD_DLL_EXPORTS=1' ]
124     else:
125         obj              = bld.stlib(features = 'cxx cxxstlib', source=libpbd_sources)
126         obj.cxxflags     = [ '-fPIC' ]
127         obj.cflags     = [ '-fPIC' ]
128         obj.defines      = []
129
130     if bld.is_defined('DEBUG_RT_ALLOC'):
131         obj.source += 'debug_rt_alloc.c'
132
133     obj.export_includes = ['.']
134     obj.includes     = ['.']
135     obj.name         = 'libpbd'
136     obj.target       = 'pbd'
137     obj.uselib       = 'GLIBMM SIGCPP XML UUID SNDFILE GIOMM'
138     if sys.platform == 'darwin':
139         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
140         if 'cocoa_open_uri.mm' not in obj.source:
141             obj.source += [ 'cocoa_open_uri.mm' ]
142         obj.uselib += ' OSX'
143     obj.vnum         = LIBPBD_LIB_VERSION
144     obj.install_path = bld.env['LIBDIR']
145     obj.defines     += [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
146
147     if bld.env['build_target'] == 'x86_64':
148         obj.defines += [ 'USE_X86_64_ASM' ]
149     if bld.env['build_target'] == 'mingw':
150         obj.defines += [ 'NO_POSIX_MEMALIGN' ]
151         obj.source += [ 'windows_special_dirs.cc' ]
152         obj.source += [ 'windows_timer_utils.cc' ]
153         obj.source += [ 'windows_mmcss.cc' ]
154         obj.uselib += ' OLE'
155
156     if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
157         # Unit tests
158         testobj              = bld(features = 'cxx cxxprogram')
159         testobj.source       = '''
160                 test/testrunner.cc
161                 test/xpath.cc
162                 test/mutex_test.cc
163                 test/scalar_properties.cc
164                 test/signals_test.cc
165                 test/convert_test.cc
166                 test/filesystem_test.cc
167                 test/xml_test.cc
168                 test/test_common.cc
169         '''.split()
170         if bld.env['build_target'] == 'mingw':
171             testobj.source += [ 'test/windows_timer_utils_test.cc' ]
172         testobj.target       = 'run-tests'
173         testobj.includes     = obj.includes + ['test', '../pbd']
174         testobj.uselib       = 'CPPUNIT XML SNDFILE'
175         testobj.use          = 'libpbd'
176         testobj.name         = 'libpbd-tests'
177         testobj.defines      = [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
178         if sys.platform != 'darwin' and bld.env['build_target'] != 'mingw':
179             testobj.linkflags    = ['-lrt']
180
181 def shutdown():
182     autowaf.shutdown()