Move things round a bit.
[dcpomatic.git] / wscript
1 APPNAME = 'dvdomatic'
2 VERSION = '0.26pre'
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
10 def configure(conf):
11     conf.load('compiler_cxx')
12
13     conf.env.append_value('CXXFLAGS', ['-D__STDC_CONSTANT_MACROS', '-D__STDC_LIMIT_MACROS', '-msse', '-mfpmath=sse', '-ffast-math', '-Wall'])
14     conf.env.append_value('CXXFLAGS', ['-DDVDOMATIC_VERSION="%s"' % VERSION])
15
16     conf.env.DEBUG_HASH = conf.options.debug_hash
17     if conf.options.debug_hash:
18         conf.env.append_value('CXXFLAGS', '-DDEBUG_HASH')
19         conf.check_cc(msg = 'Checking for library libmhash', function_name = 'mhash_init', header_name = 'mhash.h', lib = 'mhash', uselib_store = 'MHASH')
20
21     if conf.options.enable_debug:
22         conf.env.append_value('CXXFLAGS', '-g')
23     else:
24         conf.env.append_value('CXXFLAGS', '-O3')
25
26     conf.env.DISABLE_GUI = conf.options.disable_gui
27     if conf.options.disable_gui is False:
28         conf.check_cfg(package = 'glib-2.0', args = '--cflags --libs', uselib_store = 'GLIB', mandatory = True)
29         conf.check_cfg(package = 'gtkmm-2.4', args = '--cflags --libs', uselib_store = 'GTKMM', mandatory = True)
30         conf.check_cfg(package = 'cairomm-1.0', args = '--cflags --libs', uselib_store = 'CAIROMM', mandatory = True)
31
32     conf.check_cfg(package = 'sigc++-2.0', args = '--cflags --libs', uselib_store = 'SIGC++', mandatory = True)
33     conf.check_cfg(package = 'libavformat', args = '--cflags --libs', uselib_store = 'AVFORMAT', mandatory = True)
34     conf.check_cfg(package = 'libavfilter', args = '--cflags --libs', uselib_store = 'AVFILTER', mandatory = True)
35     conf.check_cfg(package = 'libavcodec', args = '--cflags --libs', uselib_store = 'AVCODEC', mandatory = True)
36     conf.check_cfg(package = 'libavutil', args = '--cflags --libs', uselib_store = 'AVUTIL', mandatory = True)
37     conf.check_cfg(package = 'libswscale', args = '--cflags --libs', uselib_store = 'SWSCALE', mandatory = True)
38     conf.check_cfg(package = 'libswresample', args = '--cflags --libs', uselib_store = 'SWRESAMPLE', mandatory = True)
39     conf.check_cfg(package = 'libpostproc', args = '--cflags --libs', uselib_store = 'POSTPROC', mandatory = True)
40     conf.check_cfg(package = 'sndfile', args = '--cflags --libs', uselib_store = 'SNDFILE', mandatory = True)
41     conf.check_cfg(package = '', path = 'Magick++-config', args = '--cppflags --cxxflags --libs', uselib_store = 'MAGICK', mandatory = True)
42     conf.check_cc(msg = 'Checking for library libtiff', function_name = 'TIFFOpen', header_name = 'tiffio.h', lib = 'tiff', uselib_store = 'TIFF')
43     conf.check_cc(fragment  = """
44                               #include <stdio.h>\n
45                               #include <openjpeg.h>\n
46                               int main () {\n
47                               void* p = (void *) opj_image_create;\n
48                               return 0;\n
49                               }
50                               """, msg = 'Checking for library openjpeg', lib = 'openjpeg', uselib_store = 'OPENJPEG')
51
52     conf.check_cc(fragment  = """
53                               #include <libssh/libssh.h>\n
54                               int main () {\n
55                               ssh_session s = ssh_new ();\n
56                               return 0;\n
57                               }
58                               """, msg = 'Checking for library libssh', lib = 'ssh', uselib_store = 'SSH')
59                               
60     conf.check_cxx(fragment = """
61                               #include <boost/thread.hpp>\n
62                               int main() { boost::thread t (); }\n
63                               """, msg = 'Checking for boost threading library', lib = 'boost_thread', uselib_store = 'BOOST_THREAD')
64     conf.check_cxx(fragment = """
65                               #include <boost/filesystem.hpp>\n
66                               int main() { boost::filesystem::copy_file ("a", "b"); }\n
67                               """, msg = 'Checking for boost filesystem library', libpath = '/usr/local/lib', lib = ['boost_filesystem', 'boost_system'], uselib_store = 'BOOST_FILESYSTEM')
68     conf.check_cxx(fragment = """
69                               #define BOOST_TEST_MODULE Config test\n
70                               #include <boost/test/unit_test.hpp>\n
71                               int main() {}
72                               """, msg = 'Checking for boost unit testing library', lib = 'boost_unit_test_framework', uselib_store = 'BOOST_TEST')
73
74 def build(bld):
75     bld.recurse('src')
76     bld.recurse('test')
77
78     d = { 'PREFIX' : '${PREFIX' }
79
80     obj = bld(features = 'subst')
81     obj.source = 'dvdomatic.desktop.in'
82     obj.target = 'dvdomatic.desktop'
83     obj.dict = d
84
85     bld.install_files('${PREFIX}/share/applications', 'dvdomatic.desktop')
86     for r in ['22x22', '32x32', '48x48', '64x64', '128x128']:
87         bld.install_files('${PREFIX}/share/icons/hicolor/%s/apps' % r, 'icons/%s/dvdomatic.png' % r)
88
89
90 def dist(ctx):
91     ctx.excl = 'TODO core *~ src/gtk/*~ src/lib/*~ .waf* build'