diff options
author | Daiki Ueno <dueno@redhat.com> | 2019-05-15 13:09:25 +0200 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2019-06-18 14:17:28 +0200 |
commit | 4f956698b64ac6eb8e5e8b7d143ceb11f1133814 (patch) | |
tree | 95b8c43ebcddf75f04ac900523e35882a14ae4d4 /p11-kit/meson.build | |
parent | 411a7a6d31cd5584ff9837260d77d8c306d3b557 (diff) |
build: Add meson build support
This adds support for meson as an alternative build system.
Diffstat (limited to 'p11-kit/meson.build')
-rw-r--r-- | p11-kit/meson.build | 299 |
1 files changed, 299 insertions, 0 deletions
diff --git a/p11-kit/meson.build b/p11-kit/meson.build new file mode 100644 index 0000000..33e1683 --- /dev/null +++ b/p11-kit/meson.build @@ -0,0 +1,299 @@ +install_headers('deprecated.h', + 'iter.h', + 'p11-kit.h', + 'pin.h', + 'remote.h', + 'uri.h', + subdir: 'p11-kit-1/p11-kit') + +libp11_kit_internal_sources = [ + 'conf.c', + 'log.c', + 'filter.c', + 'rpc-transport.c', + 'rpc-message.c', + 'rpc-client.c' +] + +libp11_kit_internal_sources += custom_target('generate virtual-fixed-generated.h', + output: 'virtual-fixed-generated.h', + command: [ + meson.current_source_dir() / 'gen-virtual-fixed.sh', + '@OUTPUT@', '64' + ]) +libp11_kit_internal_sources += 'virtual.c' + +libp11_kit_internal_c_args = [ + '-DP11_SYSTEM_CONFIG_FILE="@0@"'.format(p11_system_config_file), + '-DP11_SYSTEM_CONFIG_MODULES="@0@"'.format(p11_system_config_modules), + '-DP11_PACKAGE_CONFIG_MODULES="@0@"'.format(p11_package_config_modules), + '-DP11_USER_CONFIG_FILE="@0@"'.format(p11_user_config_file), + '-DP11_USER_CONFIG_MODULES="@0@"'.format(p11_user_config_modules), + '-DP11_MODULE_PATH="@0@"'.format(p11_module_path) +] + +libp11_kit_internal = static_library('p11-kit-internal', + libp11_kit_internal_sources, + dependencies: [libp11_common_dep, + libp11_library_dep] + libffi_deps, + c_args: libp11_kit_internal_c_args, + implicit_include_directories: false, + gnu_symbol_visibility: 'hidden') + +libp11_kit_sources = [ + 'iter.c', + 'messages.c', + 'modules.c', + 'pin.c', + 'proxy.c', + 'proxy-init.c', + 'rpc-server.c', + 'uri.c', + 'util.c' +] + +libp11_kit_symbol_map = meson.current_source_dir() / 'libp11-kit.map' +libp11_kit_ldflags = cc.get_supported_link_arguments([ + '-Wl,--version-script,' + libp11_kit_symbol_map +]) +libp11_kit_symbol_def = meson.current_source_dir() / 'libp11-kit-@0@.dll.def'.format(soversion) + +libp11_kit = shared_library('p11-kit', + libp11_kit_sources, + install: true, + version: library_version, + soversion: soversion, + dependencies: libffi_deps + dlopen_deps, + include_directories: [configinc, commoninc], + implicit_include_directories: false, + c_args: libp11_kit_internal_c_args, + link_args: libp11_kit_ldflags, + link_depends: [libp11_kit_symbol_map, + libp11_kit_symbol_def], + link_with: libp11_kit_internal, + vs_module_defs: libp11_kit_symbol_def) + +libp11_kit_dep = declare_dependency(link_with: libp11_kit, + include_directories: [configinc, commoninc]) + +meson.add_install_script( + 'meson_post_install.sh', + libdir, + datadir / 'p11-kit' / 'modules' +) + +if host_system != 'windows' + shared_module('p11-kit-client', + 'client.c', 'client-init.c', + name_prefix: '', + include_directories: [configinc, commoninc], + link_with: [libp11_kit_internal]) +endif + +fixtures_dir = meson.current_source_dir() / 'fixtures' + +if host_system == 'windows' + libp11_kit_testable_c_args = [ + '-DP11_SYSTEM_CONFIG_FILE="@0@"'.format(fixtures_dir / 'system-pkcs11.conf'), + '-DP11_SYSTEM_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'system-modules' / 'win32'), + '-DP11_PACKAGE_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'package-modules' / 'win32'), + '-DP11_USER_CONFIG_FILE="@0@"'.format(fixtures_dir / 'user-pkcs11.conf'), + '-DP11_USER_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'user-modules' / 'win32') + ] +else + libp11_kit_testable_c_args = [ + '-DP11_SYSTEM_CONFIG_FILE="@0@"'.format(fixtures_dir / 'system-pkcs11.conf'), + '-DP11_SYSTEM_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'system-modules'), + '-DP11_PACKAGE_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'package-modules'), + '-DP11_USER_CONFIG_FILE="@0@"'.format(fixtures_dir / 'user-pkcs11.conf'), + '-DP11_USER_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'user-modules') + ] +endif + +libp11_kit_testable_c_args += '-DP11_MODULE_PATH="@0@"'.format(meson.current_build_dir()) + +libp11_kit_testable = static_library('p11-kit-testable', + libp11_kit_internal_sources, + libp11_kit_sources, + c_args: libp11_kit_testable_c_args, + implicit_include_directories: false, + dependencies: [libp11_common_dep, libp11_library_dep] + libffi_deps + dlopen_deps) + +p11_kit_sources = [ + 'lists.c', + 'p11-kit.c' +] + +executable('p11-kit', + p11_kit_sources, + c_args: common_c_args, + dependencies: [libp11_tool_dep, libp11_common_dep] + libffi_deps + dlopen_deps, + link_with: libp11_kit, + install: true) + +executable('p11-kit-remote', + 'remote.c', + c_args: common_c_args, + dependencies: [libp11_tool_dep, libp11_common_dep] + libffi_deps + dlopen_deps, + link_with: libp11_kit, + install: true, + install_dir: prefix / privatedir) + +executable('p11-kit-remote-testable', + 'remote.c', + c_args: common_c_args, + dependencies: [libp11_tool_dep, libp11_common_dep] + libffi_deps + dlopen_deps, + link_with: libp11_kit_testable) + +executable('p11-kit-server', + 'server.c', + c_args: common_c_args + [ + '-DP11_KIT_REMOTE="p11-kit-remote"' + ], + dependencies: [libp11_tool_dep, libp11_common_dep] + libsystemd_deps + libffi_deps + dlopen_deps, + implicit_include_directories: false, + link_with: libp11_kit, + install: true, + install_dir: prefix / privatedir) + +executable('p11-kit-server-testable', + 'server.c', + c_args: common_c_args + [ + '-DP11_KIT_REMOTE="p11-kit-remote-testable"' + ], + implicit_include_directories: false, + dependencies: [libp11_tool_dep, libp11_common_dep] + libsystemd_deps + libffi_deps + dlopen_deps, + link_with: libp11_kit_testable) + +# Check if compilation succeeds with CRYPTOKI_GNU=1 + +pkcs11_gnu_headers = [ + 'iter.h', + 'pin.h', + 'uri.h' +] + +gnu_h_gen = generator(find_program('gen-pkcs11-gnu.sh'), + output: 'pkcs11-gnu-@BASENAME@.h', + arguments: ['@INPUT@', '@OUTPUT@']) + +gnu_h = gnu_h_gen.process(pkcs11_gnu_headers) + +static_library('p11-kit-pkcs11-gnu', + gnu_h, + 'pkcs11-gnu.c', + include_directories: [configinc, commoninc]) + +# Tests ---------------------------------------------------------------- + +p11_kit_tests = [ + 'test-progname', + 'test-util', + 'test-conf', + 'test-uri', + 'test-pin', + 'test-init', + 'test-modules', + 'test-deprecated', + 'test-proxy', + 'test-iter', + 'test-rpc', + 'test-virtual', + 'test-managed', + 'test-log', + 'test-filter', + 'test-transport' +] + +if host_system != 'windows' + p11_kit_tests += 'test-server' +endif + +foreach name : p11_kit_tests + t = executable(name, '@0@.c'.format(name), + c_args: tests_c_args + libp11_kit_testable_c_args, + include_directories: [configinc, commoninc], + dependencies: [libp11_test_dep, libp11_common_dep] + libffi_deps + dlopen_deps + pthread_create_deps, + link_with: libp11_kit_testable) + test(name, t) +endforeach + +p11_kit_progs = [ + 'print-messages', + 'frob-setuid' +] + +foreach name : p11_kit_progs + t = executable(name, '@0@.c'.format(name), + c_args: tests_c_args, + include_directories: [configinc, commoninc], + dependencies: [libp11_test_dep, libp11_common_dep] + libffi_deps + dlopen_deps + pthread_create_deps, + link_with: libp11_kit_testable) +endforeach + +p11_kit_tests_env = environment() +p11_kit_tests_env.set('abs_top_builddir', top_build_dir) +p11_kit_tests_env.set('P11_MODULE_PATH', meson.current_build_dir()) + +if host_system != 'windows' + test('test-messages.sh', + find_program('test-messages.sh'), + env: p11_kit_tests_env) + + test('test-server.sh', + find_program('test-server.sh'), + env: p11_kit_tests_env) +endif + +mock_sources = { + 'mock-one': ['mock-module-ep.c'], + 'mock-two': ['mock-module-ep2.c'], + 'mock-three': ['mock-module-ep.c'], + 'mock-four': ['mock-module-ep.c'], + 'mock-five': ['mock-module-ep3.c'], + 'mock-seven': ['mock-module-ep5.c'], + 'mock-eight': ['mock-module-ep6.c'], + 'mock-nine': ['mock-module-ep7.c'] +} + +if host_system != 'windows' + mock_sources += {'mock-six': ['mock-module-ep4.c']} +endif + +foreach name, sources : mock_sources + shared_module(name, + sources, + name_prefix: '', + include_directories: [configinc, commoninc], + dependencies: [libp11_test_dep, libp11_common_dep]) +endforeach + +p11_kit_pc_variables = [ + 'p11_module_configs=@0@'.format(prefix / p11_package_config_modules), + 'p11_module_path=@0@'.format(prefix / p11_module_path), + 'proxy_module=@0@/p11-kit-proxy.so'.format(prefix / libdir), + 'p11_system_config_modules=@0@'.format(prefix / p11_package_config_modules) +] + +if trust_paths != '' + p11_kit_pc_variables += [ + 'p11_trust_paths=@0@'.format(trust_paths) + ] +endif + +pkg.generate(libraries: libp11_kit, + filebase: 'p11-kit-1', + name: 'p11-kit', + description: 'Library and proxy module for properly loading and sharing PKCS#11 modules.', + subdirs: 'p11-kit-1', + variables: p11_kit_pc_variables) + +pkcs11_conf_example_conf = configuration_data({ + 'p11_system_config_file': prefix / p11_system_config_file, + 'p11_user_config': prefix / p11_user_config +}) +pkcs11_conf_example = configure_file(input: 'pkcs11.conf.example.in', + output: '@BASENAME@', + configuration: pkcs11_conf_example_conf) +install_data(pkcs11_conf_example, + install_dir: prefix / p11_system_config) |