Fix configure on OS X
[dcpomatic.git] / cscript
1 import glob
2 import shutil
3 import os
4
5 def dependencies(target):
6     if target.platform == 'windows':
7         return ()
8     else:
9         return (('openjpeg-cdist', None),
10                 ('ffmpeg-cdist', '7a23ec9c771184ab563cfe24ad9b427f38368961'),
11                 ('libdcp', 'v0.53'))
12
13 def build(env, target):
14     cmd = './waf configure --prefix=%s' % env.work_dir_cscript()
15     if target.platform == 'windows':
16         cmd += ' --target-windows'
17     else if target.platform == 'osx':
18         cmd += ' --osx'
19     else if target.platform == 'linux':
20         cmd += ' --static'
21     env.command(cmd)
22
23     env.command('./waf')
24
25     if target.platform == 'linux' or target.platform == 'osx':
26         env.command('./waf install')
27
28
29 def package(env, target, version):
30     if target.platform == 'windows':
31         shutil.copyfile('build/platform/windows/installer.%s.nsi' % target.bits, 'build/platform/windows/installer2.%s.nsi' % target.bits)
32         env.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
33         env.command('sed -i "s~%%deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (env.windows_prefix, target.bits))
34         env.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
35         env.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % target.bits)
36         env.command('makensis build/platform/windows/installer2.%s.nsi' % target.bits)
37         return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
38     elif target.platform == 'linux':
39         if target.bits == 32:
40             cpu = 'i386'
41         else:
42             cpu = 'amd64'
43
44         shutil.copyfile('platform/linux/control-%s-%d' % (target.version, target.bits), 'debian/control')
45         env.command('./waf dist')
46         f = open('debian/files', 'w')
47         print >>f,'dvdomatic_%s-1_%s.deb video extra' % (version, cpu)
48         shutil.rmtree('build/deb', ignore_errors=True)
49
50         os.makedirs('build/deb')
51         os.chdir('build/deb')
52         shutil.move('../../dvdomatic-%s.tar.bz2' % version, 'dvdomatic_%s.orig.tar.bz2' % version)
53         env.command('tar xjf dvdomatic_%s.orig.tar.bz2' % version)
54         os.chdir('dvdomatic-%s' % version)
55         env.command('dch -b -v %s-1 "New upstream release."' % version)
56         env.set('CDIST_LINKFLAGS', env.get('LINKFLAGS'))
57         env.set('CDIST_CXXFLAGS', env.get('CXXFLAGS'))
58         env.set('CDIST_PKG_CONFIG_PATH', env.get('PKG_CONFIG_PATH'))
59         env.command('dpkg-buildpackage')
60         
61         debs = []
62         for p in glob.glob('../*.deb'):
63             debs.append(os.path.abspath(p))
64
65         return debs
66     elif target.platform == 'osx':
67         env.command('bash platform/osx/make_dmg.sh')
68         return os.path.abspath(glob.glob('build/platform/osx/DVD-o-matic*.dmg')[0])
69
70 def make_pot(env):
71     env.command('./waf pot')
72     return [os.path.abspath('build/src/lib/libdvdomatic.pot'),
73             os.path.abspath('build/src/wx/libdvdomatic-wx.pot'),
74             os.path.abspath('build/src/tools/dvdomatic.pot')]
75
76 def make_manual(env):
77     os.chdir('doc/manual')
78     env.command('make')
79     return [os.path.abspath('pdf'), os.path.abspath('html')]