more changes to wscript files to catch up with waf 1.6 and fix OS X issues
[ardour.git] / libs / pbd / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 from waflib import TaskGen
4 import os
5 import sys
6
7 # Version of this package (even if built as a child)
8 MAJOR = '4'
9 MINOR = '1'
10 MICRO = '0'
11 LIBPBD_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
12
13 # Library version (UNIX style major, minor, micro)
14 # major increment <=> incompatible changes
15 # minor increment <=> compatible changes (additions)
16 # micro increment <=> no interface changes
17 LIBPBD_LIB_VERSION = '4.1.0'
18
19 # Variables for 'waf dist'
20 APPNAME = 'libpbd'
21 VERSION = LIBPBD_VERSION
22
23 # Mandatory variables
24 top = '.'
25 out = 'build'
26
27 path_prefix = 'libs/pbd/'
28
29 def options(opt):
30     autowaf.set_options(opt)
31
32 def configure(conf):
33     conf.load('compiler_cxx')
34     autowaf.build_version_files(path_prefix+'pbd/version.h', path_prefix+'version.cc',
35                     'libpbd', MAJOR, MINOR, MICRO)
36     autowaf.configure(conf)
37     autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
38     autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
39     if sys.platform != 'darwin':
40         autowaf.check_pkg(conf, 'uuid', uselib_store='UUID')
41
42     conf.check(function_name='getmntent', header_name='mntent.h', define_name='HAVE_GETMNTENT',mandatory=False)
43     conf.check(header_name='execinfo.h', define_name='HAVE_EXECINFO',mandatory=False)
44     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False)
45     if conf.check_cc(function_name='posix_memalign', header_name='stdlib.h', cflags='-D_XOPEN_SOURCE=600',mandatory=False) == False:
46         conf.define ('NO_POSIX_MEMALIGN',1)
47
48     conf.write_config_header('libpbd-config.h', remove=False)
49
50     # Boost headers
51     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
52     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
53     # autowaf.check_header(conf, 'cxx', 'boost/uuid/uuid.hpp')
54
55 def build(bld):
56     # Library
57     obj = bld(features = 'cxx cxxshlib')
58     obj.source = '''
59             basename.cc
60             base_ui.cc
61             boost_debug.cc
62             cartesian.cc
63             command.cc
64             convert.cc
65             controllable.cc
66             controllable_descriptor.cc
67             clear_dir.cc
68             crossthread.cc
69             cpus.cc
70             debug.cc
71             enumwriter.cc
72             event_loop.cc
73             dmalloc.cc
74             enums.cc
75             epa.cc
76             error.cc
77             filesystem.cc
78             filesystem_paths.cc
79             file_manager.cc
80             file_utils.cc
81             fpu.cc
82             id.cc
83             locale_guard.cc
84             malign.cc
85             mountpoint.cc
86             openuri.cc
87             pathscanner.cc
88             pool.cc
89             property_list.cc
90             pthread_utils.cc
91             receiver.cc
92             search_path.cc
93             semutils.cc
94             shortpath.cc
95             signals.cc
96             sndfile_manager.cc
97             stacktrace.cc
98             stateful_diff_command.cc
99             stateful.cc
100             strreplace.cc
101             strsplit.cc
102             textreceiver.cc
103             transmitter.cc
104             undo.cc
105             uuid.cc
106             version.cc
107             whitespace.cc
108             xml++.cc
109     '''
110
111     if bld.is_defined('DEBUG_RT_ALLOC'):
112         obj.source += 'debug_rt_alloc.c'
113
114     obj.export_includes = ['.']
115     obj.includes     = ['.']
116     obj.name         = 'libpbd'
117     obj.target       = 'pbd'
118     obj.uselib       = 'GLIBMM SIGCPP XML UUID SNDFILE'
119     if sys.platform == 'darwin':
120         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
121         obj.source += 'cocoa_open_uri.mm'
122         obj.uselib += ' OSX'
123     obj.vnum         = LIBPBD_LIB_VERSION
124     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
125     obj.cxxflags     = ['-DPACKAGE="libpbd"']
126
127     if bld.env['build_target'] == 'x86_64':
128         obj.cxxflags += [ '-DUSE_X86_64_ASM' ]
129
130     if bld.is_defined ('BUILD_TESTS') and bld.is_defined('HAVE_CPPUNIT'):
131         # Unit tests
132         testobj              = bld(features = 'cxx cxxprogram')
133         testobj.source       = '''
134                 test/testrunner.cc
135                 test/xpath.cc
136                 test/scalar_properties.cc
137                 test/signals_test.cc
138         '''.split()
139         testobj.target       = 'run-tests'
140         testobj.includes     = obj.includes + ['test', '../pbd']
141         testobj.uselib       = 'CPPUNIT XML SNDFILE'
142         testobj.use          = 'libpbd'
143
144
145 def shutdown():
146     autowaf.shutdown()