6 from waflib import Logs
8 APPNAME = 'libasdcp-cth'
10 this_version = subprocess.Popen(shlex.split('git tag -l --points-at HEAD'), stdout=subprocess.PIPE).communicate()[0]
11 last_version = subprocess.Popen(shlex.split('git describe --tags --abbrev=0'), stdout=subprocess.PIPE).communicate()[0]
13 if this_version == '':
14 VERSION = '%sdevel' % last_version[1:].strip()
16 VERSION = this_version[1:].strip()
19 opt.load('compiler_cxx')
20 opt.add_option('--target-windows', action='store_true', default=False, help='set up to do a cross-compile to Windows')
21 opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
22 opt.add_option('--static', action='store_true', default=False, help='build statically')
25 conf.load('compiler_cxx')
26 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
28 conf.env.TARGET_WINDOWS = conf.options.target_windows
29 conf.env.TARGET_OSX = sys.platform == 'darwin'
30 conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS and not conf.env.TARGET_OSX
31 conf.env.STATIC = conf.options.static
32 conf.env.VERSION = VERSION
34 if conf.env.TARGET_OSX:
35 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
37 if conf.env.TARGET_LINUX:
38 gcc = conf.env['CC_VERSION']
39 if int(gcc[0]) >= 4 and int(gcc[1]) > 1:
40 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result'])
42 conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
44 if conf.options.target_windows:
45 boost_lib_suffix = '-mt'
49 if conf.options.enable_debug:
50 conf.env.append_value('CXXFLAGS', '-g')
52 conf.env.append_value('CXXFLAGS', '-O2')
54 conf.check_cxx(fragment="""
55 #include <boost/version.hpp>\n
56 #if BOOST_VERSION < 104500\n
57 #error boost too old\n
59 int main(void) { return 0; }\n
62 msg='Checking for boost library >= 1.45',
64 errmsg='too old\nPlease install boost version 1.45 or higher.')
66 conf.check_cxx(fragment="""
67 #include <boost/filesystem.hpp>\n
68 int main() { boost::filesystem::copy_file ("a", "b"); }\n
70 msg='Checking for boost filesystem library',
71 libpath='/usr/local/lib',
72 lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
73 uselib_store='BOOST_FILESYSTEM')
75 conf.check(header_name='valgrind/memcheck.h', mandatory=False)
80 if bld.env.TARGET_WINDOWS:
81 boost_lib_suffix = '-mt'
87 bld(source='libasdcp-cth.pc.in',
89 includedir='%s/include/libasdcp-cth' % bld.env.PREFIX,
90 libs="-L${libdir} -lasdcp-cth -lkumu-cth -lboost_system%s" % boost_lib_suffix,
92 install_path='${LIBDIR}/pkgconfig')
96 bld.add_post_fun(post)
99 if ctx.cmd == 'install':
100 ctx.exec_command('/sbin/ldconfig')
103 os.system('etags src/*.cc src/*.h')