1 from __future__ import print_function
8 from waflib import Logs
10 APPNAME = 'libasdcp-cth'
12 if os.path.exists('.git'):
13 this_version = subprocess.Popen(shlex.split('git tag -l --points-at HEAD'), stdout=subprocess.PIPE).communicate()[0].decode('utf-8')
14 last_version = subprocess.Popen(shlex.split('git describe --tags --abbrev=0'), stdout=subprocess.PIPE).communicate()[0]
15 if this_version == '':
16 VERSION = '%sdevel' % last_version[1:].strip()
18 VERSION = this_version[1:].strip()
20 VERSION = open('VERSION').read().strip()
23 opt.load('compiler_cxx')
24 opt.add_option('--target-windows', action='store_true', default=False, help='set up to do a cross-compile to Windows')
25 opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
26 opt.add_option('--static', action='store_true', default=False, help='build statically')
29 conf.load('compiler_cxx')
30 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
32 conf.env.TARGET_WINDOWS = conf.options.target_windows
33 conf.env.TARGET_OSX = sys.platform == 'darwin'
34 conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS and not conf.env.TARGET_OSX
35 conf.env.STATIC = conf.options.static
36 conf.env.VERSION = VERSION
38 if conf.env.TARGET_OSX:
39 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
41 if conf.env.TARGET_LINUX:
42 gcc = conf.env['CC_VERSION']
43 if int(gcc[0]) >= 4 and int(gcc[1]) > 1:
44 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result'])
46 conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
48 if conf.options.target_windows:
49 boost_lib_suffix = '-mt'
53 if conf.options.enable_debug:
54 conf.env.append_value('CXXFLAGS', '-g')
56 conf.env.append_value('CXXFLAGS', '-O2')
58 conf.check_cxx(fragment="""
59 #include <boost/version.hpp>\n
60 #if BOOST_VERSION < 104500\n
61 #error boost too old\n
63 int main(void) { return 0; }\n
66 msg='Checking for boost library >= 1.45',
68 errmsg='too old\nPlease install boost version 1.45 or higher.')
70 conf.check_cxx(fragment="""
71 #include <boost/filesystem.hpp>\n
72 int main() { boost::filesystem::copy_file ("a", "b"); }\n
74 msg='Checking for boost filesystem library',
75 libpath='/usr/local/lib',
76 lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
77 uselib_store='BOOST_FILESYSTEM')
79 conf.check(header_name='valgrind/memcheck.h', mandatory=False)
84 if bld.env.TARGET_WINDOWS:
85 boost_lib_suffix = '-mt'
91 bld(source='libasdcp-cth.pc.in',
93 includedir='%s/include/libasdcp-cth' % bld.env.PREFIX,
94 libs="-L${libdir} -lasdcp-cth -lkumu-cth -lboost_system%s" % boost_lib_suffix,
96 install_path='${LIBDIR}/pkgconfig')
100 bld.add_post_fun(post)
103 if ctx.cmd == 'install':
104 ctx.exec_command('/sbin/ldconfig')
107 os.system('etags src/*.cc src/*.h')
110 f = open('VERSION', 'w')
111 print(VERSION, file=f)