Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add support for meson #3128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Checks: '-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling'
WarningsAsErrors: '-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling'
HeaderFilterRegex: '.*'
UseColor: 'true'
Empty file added MacOSX/meson.build
Empty file.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,8 @@ if test "${enable_sm}" = "yes"; then
esac
fi

AC_DEFINE([ENABLE_PKCS11], [1], [Enable building of PKCS#11 library])

if test "${with_pkcs11_provider}" = "detect"; then
if test "${WIN32}" != "yes"; then
DEFAULT_PKCS11_PROVIDER="${libdir}/opensc-pkcs11${DYN_LIB_EXT}"
Expand Down
76 changes: 76 additions & 0 deletions doc/files/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
if progxsltproc.found() and stylesheets_path != ''
xml1 = configure_file(
configuration: {
'sysconfdir': absolute_sysconfdir,
'docdir': absolute_docdir,
'libdir': absolute_libdir / '',
'DYN_LIB_EXT': '.' + extension_of_libraries,
'DEFAULT_PCSC_PROVIDER': conf.get_unquoted('DEFAULT_PCSC_PROVIDER'),
'PROFILE_DIR_DEFAULT': (host_machine.system() == 'windows' or host_machine.system() == 'cygwin')?
'obtained from windows registers' : absolute_pkgdir,
'DEFAULT_SM_MODULE': conf.get_unquoted('DEFAULT_SM_MODULE')
},
input: 'opensc.conf.5.xml.in',
output: 'opensc.conf.5.xml'
)

custom_target(
command: [progxsltproc,
'--nonet',
'--path', meson.project_source_root() / 'doc' + ':' + stylesheets_path / 'manpages',
'--xinclude',
'-o', '@OUTPUT@',
'man.xsl',
'@INPUT@'
],
input: xml1,
output: modfs.stem(xml1),
build_by_default: get_option('man'),
install: get_option('man'),
install_dir: get_option('mandir') / 'man5'
)

xml2 = configure_file(
configuration: {'pkgdatadir': absolute_pkgdir},
input: 'pkcs15-profile.5.xml.in',
output: 'pkcs15-profile.5.xml'
)

custom_target(
command: [progxsltproc,
'--nonet',
'--path', meson.project_source_root() / 'doc' + ':' + stylesheets_path / 'manpages',
'--xinclude',
'-o', '@OUTPUT@',
'man.xsl',
'@INPUT@'
],
input: xml2,
output: modfs.stem(xml2),
build_by_default: get_option('man'),
install: get_option('man'),
install_dir: get_option('mandir') / 'man5'
)

custom_target(
command: [progxsltproc,
'--nonet',
'--path', meson.project_build_root() / 'doc' / 'files' + ':' +
meson.project_source_root() / 'doc' + ':' +
stylesheets_path / 'html',
'--xinclude',
'-o', '@OUTPUT@',
'html.xsl',
'@INPUT@'
],
input: 'files.xml',
output: 'files.html',
depend_files: [xml1, xml2],
build_by_default: get_option('doc'),
install: get_option('doc'),
install_dir: absolute_docdir
)

unset_variable('xml1')
unset_variable('xml2')
endif
38 changes: 38 additions & 0 deletions doc/tools/generate_completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
if [ ! $# -eq 3 ]; then
echo "Usage: template description.1.xml generated_completion"
exit 1
fi
if [ ! -r "$1" ]; then
echo "The file \"$1\" does not exist or is not readable"
exit 2
fi
if [ ! -r "$2" ]; then
echo "The file \"$2\" does not exist or is not readable"
exit 3
fi

ALLOPTS=$(sed -n 's,.*<option>\([^<]*\)</option>.*,\1,pg' "$2" | sort -u | grep '^-' | tr '\n' ' ')

OPTSWITHARGS=$(sed -n 's,.*<option>\([^<]*\)</option>.*<replaceable>.*,\1,pg' "$2" | sort -u | grep '^-' | tr '\n' '|' | sed 's,|$$,,' | grep ^ || echo "!*")

FILEOPTS=$(sed -n 's,.*<option>\([^<]*\)</option>.*<replaceable>.*filename.*,\1,pg' "$2" | sort -u | grep '^-' | tr '\n' '|' | sed 's,|$$,,' | grep ^ || echo "!*")

PINOPTS=$(sed -En 's,.*<option>([^<]*)</option>.*<replaceable>\s*(newpin|pin|puk|sopin|sopuk)\s*<.*,\1,pg' "$2" | sort -u | grep '^-' | tr '\n' '|' | sed 's,|$$,,' | grep ^ || echo "!*")

MODULEOPTS=$(sed -n 's,.*<option>\([^<]*\)</option>.*<replaceable>.*mod.*,\1,pg' "$2" | sort -u | grep '^-' | tr '\n' '|' | sed 's,|$$,,' | grep ^ || echo "!*")

FUNCTION_NAME=$(basename "$3" | sed s,-,_,g)

PROGRAM_NAME=$(basename "$3")

cat "$1" \
| sed "s,ALLOPTS,${ALLOPTS}," \
| sed "s,OPTSWITHARGS,${OPTSWITHARGS}," \
| sed "s,FILEOPTS,${FILEOPTS}," \
| sed "s,PINOPTS,${PINOPTS}," \
| sed "s,MODULEOPTS,${MODULEOPTS}," \
| sed "s,FUNCTION_NAME,${FUNCTION_NAME}," \
| sed "s,PROGRAM_NAME,${PROGRAM_NAME}," \
> "$3"

exit 0
93 changes: 93 additions & 0 deletions doc/tools/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
sources = [
'cardos-tool.1.xml',
'dnie-tool.1.xml',
'dtrust-tool.1.xml',
'egk-tool.1.xml',
'eidenv.1.xml',
'goid-tool.1.xml',
'iasecc-tool.1.xml',
'openpgp-tool.1.xml',
'opensc-asn1.1.xml',
'opensc-explorer.1.xml',
'opensc-tool.1.xml',
'pkcs11-register.1.xml',
'pkcs11-tool.1.xml',
'pkcs15-crypt.1.xml',
'pkcs15-tool.1.xml'
]

if conf.get('ENABLE_OPENSSL')
sources += [
'cryptoflex-tool.1.xml',
'gids-tool.1.xml',
'netkey-tool.1.xml',
'piv-tool.1.xml',
'pkcs15-init.1.xml',
'sc-hsm-tool.1.xml',
'westcos-tool.1.xml'
]

if conf.get('ENABLE_OPENPACE')
sources += [
'npa-tool.1.xml'
]
endif
endif

if conf.get('ENABLE_NOTIFY')
sources += [
'opensc-notify.1.xml'
]
endif

if progxsltproc.found() and stylesheets_path != ''
foreach xml : sources
custom_target(
command: [progxsltproc,
'--nonet',
'--path', meson.project_source_root() / 'doc' + ':' + stylesheets_path / 'manpages',
'--xinclude',
'-o', '@OUTPUT@',
'man.xsl',
'@INPUT@'
],
input: xml,
output: modfs.replace_suffix(xml, ''),
build_by_default: get_option('man'),
install: get_option('man'),
install_dir: get_option('mandir') / 'man1'
)
endforeach

custom_target(
command: [progxsltproc,
'--nonet',
'--path', meson.project_source_root() / 'doc' + ':' + stylesheets_path / 'html',
'--xinclude',
'-o', '@OUTPUT@',
'html.xsl',
'@INPUT@'
],
input: 'tools.xml',
output: 'tools.html',
depend_files: sources,
build_by_default: get_option('doc'),
install: get_option('doc'),
install_dir: absolute_docdir
)
endif

if bash_completion_path != ''
foreach xml : sources
custom_target(
command: ['generate_completion.sh', '@INPUT0@', '@INPUT1@', '@OUTPUT@'],
input: ['completion-template', xml],
output: modfs.replace_suffix(modfs.replace_suffix(xml, ''), ''),
build_by_default: get_option('bash_completion'),
install: get_option('bash_completion'),
install_dir: bash_completion_path
)
endforeach
endif

unset_variable('sources')
40 changes: 40 additions & 0 deletions etc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
install_data(
'opensc.conf',
install_dir: get_option('sysconfdir')
)

if conf.get('ENABLE_OPENPACE')
install_data(
'DESRCACC100001',
'DESCHSMCVCA00001',
install_dir: conf.get_unquoted('CVCDIR')
)
endif

if get_option('doc')
conf_etc = configuration_data()
conf_etc.set('LIBDIR', absolute_libdir / '')
conf_etc.set('DEFAULT_PCSC_PROVIDER', conf.get_unquoted('DEFAULT_PCSC_PROVIDER'))
conf_etc.set('DEFAULT_SM_MODULE', conf.get_unquoted('DEFAULT_SM_MODULE'))
conf_etc.set('DEFAULT_SM_MODULE_PATH', conf.get_unquoted('DEFAULT_SM_MODULE_PATH'))
conf_etc.set('DYN_LIB_EXT', '.' + extension_of_libraries)
conf_etc.set('LIB_PRE', prefix_of_libraries)

if host_machine.system() == 'windows' or host_machine.system() == 'cygwin'
conf_etc.set('DEBUG_FILE', '%TEMP%\\opensc-debug.log')
conf_etc.set('PROFILE_DIR_DEFAULT', 'obtained from windows registers')
conf_etc.set('PROFILE_DIR', '')
else
conf_etc.set('DEBUG_FILE', '/tmp/opensc-debug.log')
conf_etc.set('PROFILE_DIR_DEFAULT', absolute_pkgdir)
conf_etc.set('PROFILE_DIR', absolute_pkgdir)
endif

configure_file(
configuration: conf_etc,
input: 'opensc.conf.example.in',
output: 'opensc.conf',
install: true,
install_dir: absolute_docdir
)
endif