Hopefully fix include paths.
[vapoursynth-svn.git] / wscript
blobd9fb1b7fac24d1015f860870c373a596113bcb8f
1 #!/usr/bin/env python
3 import os
4 from waflib import Utils
6 APPNAME = 'VapourSynth'
7 VERSION = '8'
9 TOP = os.curdir
10 OUT = 'build'
12 def options(opt):
13 opt.load('compiler_c')
14 opt.load('compiler_cxx')
15 opt.load('qt4')
17 opt.add_option('--mode', action = 'store', default = 'debug', help = 'the mode to compile in (debug/release)')
18 opt.add_option('--static', action = 'store', default = 'false', help = 'build a static library (true/false)')
20 def configure(conf):
21 def add_options(flags, options):
22 for flag in flags:
23 for option in options:
24 if option not in conf.env[flag]:
25 conf.env.append_value(flag, option)
27 conf.load('compiler_c')
28 conf.load('compiler_cxx')
29 conf.load('qt4')
31 # Load Yasm explicitly, then the Nasm module which
32 # supports both Nasm and Yasm.
33 conf.find_program('yasm', var = 'AS', mandatory = True)
34 conf.load('nasm')
36 if conf.env.DEST_OS == 'darwin':
37 if conf.env.CXX_NAME == 'gcc':
38 add_options(['ASFLAGS'],
39 ['-DPREFIX'])
41 if conf.env.CXX_NAME == 'gcc':
42 add_options(['CFLAGS', 'CXXFLAGS'],
43 ['-DVSCORE_EXPORTS',
44 '-fPIC'])
45 elif conf.env.CXX_NAME == 'msvc':
46 add_options(['CFLAGS', 'CXXFLAGS'],
47 ['/DVSCORE_EXPORTS',
48 '/EHsc',
49 '/Zc:wchar_t-'])
51 add_options(['ASFLAGS'],
52 ['-w',
53 '-Worphan-labels',
54 '-Wunrecognized-char'])
56 if conf.env.DEST_CPU in ['x86_64', 'amd64', 'x64']:
57 add_options(['ASFLAGS'],
58 ['-DARCH_X86_64=1'])
60 if conf.env.DEST_OS == 'darwin':
61 fmt = 'macho64'
62 elif conf.env.DEST_OS == 'win32':
63 fmt = 'win64'
64 else:
65 fmt = 'elf64'
66 else:
67 add_options(['ASFLAGS'],
68 ['-DARCH_X86_64=0'])
70 if conf.env.DEST_OS == 'darwin':
71 fmt = 'macho32'
72 elif conf.env.DEST_OS == 'win32':
73 fmt = 'win32'
74 else:
75 fmt = 'elf32'
77 add_options(['ASFLAGS'],
78 ['-f{0}'.format(fmt)])
80 if conf.options.mode == 'debug':
81 if conf.env.CXX_NAME == 'gcc':
82 add_options(['CFLAGS', 'CXXFLAGS'],
83 ['-DVSCORE_DEBUG',
84 '-g',
85 '-ggdb',
86 '-ftrapv'])
87 elif conf.env.CXX_NAME == 'msvc':
88 add_options(['CFLAGS', 'CXXFLAGS'],
89 ['/DVSCORE_DEBUG',
90 '/Z7'])
92 add_options(['ASFLAGS'],
93 ['-DVSCORE_DEBUG'])
94 elif conf.options.mode == 'release':
95 if conf.env.CXX_NAME == 'gcc':
96 add_options(['CFLAGS', 'CXXFLAGS'],
97 ['-O3'])
98 elif conf.env.CXX_NAME == 'msvc':
99 add_options(['CFLAGS', 'CXXFLAGS'],
100 ['/Ox'])
101 else:
102 conf.fatal('--mode must be either debug or release.')
104 # Waf always uses gcc/g++ for linking when using a GCC
105 # compatible C/C++ compiler.
106 if conf.env.CXX_NAME == 'gcc':
107 add_options(['LINKFLAGS_cxxshlib', 'LINKFLAGS_cxxprogram'],
108 ['-Wl,-Bsymbolic'])
110 conf.env.STATIC = conf.options.static
112 if not conf.env.STATIC in ['true', 'false']:
113 conf.fatal('--static must be either true or false.')
115 conf.check_cxx(lib = 'QtCore', features = 'cxx cxxprogram')
116 conf.check_cxx(lib = 'avutil', features = 'cxx cxxprogram')
117 conf.check_cxx(lib = 'swscale', features = 'cxx cxxprogram')
119 def build(bld):
120 def search_paths(paths):
121 srcpaths = []
123 for path in paths:
124 srcpaths += [os.path.join(path, '*.c'),
125 os.path.join(path, '*.cpp'),
126 os.path.join(path, '*.asm')]
128 return srcpaths
130 sources = search_paths([os.path.join('src', 'core'),
131 os.path.join('src', 'core', 'asm')])
133 if bld.env.DEST_OS == 'win32':
134 sources += search_paths([os.path.join('src', 'avisynth')])
136 bld(features = 'c qxx asm',
137 includes = 'include',
138 source = bld.path.ant_glob(sources),
139 target = 'objs')
141 bld(features = 'c qxx asm cxxshlib',
142 use = 'objs qtcore avutil swscale',
143 target = 'vapoursynth')
145 if bld.env.STATIC == 'true':
146 bld(features = 'c qxx asm cxxstlib',
147 use = 'objs qtcore avutil swscale',
148 target = 'vapoursynth')