5 from waflib import Logs
7 APPNAME = 'libasdcp-cth'
11 opt.load('compiler_cxx')
12 opt.add_option('--target-windows', action='store_true', default=False, help='set up to do a cross-compile to Windows')
13 opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
14 opt.add_option('--static', action='store_true', default=False, help='build statically')
17 conf.load('compiler_cxx')
18 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
20 conf.env.TARGET_WINDOWS = conf.options.target_windows
21 conf.env.TARGET_OSX = sys.platform == 'darwin'
22 conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS and not conf.env.TARGET_OSX
23 conf.env.STATIC = conf.options.static
24 conf.env.VERSION = VERSION
26 if conf.env.TARGET_OSX:
27 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
29 if conf.env.TARGET_LINUX:
30 gcc = conf.env['CC_VERSION']
31 if int(gcc[0]) >= 4 and int(gcc[1]) > 1:
32 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result'])
34 conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
36 if conf.options.target_windows:
37 boost_lib_suffix = '-mt'
41 if conf.options.enable_debug:
42 conf.env.append_value('CXXFLAGS', '-g')
44 conf.env.append_value('CXXFLAGS', '-O2')
46 conf.check_cxx(fragment="""
47 #include <boost/version.hpp>\n
48 #if BOOST_VERSION < 104500\n
49 #error boost too old\n
51 int main(void) { return 0; }\n
54 msg='Checking for boost library >= 1.45',
56 errmsg='too old\nPlease install boost version 1.45 or higher.')
58 conf.check_cxx(fragment="""
59 #include <boost/filesystem.hpp>\n
60 int main() { boost::filesystem::copy_file ("a", "b"); }\n
62 msg='Checking for boost filesystem library',
63 libpath='/usr/local/lib',
64 lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
65 uselib_store='BOOST_FILESYSTEM')
70 if bld.env.TARGET_WINDOWS:
71 boost_lib_suffix = '-mt'
77 bld(source='libasdcp-cth.pc.in',
79 includedir='%s/include/libasdcp-cth' % bld.env.PREFIX,
80 libs="-L${libdir} -lasdcp-cth -lkumu-cth -lboost_system%s" % boost_lib_suffix,
82 install_path='${LIBDIR}/pkgconfig')
86 bld.add_post_fun(post)
89 if ctx.cmd == 'install':
90 ctx.exec_command('/sbin/ldconfig')
93 os.system('etags src/*.cc src/*.h')