6 from waflib import Logs
8 APPNAME = 'libasdcp-cth'
10 if os.path.exists('.git'):
11 this_version = subprocess.Popen(shlex.split('git tag -l --points-at HEAD'), stdout=subprocess.PIPE).communicate()[0]
12 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()
18 VERSION = open('VERSION').read().strip()
21 opt.load('compiler_cxx')
22 opt.add_option('--target-windows', action='store_true', default=False, help='set up to do a cross-compile to Windows')
23 opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
24 opt.add_option('--static', action='store_true', default=False, help='build statically')
27 conf.load('compiler_cxx')
28 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
30 conf.env.TARGET_WINDOWS = conf.options.target_windows
31 conf.env.TARGET_OSX = sys.platform == 'darwin'
32 conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS and not conf.env.TARGET_OSX
33 conf.env.STATIC = conf.options.static
34 conf.env.VERSION = VERSION
36 if conf.env.TARGET_OSX:
37 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
39 if conf.env.TARGET_LINUX:
40 gcc = conf.env['CC_VERSION']
41 if int(gcc[0]) >= 4 and int(gcc[1]) > 1:
42 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result'])
44 conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
46 if conf.options.target_windows:
47 boost_lib_suffix = '-mt'
51 if conf.options.enable_debug:
52 conf.env.append_value('CXXFLAGS', '-g')
54 conf.env.append_value('CXXFLAGS', '-O2')
56 conf.check_cxx(fragment="""
57 #include <boost/version.hpp>\n
58 #if BOOST_VERSION < 104500\n
59 #error boost too old\n
61 int main(void) { return 0; }\n
64 msg='Checking for boost library >= 1.45',
66 errmsg='too old\nPlease install boost version 1.45 or higher.')
68 conf.check_cxx(fragment="""
69 #include <boost/filesystem.hpp>\n
70 int main() { boost::filesystem::copy_file ("a", "b"); }\n
72 msg='Checking for boost filesystem library',
73 libpath='/usr/local/lib',
74 lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
75 uselib_store='BOOST_FILESYSTEM')
77 conf.check(header_name='valgrind/memcheck.h', mandatory=False)
82 if bld.env.TARGET_WINDOWS:
83 boost_lib_suffix = '-mt'
89 bld(source='libasdcp-cth.pc.in',
91 includedir='%s/include/libasdcp-cth' % bld.env.PREFIX,
92 libs="-L${libdir} -lasdcp-cth -lkumu-cth -lboost_system%s" % boost_lib_suffix,
94 install_path='${LIBDIR}/pkgconfig')
98 bld.add_post_fun(post)
101 if ctx.cmd == 'install':
102 ctx.exec_command('/sbin/ldconfig')
105 os.system('etags src/*.cc src/*.h')
108 f = open('VERSION', 'w')