-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
meson.build
313 lines (275 loc) · 8.01 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# for ninja:
# meson setup builddir
# cd builddir ; meson compile
# fox Xcode:
# meson setup --backend=xcode xcode
# cd xcode ; meson compile
# regenerate configuration (run from builddir/)
# meson setup --reconfigure --wipe
project('pcsc-lite', 'c',
meson_version : '>=0.58.0',
version : '2.3.0')
# for config.h
conf_data = configuration_data({
'VERSION' : '"' + meson.project_version() + '"',
'PCSCLITE_HP_DROPDIR' : '"' + get_option('usbdropdir') + '"',
'HAVE_NANOSLEEP' : true,
'NO_LOG' : get_option('embedded'),
})
# for generated files from .in templates
sbindir = join_paths(get_option('prefix') , get_option('sbindir'))
confgen_data = configuration_data({
'VERSION' : meson.project_version(),
'ipcdir' : get_option('ipcdir'),
'sysconfdir' : get_option('sysconfdir'),
'sbindir_exp' : sbindir,
'PCSCLITE_CONFIG_DIR' : get_option('serialconfdir'),
'usbdropdir' : get_option('usbdropdir'),
})
# tests for functions
compiler = meson.get_compiler('c')
if compiler.has_function('getrandom', prefix : '#include <sys/random.h>')
conf_data.set('HAVE_GETRANDOM', true)
endif
if compiler.has_function('secure_getenv')
conf_data.set('HAVE_SECURE_GETENV', true)
endif
if compiler.has_function('getopt_long')
conf_data.set('HAVE_GETOPT_LONG', true)
endif
# tests for options
features = []
if get_option('usb')
conf_data.set('USE_USB', true)
features += 'USB'
endif
if get_option('serial')
conf_data.set('USE_SERIAL', true)
features += 'serial'
endif
if get_option('filter_names')
conf_data.set('FILTER_NAMES', true)
features += 'filter_names'
endif
# flex generator
gen_flex = generator(find_program('flex'),
output : '@[email protected]',
arguments : ['-o', '@OUTPUT@', '--prefix=@BASENAME@', '@INPUT@'])
# global arguments
add_global_arguments('-fvisibility=hidden', language : 'c')
# pcscd daemon
pcscd_src = [
'src/atrhandler.c',
'src/auth.c',
'src/debuglog.c',
'src/dyn_unix.c',
'src/eventhandler.c',
'src/hotplug_generic.c',
'src/hotplug_libudev.c',
'src/hotplug_libusb.c',
'src/ifdwrapper.c',
'src/pcscdaemon.c',
'src/prothandler.c',
'src/readerfactory.c',
'src/simclist.c',
'src/sys_unix.c',
'src/utils.c',
'src/winscard.c',
'src/winscard_msg.c',
'src/winscard_msg_srv.c',
'src/winscard_svc.c'
]
gen_src = gen_flex.process('src/configfile.l', 'src/tokenparser.l')
pcscd_src += gen_src
incdir = include_directories(['src', 'src/PCSC'])
# dependencies
threads_dep = dependency('threads')
pcscd_dep = [threads_dep]
if get_option('libudev')
udev_dep = dependency('libudev')
pcscd_dep += udev_dep
conf_data.set('HAVE_LIBUDEV', true)
features += 'libudev'
endif
if get_option('libusb')
if get_option('libudev')
error('You can\'t use both libudev and libusb')
endif
libusb_dep = dependency('libusb-1.0')
pcscd_dep += libusb_dep
conf_data.set('HAVE_LIBUSB', true)
features += 'libusb'
endif
cc = meson.get_compiler('c')
dl_deps = cc.find_library('dl', required: false)
pcscd_dep += dl_deps
if get_option('polkit')
polkit_dep = dependency('polkit-gobject-1')
pcscd_dep += polkit_dep
conf_data.set('HAVE_POLKIT', true)
features += 'polkit'
endif
if get_option('libsystemd')
systemd_dep = dependency('libsystemd')
pcscd_dep += systemd_dep
conf_data.set('USE_LIBSYSTEMD', true)
features += 'systemd'
endif
# architecture
r = run_command('uname', check: true)
pcsc_arch = r.stdout().strip()
if pcsc_arch == 'Darwin'
pcsc_arch = 'MacOS'
pcscd_dep += dependency('appleframeworks', modules : ['foundation', 'IOKit'])
pcscd_src += files(['src/hotplug_macosx.c', 'src/dyn_macosx.c'])
endif
conf_data.set_quoted('PCSC_ARCH', pcsc_arch)
features += pcsc_arch
features += target_machine.cpu()
features += 'ipcdir=' + get_option('ipcdir')
features += 'usbdropdir=' + get_option('usbdropdir')
features += 'serialconfdir=' + get_option('serialconfdir')
# generate PCSCLITE_FEATURES
conf_data.set('PCSCLITE_FEATURES', '"' + ' '.join(features) + '"')
executable('pcscd',
sources : pcscd_src,
include_directories : incdir,
dependencies : pcscd_dep,
c_args: '-DPCSCD',
export_dynamic : true,
install_dir : sbindir,
install : true)
# libpcsclite_real library
libpcsclite_real_src = [
'src/debug.c',
'src/winscard_clnt.c',
'src/simclist.c',
'src/sys_unix.c',
'src/utils.c',
'src/winscard_msg.c'
]
library('pcsclite_real',
libpcsclite_real_src,
include_directories : incdir,
dependencies : threads_dep,
c_args: '-DLIBPCSCLITE -DSIMCLIST_NO_DUMPRESTORE',
soversion : 1,
install : true)
# libpcsclite library
libpcsclite_src = [
'src/error.c',
'src/libredirect.c',
'src/sys_unix.c'
]
libpcsclite = library('pcsclite',
libpcsclite_src,
dependencies : dl_deps,
include_directories : incdir,
soversion : 1,
install : true)
# libpcsclite_fake library
library('pcsclite_fake',
sources : 'src/libfake.c',
include_directories : incdir)
# libpcscspy library
library('pcscspy',
sources : ['src/spy/libpcscspy.c', 'src/sys_unix.c'],
dependencies : dl_deps,
include_directories : incdir,
soversion : 0,
install : true)
install_data('src/spy/pcsc-spy',
install_dir : get_option('bindir'))
install_data('src/spy/setup_spy.sh',
install_dir : 'share/doc/pcsc-lite')
run_command('pod2man',
['--date=2024-01-01', 'src/spy/pcsc-spy.pod', 'pcsc-spy.1'],
check : true)
install_data('pcsc-spy.1',
install_dir : join_paths(get_option('mandir'), 'man1'))
# testpcsc program
executable('testpcsc',
sources : 'src/testpcsc.c',
include_directories : incdir,
link_with : libpcsclite)
executable('pcsc_demo',
sources : 'doc/example/pcsc_demo.c',
include_directories : incdir,
link_with : libpcsclite)
# PC/SC headers
install_headers(
['src/PCSC/debuglog.h',
'src/PCSC/ifdhandler.h',
'src/PCSC/reader.h',
'src/PCSC/winscard.h',
'src/PCSC/wintypes.h'],
install_dir : get_option('includedir') / 'PCSC')
# data
if get_option('polkit')
install_data('doc/org.debian.pcsc-lite.policy',
install_dir : polkit_dep.get_variable('policydir'))
endif
install_data('etc/fr.apdu.pcsclite.metainfo.xml',
install_dir : 'share/metainfo'
)
install_data('etc/pcscd',
install_dir : 'etc/default'
)
# generate config.h
configure_file(output : 'config.h',
configuration : conf_data)
# generate from .in files
configure_file(output : 'pcsclite.h',
input : 'src/PCSC/pcsclite.h.in',
install_dir : get_option('prefix') / get_option('includedir') / 'PCSC',
configuration : confgen_data)
configure_file(output : 'pcscd.h',
input : 'src/pcscd.h.in',
configuration : confgen_data)
if get_option('libsystemd')
systemd = dependency('systemd')
unit = get_option('systemdunit')
systemdsystemunitdir = systemd.get_variable(pkgconfig : 'systemd' + unit + 'unitdir')
configure_file(output : 'pcscd.socket',
input : 'etc/pcscd.socket.in',
install_dir : systemdsystemunitdir,
configuration : confgen_data)
configure_file(output : 'pcscd.service',
input : 'etc/pcscd.service.in',
install_dir : systemdsystemunitdir,
configuration : confgen_data)
endif
configure_file(output : 'pcscd.8',
input : 'doc/pcscd.8.in',
install_dir : join_paths(get_option('mandir'), 'man8'),
configuration : confgen_data)
if get_option('serial')
configure_file(output : 'reader.conf.5',
input : 'doc/reader.conf.5.in',
install_dir : join_paths(get_option('mandir'), 'man5'),
configuration : confgen_data)
endif
# pkg-config libpcsclite.pc
pkg = import('pkgconfig')
pkg.generate(
libraries : '-L${libdir} -lpcsclite',
libraries_private : '-pthread',
subdirs : 'PCSC',
version : meson.project_version(),
name : 'PCSC Lite',
filebase : 'libpcsclite',
variables : [
'usbdropdir=' + conf_data.get_unquoted('PCSCLITE_HP_DROPDIR'),
'serialconfdir=' + get_option('serialconfdir')],
description : 'PC/SC smart card interface')
# generate documentation
configure_file(output : 'doxygen.conf',
input : 'doc/doxygen.conf.in',
configuration : confgen_data)
doxygen = find_program('doxygen', required : false)
if doxygen.found()
message('Doxygen found')
run_target('doc', command : [doxygen, 'doxygen.conf'])
else
warning('Documentation disabled without doxygen')
endif