Repository navigation
Expand file tree
/
Copy pathmeson.build
More file actions
162 lines (144 loc) · 4.84 KB
/
Copy pathmeson.build
File metadata and controls
162 lines (144 loc) · 4.84 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
project(
'modemu2k',
'c',
version: '0.2.5',
meson_version: '>= 0.56.0',
default_options: [
'warning_level=3',
'c_std=gnu99',
],
)
add_project_arguments(['-D_GNU_SOURCE'], language: 'c')
cc = meson.get_compiler('c')
extra_flags = [
'-fno-common',
'-fstack-protector-strong',
'-Wformat-security',
'-Wformat-overflow=2',
]
add_project_arguments(cc.get_supported_arguments(extra_flags), language: 'c')
conf = configuration_data()
conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('PACKAGE_STRING', meson.project_name())
conf.set_quoted('PACKAGE_URL', 'http://theimpossibleastronaut.com/modemu2k/')
conf.set_quoted(
'PACKAGE_BUGREPORT',
'https://github.com/theimpossibleastronaut/modemu2k/issues',
)
# Require POSIX PTY allocation (posix_openpt/grantpt/unlockpt/ptsname),
# POSIX since 2001. The legacy BSD /dev/pty?? scan fallback was
# removed; if you ever need to bring up a pre-POSIX platform, recover
# the fallback from git history.
if not cc.has_function(
'posix_openpt',
prefix: '#define _XOPEN_SOURCE 600\n#include <stdlib.h>\n#include <fcntl.h>',
)
error('posix_openpt() is required but was not found on this platform.')
endif
config_h = configure_file(output: 'config.h', configuration: conf)
pkg = import('pkgconfig')
version_components = meson.project_version().split('.')
version_conf = configuration_data()
version_conf.set('M2K_VERSION_MAJOR', version_components[0])
version_conf.set('M2K_VERSION_MINOR', version_components[1])
version_conf.set('M2K_VERSION_PATCH', version_components[2])
version_conf.set_quoted('M2K_VERSION', meson.project_version())
version_h = configure_file(
output: 'modemu2k_version.h',
configuration: version_conf,
)
# Docs shipped by install_data and tracked as doc-target inputs; listed
# once so the two lists can't drift apart.
doc_files = files(
'README.md',
'QUICKSTART.md',
'HACKING.md',
'ChangeLog',
)
subdir('src')
# examples/ exposes `example_sources` (used by the doc target's
# depend_files below) and, in standalone mode, builds the per-example
# executables as a signature-drift compile check.
subdir('examples')
# When consumed as a meson subproject, the parent project only needs
# libmodemu2k (exposed via dep_modemu2k from src/meson.build). Skip
# the CLI binary, the man page, the helper-script wrappers, tests,
# and the doc data files — those are only relevant to a standalone
# build.
if not meson.is_subproject()
modemu2k_exe = executable(
'modemu2k',
['src/main.c', 'src/cmdarg.c'],
include_directories: 'src',
dependencies: dep_modemu2k,
install: true,
)
install_headers('modemu2k.h', version_h, subdir: 'modemu2k')
endif
# The man page .TH version is templated from the project version so it can
# never drift; MAN_DATE is bumped by hand at release (see release-process.txt).
man_date = 'July 2026'
man_page = configure_file(
input: 'modemu2k.1.in',
output: 'modemu2k.1',
configuration: {
'VERSION': meson.project_version(),
'MAN_DATE': man_date,
},
)
if get_option('gen-docs')
doxygen = find_program('doxygen', required: true)
groff = find_program('groff', required: true)
man_to_fragment = find_program('doxygen/man-to-fragment.sh')
subdir('doxygen')
doxyfile = configure_file(
input: 'doxygen/Doxyfile.in',
output: 'Doxyfile',
configuration: {
'PROJECT_NAME': meson.project_name(),
'PROJECT_VERSION': meson.project_version(),
'SOURCE_ROOT': meson.project_source_root(),
'BUILD_ROOT': meson.project_build_root(),
},
)
# Render the man page to an HTML fragment that doxygen/manpage.md
# @htmlincludes into the Related Pages section. man-to-fragment.sh
# wraps `groff -Thtml -mandoc` and strips the standalone HTML
# wrapper so the result slots into doxygen's page chrome cleanly.
manpage_fragment = custom_target(
'manpage-fragment',
input: man_page,
output: 'modemu2k.1.fragment.html',
command: [man_to_fragment, '@INPUT@'],
capture: true,
)
docs_tgt = custom_target(
'doxygen-html',
output: 'html',
command: [doxygen, doxyfile],
depends: manpage_fragment,
depend_files: [
doc_files,
files(
'modemu2k.h',
'tests/test_connect.c',
),
man_page,
example_sources,
doxygen_inputs,
],
install: true,
install_dir: get_option('docdir'),
build_by_default: true,
)
alias_target('docs', docs_tgt)
endif
if not meson.is_subproject()
install_man(man_page)
subdir('scripts')
subdir('tests')
install_data(
[doc_files, files('COPYING', 'AUTHORS')],
install_dir: get_option('docdir'),
)
endif