File: meson.build

package info (click to toggle)
libudfread 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 268 kB
  • sloc: ansic: 2,076; makefile: 3
file content (111 lines) | stat: -rw-r--r-- 2,829 bytes parent folder | download | duplicates (2)
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
# Copyright (C) 2025 Rob Hall
# SPDX-License-Identifier: MIT

project('libudfread', 'c',
	  version: '1.2.0',
	  default_options: ['buildtype=debugoptimized',
                      'c_std=c99',
                      'default_library=both',
                      'optimization=3',
                      'warning_level=3'],
	  meson_version: '>= 0.60.0')

cc = meson.get_compiler('c')

# Configuration data for config.h
cdata = configuration_data()
cdata.set('HAVE_UDFREAD_VERSION_H', 1)
add_project_arguments('-DHAVE_CONFIG_H=1', language: 'c')

# Include directories
libudfread_inc_dirs = include_directories('.', 'src', 'src/udfread')

# The version number for the shared library
libudfread_soname_version = '3.0.0'

libudfread_version = meson.project_version()
libudfread_version_split = libudfread_version.split('.')

#
# OS/Compiler checks and defines
#

# Arguments in test_args will be used even on feature tests
test_args = ['-D_ISOC99_SOURCE']

optional_arguments = []

if host_machine.system() != 'windows'
    test_args += '-D_POSIX_C_SOURCE=200809L'
endif

# Header checks

check_headers = [
    'unistd.h',
    'fcntl.h',
]

foreach h: check_headers
    if cc.has_header(h, args: test_args)
        cdata.set('HAVE_' + h.underscorify().to_upper(), 1)
    endif
endforeach

if host_machine.system() != 'windows'
    if not cc.has_function('pread', prefix: '#include <unistd.h>', args: test_args)
        error('Function pread not found.')
    endif
endif

# External dependencies and libraries

if host_machine.system() == 'windows'
    thread_dependency = []
else
    thread_dependency = dependency('threads', required: false)
    if thread_dependency.found()
        cdata.set('HAVE_PTHREAD_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 cc.get_argument_syntax() != 'msvc'
    optional_arguments += [
        '-Wdisabled-optimization',
        '-Wpointer-arith',
        '-Wredundant-decls',
        '-Wcast-qual',
        '-Wwrite-strings',
        '-Wundef',
        '-Wshadow',
        '-Wmissing-prototypes',
        '-Werror=implicit-function-declaration',
        '-Werror-implicit-function-declaration',
    ]
    if get_option('warning_level') in ['3', 'everything']
        optional_arguments += '-Winline'
    endif
    if get_option('optimization') == '3'
        optional_arguments += '-fomit-frame-pointer'
    endif
endif

add_project_arguments(test_args, language: 'c')
add_project_arguments(cc.get_supported_arguments(optional_arguments), language: 'c')

# Generate config.h
config_h_target = configure_file(output: 'config.h', configuration: cdata)

# Include subdir meson.build files
# The order is important!

subdir('src/udfread')

subdir('src')

subdir('examples')