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