summaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build1882
1 files changed, 1882 insertions, 0 deletions
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000000..358ac9a372
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,1882 @@
+project('mpv',
+ 'c',
+ license: ['GPL2+', 'LGPL2.1+'],
+ version: files('./VERSION'),
+ meson_version: '>=0.60.3',
+ default_options: [
+ 'buildtype=debugoptimized',
+ 'b_lundef=false',
+ 'c_std=c11',
+ 'warning_level=1',
+ ]
+)
+
+build_root = meson.project_build_root()
+source_root = meson.project_source_root()
+python = find_program('python3')
+
+ffmpeg = {
+ 'name': 'ffmpeg',
+ 'deps': [dependency('libavutil', version: '>= 56.12.100'),
+ dependency('libavcodec', version: '>= 58.12.100'),
+ dependency('libavformat', version: '>= 58.9.100'),
+ dependency('libswscale', version: '>= 5.0.101'),
+ dependency('libavfilter', version: '>= 7.14.100'),
+ dependency('libswresample', version: '>= 3.0.100')],
+}
+
+libass = dependency('libass', version: '>= 0.12.2')
+pthreads = dependency('threads')
+
+dependencies = [ffmpeg['deps'],
+ libass,
+ pthreads]
+
+features = [ffmpeg['name'], libass.name(), pthreads.name()]
+
+# Builtin options we'd like to add to features.
+if get_option('optimization') != '0'
+ features += 'optimize'
+endif
+
+if get_option('debug')
+ features += 'debug'
+endif
+
+
+# generic sources
+sources = files(
+ ## Audio
+ 'audio/aframe.c',
+ 'audio/chmap.c',
+ 'audio/chmap_sel.c',
+ 'audio/decode/ad_lavc.c',
+ 'audio/decode/ad_spdif.c',
+ 'audio/filter/af_drop.c',
+ 'audio/filter/af_format.c',
+ 'audio/filter/af_lavcac3enc.c',
+ 'audio/filter/af_scaletempo.c',
+ 'audio/filter/af_scaletempo2.c',
+ 'audio/filter/af_scaletempo2_internals.c',
+ 'audio/fmt-conversion.c',
+ 'audio/format.c',
+ 'audio/out/ao.c',
+ 'audio/out/ao_lavc.c',
+ 'audio/out/ao_null.c',
+ 'audio/out/ao_pcm.c',
+ 'audio/out/buffer.c',
+
+ ## Core
+ 'common/av_common.c',
+ 'common/av_log.c',
+ 'common/codecs.c',
+ 'common/common.c',
+ 'common/encode_lavc.c',
+ 'common/msg.c',
+ 'common/playlist.c',
+ 'common/recorder.c',
+ 'common/stats.c',
+ 'common/tags.c',
+ 'common/version.c',
+
+ ## Demuxers
+ 'demux/codec_tags.c',
+ 'demux/cue.c',
+ 'demux/cache.c',
+ 'demux/demux.c',
+ 'demux/demux_cue.c',
+ 'demux/demux_disc.c',
+ 'demux/demux_edl.c',
+ 'demux/demux_lavf.c',
+ 'demux/demux_mf.c',
+ 'demux/demux_mkv.c',
+ 'demux/demux_mkv_timeline.c',
+ 'demux/demux_null.c',
+ 'demux/demux_playlist.c',
+ 'demux/demux_raw.c',
+ 'demux/demux_timeline.c',
+ 'demux/ebml.c',
+ 'demux/packet.c',
+ 'demux/timeline.c',
+
+ ## Filters
+ 'filters/f_async_queue.c',
+ 'filters/f_autoconvert.c',
+ 'filters/f_auto_filters.c',
+ 'filters/f_decoder_wrapper.c',
+ 'filters/f_demux_in.c',
+ 'filters/f_hwtransfer.c',
+ 'filters/f_lavfi.c',
+ 'filters/f_output_chain.c',
+ 'filters/f_swresample.c',
+ 'filters/f_swscale.c',
+ 'filters/f_utils.c',
+ 'filters/filter.c',
+ 'filters/frame.c',
+ 'filters/user_filters.c',
+
+ ## Input
+ 'input/cmd.c',
+ 'input/event.c',
+ 'input/input.c',
+ 'input/ipc.c',
+ 'input/keycodes.c',
+
+ ## Misc
+ 'misc/bstr.c',
+ 'misc/charset_conv.c',
+ 'misc/dispatch.c',
+ 'misc/json.c',
+ 'misc/natural_sort.c',
+ 'misc/node.c',
+ 'misc/rendezvous.c',
+ 'misc/thread_pool.c',
+ 'misc/thread_tools.c',
+
+ ## Options
+ 'options/m_config_core.c',
+ 'options/m_config_frontend.c',
+ 'options/m_option.c',
+ 'options/m_property.c',
+ 'options/options.c',
+ 'options/parse_commandline.c',
+ 'options/parse_configfile.c',
+ 'options/path.c',
+
+ ## Player
+ 'player/audio.c',
+ 'player/client.c',
+ 'player/command.c',
+ 'player/configfiles.c',
+ 'player/external_files.c',
+ 'player/loadfile.c',
+ 'player/main.c',
+ 'player/misc.c',
+ 'player/osd.c',
+ 'player/playloop.c',
+ 'player/screenshot.c',
+ 'player/scripting.c',
+ 'player/sub.c',
+ 'player/video.c',
+
+ ## Streams
+ 'stream/cookies.c',
+ 'stream/stream.c',
+ 'stream/stream_avdevice.c',
+ 'stream/stream_cb.c',
+ 'stream/stream_concat.c',
+ 'stream/stream_edl.c',
+ 'stream/stream_file.c',
+ 'stream/stream_lavf.c',
+ 'stream/stream_memory.c',
+ 'stream/stream_mf.c',
+ 'stream/stream_null.c',
+ 'stream/stream_slice.c',
+
+ ## Subtitles
+ 'sub/ass_mp.c',
+ 'sub/dec_sub.c',
+ 'sub/draw_bmp.c',
+ 'sub/filter_sdh.c',
+ 'sub/img_convert.c',
+ 'sub/lavc_conv.c',
+ 'sub/osd.c',
+ 'sub/osd_libass.c',
+ 'sub/sd_ass.c',
+ 'sub/sd_lavc.c',
+
+ ## Video
+ 'video/csputils.c',
+ 'video/decode/vd_lavc.c',
+ 'video/filter/refqueue.c',
+ 'video/filter/vf_format.c',
+ 'video/filter/vf_sub.c',
+ 'video/fmt-conversion.c',
+ 'video/hwdec.c',
+ 'video/image_loader.c',
+ 'video/image_writer.c',
+ 'video/img_format.c',
+ 'video/mp_image.c',
+ 'video/mp_image_pool.c',
+ 'video/out/aspect.c',
+ 'video/out/bitmap_packer.c',
+ 'video/out/dither.c',
+ 'video/out/dr_helper.c',
+ 'video/out/filter_kernels.c',
+ 'video/out/gpu/context.c',
+ 'video/out/gpu/error_diffusion.c',
+ 'video/out/gpu/hwdec.c',
+ 'video/out/gpu/lcms.c',
+ 'video/out/gpu/libmpv_gpu.c',
+ 'video/out/gpu/osd.c',
+ 'video/out/gpu/ra.c',
+ 'video/out/gpu/shader_cache.c',
+ 'video/out/gpu/spirv.c',
+ 'video/out/gpu/user_shaders.c',
+ 'video/out/gpu/utils.c',
+ 'video/out/gpu/video.c',
+ 'video/out/gpu/video_shaders.c',
+ 'video/out/libmpv_sw.c',
+ 'video/out/vo.c',
+ 'video/out/vo_gpu.c',
+ 'video/out/vo_image.c',
+ 'video/out/vo_lavc.c',
+ 'video/out/vo_libmpv.c',
+ 'video/out/vo_null.c',
+ 'video/out/vo_tct.c',
+ 'video/out/win_state.c',
+ 'video/repack.c',
+ 'video/sws_utils.c',
+
+ ## osdep
+ 'osdep/io.c',
+ 'osdep/semaphore_osx.c',
+ 'osdep/subprocess.c',
+ 'osdep/threads.c',
+ 'osdep/timer.c',
+
+ ## tree_allocator
+ 'ta/ta.c',
+ 'ta/ta_talloc.c',
+ 'ta/ta_utils.c'
+)
+
+
+# compiler stuff
+cc = meson.get_compiler('c')
+
+flags = ['-D_ISOC99_SOURCE', '-D_GNU_SOURCE',
+ '-D_FILE_OFFSET_BITS=64']
+link_flags = []
+
+test_flags = ['-Werror=implicit-function-declaration',
+ '-Wno-error=deprecated-declarations',
+ '-Wno-error=unused-function',
+ '-Wempty-body',
+ '-Wdisabled-optimization',
+ '-Wstrict-prototypes',
+ '-Wno-format-zero-length',
+ '-Wno-redundant-decls',
+ '-Wvla',
+ '-Wno-format-truncation',
+ '-Wimplicit-fallthrough',
+ '-fno-math-errno']
+
+flags += cc.get_supported_arguments(test_flags)
+
+if cc.has_multi_arguments('-Wformat', '-Werror=format-security')
+ flags += '-Werror=format-security'
+endif
+
+if cc.get_id() == 'gcc'
+ gcc_flags = ['-Wundef', '-Wmissing-prototypes', '-Wshadow',
+ '-Wno-switch', '-Wparentheses', '-Wpointer-arith',
+ '-Wno-pointer-sign',
+ # GCC bug 66425
+ '-Wno-unused-result']
+ flags += gcc_flags
+endif
+
+if cc.get_id() == 'clang'
+ clang_flags = ['-Wno-logical-op-parentheses', '-Wno-switch',
+ '-Wno-tautological-compare', '-Wno-pointer-sign',
+ '-Wno-tautological-constant-out-of-range-compare']
+ flags += clang_flags
+endif
+
+darwin = host_machine.system() == 'darwin'
+win32 = host_machine.system() == 'cygwin' or host_machine.system() == 'windows'
+posix = false
+if not win32
+ posix = true
+ features += 'posix'
+else
+ features += 'win32'
+endif
+
+mswin_flags = ['-D_WIN32_WINNT=0x0602', '-DUNICODE', '-DCOBJMACROS',
+ '-DINITGUID', '-U__STRICT_ANSI__']
+
+mswin_linkflags = ['-Wl,--major-os-version=6,--minor-os-version=0',
+ '-Wl,--major-subsystem-version=6,--minor-subsystem-version=0']
+
+if host_machine.system() == 'windows'
+ flags += [mswin_flags, '-D__USE_MINGW_ANSI_STDIO=1']
+ link_flags += [mswin_linkflags, '-mwindows']
+endif
+
+if host_machine.system() == 'cygwin'
+ features += 'cygwin'
+ flags += [mswin_flags, '-mwin32']
+ link_flags += mswin_linkflags
+endif
+
+noexecstack = false
+if cc.has_link_argument('-Wl,-z,noexecstack')
+ link_flags += '-Wl,-z,noexecstack'
+ noexecstack = true
+endif
+
+if cc.has_link_argument('-Wl,--nxcompat,--no-seh,--dynamicbase')
+ link_flags += '-Wl,--nxcompat,--no-seh,--dynamicbase'
+ noexecstack = true
+endif
+
+if noexecstack
+ features += 'noexecstack'
+endif
+
+if not get_option('build-date')
+ flags += '-DNO_BUILD_TIMESTAMPS'
+else
+ features += 'build-date'
+endif
+
+if get_option('ta-leak-report')
+ features += 'ta-leak-report'
+endif
+
+libdl_dep = cc.find_library('libdl', required: false)
+libdl = cc.has_function('dlopen', dependencies: libdl_dep, prefix: '#include <dlfcn.h>')
+if libdl
+ dependencies += libdl_dep
+ features += 'libdl'
+endif
+
+cplugins = get_option('cplugins').require(
+ libdl and not win32 and cc.has_link_argument('-rdynamic'),
+ error_message: 'cplugins not supported by the os or compiler!',
+)
+if cplugins.allowed()
+ features += 'cplugins'
+ link_flags += '-rdynamic'
+endif
+
+if get_option('tests')
+ features += 'tests'
+ sources += files('test/chmap.c',
+ 'test/gl_video.c',
+ 'test/img_format.c',
+ 'test/json.c',
+ 'test/linked_list.c',
+ 'test/paths.c',
+ 'test/scale_sws.c',
+ 'test/scale_test.c',
+ 'test/tests.c')
+endif
+
+includedir = []
+win32_pthreads = get_option('win32-internal-pthreads').require(
+ win32 and not posix,
+ error_message: 'the os is not win32!',
+)
+if win32_pthreads.allowed()
+ features += 'win32-internal-pthreads'
+ flags += ['-isystem', '-I', '-DIN_WINPTHREAD']
+ # Note: Adding this include causes POSIX_TIMERS to be defined for
+ # unclear reasons (some confusion with <pthread.h> probably).
+ # Hack around it by using HAVE_WIN32_INTERNAL_PTHREADS.
+ includedir += include_directories('osdep/win32/include')
+ sources += files('osdep/win32/pthread.c')
+endif
+
+pthread_debug = get_option('pthread-debug').require(
+ win32_pthreads.disabled(),
+ error_message: 'win32-internal-pthreads was found!',
+)
+if pthread_debug.allowed()
+ features += 'pthread-debug'
+ flags += '-DMP_PTHREAD_DEBUG'
+endif
+
+add_project_arguments(flags, language: 'c')
+add_project_link_arguments(link_flags, language: ['c', 'objc'])
+
+
+# osdep
+cocoa = dependency('appleframeworks', modules: ['Cocoa', 'IOKit', 'QuartzCore'],
+ required: get_option('cocoa'))
+if cocoa.found()
+ dependencies += cocoa
+ features += 'cocoa'
+ sources += files('osdep/macosx_application.m',
+ 'osdep/macosx_events.m',
+ 'osdep/macosx_menubar.m',
+ 'osdep/main-fn-cocoa.c',
+ 'osdep/path-macosx.m',
+ 'video/out/cocoa_common.m',
+ 'video/out/cocoa/events_view.m',
+ 'video/out/cocoa/video_view.m',
+ 'video/out/cocoa/window.m')
+endif
+
+if posix
+ sources += files('input/ipc-unix.c',
+ 'osdep/path-unix.c',
+ 'osdep/polldev.c',
+ 'osdep/subprocess-posix.c',
+ 'osdep/terminal-unix.c',
+ 'sub/filter_regex.c')
+endif
+
+if posix and not cocoa.found()
+ sources += files('osdep/main-fn-unix.c')
+endif
+
+if darwin
+ sources += files('osdep/timer-darwin.c')
+endif
+
+if posix and not darwin
+ sources += files('osdep/timer-linux.c')
+endif
+
+cd_devices = {
+ 'windows': 'D:',
+ 'cygwin': 'D:',
+ 'darwin': '/dev/disk1',
+ 'freebsd': '/dev/cd0',
+ 'openbsd': '/dev/rcd0c',
+ 'linux': '/dev/sr0',
+}
+if host_machine.system() in cd_devices
+ cd_device = cd_devices[host_machine.system()]
+else
+ cd_device = '/dev/cdrom'
+endif
+
+dvd_devices = {
+ 'windows': 'D:',
+ 'cygwin': 'D:',
+ 'darwin': '/dev/diskN',
+ 'freebsd': '/dev/cd0',
+ 'openbsd': '/dev/rcd0c',
+ 'linux': '/dev/sr0',
+}
+if host_machine.system() in cd_devices
+ dvd_device = dvd_devices[host_machine.system()]
+else
+ dvd_device = '/dev/dvd'
+endif
+
+android = host_machine.system() == 'android'
+if android
+ dependencies += cc.find_library('android')
+ features += 'android'
+ sources += files('audio/out/ao_audiotrack.c',
+ 'misc/jni.c',
+ 'osdep/android/strnlen.c',
+ 'video/out/android_common.c',
+ 'video/out/vo_mediacodec_embed.c')
+endif
+
+uwp_opt = get_option('uwp').require(
+ not get_option('cplayer'),
+ error_message: 'cplayer is not false!',
+)
+uwp = cc.find_library('windowsapp', required: uwp_opt)
+if uwp.found()
+ dependencies += uwp
+ features += 'uwp'
+ sources += files('osdep/path-uwp.c')
+endif
+
+if win32
+ sources += files('osdep/timer-win2.c',
+ 'osdep/w32_keyboard.c',
+ 'osdep/windows_utils.c')
+endif
+
+win32_desktop = win32 and not uwp.found()
+if win32_desktop
+ win32_desktop_libs = [cc.find_library('avrt'),
+ cc.find_library('dwmapi'),
+ cc.find_library('gdi32'),
+ cc.find_library('ole32'),
+ cc.find_library('uuid'),
+ cc.find_library('version'),
+ cc.find_library('winmm')]
+ dependencies += win32_desktop_libs
+ features += 'win32-desktop'
+ sources += files('input/ipc-win.c',
+ 'osdep/main-fn-win.c',
+ 'osdep/path-win.c',
+ 'osdep/subprocess-win.c',
+ 'osdep/terminal-win.c',
+ 'video/out/w32_common.c',
+ 'video/out/win32/displayconfig.c',
+ 'video/out/win32/droptarget.c')
+endif
+
+if not posix and not win32_desktop
+ sources += files('input/ipc-dummy.c',
+ 'osdep/subprocess-dummy.c',
+ 'osdep/terminal-dummy.c')
+endif
+
+glob_posix = cc.has_function('glob', prefix: '#include <glob.h>')
+if glob_posix
+ features += 'glob_posix'
+endif
+
+glob_win32 = win32 and not posix
+if glob_win32
+ features += 'glob_win32'
+ sources += files('osdep/glob-win.c')
+endif
+
+glob = glob_posix or glob_win32
+if glob
+ features += 'glob'
+endif
+
+vt_h = cc.has_header_symbol('sys/vt.h', 'VT_GETMODE')
+if vt_h
+ features += 'vt.h'
+endif
+
+consio_h = not vt_h and cc.has_header_symbol('sys/consio.h', 'VT_GETMODE')
+if consio_h
+ features += 'consio.h'
+endif
+
+fragments = join_paths(source_root, 'waftools', 'fragments')
+
+glibc_thread_name = cc.compiles(files(join_paths(fragments, 'glibc_thread_name.c')),
+ name: 'glibc-thread-name check')
+if glibc_thread_name and posix
+ features += 'glibc-thread-name'
+endif
+
+osx_thread_name = false
+if not glibc_thread_name
+ osx_thread_name = cc.compiles(files(join_paths(fragments, 'osx_thread_name.c')),
+ name: 'osx-thread-name check')
+ if osx_thread_name
+ features += 'osx-thread-name'
+ endif
+endif
+
+bsd_thread_name = false
+if not osx_thread_name and not glibc_thread_name
+ bsd_thread_name = cc.compiles(files(join_paths(fragments, 'bsd_thread_name.c')),
+ name: 'bsd-thread-name check')
+ if bsd_thread_name and posix
+ features += 'bsd-thread-name'
+ endif
+endif
+
+vector = cc.compiles(files(join_paths(fragments, 'vector.c')), name: 'vector check')
+if vector
+ features += 'vector'
+elif get_option('vector').enabled()
+ error('vector enabled but it could not be found!')
+endif
+
+bsd_fstatfs = cc.has_function('fstatfs', prefix: '#include <sys/mount.h>\n#include <sys/param.h>')
+if bsd_fstatfs
+ features += 'bsd-fstatfs'
+endif
+
+linux_fstatfs = cc.has_function('fstatfs', prefix: '#include <sys/vfs.h>')
+if linux_fstatfs
+ features += 'linux-fstatfs'
+endif
+
+
+# various file generations
+tools_directory = join_paths(source_root, 'TOOLS')
+file2string = find_program(join_paths(tools_directory, 'file2string.py'))
+matroska = find_program(join_paths(tools_directory, 'matroska.py'))
+version_py = find_program(join_paths(source_root, 'version.py'))
+
+subdir('generated')
+subdir(join_paths('generated', 'etc'))
+subdir(join_paths('generated', 'sub'))
+
+if darwin
+ subdir(join_paths('generated', 'TOOLS', 'osxbundle', 'mpv.app', 'Contents', 'Resources'))
+endif
+
+
+# misc dependencies
+cdda_opt = get_option('cdda').require(
+ get_option('gpl'),
+ error_message: 'the build is not GPL!',
+)
+cdda = dependency('libcdio_paranoia', required: cdda_opt)
+if cdda.found()
+ dependencies += cdda
+ features += 'cdda'
+ sources += files('stream/stream_cdda.c')
+endif
+
+dvbin = get_option('dvbin').require(
+ get_option('gpl'),
+ error_message: 'the build is not GPL!',
+)
+if dvbin.allowed()
+ features += 'dvbin'
+ sources += files('stream/dvb_tune.c',
+ 'stream/stream_dvb.c')
+endif
+
+dvdnav_opt = get_option('dvdnav').require(
+ get_option('gpl'),
+ error_message: 'the build is not GPL!',
+)
+dvdnav = dependency('dvdnav', version: '>= 4.2.0', required: dvdnav_opt)
+dvdread = dependency('dvdread', version: '>= 4.1.0', required: dvdnav_opt)
+if dvdnav.found() and dvdread.found()
+ dependencies += [dvdnav, dvdread]
+ features += 'dvdnav'
+ sources += files('stream/stream_dvdnav.c')
+endif
+
+iconv = dependency('iconv', required: get_option('iconv'))
+if iconv.found()
+ dependencies += iconv
+ features += 'iconv'
+endif
+
+javascript = dependency('mujs', version: '>= 1.0.0', required: get_option('javascript'))
+if javascript.found()
+ dependencies += javascript
+ features += 'javascript'
+ sources += files('player/javascript.c',
+ 'sub/filter_jsre.c')
+ subdir(join_paths('generated', 'player', 'javascript'))
+endif
+
+lcms2 = dependency('lcms2', version: '>= 2.6', required: get_option('lcms2'))
+if lcms2.found()
+ dependencies += lcms2
+ features += 'lcms2'
+endif
+
+libarchive = dependency('libarchive', version: '>= 3.4.0', required: get_option('libarchive'))
+if libarchive.found()
+ dependencies += libarchive
+ features += 'libarchive'
+ sources += files('demux/demux_libarchive.c',
+ 'stream/stream_libarchive.c')
+endif
+
+libavdevice = dependency('libavdevice', version: '>= 57.0.0', required: get_option('libavdevice'))
+if libavdevice.found()
+ dependencies += libavdevice
+ features += 'libavdevice'
+endif
+
+libbluray = dependency('libbluray', version: '>= 0.3.0', required: get_option('libbluray'))
+if libbluray.found()
+ dependencies += libbluray
+ features += 'libbluray'
+ sources += files('stream/stream_bluray.c')
+endif
+
+libm = cc.find_library('m', required: false)
+if libm.found()
+ dependencies += libm
+ features += 'libm'
+endif
+
+librt = cc.find_library('rt', required: false)
+if librt.found()
+ dependencies += librt
+ features += 'librt'
+endif
+
+lua = {
+ 'name': 'lua',
+ 'use': false,
+}
+lua_opt = get_option('lua')
+if lua_opt != 'disabled'
+ lua_version = [['lua', ['>=5.1.0', '<5.3.0']], # generic lua.pc
+ ['lua52', '>= 5.2.0'],
+ ['lua5.2', '>= 5.2.0'],
+ ['lua-5.2', '>= 5.2.0'],
+ ['luajit', '>= 2.0.0'],
+ ['lua51', '>= 5.1.0'],
+ ['lua5.1', '>= 5.1.0'],
+ ['lua-5.1', '>= 5.1.0']]
+ foreach version : lua_version
+ if lua_opt == 'auto' or lua_opt == 'enabled'
+ lua += {'deps': dependency(version[0], version: version[1], required: false)}
+ if lua['deps'].found()
+ lua += {'use': true}
+ break
+ endif
+ elif lua_opt == version[0]
+ lua += {'deps': dependency(version[0], version: version[1])}
+ if lua['deps'].found()
+ lua += {'use': true}
+ break
+ endif
+ endif
+ endforeach
+endif
+
+# Dumb hack for macOS if we're using luajit so the shared libary compiles.
+# The partial dependency is only used for libmpv and not mpv itself.
+# https://github.com/Homebrew/homebrew-core/issues/37169
+luajit_full = dependency('', required: false)
+luajit_partial = dependency('', required: false)
+if lua['use']
+ if darwin and lua['deps'].name() == 'luajit'
+ luajit_full = lua['deps']
+ luajit_partial = lua['deps'].partial_dependency(compile_args: true, link_args: false,
+ links: true, includes: true, sources: true)
+ else
+ dependencies += lua['deps']
+ endif
+
+ features += lua['deps'].name()
+ sources += files('player/lua.c')
+ subdir(join_paths('generated', 'player', 'lua'))
+endif
+if not lua['use'] and lua_opt == 'enabled'
+ error('lua enabled but no suitable lua version could be found!')
+endif
+
+rubberband = dependency('rubberband', version: '>= 1.8.0', required: get_option('rubberband'))
+if rubberband.found()
+ dependencies += rubberband
+ features += 'rubberband'
+ sources += files('audio/filter/af_rubberband.c')
+endif
+
+sdl2 = dependency('sdl2', required: get_option('sdl2'))
+if sdl2.found()
+ dependencies += sdl2
+ features += 'sdl2'
+endif
+
+sdl2_gamepad = get_option('sdl2-gamepad').require(
+ sdl2.found(),
+ error_message: 'sdl2 was not found!',
+)
+if sdl2_gamepad.allowed()
+ features += 'sdl2-gamepad'
+ sources += files('input/sdl_gamepad.c')
+endif
+
+stdatomic = cc.find_library('atomic', required: get_option('stdatomic'))
+if stdatomic.found()
+ dependencies += stdatomic
+ features += 'stdatomic'
+endif
+
+uchardet_opt = get_option('uchardet').require(
+ iconv.found(),
+ error_message: 'iconv was not found!',
+)
+uchardet = dependency('uchardet', required: uchardet_opt)
+if uchardet.found()
+ dependencies += uchardet
+ features += 'uchardet'
+endif
+
+vapoursynth = dependency('vapoursynth', version: '>= 24', required: get_option('vapoursynth'))
+vapoursynth_script = dependency('vapoursynth-script', version: '>= 23',
+ required: get_option('vapoursynth'))
+if vapoursynth.found() and vapoursynth_script.found()
+ dependencies += [vapoursynth, vapoursynth_script]
+ features += 'vapoursynth'
+ sources += files('video/filter/vf_vapoursynth.c')
+endif
+
+zimg = dependency('zimg', version: '>= 2.9', required: get_option('zimg'))
+if zimg.found()
+ dependencies += zimg
+ features += 'zimg'
+ sources += files('video/filter/vf_fingerprint.c',
+ 'video/zimg.c')
+ if get_option('tests')
+ sources += files('test/repack.c',
+ 'test/scale_zimg.c')
+ endif
+endif
+
+zlib = dependency('zlib', required: get_option('zlib'))
+if zlib.found()
+ dependencies += zlib
+ features += 'zlib'
+endif
+
+
+# audio output dependencies
+alsa = dependency('alsa', version: '>= 1.0.18', required: get_option('alsa'))
+if alsa.found()
+ dependencies += alsa
+ features += 'alsa'
+ sources += files('audio/out/ao_alsa.c')
+endif
+
+audiounit = {
+ 'name': 'audiounit',
+ 'deps': dependency('appleframeworks', modules: ['Foundation', 'AudioToolbox'],
+ required: get_option('audiounit')),
+ 'symbol': cc.has_header_symbol('AudioToolbox/AudioToolbox.h', 'kAudioUnitSubType_RemoteIO',
+ required: get_option('audiounit')),
+ 'use': false,
+}
+if audiounit['deps'].found() and audiounit['symbol']
+ dependencies += audiounit['deps']
+ features += 'audiounit'
+ sources += files('audio/out/ao_audiounit.m')
+ audiounit += {'use': true}
+endif
+
+coreaudio = dependency('appleframeworks', modules: ['CoreFoundation', 'CoreAudio',
+ 'AudioUnit', 'AudioToolbox'], required: get_option('coreaudio'))
+if coreaudio.found()
+ dependencies += coreaudio
+ features += 'coreaudio'
+ sources += files('audio/out/ao_coreaudio.c',
+ 'audio/out/ao_coreaudio_exclusive.c',
+ 'audio/out/ao_coreaudio_properties.c')
+endif
+
+if audiounit['use'] or coreaudio.found()
+ sources += files('audio/out/ao_coreaudio_chmap.c',
+ 'audio/out/ao_coreaudio_utils.c')
+endif
+
+jack_opt = get_option('jack').require(
+ get_option('gpl'),
+ error_message: 'the build is not GPL!',
+)
+jack = dependency('jack', required: jack_opt)
+if jack.found()
+ dependencies += jack
+ features += 'jack'
+ sources += files('audio/out/ao_jack.c')
+endif
+
+openal = dependency('openal', version: '>= 1.13', required: get_option('openal'))
+if openal.found()
+ dependencies += openal
+ features += 'openal'
+ sources += files('audio/out/ao_openal.c')
+endif
+
+opensles = cc.find_library('OpenSLES', required: get_option('opensles'))
+if opensles.found()
+ dependencies += opensles
+ features += 'opensles'
+ sources += files('audio/out/ao_opensles.c')
+endif
+
+oss_opt = get_option('oss-audio').require(
+ get_option('gpl'),
+ error_message: 'the build is not GPL!',
+)
+oss = cc.has_header_symbol('sys/soundcard.h', 'SNDCTL_DSP_SETPLAYVOL',
+ required: oss_opt)
+if oss
+ features += 'oss-audio'
+ sources += files('audio/out/ao_oss.c')
+endif
+
+pipewire = dependency('libpipewire-0.3', version: '>= 0.3', required: get_option('pipewire'))
+if pipewire.found()
+ dependencies += pipewire
+ features += 'pipewire'
+ sources += files('audio/out/ao_pipewire.c')
+endif
+
+pulse = dependency('libpulse', version: '>= 1.0', required: get_option('pulse'))
+if pulse.found()
+ dependencies += pulse
+ features += 'pulse'
+ sources += files('audio/out/ao_pulse.c')
+endif
+
+sdl2_audio = get_option('sdl2-audio').require(
+ sdl2.found(),
+ error_message: 'sdl2 was not found!',
+)
+if sdl2_audio.allowed()
+ features += 'sdl2-audio'
+ sources += files('audio/out/ao_sdl.c')
+endif
+
+sndio = dependency('sndio', required: get_option('sndio'))
+if sndio.found()
+ dependencies += sndio
+ features += 'sndio'
+ sources += files('audio/out/ao_sndio.c')
+endif
+
+wasapi = cc.has_header_symbol('audioclient.h', 'IAudioClient', required: get_option('wasapi'))
+if wasapi
+ features += 'wasapi'
+ sources += files('audio/out/ao_wasapi.c',
+ 'audio/out/ao_wasapi_changenotify.c',
+ 'audio/out/ao_wasapi_utils.c')
+endif
+
+
+# video output dependencies
+caca_opt = get_option('caca').require(
+ get_option('gpl'),
+ error_message: 'the build is not GPL!',
+)
+caca = dependency('caca', version: '>= 0.99.beta18', required: caca_opt)
+if caca.found()
+ dependencies += caca
+ features += 'caca'
+ sources += files('video/out/vo_caca.c')
+endif
+
+direct3d_opt = get_option('direct3d').require(
+ get_option('gpl') and win32_desktop,
+ error_message: 'the build is not GPL or this is not a win32 desktop!',
+)
+direct3d = cc.check_header('d3d9.h', required: direct3d_opt)
+if direct3d
+ features += 'direct3d'
+ sources += files('video/out/vo_direct3d.c')
+endif
+
+drm = {
+ 'name': 'drm',
+ 'deps': dependency('libdrm', version: '>= 2.4.75', required: get_option('drm')),
+ 'header': vt_h or consio_h,
+}
+drm += {'use': drm['deps'].found() and drm['header']}
+if drm['use']
+ dependencies += drm['deps']
+ features += drm['name']
+ sources += files('video/out/drm_atomic.c',
+ 'video/out/drm_common.c',
+ 'video/out/drm_prime.c',
+ 'video/out/opengl/hwdec_drmprime_drm.c',
+ 'video/out/vo_drm.c')
+endif
+
+gbm = dependency('gbm', version: '>=17.1.0', required: get_option('gbm'))
+if gbm.found()
+ dependencies += gbm
+ features += 'gbm'
+endif
+
+jpeg = dependency('libjpeg', required: get_option('jpeg'))
+if jpeg.found()
+ dependencies += jpeg
+ features += 'jpeg'
+endif
+
+libplacebo_next = false
+libplacebo = dependency('libplacebo', version: '>=4.157.0', required: get_option('libplacebo'))
+if libplacebo.found()
+ dependencies += libplacebo
+ features += 'libplacebo'
+ sources += files('video/out/placebo/ra_pl.c',
+ 'video/out/placebo/utils.c')
+ pl_api_ver = libplacebo.version().split('.')[1]
+ if pl_api_ver.version_compare('>=190')
+ features += 'libplacebo-next'
+ libplacebo_next = true
+ message('libplacebo v4.190+ found! Enabling vo_gpu_next.')
+ sources += files('video/out/vo_gpu_next.c',
+ 'video/out/gpu_next/context.c')
+ else
+ message('libplacebo v4.190+ not found! Disabling vo_gpu_next.')
+ endif
+endif
+
+sdl2_video = get_option('sdl2-video').require(
+ sdl2.found(),
+ error_message: 'sdl2 was not found!',
+)
+if sdl2_video.allowed()
+ features += 'sdl2-video'
+ sources += files('video/out/vo_sdl.c')
+endif
+
+shaderc = dependency('shaderc', required: get_option('shaderc'))
+if shaderc.found()
+ dependencies += shaderc
+ features += shaderc.name()
+ sources += files('video/out/gpu/spirv_shaderc.c')
+endif
+
+sixel = dependency('libsixel', version: '>= 1.5', required: get_option('sixel'))
+if sixel.found()
+ dependencies += sixel
+ features += 'sixel'
+ sources += files('video/out/vo_sixel.c')
+endif
+
+spirv_cross = dependency('spirv-cross-c-shared', required: get_option('spirv-cross'))
+if spirv_cross.found()
+ features += 'spirv-cross'
+ dependencies += spirv_cross
+endif
+
+d3d11 = {
+ 'name': 'd3d11',
+ 'use': win32_desktop and shaderc.found() and spirv_cross.found() and
+ get_option('d3d11').allowed(),
+}
+d3d11 = get_option('d3d11').require(
+ win32_desktop and shaderc.found() and spirv_cross.found(),
+ error_message: 'Either is not a win32 desktop or shaderc nor spirv-cross were found!',
+)
+if d3d11.allowed()
+ features += 'd3d11'
+ sources += files('video/out/d3d11/context.c',
+ 'video/out/d3d11/ra_d3d11.c')
+endif
+
+wayland = {
+ 'name': 'wayland',
+ 'deps': [dependency('wayland-client', version: '>= 1.15.0', required: get_option('wayland')),
+ dependency('wayland-cursor', version: '>= 1.15.0', required: get_option('wayland')),
+ dependency('wayland-protocols', version: '>= 1.15', required: get_option('wayland')),
+ dependency('xkbcommon', version: '>= 0.3.0', required: get_option('wayland'))],
+ 'header': cc.check_header('linux/input-event-codes.h', required: get_option('wayland')),
+ 'scanner': find_program('wayland-scanner', required: get_option('wayland')),
+ 'use': true,
+}
+foreach dep: wayland['deps']
+ if not dep.found()
+ wayland += {'use': false}
+ break
+ endif
+endforeach
+
+if not wayland['header'] or not wayland['scanner'].found()
+ wayland += {'use': false}
+endif
+
+if wayland['use']
+ features += wayland['name']
+ subdir(join_paths('generated', 'wayland'))
+endif
+
+memfd_create = false
+if wayland['use']
+ memfd_create = cc.has_function('memfd_create',
+ prefix: '#define _GNU_SOURCE\n#include <sys/mman.h>')
+endif
+if wayland['use'] and memfd_create
+ features += 'memfd_create'
+ sources += files('video/out/vo_wlshm.c')
+endif
+
+x11_opt = get_option('x11').require(
+ get_option('gpl'),
+ error_message: 'the build is not GPL!',
+)
+x11 = {
+ 'name': 'x11',
+ 'deps': [dependency('x11', version: '>= 1.0.0', required: x11_opt),
+ dependency('xscrnsaver', version: '>= 1.0.0', required: x11_opt),
+ dependency('xext', version: '>= 1.0.0', required: x11_opt),
+ dependency('xinerama', version: '>= 1.0.0', required: x11_opt),
+ dependency('xrandr', version: '>= 1.2.0', required: x11_opt)],
+ 'use': true,
+}
+foreach dep: x11['deps']
+ if not dep.found()
+ x11 += {'use': false}
+ break
+ endif
+endforeach
+
+if x11['use']
+ dependencies += x11['deps']
+ features += x11['name']
+ sources += files('video/out/vo_x11.c',
+ 'video/out/x11_common.c')
+endif
+
+xv_opt = get_option('xv').require(
+ x11['use'],
+ error_message: 'x11 could not be found!',
+)
+xv = dependency('xv', required: xv_opt)
+if xv.found()
+ dependencies += xv
+ features += 'xv'
+ sources += files('video/out/vo_xv.c')
+endif
+
+
+# OpenGL feature checking
+gl = {
+ 'name': 'gl',
+ 'opt': get_option('gl').allowed(),
+ 'use': false,
+}
+
+GL = dependency('', required: false)
+if darwin
+ GL = dependency('appleframeworks', modules: 'OpenGL', required: get_option('gl-cocoa'))
+elif win32_desktop
+ GL = dependency('GL', required: get_option('gl-win32'))
+elif x11['use']
+ GL = dependency('GL', required: get_option('gl-x11'))
+endif
+
+gl_cocoa = get_option('gl