1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
from __future__ import print_function
import subprocess
import shlex
import os
import sys
from waflib import Logs
APPNAME = 'libasdcp-carl'
if os.path.exists('.git'):
this_version = subprocess.Popen(shlex.split('git tag -l --points-at HEAD'), stdout=subprocess.PIPE).communicate()[0].decode('utf-8')
last_version = subprocess.Popen(shlex.split('git describe --tags --abbrev=0'), stdout=subprocess.PIPE).communicate()[0].decode('utf-8')
if this_version == '':
VERSION = '%sdevel' % last_version[1:].strip()
else:
VERSION = this_version[1:].strip()
else:
VERSION = open('VERSION').read().strip()
def options(opt):
opt.load('compiler_cxx')
opt.add_option('--target-windows-64', action='store_true', default=False, help='set up to do a cross-compile to Windows 64-bit')
opt.add_option('--target-windows-32', action='store_true', default=False, help='set up to do a cross-compile to Windows 32-bit')
opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
opt.add_option('--static', action='store_true', default=False, help='build statically')
def configure(conf):
conf.load('compiler_cxx')
conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
conf.env.TARGET_WINDOWS_64 = conf.options.target_windows_64
conf.env.TARGET_WINDOWS_32 = conf.options.target_windows_32
conf.env.TARGET_OSX = sys.platform == 'darwin'
conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS_64 and not conf.env.TARGET_WINDOWS_32 and not conf.env.TARGET_OSX
conf.env.STATIC = conf.options.static
conf.env.VERSION = VERSION
if conf.env.TARGET_OSX:
conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
if conf.env.TARGET_LINUX:
gcc = conf.env['CC_VERSION']
conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-deprecated-copy', '-Wno-class-memaccess'])
conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
if conf.options.target_windows_64:
boost_lib_suffix = '-mt-x64'
elif conf.options.target_windows_32:
boost_lib_suffix = '-mt-x32'
else:
boost_lib_suffix = ''
if conf.options.enable_debug:
conf.env.append_value('CXXFLAGS', '-g')
else:
conf.env.append_value('CXXFLAGS', '-O2')
conf.check_cxx(fragment="""
#include <boost/version.hpp>\n
#if BOOST_VERSION < 104500\n
#error boost too old\n
#endif\n
int main(void) { return 0; }\n
""",
mandatory=True,
msg='Checking for boost library >= 1.45',
okmsg='yes',
errmsg='too old\nPlease install boost version 1.45 or higher.')
conf.check_cxx(fragment="""
#include <boost/filesystem.hpp>\n
int main() { boost::filesystem::copy_file ("a", "b"); }\n
""",
msg='Checking for boost filesystem library',
libpath='/usr/local/lib',
lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
uselib_store='BOOST_FILESYSTEM')
conf.check(header_name='valgrind/memcheck.h', mandatory=False)
conf.recurse('src')
def build(bld):
if bld.env.TARGET_WINDOWS_64:
boost_lib_suffix = '-mt-x64'
flags = '-DKM_WIN32 -DWIN32_LEAN_AND_MEAN'
elif bld.env.TARGET_WINDOWS_32:
boost_lib_suffix = '-mt-x32'
flags = '-DKM_WIN32 -DWIN32_LEAN_AND_MEAN'
else:
boost_lib_suffix = ''
flags = ''
bld(source='libasdcp-carl.pc.in',
version=VERSION,
includedir='%s/include/libasdcp-carl' % bld.env.PREFIX,
libs="-L${libdir} -lasdcp-carl -lkumu-carl -lboost_system%s" % boost_lib_suffix,
cflags=flags,
install_path='${LIBDIR}/pkgconfig')
bld.recurse('src')
bld.add_post_fun(post)
def post(ctx):
if ctx.cmd == 'install':
ctx.exec_command('/sbin/ldconfig')
def tags(bld):
os.system('etags src/*.cc src/*.h')
def dist(bld):
f = open('VERSION', 'w')
print(VERSION, file=f)
f.close()
|