1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
# Copyright (C) 2025 Rob Hall
# SPDX-License-Identifier: MIT
project('libdvdread', 'c',
version: '7.0.1',
meson_version: '>= 0.60.0',
default_options: ['buildtype=debugoptimized',
'c_std=c11',
'default_library=both',
'warning_level=2'])
dvdread_src_root = meson.current_source_dir()
dvdread_build_root = meson.current_build_dir()
cc = meson.get_compiler('c')
# Configuration data for config.h
cdata = configuration_data()
# Include directories
dvdread_inc_dirs = include_directories('.', 'src', 'src/dvdread')
if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
# extra POSIX headers not found in the Windows SDK
dvdread_inc_dirs = [dvdread_inc_dirs, include_directories('msvc/include', 'msvc/contrib/dirent')]
endif
# The version number for the shared library
dvdread_soname_version = '8.1.0'
dvdread_version = meson.project_version()
dvdread_version_split = dvdread_version.split('.')
cdata.set_quoted('PACKAGE_VERSION', dvdread_version)
#
# OS/Compiler checks and defines
#
# Arguments in test_args will be used even on feature tests
test_args = ['-D_DEFAULT_SOURCE']
optional_arguments = []
optional_link_arguments = []
extra_dependencies = []
if host_machine.system() == 'sunos'
test_args += '-D__EXTENSIONS__'
endif
# Header checks
check_headers = [
'sys/param.h',
'limits.h',
]
foreach h : check_headers
if cc.has_header(h, args: test_args)
cdata.set('HAVE_' + h.underscorify().to_upper(), 1)
endif
endforeach
cdata.set('UNUSED', cc.has_function_attribute('unused') ? '__attribute__((unused))' : '')
if host_machine.endian() == 'big'
cdata.set('WORDS_BIGENDIAN', 1)
endif
if host_machine.system() == 'windows'
# dvdread_headers += files('msvc/contrib/win32_cs.h')
if cc.has_function('gettimeofday', prefix: '#include <sys/time.h>', args: test_args)
cdata.set('HAVE_GETTIMEOFDAY', 1)
endif
elif host_machine.system() == 'linux'
if cc.has_function('getmntent_r', prefix: '#include <mntent.h>', args: test_args)
cdata.set('HAVE_GETMNTENT_R', 1)
endif
endif
if cc.has_function('strerror_r', prefix: '#include <string.h>', args: test_args)
cdata.set('HAVE_STRERROR_R', 1)
cdata.set('HAVE_DECL_STRERROR_R', 1)
elif cc.has_function('strerror_s', prefix: '#include <string.h>', args: test_args)
cdata.set('HAVE_STRERROR_S', 1)
endif
cdata.set10('HAVE_STATIC_ASSERT', cc.compiles('_Static_assert(1, "The impossible happened.");', name : '_Static_assert'))
# External dependencies and libraries
# libdvdcss is loaded dynamically if it is not found or requested
libdl_dependency = []
libdvdcss_dependency = dependency('libdvdcss',
version: '>= 1.2', method: 'pkg-config', required: get_option('libdvdcss'))
if libdvdcss_dependency.found()
cdata.set('HAVE_DVDCSS_DVDCSS_H', 1)
elif host_machine.system() != 'windows'
# Using builtin dlfcn (may require linking to libdl depending on the system)
if not cc.has_function('dlopen', prefix: '#include <dlfcn.h>', args: test_args)
libdl_dependency = cc.find_library('dl')
endif
cdata.set('HAVE_DLFCN_H', 1)
endif
if libdvdcss_dependency.found()
if cc.has_header('dvdcss/dvdcpxm.h', dependencies: libdvdcss_dependency)
cdata.set('HAVE_DVDCSS_DVDCPXM_H', 1)
endif
endif
# Compiler flag tests
# Compiler flags that should be set
# But when the compiler does not supports them
# it is not an error and silently tolerated
if get_option('warning_level') in ['2', '3', 'everything']
optional_arguments += '-Wsign-compare'
endif
add_project_arguments(cc.get_supported_arguments(optional_arguments), language: 'c')
add_project_link_arguments(cc.get_supported_link_arguments(optional_link_arguments), language: 'c')
add_project_arguments(test_args, language: 'c')
# Generate config.h
config_h_target = configure_file(output: 'config.h', configuration: cdata)
install_data(['AUTHORS', 'COPYING', 'NEWS', 'README.md', 'TODO'],
install_dir: get_option('datadir') / 'doc/libdvdread',
install_tag: 'doc')
if import('fs').is_file('.git/logs/HEAD')
git_exe = find_program('git', required: false, disabler: true)
custom_target('ChangeLog', output: 'ChangeLog',
depend_files: '.git/logs/HEAD',
command: ['git', 'log'], capture: true,
install: true,
install_dir: get_option('datadir') / 'doc/libdvdread',
install_tag: 'doc')
endif
# Include subdir meson.build files
# The order is important!
subdir('src/dvdread')
subdir('src')
subdir('doc')
|