1 from __future__ import print_function
8 from waflib import Logs
10 APPNAME = 'libasdcp-carl'
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.STATIC = conf.options.static
35 conf.env.VERSION = VERSION
37 if conf.env.TARGET_OSX:
38 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
40 conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
42 if conf.options.target_windows:
43 boost_lib_suffix = '-mt'
47 if conf.options.enable_debug:
48 conf.env.append_value('CXXFLAGS', '-g')
50 conf.env.append_value('CXXFLAGS', '-O2')
52 conf.check_cxx(fragment="""
53 #include <boost/version.hpp>\n
54 #if BOOST_VERSION < 104500\n
55 #error boost too old\n
57 int main(void) { return 0; }\n
60 msg='Checking for boost library >= 1.45',
62 errmsg='too old\nPlease install boost version 1.45 or higher.')
64 conf.check_cxx(fragment="""
65 #include <boost/filesystem.hpp>\n
66 int main() { boost::filesystem::copy_file ("a", "b"); }\n
68 msg='Checking for boost filesystem library',
69 libpath='/usr/local/lib',
70 lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
71 uselib_store='BOOST_FILESYSTEM')
76 if bld.env.TARGET_WINDOWS:
77 boost_lib_suffix = '-mt'
78 flags = '-DKM_WIN32 -DWIN32_LEAN_AND_MEAN'
83 bld(source='libasdcp-carl.pc.in',
85 includedir='%s/include/libasdcp-carl' % bld.env.PREFIX,
86 libs="-L${libdir} -lasdcp-carl -lkumu-carl -lboost_system%s" % boost_lib_suffix,
88 install_path='${LIBDIR}/pkgconfig')
92 bld.add_post_fun(post)
95 if ctx.cmd == 'install':
96 ctx.exec_command('/sbin/ldconfig')
99 os.system('etags src/*.cc src/*.h')
102 f = open('VERSION', 'w')
103 print(VERSION, file=f)