ceacc0093851c87dbbaf891f1ea50f73996de671
[dcpomatic.git] / wscript
1 APPNAME = 'dvdomatic'
2 VERSION = '0.26'
3
4 def options(opt):
5     opt.load('compiler_cxx')
6     opt.add_option('--debug-hash', action='store_true', default = False, help = 'print hashes of data at various points')
7     opt.add_option('--enable-debug', action='store_true', default = False, help = 'build with debugging information and without optimisation')
8     opt.add_option('--disable-gui', action='store_true', default = False, help = 'disable building of GUI tools')
9     opt.add_option('--ffmpeg-083', action='store_true', default = False, help = 'Use FFmpeg version in Ubuntu 12.04')
10
11 def configure(conf):
12     conf.load('compiler_cxx')
13
14     conf.env.append_value('CXXFLAGS', ['-D__STDC_CONSTANT_MACROS', '-D__STDC_LIMIT_MACROS', '-msse', '-mfpmath=sse', '-ffast-math', '-Wall'])
15     conf.env.append_value('CXXFLAGS', ['-DDVDOMATIC_VERSION="%s"' % VERSION])
16
17     conf.env.DEBUG_HASH = conf.options.debug_hash
18
19     if conf.options.enable_debug:
20         conf.env.append_value('CXXFLAGS', '-g')
21     else:
22         conf.env.append_value('CXXFLAGS', '-O3')
23
24     if conf.options.ffmpeg_083:
25         conf.env.append_value('CXXFLAGS', '-DDVDOMATIC_FFMPEG_0_8_3')
26
27     conf.env.DISABLE_GUI = conf.options.disable_gui
28
29     conf.check_cfg(package = 'sigc++-2.0', args = '--cflags --libs', uselib_store = 'SIGC++', mandatory = True)
30     conf.check_cfg(package = 'libavformat', args = '--cflags --libs', uselib_store = 'AVFORMAT', mandatory = True)
31     conf.check_cfg(package = 'libavfilter', args = '--cflags --libs', uselib_store = 'AVFILTER', mandatory = True)
32     conf.check_cfg(package = 'libavcodec', args = '--cflags --libs', uselib_store = 'AVCODEC', mandatory = True)
33     conf.check_cfg(package = 'libavutil', args = '--cflags --libs', uselib_store = 'AVUTIL', mandatory = True)
34     conf.check_cfg(package = 'libswscale', args = '--cflags --libs', uselib_store = 'SWSCALE', mandatory = True)
35     conf.check_cfg(package = 'libpostproc', args = '--cflags --libs', uselib_store = 'POSTPROC', mandatory = True)
36     conf.check_cfg(package = 'sndfile', args = '--cflags --libs', uselib_store = 'SNDFILE', mandatory = True)
37     conf.check_cfg(package = 'libdcp', args = '--cflags --libs', uselib_store = 'DCP', mandatory = True)
38     conf.check_cfg(package = '', path = 'Magick++-config', args = '--cppflags --cxxflags --libs', uselib_store = 'MAGICK', mandatory = True)
39     conf.check_cc(msg = 'Checking for library libtiff', function_name = 'TIFFOpen', header_name = 'tiffio.h', lib = 'tiff', uselib_store = 'TIFF')
40     conf.check_cc(fragment  = """
41                               #include <stdio.h>\n
42                               #include <openjpeg.h>\n
43                               int main () {\n
44                               void* p = (void *) opj_image_create;\n
45                               return 0;\n
46                               }
47                               """, msg = 'Checking for library openjpeg', lib = 'openjpeg', uselib_store = 'OPENJPEG')
48
49     conf.check_cc(fragment  = """
50                               #include <libssh/libssh.h>\n
51                               int main () {\n
52                               ssh_session s = ssh_new ();\n
53                               return 0;\n
54                               }
55                               """, msg = 'Checking for library libssh', lib = 'ssh', uselib_store = 'SSH')
56                               
57     conf.check_cxx(fragment = """
58                               #include <boost/thread.hpp>\n
59                               int main() { boost::thread t (); }\n
60                               """, msg = 'Checking for boost threading library', lib = 'boost_thread', uselib_store = 'BOOST_THREAD')
61     conf.check_cxx(fragment = """
62                               #include <boost/filesystem.hpp>\n
63                               int main() { boost::filesystem::copy_file ("a", "b"); }\n
64                               """, msg = 'Checking for boost filesystem library', libpath = '/usr/local/lib', lib = ['boost_filesystem', 'boost_system'], uselib_store = 'BOOST_FILESYSTEM')
65
66     conf.recurse('src')
67     conf.recurse('test')
68
69 def build(bld):
70     bld.recurse('src')
71     bld.recurse('test')
72
73     d = { 'PREFIX' : '${PREFIX' }
74
75     obj = bld(features = 'subst')
76     obj.source = 'dvdomatic.desktop.in'
77     obj.target = 'dvdomatic.desktop'
78     obj.dict = d
79
80     bld.install_files('${PREFIX}/share/applications', 'dvdomatic.desktop')
81     for r in ['22x22', '32x32', '48x48', '64x64', '128x128']:
82         bld.install_files('${PREFIX}/share/icons/hicolor/%s/apps' % r, 'icons/%s/dvdomatic.png' % r)
83
84
85 def dist(ctx):
86     ctx.excl = 'TODO core *~ src/gtk/*~ src/lib/*~ .waf* build .git'