xref: /aosp_15_r20/external/libdav1d/meson.build (revision c09093415860a1c2373dacd84c4fde00c507cdfd)
1# Copyright © 2018-2024, VideoLAN and dav1d authors
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice, this
8#    list of conditions and the following disclaimer.
9#
10# 2. Redistributions in binary form must reproduce the above copyright notice,
11#    this list of conditions and the following disclaimer in the documentation
12#    and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25project('dav1d', ['c'],
26    version: '1.5.0',
27    default_options: ['c_std=c99',
28                      'warning_level=2',
29                      'buildtype=release',
30                      'b_ndebug=if-release'],
31    meson_version: '>= 0.49.0')
32
33dav1d_src_root = meson.current_source_dir()
34cc = meson.get_compiler('c')
35
36# Configuratin data for config.h
37cdata = configuration_data()
38
39# Configuration data for config.asm
40cdata_asm = configuration_data()
41
42# Include directories
43dav1d_inc_dirs = include_directories(['.', 'include/dav1d', 'include'])
44
45dav1d_api_version_major    = cc.get_define('DAV1D_API_VERSION_MAJOR',
46                                           prefix: '#include "dav1d/version.h"',
47                                           include_directories: dav1d_inc_dirs).strip()
48dav1d_api_version_minor    = cc.get_define('DAV1D_API_VERSION_MINOR',
49                                           prefix: '#include "dav1d/version.h"',
50                                           include_directories: dav1d_inc_dirs).strip()
51dav1d_api_version_revision = cc.get_define('DAV1D_API_VERSION_PATCH',
52                                           prefix: '#include "dav1d/version.h"',
53                                           include_directories: dav1d_inc_dirs).strip()
54dav1d_soname_version       = '@0@.@1@.@2@'.format(dav1d_api_version_major,
55                                                  dav1d_api_version_minor,
56                                                  dav1d_api_version_revision)
57
58#
59# Option handling
60#
61
62# Bitdepth option
63dav1d_bitdepths = get_option('bitdepths')
64foreach bitdepth : ['8', '16']
65    cdata.set10('CONFIG_@0@BPC'.format(bitdepth), dav1d_bitdepths.contains(bitdepth))
66endforeach
67
68# ASM option
69is_asm_enabled = (get_option('enable_asm') == true and
70    (host_machine.cpu_family() == 'aarch64' or
71     host_machine.cpu_family().startswith('arm') or
72     host_machine.cpu() == 'ppc64le' or
73     host_machine.cpu_family().startswith('riscv') or
74     host_machine.cpu_family().startswith('loongarch') or
75     host_machine.cpu_family() == 'x86' or
76     (host_machine.cpu_family() == 'x86_64' and cc.get_define('__ILP32__').strip() == '')))
77cdata.set10('HAVE_ASM', is_asm_enabled)
78
79if is_asm_enabled and get_option('b_sanitize') == 'memory'
80    error('asm causes false positive with memory sanitizer. Use \'-Denable_asm=false\'.')
81endif
82
83cdata.set10('TRIM_DSP_FUNCTIONS', get_option('trim_dsp') == 'true' or
84    (get_option('trim_dsp') == 'if-release' and get_option('buildtype') == 'release'))
85
86# Logging option
87cdata.set10('CONFIG_LOG', get_option('logging'))
88
89cdata.set10('CONFIG_MACOS_KPERF', get_option('macos_kperf'))
90
91#
92# OS/Compiler checks and defines
93#
94
95# Arguments in test_args will be used even on feature tests
96test_args = []
97
98optional_arguments = []
99optional_link_arguments = []
100
101if host_machine.system() in ['linux', 'gnu', 'emscripten']
102    test_args += '-D_GNU_SOURCE'
103    add_project_arguments('-D_GNU_SOURCE', language: 'c')
104endif
105
106have_clock_gettime = false
107have_posix_memalign = false
108have_memalign = false
109have_aligned_alloc = false
110if host_machine.system() == 'windows'
111    cdata.set('_WIN32_WINNT',           '0x0601')
112    cdata.set('UNICODE',                1) # Define to 1 for Unicode (Wide Chars) APIs
113    cdata.set('_UNICODE',               1) # Define to 1 for Unicode (Wide Chars) APIs
114    cdata.set('__USE_MINGW_ANSI_STDIO', 1) # Define to force use of MinGW printf
115    cdata.set('_CRT_DECLARE_NONSTDC_NAMES', 1) # Define to get off_t from sys/types.h on MSVC
116    if cc.has_function('fseeko', prefix : '#include <stdio.h>', args : test_args)
117        cdata.set('_FILE_OFFSET_BITS', 64) # Not set by default by Meson on Windows
118    else
119        cdata.set('fseeko', '_fseeki64')
120        cdata.set('ftello', '_ftelli64')
121    endif
122
123    if host_machine.cpu_family() == 'x86_64'
124        if cc.get_argument_syntax() != 'msvc'
125            optional_link_arguments += '-Wl,--dynamicbase,--nxcompat,--tsaware,--high-entropy-va'
126        endif
127    elif host_machine.cpu_family() == 'x86' or host_machine.cpu_family() == 'arm'
128        if cc.get_argument_syntax() == 'msvc'
129            optional_link_arguments += '/largeaddressaware'
130        else
131            optional_link_arguments += '-Wl,--dynamicbase,--nxcompat,--tsaware,--large-address-aware'
132        endif
133    endif
134
135    # On Windows, we use a compatibility layer to emulate pthread
136    thread_dependency = []
137    thread_compat_dep = declare_dependency(sources : files('src/win32/thread.c'))
138
139    rt_dependency = []
140
141    rc_version_array = meson.project_version().split('.')
142    winmod = import('windows')
143    rc_data = configuration_data()
144    rc_data.set('PROJECT_VERSION_MAJOR', rc_version_array[0])
145    rc_data.set('PROJECT_VERSION_MINOR', rc_version_array[1])
146    rc_data.set('PROJECT_VERSION_REVISION', rc_version_array[2])
147    rc_data.set('API_VERSION_MAJOR', dav1d_api_version_major)
148    rc_data.set('API_VERSION_MINOR', dav1d_api_version_minor)
149    rc_data.set('API_VERSION_REVISION', dav1d_api_version_revision)
150    rc_data.set('COPYRIGHT_YEARS', '2018-2024')
151else
152    thread_dependency = dependency('threads')
153    thread_compat_dep = []
154
155    rt_dependency = []
156    if cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args)
157        have_clock_gettime = true
158    elif host_machine.system() not in ['darwin', 'ios', 'tvos']
159        rt_dependency = cc.find_library('rt', required: false)
160        if not cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args, dependencies : rt_dependency)
161            error('clock_gettime not found')
162        endif
163        have_clock_gettime = true
164    endif
165
166    have_posix_memalign = cc.has_function('posix_memalign', prefix : '#include <stdlib.h>', args : test_args)
167    have_memalign = cc.has_function('memalign', prefix : '#include <malloc.h>', args : test_args)
168    have_aligned_alloc = cc.has_function('aligned_alloc', prefix : '#include <stdlib.h>', args : test_args)
169endif
170
171cdata.set10('HAVE_CLOCK_GETTIME', have_clock_gettime)
172cdata.set10('HAVE_POSIX_MEMALIGN', have_posix_memalign)
173cdata.set10('HAVE_MEMALIGN', have_memalign)
174cdata.set10('HAVE_ALIGNED_ALLOC', have_aligned_alloc)
175
176# check for fseeko on android. It is not always available if _FILE_OFFSET_BITS is defined to 64
177have_fseeko = true
178if host_machine.system() == 'android'
179    if not cc.has_function('fseeko', prefix : '#include <stdio.h>', args : test_args)
180        if cc.has_function('fseeko', prefix : '#include <stdio.h>', args : test_args + ['-U_FILE_OFFSET_BITS'])
181            warning('Files larger than 2 gigabytes might not be supported in the dav1d CLI tool.')
182            add_project_arguments('-U_FILE_OFFSET_BITS', language: 'c')
183        elif get_option('enable_tools')
184            error('dav1d CLI tool needs fseeko()')
185        else
186            have_fseeko = false
187        endif
188    endif
189endif
190
191libdl_dependency = []
192have_dlsym = false
193if host_machine.system() == 'linux'
194    libdl_dependency = cc.find_library('dl', required : false)
195    have_dlsym = cc.has_function('dlsym', prefix : '#include <dlfcn.h>', args : test_args, dependencies : libdl_dependency)
196endif
197cdata.set10('HAVE_DLSYM', have_dlsym)
198
199libm_dependency = cc.find_library('m', required: false)
200
201
202# Header checks
203
204stdatomic_dependencies = []
205if not cc.check_header('stdatomic.h')
206    if cc.get_id() == 'msvc'
207        # we have a custom replacement for MSVC
208        stdatomic_dependencies += declare_dependency(
209            include_directories : include_directories('include/compat/msvc'),
210        )
211    elif cc.compiles('''int main() { int v = 0; return __atomic_fetch_add(&v, 1, __ATOMIC_SEQ_CST); }''',
212                     name : 'GCC-style atomics', args : test_args)
213        stdatomic_dependencies += declare_dependency(
214            include_directories : include_directories('include/compat/gcc'),
215        )
216    else
217        error('Atomics not supported')
218    endif
219endif
220
221if host_machine.cpu_family().startswith('wasm')
222    # enable atomics + bulk-memory features
223    stdatomic_dependencies += thread_dependency.partial_dependency(compile_args: true)
224endif
225
226cdata.set10('HAVE_SYS_TYPES_H', cc.check_header('sys/types.h'))
227cdata.set10('HAVE_UNISTD_H', cc.check_header('unistd.h'))
228cdata.set10('HAVE_IO_H', cc.check_header('io.h'))
229
230have_pthread_np = cc.check_header('pthread_np.h')
231cdata.set10('HAVE_PTHREAD_NP_H', have_pthread_np)
232test_args += '-DHAVE_PTHREAD_NP_H=' + (have_pthread_np ? '1' : '0')
233
234# Function checks
235
236if not cc.has_function('getopt_long', prefix : '#include <getopt.h>', args : test_args)
237    getopt_dependency = declare_dependency(
238        sources: files('tools/compat/getopt.c'),
239        include_directories : include_directories('include/compat'),
240    )
241else
242    getopt_dependency = []
243endif
244
245have_getauxval = false
246have_elf_aux_info = false
247if (host_machine.cpu_family() == 'aarch64' or
248    host_machine.cpu_family().startswith('arm') or
249    host_machine.cpu_family().startswith('loongarch') or
250    host_machine.cpu() == 'ppc64le' or
251    host_machine.cpu_family().startswith('riscv'))
252    have_getauxval = cc.has_function('getauxval', prefix : '#include <sys/auxv.h>', args : test_args)
253    have_elf_aux_info = cc.has_function('elf_aux_info', prefix : '#include <sys/auxv.h>', args : test_args)
254endif
255
256cdata.set10('HAVE_GETAUXVAL', have_getauxval)
257cdata.set10('HAVE_ELF_AUX_INFO', have_elf_aux_info)
258
259pthread_np_prefix = '''
260#include <pthread.h>
261#if HAVE_PTHREAD_NP_H
262#include <pthread_np.h>
263#endif
264'''
265cdata.set10('HAVE_PTHREAD_GETAFFINITY_NP', cc.has_function('pthread_getaffinity_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency))
266cdata.set10('HAVE_PTHREAD_SETAFFINITY_NP', cc.has_function('pthread_setaffinity_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency))
267cdata.set10('HAVE_PTHREAD_SETNAME_NP', cc.has_function('pthread_setname_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency))
268cdata.set10('HAVE_PTHREAD_SET_NAME_NP', cc.has_function('pthread_set_name_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency))
269
270cdata.set10('HAVE_C11_GENERIC', cc.compiles('int x = _Generic(0, default: 0);', name: '_Generic', args: test_args))
271
272# Compiler flag tests
273
274if cc.has_argument('-fvisibility=hidden')
275    add_project_arguments('-fvisibility=hidden', language: 'c')
276else
277    warning('Compiler does not support -fvisibility=hidden, all symbols will be public!')
278endif
279
280# Compiler flags that should be set
281# But when the compiler does not supports them
282# it is not an error and silently tolerated
283if cc.get_argument_syntax() != 'msvc'
284    optional_arguments += [
285      '-Wundef',
286      '-Werror=vla',
287      '-Wno-maybe-uninitialized',
288      '-Wno-missing-field-initializers',
289      '-Wno-unused-parameter',
290      '-Wstrict-prototypes',
291      '-Werror=missing-prototypes',
292      '-Wshorten-64-to-32',
293    ]
294    if host_machine.cpu_family() == 'x86'
295        optional_arguments += [
296          '-msse2',
297          '-mfpmath=sse',
298        ]
299    endif
300else
301    optional_arguments += [
302      '-wd4028', # parameter different from declaration
303      '-wd4090', # broken with arrays of pointers
304      '-wd4996'  # use of POSIX functions
305    ]
306endif
307
308if (get_option('buildtype') != 'debug' and get_option('buildtype') != 'plain')
309    optional_arguments += '-fomit-frame-pointer'
310    optional_arguments += '-ffast-math'
311endif
312
313if (host_machine.system() in ['darwin', 'ios', 'tvos'] and cc.get_id() == 'clang' and
314    cc.version().startswith('11'))
315    # Workaround for Xcode 11 -fstack-check bug, see #301
316    optional_arguments += '-fno-stack-check'
317endif
318
319if (host_machine.cpu_family() == 'aarch64' or host_machine.cpu_family().startswith('arm'))
320    optional_arguments += '-fno-align-functions'
321endif
322
323add_project_arguments(cc.get_supported_arguments(optional_arguments), language : 'c')
324add_project_link_arguments(cc.get_supported_link_arguments(optional_link_arguments), language : 'c')
325
326# libFuzzer related things
327fuzzing_engine = get_option('fuzzing_engine')
328if fuzzing_engine == 'libfuzzer'
329    if not cc.has_argument('-fsanitize=fuzzer')
330        error('fuzzing_engine libfuzzer requires "-fsanitize=fuzzer"')
331    endif
332    fuzzer_args = ['-fsanitize=fuzzer-no-link', '-fsanitize=fuzzer']
333    add_project_arguments(cc.first_supported_argument(fuzzer_args), language : 'c')
334endif
335
336cdata.set10('ENDIANNESS_BIG', host_machine.endian() == 'big')
337
338if host_machine.cpu_family().startswith('x86')
339    if get_option('stack_alignment') > 0
340        stack_alignment = get_option('stack_alignment')
341    elif host_machine.cpu_family() == 'x86_64' or host_machine.system() in ['linux', 'darwin', 'ios', 'tvos']
342        stack_alignment = 16
343    else
344        stack_alignment = 4
345    endif
346    cdata_asm.set('STACK_ALIGNMENT', stack_alignment)
347endif
348
349cdata.set10('ARCH_AARCH64', host_machine.cpu_family() == 'aarch64' or host_machine.cpu() == 'arm64')
350cdata.set10('ARCH_ARM',     host_machine.cpu_family().startswith('arm') and host_machine.cpu() != 'arm64')
351
352have_as_func = false
353have_as_arch = false
354aarch64_extensions = {
355    'dotprod': 'udot v0.4s, v0.16b, v0.16b',
356    'i8mm':    'usdot v0.4s, v0.16b, v0.16b',
357    'sve':     'whilelt p0.s, x0, x1',
358    'sve2':    'sqrdmulh z0.s, z0.s, z0.s',
359}
360supported_aarch64_archexts = []
361supported_aarch64_instructions = []
362if (is_asm_enabled and
363    (host_machine.cpu_family() == 'aarch64' or
364     host_machine.cpu_family().startswith('arm')))
365
366   as_func_code = '''__asm__ (
367".func meson_test"
368".endfunc"
369);
370'''
371    have_as_func = cc.compiles(as_func_code)
372
373    # fedora package build infrastructure uses a gcc specs file to enable
374    # '-fPIE' by default. The chosen way only adds '-fPIE' to the C compiler
375    # with integrated preprocessor. It is not added to the standalone
376    # preprocessor or the preprocessing stage of '.S' files. So we have to
377    # compile code to check if we have to define PIC for the arm asm to
378    # avoid absolute relocations when building for example checkasm.
379    check_pic_code = '''
380#if defined(PIC)
381#error "PIC already defined"
382#elif !(defined(__PIC__) || defined(__pic__))
383#error "no pic"
384#endif
385'''
386    if cc.compiles(check_pic_code)
387        cdata.set('PIC', '3')
388    endif
389
390    if host_machine.cpu_family() == 'aarch64'
391        have_as_arch = cc.compiles('''__asm__ (".arch armv8-a");''')
392        as_arch_str = ''
393        if have_as_arch
394            as_arch_level = 'armv8-a'
395            # Check what .arch levels are supported. In principle, we only
396            # want to detect up to armv8.2-a here (binutils requires that
397            # in order to enable i8mm). However, older Clang versions
398            # (before Clang 17, and Xcode versions up to and including 15.0)
399            # didn't support controlling dotprod/i8mm extensions via
400            # .arch_extension, therefore try to enable a high enough .arch
401            # level as well, to implicitly make them available via that.
402            foreach arch : ['armv8.2-a', 'armv8.4-a', 'armv8.6-a']
403                if cc.compiles('__asm__ (".arch ' + arch + '\\n");')
404                    as_arch_level = arch
405                endif
406            endforeach
407            # Clang versions before 17 also had a bug
408            # (https://github.com/llvm/llvm-project/issues/32220)
409            # causing a plain ".arch <level>" to not have any effect unless it
410            # had an extra "+<feature>" included - but it was activated on the
411            # next ".arch_extension" directive instead. Check if we can include
412            # "+crc" as dummy feature to make the .arch directive behave as
413            # expected and take effect right away.
414            if cc.compiles('__asm__ (".arch ' + as_arch_level + '+crc\\n");')
415                as_arch_level = as_arch_level + '+crc'
416            endif
417            cdata.set('AS_ARCH_LEVEL', as_arch_level)
418            as_arch_str = '".arch ' + as_arch_level + '\\n"'
419        endif
420        foreach name, instr : aarch64_extensions
421            # Test for support for the various extensions. First test if
422            # the assembler supports the .arch_extension directive for
423            # enabling/disabling the extension, then separately check whether
424            # the instructions themselves are supported. Even if .arch_extension
425            # isn't supported, we may be able to assemble the instructions
426            # if the .arch level includes support for them.
427            code = '__asm__ (' + as_arch_str
428            code += '".arch_extension ' + name + '\\n"'
429            code += ');'
430            supports_archext = cc.compiles(code)
431            code = '__asm__ (' + as_arch_str
432            if supports_archext
433                supported_aarch64_archexts += name
434                code += '".arch_extension ' + name + '\\n"'
435            endif
436            code += '"' + instr + '\\n"'
437            code += ');'
438            if cc.compiles(code, name: name.to_upper())
439                supported_aarch64_instructions += name
440            endif
441        endforeach
442    endif
443endif
444
445cdata.set10('HAVE_AS_FUNC', have_as_func)
446cdata.set10('HAVE_AS_ARCH_DIRECTIVE', have_as_arch)
447foreach name, _ : aarch64_extensions
448    cdata.set10('HAVE_AS_ARCHEXT_' + name.to_upper() + '_DIRECTIVE', name in supported_aarch64_archexts)
449    cdata.set10('HAVE_' + name.to_upper(), name in supported_aarch64_instructions)
450endforeach
451
452cdata.set10('ARCH_X86', host_machine.cpu_family().startswith('x86'))
453cdata.set10('ARCH_X86_64', host_machine.cpu_family() == 'x86_64')
454cdata.set10('ARCH_X86_32', host_machine.cpu_family() == 'x86')
455
456if host_machine.cpu_family().startswith('x86')
457    cdata_asm.set('private_prefix', 'dav1d')
458    cdata_asm.set10('ARCH_X86_64', host_machine.cpu_family() == 'x86_64')
459    cdata_asm.set10('ARCH_X86_32', host_machine.cpu_family() == 'x86')
460    cdata_asm.set10('PIC', true)
461
462    # Convert SSE asm into (128-bit) AVX when compiler flags are set to use AVX instructions
463    cdata_asm.set10('FORCE_VEX_ENCODING', cc.get_define('__AVX__').strip() != '')
464endif
465
466cdata.set10('ARCH_PPC64LE', host_machine.cpu() == 'ppc64le')
467
468cdata.set10('ARCH_RISCV', host_machine.cpu_family().startswith('riscv'))
469cdata.set10('ARCH_RV32', host_machine.cpu_family() == 'riscv32')
470cdata.set10('ARCH_RV64', host_machine.cpu_family() == 'riscv64')
471
472cdata.set10('ARCH_LOONGARCH', host_machine.cpu_family().startswith('loongarch'))
473cdata.set10('ARCH_LOONGARCH32', host_machine.cpu_family() == 'loongarch32')
474cdata.set10('ARCH_LOONGARCH64', host_machine.cpu_family() == 'loongarch64')
475
476# meson's cc.symbols_have_underscore_prefix() is unfortunately unrelieably
477# when additional flags like '-fprofile-instr-generate' are passed via CFLAGS
478# see following meson issue https://github.com/mesonbuild/meson/issues/5482
479if (host_machine.system() in ['darwin', 'ios', 'tvos'] or
480   (host_machine.system() == 'windows' and host_machine.cpu_family() == 'x86'))
481    cdata.set10('PREFIX', true)
482    cdata_asm.set10('PREFIX', true)
483endif
484
485#
486# ASM specific stuff
487#
488if is_asm_enabled and host_machine.cpu_family().startswith('x86')
489
490    # NASM compiler support
491
492    nasm = find_program('nasm')
493
494    # check NASM version
495    if nasm.found()
496        nasm_r = run_command(nasm, '-v', check: true)
497
498        out = nasm_r.stdout().strip().split()
499        if out[1].to_lower() == 'version'
500            if out[2].version_compare('<2.14')
501                error('nasm 2.14 or later is required, found nasm @0@'.format(out[2]))
502            endif
503        else
504            error('unexpected nasm version string: @0@'.format(nasm_r.stdout()))
505        endif
506    endif
507
508    # Generate config.asm
509    config_asm_target = configure_file(output: 'config.asm', output_format: 'nasm', configuration: cdata_asm)
510
511    if host_machine.system() == 'windows'
512        nasm_format = 'win'
513    elif host_machine.system() in ['darwin', 'ios', 'tvos']
514        nasm_format = 'macho'
515    else
516        nasm_format = 'elf'
517    endif
518    if host_machine.cpu_family() == 'x86_64'
519        nasm_format += '64'
520    else
521        nasm_format += '32'
522    endif
523
524    nasm_gen = generator(nasm,
525        output: '@[email protected]',
526        depfile: '@[email protected]',
527        arguments: [
528            '-f', nasm_format,
529            '-I', '@0@/src/'.format(dav1d_src_root),
530            '-I', '@0@/'.format(meson.current_build_dir()),
531            '-MQ', '@OUTPUT@', '-MF', '@DEPFILE@',
532            '@EXTRA_ARGS@',
533            '@INPUT@',
534            '-o', '@OUTPUT@'
535        ])
536endif
537
538use_gaspp = false
539if (is_asm_enabled and
540    (host_machine.cpu_family() == 'aarch64' or
541     host_machine.cpu_family().startswith('arm')) and
542    cc.get_argument_syntax() == 'msvc' and
543    (cc.get_id() != 'clang-cl' or meson.version().version_compare('<0.58.0')))
544    gaspp = find_program('gas-preprocessor.pl')
545    use_gaspp = true
546    gaspp_gen = generator(gaspp,
547        output: '@[email protected]',
548        arguments: [
549            '-as-type', 'armasm',
550            '-arch', host_machine.cpu_family(),
551            '--',
552            host_machine.cpu_family() == 'aarch64' ? 'armasm64' : 'armasm',
553            '-nologo',
554            '-I@0@'.format(dav1d_src_root),
555            '-I@0@/'.format(meson.current_build_dir()),
556            '@INPUT@',
557            '-c',
558            '-o', '@OUTPUT@'
559        ])
560endif
561
562if is_asm_enabled and host_machine.cpu_family().startswith('riscv')
563    as_option_code = '''__asm__ (
564".option arch, +v\n"
565"vsetivli zero, 0, e8, m1, ta, ma"
566);
567'''
568    if not cc.compiles(as_option_code, name : 'RISC-V Vector')
569        error('Compiler doesn\'t support \'.option arch\' asm directive. Update to binutils>=2.38 or clang>=17 or use \'-Denable_asm=false\'.')
570    endif
571endif
572
573# Generate config.h
574config_h_target = configure_file(output: 'config.h', configuration: cdata)
575
576
577
578#
579# Include subdir meson.build files
580# The order is important!
581
582subdir('include')
583
584subdir('doc')
585
586subdir('src')
587
588subdir('tools')
589
590subdir('examples')
591
592subdir('tests')
593