5 VERSION = '0.98.0devel'
8 opt.load('compiler_cxx')
9 opt.add_option('--target-windows', action='store_true', default=False, help='set up to do a cross-compile to Windows')
10 opt.add_option('--osx', action='store_true', default=False, help='set up to build on OS X')
11 opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
12 opt.add_option('--static', action='store_true', default=False, help='build libdcp and in-tree dependencies statically, and link statically to openjpeg and cxml')
13 opt.add_option('--valgrind', action='store_true', default=False, help='build with instructions to Valgrind to reduce false positives')
14 opt.add_option('--disable-tests', action='store_true', default=False, help='disable building of tests')
17 conf.load('compiler_cxx')
18 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
19 conf.env.append_value('CXXFLAGS', ['-DLIBDCP_VERSION="%s"' % VERSION])
21 conf.env.TARGET_WINDOWS = conf.options.target_windows
22 conf.env.STATIC = conf.options.static
23 conf.env.OSX = conf.options.osx
24 conf.env.ENABLE_DEBUG = conf.options.enable_debug
25 conf.env.DISABLE_TESTS = conf.options.disable_tests
27 if conf.options.target_windows:
28 conf.env.append_value('CXXFLAGS', '-DLIBDCP_WINDOWS')
30 conf.env.append_value('CXXFLAGS', '-DLIBDCP_POSIX')
32 if conf.options.valgrind:
33 conf.env.append_value('CXXFLAGS', '-DLIBDCP_VALGRIND')
35 if not conf.options.osx:
36 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter'])
38 conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
39 conf.check_cfg(package='libxml++-2.6', args='--cflags --libs', uselib_store='LIBXML++', mandatory=True)
40 conf.check_cfg(package='xmlsec1', args='--cflags --libs', uselib_store='XMLSEC1', mandatory=True)
41 # Remove erroneous escaping of quotes from xmlsec1 defines
42 conf.env.DEFINES_XMLSEC1 = [f.replace('\\', '') for f in conf.env.DEFINES_XMLSEC1]
44 if conf.options.static:
45 conf.check_cc(fragment="""
47 #include <openjpeg.h>\n
49 void* p = (void *) opj_image_create;\n
53 msg='Checking for library openjpeg', stlib='openjpeg', uselib_store='OPENJPEG', mandatory=True)
55 conf.env.HAVE_CXML = 1
56 conf.env.STLIB_CXML = ['cxml']
58 conf.check_cfg(package='libopenjpeg', args='--cflags --libs', uselib_store='OPENJPEG', mandatory=True)
59 conf.check_cfg(package='libcxml', atleast_version='0.11.0', args='--cflags --libs', uselib_store='CXML', mandatory=True)
61 if conf.options.target_windows:
62 boost_lib_suffix = '-mt'
66 if conf.options.enable_debug:
67 conf.env.append_value('CXXFLAGS', '-g')
69 # Somewhat experimental use of -O2 rather than -O3 to see if
70 # Windows builds are any more reliable
71 conf.env.append_value('CXXFLAGS', '-O2')
73 conf.check_cxx(fragment="""
74 #include <boost/version.hpp>\n
75 #if BOOST_VERSION < 104500\n
76 #error boost too old\n
78 int main(void) { return 0; }\n
81 msg='Checking for boost library >= 1.45',
83 errmsg='too old\nPlease install boost version 1.45 or higher.')
85 conf.check_cxx(fragment="""
86 #include <boost/filesystem.hpp>\n
87 int main() { boost::filesystem::copy_file ("a", "b"); }\n
89 msg='Checking for boost filesystem library',
90 libpath='/usr/local/lib',
91 lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
92 uselib_store='BOOST_FILESYSTEM')
94 conf.check_cxx(fragment="""
95 #include <boost/signals2.hpp>\n
96 int main() { boost::signals2::signal<void (int)> x; }\n
98 msg='Checking for boost signals2 library',
99 uselib_store='BOOST_SIGNALS2')
101 conf.check_cxx(fragment="""
102 #include <boost/date_time.hpp>\n
103 int main() { boost::gregorian::day_clock::local_day(); }\n
105 msg='Checking for boost datetime library',
106 libpath='/usr/local/lib',
107 lib=['boost_date_time%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
108 uselib_store='BOOST_DATETIME')
110 if not conf.env.DISABLE_TESTS:
112 conf.recurse('asdcplib')
115 create_version_cc(bld, VERSION)
117 if bld.env.TARGET_WINDOWS:
118 boost_lib_suffix = '-mt'
120 boost_lib_suffix = ''
122 bld(source='libdcp.pc.in',
124 includedir='%s/include' % bld.env.PREFIX,
125 libs="-L${libdir} -ldcp -lasdcp-libdcp -lkumu-libdcp -lcxml -lboost_system%s" % boost_lib_suffix,
126 install_path='${LIBDIR}/pkgconfig')
130 if not bld.env.DISABLE_TESTS:
132 bld.recurse('asdcplib')
133 bld.recurse('examples')
135 bld.add_post_fun(post)
138 ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~ __pycache__ GPATH GRTAGS GSYMS GTAGS'
140 def create_version_cc(bld, version):
141 if os.path.exists('.git'):
142 cmd = "LANG= git log --abbrev HEAD^..HEAD ."
143 output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
144 o = output[0].decode('utf-8')
145 commit = o.replace ("commit ", "")[0:10]
150 text = '#include "version.h"\n'
151 text += 'char const * libdcp::git_commit = \"%s\";\n' % commit
152 text += 'char const * libdcp::version = \"%s\";\n' % version
153 if bld.env.ENABLE_DEBUG:
154 debug_string = 'true'
156 debug_string = 'false'
157 text += 'bool const built_with_debug = %s;\n' % debug_string
158 print('Writing version information to src/version.cc')
159 o = open('src/version.cc', 'w')
163 print('Could not open src/version.cc for writing\n')
167 if ctx.cmd == 'install':
168 ctx.exec_command('/sbin/ldconfig')