summaryrefslogtreecommitdiff
path: root/wscript
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-03-16 21:01:00 +0100
committerCarl Hetherington <cth@carlh.net>2024-03-21 20:25:17 +0100
commit98c19786875a24786f2e0ecb3a54e1711bdcd307 (patch)
treef97dadc7d1f2270fead5da68c8c9c84a2a171be8 /wscript
parent029917a06659f4fa313e41f7bc77b4273166609d (diff)
Add waf build system.
Diffstat (limited to 'wscript')
-rw-r--r--wscript87
1 files changed, 87 insertions, 0 deletions
diff --git a/wscript b/wscript
new file mode 100644
index 0000000..d0eadf4
--- /dev/null
+++ b/wscript
@@ -0,0 +1,87 @@
+from __future__ import print_function
+
+import subprocess
+import shlex
+import os
+import sys
+import distutils.spawn
+from waflib import Logs
+
+APPNAME = 'libasdcp-dcpomatic'
+
+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.enable_debug:
+ conf.env.append_value('CXXFLAGS', '-g')
+ else:
+ conf.env.append_value('CXXFLAGS', '-O2')
+
+ conf.check(header_name='valgrind/memcheck.h', mandatory=False)
+
+ conf.recurse('src')
+
+def build(bld):
+ if bld.env.TARGET_WINDOWS_64:
+ flags = '-DKM_WIN32 -DWIN32_LEAN_AND_MEAN -DKM_WIN32_UTF8'
+ elif bld.env.TARGET_WINDOWS_32:
+ flags = '-DKM_WIN32 -DWIN32_LEAN_AND_MEAN -DKM_WIN32_UTF8'
+ else:
+ flags = ''
+
+ bld(source='libasdcp-dcpomatic.pc.in',
+ version=VERSION,
+ includedir='%s/include/libasdcp-dcpomatic' % bld.env.PREFIX,
+ libs="-L${libdir} -lasdcp-dcpomatic -lkumu-dcpomatic",
+ 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()