forked from knik0/faac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
282 lines (236 loc) · 6.09 KB
/
meson.build
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# SPDX-FileCopyrightText: 2023 Amyspark <amy@amyspark.me>
# SPDX-License-Identifier: BSD-3-Clause
project(
'FAAC',
'c', 'cpp',
version: '1.30',
license: 'LGPL-2.1-or-later',
default_options: [
'c_std=c99',
'warning_level=1',
'b_lundef=true',
]
)
compiler = meson.get_compiler('c')
dependencies = []
cdata = configuration_data()
m = compiler.find_library('m', required: false)
dependencies += m
if compiler.get_argument_syntax() == 'msvc'
add_project_arguments(
'-EHs',
language: ['c', 'cpp']
)
else
add_project_arguments(
'-fexceptions',
language: ['c', 'cpp']
)
endif
have_getopt_h = compiler.has_header('getopt.h')
have_immintrin_h = compiler.has_header('immintrin.h')
have_getopt_long = compiler.has_function('getopt_long')
use_drm = get_option('drm')
mingw = target_machine.system() == 'windows' and (compiler.get_id() == 'gcc' or compiler.get_id() == 'clang')
cpusse = target_machine.cpu_family() == 'x86' or target_machine.cpu_family() == 'x86_64'
# include/Makefile
faac_headers = files(
'include/faac.h',
'include/faaccfg.h'
)
install_headers(faac_headers)
# libfaac/Makefile
faac_srcs = files(
'libfaac/bitstream.c',
'libfaac/fft.c',
'libfaac/frame.c',
'libfaac/blockswitch.c',
'libfaac/util.c',
'libfaac/channels.c',
'libfaac/filtbank.c',
'libfaac/tns.c',
'libfaac/quantize.c',
'libfaac/huff2.c',
'libfaac/huffdata.c',
'libfaac/stereo.c',
)
faac_includes = [
include_directories('include'),
include_directories('libfaac'),
]
faac_args = [
'-DPACKAGE_VERSION="@0@"'.format(meson.project_version())
]
faac_link_args = []
if cpusse
if compiler.get_argument_syntax() == 'msvc'
faac_link_args += compiler.get_supported_arguments('-arch:SSE2')
else
faac_link_args += compiler.get_supported_arguments('-msse2')
endif
endif
if have_immintrin_h
faac_args += '-DHAVE_IMMINTRIN_H'
endif
if mingw
faac_link_args += compiler.get_supported_link_arguments('-Wl,--add-stdcall-alias')
endif
makedef = find_program('packaging/makedef.py')
makedef_args = [makedef]
if compiler.get_argument_syntax() == 'msvc'
dumpbin = find_program('dumpbin', required: true)
makedef_args += ['--dumpbin', dumpbin]
else
nm = find_program('nm', 'llvm-nm', required: true)
makedef_args += ['--nm', nm]
endif
extern_prefix = compiler.symbols_have_underscore_prefix() ? '_' : ''
if target_machine.system() == 'windows'
makedef_args += ['--prefix', extern_prefix]
makedef_args += ['--format', 'msvc']
elif target_machine.system() == 'darwin'
makedef_args += ['--format', 'darwin']
else
makedef_args += ['--prefix', extern_prefix]
makedef_args += ['--format', 'gcc']
endif
if use_drm
faac_srcs += files(
'libfaac/kiss_fft/kiss_fftr.c',
'libfaac/kiss_fft/kiss_fft.c',
)
faac_includes += include_directories('libfaac/kiss_fft')
faac_args += '-DDRM'
faac_static = static_library(
'faac_drm_static',
faac_srcs,
c_args: faac_args,
include_directories: faac_includes,
dependencies: m,
link_args: faac_link_args,
install: false,
)
vs_module_def = custom_target(
'faac_drm_def',
output: 'faac_drm.def',
command: [makedef_args, faac_static],
capture: true
)
faac_link_deps = []
if target_machine.system() == 'darwin'
faac_link_args += '-Wl,-exported_symbols_list,@0@'.format(meson.current_build_dir() / 'faac_drm.def')
faac_link_deps += vs_module_def
elif target_machine.system() != 'windows' and target_machine.system() != 'cygwin'
faac_link_args += '-Wl,--version-script=@0@'.format(meson.current_build_dir() / 'faac_drm.def')
faac_link_deps += vs_module_def
endif
faac = library(
'faac_drm',
link_whole: faac_static,
link_args: faac_link_args,
link_depends: faac_link_deps,
vs_module_defs: vs_module_def,
version: meson.project_version(),
install: true,
)
else
faac_static = static_library(
'faac_static',
faac_srcs,
c_args: faac_args,
include_directories: faac_includes,
dependencies: m,
link_args: faac_link_args,
install: false,
)
vs_module_def = custom_target(
'faac_def',
output: 'faac.def',
command: [makedef_args, faac_static],
capture: true
)
faac_link_deps = []
if target_machine.system() == 'darwin'
faac_link_args += '-Wl,-exported_symbols_list,@0@'.format(meson.current_build_dir() / 'faac.def')
faac_link_deps += vs_module_def
elif target_machine.system() != 'windows' and target_machine.system() != 'cygwin'
faac_link_args += '-Wl,--version-script=@0@'.format(meson.current_build_dir() / 'faac.def')
faac_link_deps += vs_module_def
endif
faac = library(
'faac',
link_whole: faac_static,
link_args: faac_link_args,
link_depends: faac_link_deps,
vs_module_defs: vs_module_def,
version: meson.project_version(),
install: true,
)
endif
faac_dep = declare_dependency(
link_with: faac,
dependencies: m,
include_directories: faac_includes,
)
# common/Makefile
# frontend/Makefile
windows = import('windows')
if not use_drm
install_man(files('docs/faac.1'))
faac_bin_srcs = files(
'frontend/main.c',
'frontend/input.c',
'frontend/mp4write.c',
)
if not have_getopt_h or not have_getopt_long
faac_bin_srcs += files(
'frontend/getopt.c',
)
endif
faac_bin_deps = [
faac_dep,
m,
]
if target_machine.system() == 'windows'
faac_bin_deps += [
compiler.find_library('ws2_32', required: true),
]
endif
faac_bin_includes = [
include_directories('include'),
include_directories('frontend'),
]
faac_bin = executable(
'faac',
c_args: '-DHAVE_GETOPT_H',
faac_bin_srcs,
include_directories: faac_bin_includes,
dependencies: faac_bin_deps,
install: true,
)
if target_machine.system() == 'windows'
faac_gui_srcs = files(
'frontend/maingui.c',
'frontend/input.c',
)
faac_gui_deps = faac_bin_deps + compiler.find_library('comdlg32', required: true)
faac_gui_srcs += [
windows.compile_resources('frontend/faacgui.rc'),
windows.compile_resources('frontend/icon.rc',
depend_files: files('frontend/faac.ico')
),
]
faacgui = executable(
'faacgui',
faac_gui_srcs,
include_directories: faac_bin_includes,
dependencies: faac_gui_deps,
install: true,
)
endif
endif
pkg = import('pkgconfig')
pkg.generate(
faac,
description: 'Freeware Advanced Audio Coder'
)