-
-
Notifications
You must be signed in to change notification settings - Fork 79
/
meson.build
202 lines (180 loc) · 4.97 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
# for ninja:
# meson setup builddir
# cd builddir ; meson compile
# regenerate configuration (run from builddir/)
# meson setup --reconfigure --wipe
project('ccid', 'c',
meson_version : '>=0.58.0',
version : '1.6.1')
# for config.h
conf_data = configuration_data({
'VERSION' : '"' + meson.project_version() + '"',
'ENABLE_ZLP' : get_option('zlp'),
'NO_LOG' : get_option('embedded'),
'USE_OS_LOG' : get_option('os_log'),
'USE_COMPOSITE_AS_MULTISLOT' : get_option('composite-as-multislot'),
})
# global arguments
add_global_arguments('-fvisibility=hidden', language : 'c')
# tests for functions
compiler = meson.get_compiler('c')
if compiler.has_function('strlcpy')
conf_data.set('HAVE_STRLCPY', true)
endif
if compiler.has_function('strlcat')
conf_data.set('HAVE_STRLCAT', true)
endif
if compiler.has_function('secure_getenv')
conf_data.set('HAVE_SECURE_GETENV', true)
endif
# variables
bundle_id = 'ifd-ccid.bundle'
extra_bundle_id = get_option('extra_bundle_id')
if extra_bundle_id != ''
bundle_id = 'ifd-ccid-' + extra_bundle_id + '.bundle'
else
endif
dyn_lib_ext = '.so'
pcsc_dep = dependency('libpcsclite')
pcsc_cflags = pcsc_dep.partial_dependency(compile_args : true)
libusb_dep = dependency('libusb-1.0')
zlib_dep = dependency('zlib')
threads_dep = dependency('threads')
r = run_command('uname', check: true)
pcsc_arch = r.stdout().strip()
if pcsc_arch == 'Darwin'
pcsc_arch = 'MacOS'
dyn_lib_ext = '.dylib'
libusb_dep = dependency('libusb-1.0', static : true)
endif
# flex generator
gen_flex = generator(find_program('flex'),
output : '@BASENAME@.c',
arguments : ['-o', '@OUTPUT@', '--prefix=@BASENAME@', '@INPUT@'])
conf_data.set_quoted('PCSCLITE_HP_DROPDIR', pcsc_dep.get_variable('usbdropdir'))
conf_data.set_quoted('BUNDLE', bundle_id)
# libccid
libccid_src = [
'src/ccid.c',
'src/ccid_usb.c',
'src/commands.c',
'src/ifdhandler.c',
'src/simclist.c',
'src/strlcpy.c',
'src/sys_unix.c',
'src/utils.c',
'src/openct/buffer.c',
'src/openct/checksum.c',
'src/openct/proto-t1.c',
'src/towitoko/atr.c',
'src/towitoko/pps.c',
]
gen_src = gen_flex.process('src/tokenparser.l')
libccid_src += gen_src
if not get_option('pcsclite')
libccid_src += 'src/debug.c'
endif
library('ccid',
libccid_src,
c_args : ['-DSIMCLIST_NO_DUMPRESTORE'],
override_options : ['b_lundef=false'],
include_directories : ['src'],
dependencies : [libusb_dep, pcsc_cflags],
install : true,
install_dir : join_paths(pcsc_dep.get_variable('usbdropdir'), bundle_id, 'Contents', pcsc_arch))
if get_option('serial')
# libccidtwin
libccidtwin_src = [
'src/ccid.c',
'src/ccid_serial.c',
'src/commands.c',
'src/ifdhandler.c',
'src/simclist.c',
'src/strlcpy.c',
'src/sys_unix.c',
'src/utils.c',
'src/openct/buffer.c',
'src/openct/checksum.c',
'src/openct/proto-t1.c',
'src/towitoko/atr.c',
'src/towitoko/pps.c',
gen_src,
]
if not get_option('pcsclite')
libccidtwin_src += 'src/debug.c'
endif
libccidtwin_dir = join_paths(pcsc_dep.get_variable('usbdropdir'), 'serial')
library('ccidtwin',
libccidtwin_src,
c_args : ['-DSIMCLIST_NO_DUMPRESTORE', '-DTWIN_SERIAL'],
override_options : ['b_lundef=false'],
include_directories : ['src'],
dependencies : [pcsc_cflags],
install : true,
install_dir : libccidtwin_dir)
# reader.conf
conf_data.set('TARGET', join_paths(libccidtwin_dir, 'libccidtwin' + dyn_lib_ext))
configure_file(output : 'libccidtwin',
input : 'src/reader.conf.in',
install_dir : join_paths(get_option('sysconfdir'), 'reader.conf.d'),
configuration : conf_data)
endif
# parse
parse_src = [
'src/parse.c',
'src/debug.c',
'src/ccid_usb.c',
'src/sys_unix.c',
'src/strlcpy.c',
'src/simclist.c',
]
parse_src += gen_src
executable('parse',
parse_src,
include_directories : ['src'],
dependencies : [libusb_dep, pcsc_cflags, zlib_dep, threads_dep],
)
# scardcontrol
scardcontrol_src = [
'examples/scardcontrol.c',
'examples/PCSCv2part10.c',
]
executable('scardcontrol',
scardcontrol_src,
dependencies : [pcsc_dep],
)
# contrib Kobil_mIDentity_switch
executable('Kobil_mIDentity_switch',
'contrib/Kobil_mIDentity_switch/Kobil_mIDentity_switch.c',
dependencies : [libusb_dep],
)
# contrib RSA_SecurID_getpasswd
executable('RSA_SecurID_getpasswd',
'contrib/RSA_SecurID/RSA_SecurID_getpasswd.c',
dependencies : [pcsc_dep],
)
# Info.plist
command = [
find_program('src/create_Info_plist.pl'),
files('readers/supported_readers.txt'),
'@INPUT@',
'--version=' + meson.project_version(),
'--target=libccid' + dyn_lib_ext
]
if not get_option('class')
command += '--no-class'
endif
if extra_bundle_id != ''
command += '--extra_bundle_id=.' + extra_bundle_id
endif
custom_target('Info.plist',
output : 'Info.plist',
input : 'src/Info.plist.src',
build_by_default : true,
capture : true,
command : command,
install : true,
install_dir : join_paths(pcsc_dep.get_variable('usbdropdir'), bundle_id, 'Contents'))
# generate config.h
configure_file(output : 'config.h',
configuration : conf_data)