Add pbd/resource.h for portable access to resource limits
[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     'convert.cc',
38     'controllable.cc',
39     'controllable_descriptor.cc',
40     'clear_dir.cc',
41     'crossthread.cc',
42     'cpus.cc',
43     'debug.cc',
44     'enumwriter.cc',
45     'event_loop.cc',
46     'enums.cc',
47     'epa.cc',
48     'error.cc',
49     'file_manager.cc',
50     'file_utils.cc',
51     'fpu.cc',
52     'id.cc',
53     'locale_guard.cc',
54     'malign.cc',
55     'mountpoint.cc',
56     'openuri.cc',
57     'pathexpand.cc',
58     'pathscanner.cc',
59     'pool.cc',
60     'property_list.cc',
61     'pthread_utils.cc',
62     'receiver.cc',
63     'resource.cc',
64     'search_path.cc',
65     'semutils.cc',
66     'shortpath.cc',
67     'signals.cc',
68     'sndfile_manager.cc',
69     'stacktrace.cc',
70     'stateful_diff_command.cc',
71     'stateful.cc',
72     'strreplace.cc',
73     'strsplit.cc',
74     'textreceiver.cc',
75     'transmitter.cc',
76     'undo.cc',
77     'uuid.cc',
78     'version.cc',
79     'whitespace.cc',
80     'xml++.cc',
81 ]
82
83 def options(opt):
84     autowaf.set_options(opt)
85
86 def configure(conf):
87     conf.load('compiler_cxx')
88     autowaf.build_version_files(path_prefix+'pbd/version.h', path_prefix+'version.cc',
89                     'libpbd', MAJOR, MINOR, MICRO)
90     autowaf.configure(conf)
91     autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
92     autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
93
94     conf.check(function_name='getmntent', header_name='mntent.h', define_name='HAVE_GETMNTENT',mandatory=False)
95     conf.check(header_name='execinfo.h', define_name='HAVE_EXECINFO',mandatory=False)
96     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False)
97     conf.check_cc(function_name='posix_memalign', header_name='stdlib.h', cflags='-D_XOPEN_SOURCE=600', define_name='HAVE_POSIX_MEMALIGN', mandatory=False)
98
99     conf.write_config_header('libpbd-config.h', remove=False)
100
101     # Boost headers
102     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
103     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
104
105 def build(bld):
106     
107     # Make signals_generated.h using signals.py
108     bld(rule = 'python ${SRC} ${TGT}', source = 'pbd/signals.py', target = 'pbd/signals_generated.h')
109
110     # Library
111     if bld.is_defined ('INTERNAL_SHARED_LIBS'):
112         print('BUILD SHARED LIB')
113         obj              = bld.shlib(features = 'cxx cxxshlib', source=libpbd_sources)
114     else:
115         print('BUILD STATIC LIB')
116         obj              = bld.stlib(features = 'cxx cxxstlib', source=libpbd_sources)
117         obj.cxxflags     = [ '-fPIC' ]
118
119     if bld.is_defined('DEBUG_RT_ALLOC'):
120         obj.source += 'debug_rt_alloc.c'
121
122     obj.export_includes = ['.']
123     obj.includes     = ['.']
124     obj.name         = 'libpbd'
125     obj.target       = 'pbd'
126     obj.uselib       = 'GLIBMM SIGCPP XML UUID SNDFILE GIOMM'
127     if sys.platform == 'darwin':
128         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
129         obj.source += [ 'cocoa_open_uri.mm' ]
130         obj.uselib += ' OSX'
131     obj.vnum         = LIBPBD_LIB_VERSION
132     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
133     obj.defines     = ['PACKAGE="' + I18N_PACKAGE + '"']
134
135     if bld.env['build_target'] == 'x86_64':
136         obj.defines += [ 'USE_X86_64_ASM' ]
137
138     if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
139         # Unit tests
140         testobj              = bld(features = 'cxx cxxprogram')
141         testobj.source       = '''
142                 test/testrunner.cc
143                 test/xpath.cc
144                 test/scalar_properties.cc
145                 test/signals_test.cc
146                 test/convert_test.cc
147                 test/filesystem_test.cc
148                 test/test_common.cc
149         '''.split()
150         testobj.target       = 'run-tests'
151         testobj.includes     = obj.includes + ['test', '../pbd']
152         testobj.uselib       = 'CPPUNIT XML SNDFILE'
153         testobj.use          = 'libpbd'
154         testobj.name         = 'libpbd-tests'
155         if sys.platform != 'darwin':
156             testobj.linkflags    = ['-lrt']
157
158
159 def shutdown():
160     autowaf.shutdown()