2 from waflib.extras import autowaf as autowaf
3 from waflib import Options
4 from waflib import TaskGen
8 # Version of this package (even if built as a child)
12 LIBPBD_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
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'
21 # Variables for 'waf dist'
23 VERSION = LIBPBD_VERSION
24 I18N_PACKAGE = 'libpbd4'
30 path_prefix = 'libs/pbd/'
38 'configuration_variable.cc',
74 'stateful_diff_command.cc',
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')
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)
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)
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',
126 if Options.options.internal_shared_libs:
127 conf.define('INTERNAL_SHARED_LIBS', 1)
129 conf.write_config_header('libpbd-config.h', remove=False)
132 if not autowaf.is_child(): # Building standalone, install dev stuff
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')
139 autowaf.build_pc(bld, 'libpbd', LIBPBD_VERSION, LIBPBD_MAJOR_VERSION, [],
140 {'LIBPBD_VERSION' : LIBPBD_VERSION,
141 'LIBPBD_MAJOR_VERSION' : LIBPBD_MAJOR_VERSION})
143 # Make signals_generated.h using signals.py
144 bld(rule = sys.executable + ' ${SRC} ${TGT}', source = 'pbd/signals.py', target = 'pbd/signals_generated.h')
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' ]
151 obj = bld.stlib(features = 'cxx cxxstlib', source=libpbd_sources)
152 obj.cxxflags = [ '-fPIC' ]
153 obj.cflags = [ '-fPIC' ]
156 if bld.is_defined('DEBUG_RT_ALLOC'):
157 obj.source += 'debug_rt_alloc.c'
159 obj.export_includes = ['.']
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' ]
169 obj.vnum = LIBPBD_LIB_VERSION
170 obj.install_path = bld.env['LIBDIR']
171 obj.defines += [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
173 if sys.platform.startswith('netbsd'):
174 obj.linkflags = '-lexecinfo'
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' ]
185 if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
187 testobj = bld(features = 'cxx cxxprogram')
192 test/scalar_properties.cc
195 test/filesystem_test.cc
197 test/reallocpool_test.cc
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']