PBD::Signal<...>::connect() is already thread safe, so drop intermediate proxy/call_s...
[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 LIBPBD_MAJOR_VERSION = '4'
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     '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_archive.cc',
52     'file_utils.cc',
53     'fpu.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     'reallocpool.cc',
67     'receiver.cc',
68     'resource.cc',
69     'search_path.cc',
70     'semutils.cc',
71     'shortpath.cc',
72     'signals.cc',
73     'stacktrace.cc',
74     'stateful_diff_command.cc',
75     'stateful.cc',
76     'strreplace.cc',
77     'strsplit.cc',
78     'system_exec.cc',
79     'textreceiver.cc',
80     'timer.cc',
81     'timing.cc',
82     'tlsf.cc',
83     'transmitter.cc',
84     'undo.cc',
85     'uuid.cc',
86     'whitespace.cc',
87     'xml++.cc',
88 ]
89
90 def options(opt):
91     opt.load('compiler_cxx')
92     autowaf.set_options(opt)
93     opt.add_option('--ppc', action='store_true', default=False, dest='ppc',
94                    help='Compile with -arch ppc (OS X ONLY)')
95     opt.add_option('--dist-target', type='string', default='auto', dest='dist_target',
96                     help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,tiger,leopard,mingw,msvc]')
97     opt.add_option('--internal-shared-libs', action='store_true', default=True, dest='internal_shared_libs',
98                    help='Build internal libs as shared libraries')
99
100 def configure(conf):
101     conf.load('compiler_cxx')
102     autowaf.configure(conf)
103     autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
104     autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
105     autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL', atleast_version='7.0.0', mandatory=True)
106     autowaf.check_pkg(conf, 'libarchive', uselib_store='ARCHIVE', atleast_version='3.0.0', mandatory=True)
107     autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0', mandatory=True)
108     autowaf.check_pkg(conf, 'giomm-2.4', uselib_store='GIOMM', atleast_version='2.2', mandatory=True)
109
110     conf.check(function_name='getmntent', header_name='mntent.h', define_name='HAVE_GETMNTENT',mandatory=False)
111     conf.check(header_name='execinfo.h', define_name='HAVE_EXECINFO',mandatory=False)
112     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False)
113     if not Options.options.ppc:
114         conf.check_cc(function_name='posix_memalign', header_name='stdlib.h', cflags='-D_XOPEN_SOURCE=600', define_name='HAVE_POSIX_MEMALIGN', mandatory=False)
115     conf.check(function_name='localtime_r', header_name='time.h', define_name='HAVE_LOCALTIME_R',mandatory=False)
116
117     # Boost headers
118     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
119     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
120     if Options.options.dist_target == 'mingw':
121         conf.check(compiler='cxx',
122                    lib='ole32',
123                    mandatory=True,
124                    uselib_store='OLE')
125
126     if Options.options.internal_shared_libs:
127         conf.define('INTERNAL_SHARED_LIBS', 1)
128
129     conf.write_config_header('libpbd-config.h', remove=False)
130
131 def build(bld):
132     if not autowaf.is_child():  # Building standalone, install dev stuff
133         # C++ Headers
134         includedir = '${INCLUDEDIR}/pbd-%s/pbd' % LIBPBD_MAJOR_VERSION
135         bld.install_files(includedir, bld.path.ant_glob('pbd/*.h'))
136         bld.install_files(includedir, 'build/pbd/signals_generated.h')
137
138         # Pkgconfig file
139         autowaf.build_pc(bld, 'libpbd', LIBPBD_VERSION, LIBPBD_MAJOR_VERSION, [],
140                          {'LIBPBD_VERSION' : LIBPBD_VERSION,
141                           'LIBPBD_MAJOR_VERSION' : LIBPBD_MAJOR_VERSION})
142
143     # Make signals_generated.h using signals.py
144     bld(rule = sys.executable + ' ${SRC} ${TGT}', source = 'pbd/signals.py', target = 'pbd/signals_generated.h')
145
146     # Library
147     if bld.is_defined ('INTERNAL_SHARED_LIBS'):
148         obj              = bld.shlib(features = 'cxx cxxshlib', source=libpbd_sources)
149         obj.defines = [ 'LIBPBD_DLL_EXPORTS=1' ]
150     else:
151         obj              = bld.stlib(features = 'cxx cxxstlib', source=libpbd_sources)
152         obj.cxxflags     = [ '-fPIC' ]
153         obj.cflags     = [ '-fPIC' ]
154         obj.defines      = []
155
156     if bld.is_defined('DEBUG_RT_ALLOC'):
157         obj.source += 'debug_rt_alloc.c'
158
159     obj.export_includes = ['.']
160     obj.includes     = ['.']
161     obj.name         = 'libpbd'
162     obj.target       = 'pbd'
163     obj.uselib       = 'GLIBMM SIGCPP XML UUID SNDFILE GIOMM ARCHIVE CURL'
164     if sys.platform == 'darwin':
165         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
166         if 'cocoa_open_uri.mm' not in obj.source:
167             obj.source += [ 'cocoa_open_uri.mm' ]
168         obj.uselib += ' OSX'
169     obj.vnum         = LIBPBD_LIB_VERSION
170     obj.install_path = bld.env['LIBDIR']
171     obj.defines     += [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
172
173     if sys.platform.startswith('netbsd'):
174         obj.linkflags = '-lexecinfo'
175
176     if bld.env['build_target'] == 'x86_64':
177         obj.defines += [ 'USE_X86_64_ASM' ]
178     if bld.env['build_target'] == 'mingw':
179         obj.defines += [ 'NO_POSIX_MEMALIGN' ]
180         obj.source += [ 'windows_special_dirs.cc' ]
181         obj.source += [ 'windows_timer_utils.cc' ]
182         obj.source += [ 'windows_mmcss.cc' ]
183         obj.uselib += ' OLE'
184
185     if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
186         # Unit tests
187         testobj              = bld(features = 'cxx cxxprogram')
188         testobj.source       = '''
189                 test/testrunner.cc
190                 test/xpath.cc
191                 test/mutex_test.cc
192                 test/scalar_properties.cc
193                 test/signals_test.cc
194                 test/convert_test.cc
195                 test/filesystem_test.cc
196                 test/natsort_test.cc
197                 test/reallocpool_test.cc
198                 test/xml_test.cc
199                 test/test_common.cc
200         '''.split()
201         if bld.env['build_target'] == 'mingw':
202             testobj.source += [ 'test/windows_timer_utils_test.cc' ]
203         testobj.target       = 'run-tests'
204         testobj.includes     = obj.includes + ['test', '../pbd']
205         testobj.uselib       = 'CPPUNIT XML SNDFILE'
206         testobj.use          = 'libpbd'
207         testobj.name         = 'libpbd-tests'
208         testobj.defines      = [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
209         if sys.platform != 'darwin' and bld.env['build_target'] != 'mingw':
210             testobj.linkflags    = ['-lrt']