-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a969360
commit 4dd76e5
Showing
3 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
# for ninja: | ||
# meson setup builddir | ||
# cd builddir ; meson compile | ||
|
||
# regenerate configuration (run from builddir/) | ||
# meson setup --reconfigure --wipe | ||
|
||
project('ccid', 'c', | ||
version : '1.5.6') | ||
|
||
# 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'), | ||
}) | ||
|
||
# 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') | ||
|
||
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 : '@[email protected]', | ||
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/simclist.c', | ||
] | ||
parse_src += gen_src | ||
|
||
executable('parse', | ||
parse_src, | ||
include_directories : ['src'], | ||
dependencies : [libusb_dep, pcsc_cflags, zlib_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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
option('extra_bundle_id', | ||
type : 'string', | ||
value : '', | ||
description : 'appended to the name of the bundle directory') | ||
|
||
option('class', | ||
type : 'boolean', | ||
value : 'true', | ||
description : 'enable the CCIDCLASSDRIVER in Info.plist') | ||
|
||
option('composite-as-multislot', | ||
type : 'boolean', | ||
value : 'false', | ||
description : 'composite device are seen as multi-slots') | ||
|
||
option('embedded', | ||
type : 'boolean', | ||
value : 'false', | ||
description : 'for embedded systems [limit RAM and CPU resources by disabling features (log)]') | ||
|
||
option('os_log', | ||
type : 'boolean', | ||
value : 'false', | ||
description : 'use os_log(3) instead of printf() for debug (Sierra 10.12 and up)]') | ||
|
||
option('pcsclite', | ||
type : 'boolean', | ||
value : 'true', | ||
description : 'use pcsc-lite debug support') | ||
|
||
option('serial', | ||
type : 'boolean', | ||
value : 'false', | ||
description : 'enable the driver for the serial CCID readers') | ||
|
||
option('zlp', | ||
type : 'boolean', | ||
value : 'false', | ||
description : 'enable the Zero Length Packet patch for some Gemalto readers') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
meson.options |