From 3f3a96c80893d755254c73a69dad057e6bfcb523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Thu, 22 Feb 2018 14:22:22 +0100 Subject: [PATCH] build: Port to meson build system meson is a build system focused on speed an ease of use, which helps speeding up the software development. This patch adds meson support along autotools. --- actions/meson.build | 10 ++ data/meson.build | 65 ++++++++ docs/man/meson.build | 36 ++++ docs/meson.build | 39 +++++ docs/polkit/meson.build | 31 ++++ meson.build | 363 +++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 21 +++ meson_post_install.py | 34 ++++ po/meson.build | 1 + src/examples/meson.build | 26 +++ src/meson.build | 18 ++ src/polkit/meson.build | 128 +++++++++++++++ src/polkitagent/meson.build | 122 ++++++++++++++ src/polkitbackend/meson.build | 72 ++++++++ src/programs/meson.build | 16 ++ src/symbol.map | 6 + test/meson.build | 29 ++++ test/polkit/meson.build | 23 +++ test/polkitbackend/meson.build | 20 +++ 19 files changed, 1060 insertions(+) create mode 100644 actions/meson.build create mode 100644 data/meson.build create mode 100644 docs/man/meson.build create mode 100644 docs/meson.build create mode 100644 docs/polkit/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 meson_post_install.py create mode 100644 po/meson.build create mode 100644 src/examples/meson.build create mode 100644 src/meson.build create mode 100644 src/polkit/meson.build create mode 100644 src/polkitagent/meson.build create mode 100644 src/polkitbackend/meson.build create mode 100644 src/programs/meson.build create mode 100644 src/symbol.map create mode 100644 test/meson.build create mode 100644 test/polkit/meson.build create mode 100644 test/polkitbackend/meson.build diff --git a/actions/meson.build b/actions/meson.build new file mode 100644 index 0000000..bb570b4 --- /dev/null +++ b/actions/meson.build @@ -0,0 +1,10 @@ +policy = 'org.freedesktop.policykit.policy' + +custom_target( + policy, + input: policy + '.in', + output: policy, + command: intltool_xml_cmd, + install: true, + install_dir: pk_actiondir +) diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..8939559 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,65 @@ +service_conf = configuration_data() +service_conf.set('libprivdir', pk_pkglibdir) + +service = 'org.freedesktop.PolicyKit1.service' + +configure_file( + input: service + '.in', + output: service, + configuration: service_conf, + install: true, + install_dir: dbus_sys_dir +) + +dbus_conf = configuration_data() +dbus_conf.set('polkitd_user', polkitd_user) + +dbus = 'org.freedesktop.PolicyKit1.conf' + +configure_file( + input: dbus + '.in', + output: dbus, + configuration: dbus_conf, + install: true, + install_dir: dbus_conf_dir +) + +if enable_pam + pam_conf = configuration_data() + pam_conf.set('PAM_FILE_INCLUDE_AUTH', pam_file_include_auth) + pam_conf.set('PAM_FILE_INCLUDE_ACCOUNT', pam_file_include_account) + pam_conf.set('PAM_FILE_INCLUDE_PASSWORD', pam_file_include_password) + pam_conf.set('PAM_FILE_INCLUDE_SESSION', pam_file_include_session) + + pam = 'polkit-1' + + configure_file( + input: pam + '.in', + output: pam, + configuration: pam_conf, + install: true, + install_dir: join_paths(pk_sysconfdir, 'pam.d') + ) +endif + +its_data = files( + 'polkit.its', + 'polkit.loc' +) + +install_data( + its_data, + install_dir: join_paths(pk_datadir, 'gettext', 'its') +) + +if enable_systemd + service = 'polkit.service' + + configure_file( + input: service + '.in', + output: service, + configuration: service_conf, + install: true, + install_dir: systemd_system_unit_dir + ) +endif diff --git a/docs/man/meson.build b/docs/man/meson.build new file mode 100644 index 0000000..8496cab --- /dev/null +++ b/docs/man/meson.build @@ -0,0 +1,36 @@ +xsltproc = find_program('xsltproc', required: false) +assert(xsltproc.found(), 'xsltproc is required for man pages generation') + +xsltproc_cmd = [ + xsltproc, + '--output', '@OUTPUT@', + '--nonet', + '--stringparam', 'man.base.url.for.relative.links', pk_api_docpath + '/', + 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl', + '@INPUT@' +] + +mans = [ + ['polkit', '8'], + ['polkitd', '8'], + ['pkexec', '1'], + ['pkcheck', '1'], + ['pkaction', '1'], + ['pkttyagent', '1'] +] + +foreach man: mans + xml = files(man[0] + '.xml') + content_files += xml + + output = '@0@.@1@'.format(man[0], man[1]) + + custom_target( + output, + input: xml, + output: output, + command: xsltproc_cmd, + install: true, + install_dir: join_paths(pk_mandir, 'man' + man[1]) + ) +endforeach diff --git a/docs/meson.build b/docs/meson.build new file mode 100644 index 0000000..ae1f77d --- /dev/null +++ b/docs/meson.build @@ -0,0 +1,39 @@ +extensiondir_conf = configuration_data() +extensiondir_conf.set('libdir', pk_libdir) + +extensiondir = 'extensiondir.xml' + +content_files += configure_file( + input: extensiondir + '.in', + output: extensiondir, + configuration: extensiondir_conf +) + +version_conf = configuration_data() +version_conf.set('VERSION', pk_version) + +version = 'version.xml' + +content_files += configure_file( + input: version + '.in', + output: version, + configuration: version_conf +) + +html_images = files( + 'polkit-architecture.png', + 'polkit-authentication-agent-example.png', + 'polkit-authentication-agent-example-wheel.png' +) + +pk_api_docpath = join_paths(pk_prefix, gnome.gtkdoc_html_dir(pk_api_name)) + +enable_man = get_option('man') +if enable_man + subdir('man') +endif + +enable_gtk_doc = get_option('gtk_doc') +if enable_gtk_doc + subdir('polkit') +endif diff --git a/docs/polkit/meson.build b/docs/polkit/meson.build new file mode 100644 index 0000000..43d5ea9 --- /dev/null +++ b/docs/polkit/meson.build @@ -0,0 +1,31 @@ +doc_module = pk_api_name + +private_headers = [ + 'polkitagenthelperprivate.h', + 'polkitprivate.h' +] + +content_files += files( + 'docbook-interface-org.freedesktop.PolicyKit1.AuthenticationAgent.xml', + 'docbook-interface-org.freedesktop.PolicyKit1.Authority.xml' +) + +gnome.gtkdoc( + doc_module, + main_xml: doc_module + '-docs.xml', + src_dir: [ + join_paths(meson.source_root(), 'src', 'polkit'), + join_paths(meson.source_root(), 'src', 'polkitagent'), + ], + dependencies: libpolkit_agent_dep, + scan_args: [ + '--rebuild-types', + '--ignore-headers=' + ' '.join(private_headers), + ], + mkdb_args: '--name-space=' + meson.project_name(), + html_assets: html_images, + fixxref_args: '--html-dir=' + pk_api_docpath, + gobject_typesfile: files(doc_module + '.types'), + content_files: content_files, + install: true +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..ea893ca --- /dev/null +++ b/meson.build @@ -0,0 +1,363 @@ +project( + 'polkit', ['c', 'cpp'], + version: '0.114', + license: 'LGPL2+', + default_options: [ + 'buildtype=debugoptimized', + 'c_std=c99' + #'werror=true' + ], + meson_version: '>= 0.44.0' +) + +pk_version = meson.project_version() + +pk_api_version = '1' +pk_api_name = '@0@-@1@'.format(meson.project_name(), pk_api_version) + +pk_gir_ns = 'Polkit' +pk_gir_version = '1.0' + +pk_prefix = get_option('prefix') +pk_bindir = join_paths(get_option('prefix'), get_option('bindir')) +pk_datadir = join_paths(pk_prefix, get_option('datadir')) +pk_includedir = join_paths(pk_prefix, get_option('includedir')) +pk_libdir = join_paths(pk_prefix, get_option('libdir')) +pk_mandir = join_paths(pk_prefix, get_option('mandir')) +pk_sysconfdir = join_paths(pk_prefix, get_option('sysconfdir')) + +pk_pkgdatadir = join_paths(pk_datadir, pk_api_name) +pk_pkgincludedir = join_paths(pk_includedir, pk_api_name) +pk_pkglibdir = join_paths(pk_libdir, pk_api_name) +pk_pkgsysconfdir = join_paths(pk_sysconfdir, pk_api_name) + +pk_actiondir = join_paths(pk_pkgdatadir, 'actions') + +soversion = 0 +current = 0 +revision = 0 +libversion = '@0@.@1@.@2@'.format(soversion, current, revision) + +pk_gettext = pk_api_name + +cc = meson.get_compiler('c') + +config_h = configuration_data() + +# defines +set_defines = [ + # package + ['PACKAGE_BUGREPORT', 'http://lists.freedesktop.org/mailman/listinfo/polkit-devel'], + ['PACKAGE_NAME', meson.project_name()], + ['PACKAGE_URL', 'http://www.freedesktop.org/wiki/Software/polkit'], + ['PACKAGE_VERSION', pk_version], + ['VERSION', pk_version], + # i18n + ['GETTEXT_PACKAGE', pk_gettext] +] + +foreach define: set_defines + config_h.set_quoted(define[0], define[1]) +endforeach + +# functions +check_functions = [ + 'clearenv', + 'fdatasync' +] + +foreach func: check_functions + config_h.set('HAVE_' + func.underscorify().to_upper(), cc.has_function(func)) +endforeach + +# compiler flags +common_flags = ['-DHAVE_CONFIG_H'] +compiler_flags = [] + +if get_option('buildtype').contains('debug') + test_cflags = [ + '-Waggregate-return', + '-Wdeclaration-after-statement', + '-Wformat=2', + '-Wimplicit-function-declaration', + '-Winit-self', + '-Wmissing-declarations', + '-Wmissing-include-dirs', + '-Wmissing-prototypes', + '-Wstrict-prototypes' + ] + + compiler_flags += cc.get_supported_arguments(test_cflags) +endif + +add_project_arguments(common_flags + compiler_flags, language: 'c') + +version_script_ldflag = '-Wl,--version-script' +have_version_script = host_machine.system().contains('linux') and cc.has_argument(version_script_ldflag) + +glib_min_version = '2.30' +glib_max_version = '2.34' + +glib_dep = declare_dependency( + dependencies: [ + dependency('gio-unix-2.0', version: '>= ' + glib_min_version), + dependency('gmodule-2.0') + ], + compile_args: [ + '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_' + glib_min_version.underscorify(), + '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_' + glib_max_version.underscorify() + ] +) + +expat_dep = dependency('expat') +assert(cc.has_header('expat.h', dependencies: expat_dep), 'Can\'t find expat.h. Please install expat.') +assert(cc.has_function('XML_ParserCreate', dependencies: expat_dep), 'Can\'t find expat library. Please install expat.') + +mozjs_dep = dependency('mozjs-24') + +dbus_dep = dependency('dbus-1', required: false) + +dbus_conf_dir = get_option('dbus_conf_dir') +if dbus_conf_dir == '' + assert(dbus_dep.found(), 'D-Bus required but not found, please provide a valid system bus config dir') + dbus_conf_dir = join_paths(dbus_dep.get_pkgconfig_variable('sysconfdir'), 'dbus-1', 'system.d') +endif + +dbus_sys_dir = get_option('dbus_sys_dir') +if dbus_sys_dir == '' + assert(dbus_dep.found(), 'D-Bus required but not found, please provide a valid system bus services dir') + dbus_sys_dir = dbus_dep.get_pkgconfig_variable('system_bus_services_dir') +endif + +# check OS +host_system = host_machine.system() +config_h.set('HAVE_' + host_system.to_upper(), true) + +# Check whether setnetgrent has a return value +config_h.set('HAVE_NETGROUP_H', cc.has_header('netgroup.h')) + +setnetgrent_return_src = ''' + #include + #ifdef HAVE_NETGROUP_H + #include + #else + #include + #endif + int main() { + int r = setnetgrent (NULL); + }; +''' + +config_h.set('HAVE_SETNETGRENT_RETURN', cc.compiles(setnetgrent_return_src, name: 'setnetgrent return support')) + +# Select wether to use libsystemd-login or ConsoleKit for session tracking +enable_systemd = get_option('systemd') +if enable_systemd + libsystemd_dep = dependency('libsystemd', required: false) + if not libsystemd_dep.found() + libsystemd_dep = dependency('libsystemd-login', required: false) + assert(libsystemd_dep.found(), 'libsystemd support requested but libsystemd or libsystemd-login library not found') + endif + session_tracking = 'libsystemd-login' + + func = 'sd_uid_get_display' + config_h.set10('HAVE_' + func.underscorify().to_upper(), cc.has_function(func, dependencies: libsystemd_dep)) + + # systemd unit / service files + systemd_system_unit_dir = get_option('systemdsystemunitdir') + if systemd_system_unit_dir == '' + systemd_dep = dependency('systemd', required: false) + assert(systemd_dep.found(), 'systemd required but not found, please provide a valid systemd user unit dir or disable it') + systemd_system_unit_dir = systemd_dep.get_pkgconfig_variable('systemdsystemunitdir') + endif +else + session_tracking = 'ConsoleKit' +endif + +# User for running polkitd +polkitd_user = get_option('polkitd_user') +config_h.set_quoted('POLKITD_USER', polkitd_user) + +# Select which authentication framework to use +enable_pam = false +auth_deps = [] + +auth_fw = get_option('authfw') +if auth_fw == 'pam' + # Check for PAM + pam_dep = cc.find_library('pam') + assert(pam_dep.found() and cc.has_function('pam_start', dependencies: pam_dep), 'Could not find pam/pam-devel, please install the needed packages.') + + # how to call pam_strerror + pam_strerror_src = ''' + #include + #include + #include + #endif + int main() { + @0@ + }; + ''' + + # FIXME: Not necessary anymore? + if cc.compiles(pam_strerror_src.format('pam_handle_t *pamh = 0; char *s = pam_strerror(pamh, PAM_SUCCESS);')) + # FIXME: unused? + config_h.set('PAM_STRERROR_TWO_ARGS', true) + elif cc.compiles(pam_strerror_src.format('char *s = pam_strerror(PAM_SUCCESS);')) + message('how to call pam_strerror: 1') + else + message('how to call pam_strerror: unknown') + endif + + pam_prefix = get_option('pam_prefix') + if pam_prefix == '' + pam_prefix = pk_sysconfdir + else + message('PAM files will be installed in prefix ' + pam_prefix) + endif + + pam_module_dir = get_option('pam_module_dir') + if pam_module_dir == '' + pam_module_dir = join_paths(pk_libdir, 'security') + endif + + enable_pam = true + auth_deps += pam_dep +elif auth_fw == 'shadow' + auth_deps += cc.find_library('crypt') +endif +config_h.set('POLKIT_AUTHFW_' + auth_fw.to_upper(), true) + +# FIXME: sigtimedwait is not used anywhere? +''' +if host_system == 'solaris' + rt_dep = cc.find_library('rt') + cc.has_function('sigtimedwait', dependencies: rt_dep) +else + cc.has_function('sigtimedwait') +endif +''' + +os_type = get_option('os_type') +if os_type == '' + if run_command('test', '-e', '/etc/sysconfig/network-scripts').returncode() == 0 + os_type = 'redhat' + elif run_command('test', '-e', '/etc/SuSE-release').returncode() == 0 + os_type = 'suse' + elif run_command('test', '-e', '/etc/debian_version').returncode() == 0 + os_type = 'debian' + elif run_command('test', '-e', '/etc/gentoo-release').returncode() == 0 + os_type = 'gentoo' + elif run_command('test', '-e', '/etc/pardus-release').returncode() == 0 + os_type = 'pardus' + else + message('Linux distribution autodetection failed, specify the distribution to target using -Dos_type=') + endif +endif + +pam_include = get_option('pam_include') + +if pam_include == '' + if ['suse', 'solaris'].contains(os_type) + pam_file_include_auth = 'common-auth' + pam_file_include_account = 'common-account' + pam_file_include_password = 'common-password' + pam_file_include_session = 'common-session' + elif os_type.contains('bsd') + pam_file_include_auth = 'system' + pam_file_include_account = 'system' + pam_file_include_password = 'system' + pam_file_include_session = 'system' + #if ['redhat', 'gentoo', 'pardus'].contains(os_type) + else + pam_file_include_auth = 'system-auth' + pam_file_include_account = 'system-auth' + pam_file_include_password = 'system-auth' + pam_file_include_session = 'system-auth' + endif +else + pam_file_include_auth = pam_include + pam_file_include_account = pam_include + pam_file_include_password = pam_include + pam_file_include_session = pam_include +endif + +enable_introspection = get_option('introspection') +if enable_introspection + gir_dep = dependency('gobject-introspection-1.0', version: '>= 0.6.2') +endif + +gnome = import('gnome') +i18n = import('i18n') +pkg = import('pkgconfig') + +data_dir = join_paths(meson.source_root(), 'data') +po_dir = join_paths(meson.source_root(), 'po') + +intltool_merge = find_program('intltool-merge') +intltool_cache = join_paths(po_dir, '.intltool-merge-cache') +intltool_desktop_cmd = [intltool_merge, '-d', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@'] +intltool_xml_cmd = [intltool_merge, '-x', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@'] + +top_inc = include_directories('.', 'src') + +content_files = files('COPYING') + +subdir('actions') +subdir('data') +subdir('src') +subdir('docs') +subdir('po') + +enable_tests = get_option('tests') +if enable_tests + subdir('test') +endif + +configure_file( + output: 'config.h', + configuration: config_h +) + +meson.add_install_script( + 'meson_post_install.py', + pk_bindir, + pk_pkgdatadir, + pk_pkglibdir, + pk_pkgsysconfdir, + polkitd_user +) + +output = '\n ' + meson.project_name() + ' ' + meson.project_version() + '\n' +output += ' ============\n\n' +output += ' prefix: ' + pk_prefix + '\n' +output += ' datadir: ' + pk_datadir + '\n\n' +output += ' includedir: ' + pk_includedir + '\n' +output += ' libdir: ' + pk_libdir + '\n' +output += ' sysconfdir: ' + pk_sysconfdir + '\n' +output += ' source code location: ' + meson.source_root() + '\n' +output += ' compiler: ' + cc.get_id() + '\n' +output += ' cflags: ' + ' '.join(compiler_flags) + '\n\n' +if enable_man + output += ' xsltproc: ' + xsltproc.path() + '\n' +endif +output += ' introspection: ' + enable_introspection.to_string() + '\n' +output += ' Distribution/OS: ' + os_type + '\n' +output += ' Authentication framework: ' + auth_fw + '\n' +output += ' Session tracking: ' + session_tracking + '\n' +if enable_systemd + output += ' systemdsystemunitdir: ' + systemd_system_unit_dir + '\n' +endif +output += ' polkitd user: ' + polkitd_user + ' \n' +output += ' PAM support: ' + enable_pam.to_string() + '\n\n' +if enable_pam + output += ' PAM file auth: ' + pam_file_include_auth + '\n' + output += ' PAM file acount: ' + pam_file_include_account + '\n' + output += ' PAM file password: ' + pam_file_include_password + '\n' + output += ' PAM file session: ' + pam_file_include_session + '\n\n' +endif +output += ' Building api docs: ' + enable_gtk_doc.to_string() + '\n' +output += ' Building man pages: ' + enable_man.to_string() + '\n' +output += ' Building examples: ' + enable_examples.to_string() + '\n' +output += ' Building tests: ' + enable_tests.to_string() +message(output) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..6e9f3fd --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,21 @@ +option('dbus_conf_dir', type: 'string', value: '', description: 'where D-Bus system.d directory is') +option('dbus_sys_dir', type: 'string', value: '', description: 'where D-Bus system service directory is') + +option('systemd', type: 'boolean', value: true, description: 'Use libsystemd') +option('systemdsystemunitdir', type: 'string', value: '', description: 'custom directory for systemd system units') + +option('polkitd_user', type: 'string', value: 'polkitd', description: 'User for running polkitd (polkitd)') + +option('authfw', type: 'combo', choices: ['pam', 'shadow', 'bsdauth'], value: 'pam', description: 'Authentication framework (pam/shadow)') +option('os_type', type: 'combo', choices: ['redhat', 'suse', 'gentoo', 'pardus', 'solaris', 'netbsd', ''], value: '', description: 'distribution or OS') + +option('pam_include', type: 'string', value: '', description: 'pam file to include') +option('pam_module_dir', type: 'string', value: '', description: 'directory to install PAM security module') +option('pam_prefix', type: 'string', value: '', description: 'specify where pam files go') + +option('examples', type: 'boolean', value: false, description: 'Build example programs') +option('tests', type: 'boolean', value: false, description: 'Build tests') +option('introspection', type: 'boolean', value: true, description: 'Enable introspection for this build') + +option('gtk_doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation') +option('man', type: 'boolean', value: false, description: 'build manual pages') diff --git a/meson_post_install.py b/meson_post_install.py new file mode 100644 index 0000000..a365195 --- /dev/null +++ b/meson_post_install.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import os +import subprocess +import sys + +destdir = os.environ.get('DESTDIR', '') + +bindir = os.path.normpath(destdir + os.sep + sys.argv[1]) +pkgdatadir = os.path.normpath(destdir + os.sep + sys.argv[2]) +pkglibdir = os.path.normpath(destdir + os.sep + sys.argv[3]) +pkgsysconfdir = os.path.normpath(destdir + os.sep + sys.argv[4]) + +polkitd_user = sys.argv[5] + +subprocess.call(['chmod', '4755', os.path.join(bindir, 'pkexec')]) + +dst_dirs = [ + os.path.join(pkgsysconfdir, 'rules.d'), + os.path.join(pkgdatadir, 'rules.d') +] + +for dst in dst_dirs: + if not os.path.exists(dst): + os.makedirs(dst) + subprocess.call(['chmod', '700', dst]) + subprocess.call(['chown', polkitd_user, dst]) + +# polkit-agent-helper-1 need to be setuid root because it's used to +# authenticate not only the invoking user, but possibly also root +# and/or other users. +dst = os.path.join(pkglibdir, 'polkit-agent-helper-1') +subprocess.call(['chown', 'root', dst]) +subprocess.call(['chmod', '4755', dst]) diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..4d9ab58 --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext(pk_api_name, preset: 'glib') diff --git a/src/examples/meson.build b/src/examples/meson.build new file mode 100644 index 0000000..497fc5e --- /dev/null +++ b/src/examples/meson.build @@ -0,0 +1,26 @@ +policy = 'org.freedesktop.policykit.examples.pkexec.policy' + +custom_target( + policy, + input: policy + '.in', + output: policy, + command: intltool_xml_cmd, + install: true, + install_dir: pk_actiondir +) + +program = 'cancel' + +executable( + program, + program + '.c', + include_directories: top_inc, + dependencies: libpolkit_gobject_dep +) + +executable( + 'pk-example-frobnicate', + 'frobnicate.c', + dependencies: glib_dep, + install: true +) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..2c8c365 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,18 @@ +src_inc = include_directories('.') + +symbol_map = join_paths(meson.current_source_dir(), 'symbol.map') + +ldflags = [] +if have_version_script + ldflags += version_script_ldflag + ',@0@'.format(symbol_map) +endif + +subdir('polkit') +subdir('polkitbackend') +subdir('polkitagent') +subdir('programs') + +enable_examples = get_option('examples') +if enable_examples + subdir('examples') +endif diff --git a/src/polkit/meson.build b/src/polkit/meson.build new file mode 100644 index 0000000..dd1dee6 --- /dev/null +++ b/src/polkit/meson.build @@ -0,0 +1,128 @@ +name = '@0@-gobject-@1@'.format(meson.project_name(), pk_api_version) + +enum_headers = files( + 'polkitauthorityfeatures.h', + 'polkitcheckauthorizationflags.h', + 'polkiterror.h', + 'polkitimplicitauthorization.h' +) + +headers = enum_headers + files( + 'polkitactiondescription.h', + 'polkitauthority.h', + 'polkitauthorizationresult.h', + 'polkitdetails.h', + 'polkit.h', + 'polkitidentity.h', + 'polkitpermission.h', + 'polkitsubject.h', + 'polkitsystembusname.h', + 'polkittemporaryauthorization.h', + 'polkitunixgroup.h', + 'polkitunixnetgroup.h', + 'polkitunixprocess.h', + 'polkitunixsession.h', + 'polkitunixuser.h' +) + +private_headers = files( + 'polkitprivate.h', + 'polkittypes.h', +) + +install_headers( + headers + private_headers, + install_dir: join_paths(pk_pkgincludedir, 'polkit') +) + +enum_types = 'polkitenumtypes' + +enum_sources = gnome.mkenums( + enum_types, + sources: enum_headers, + h_template: enum_types + '.h.template', + c_template: enum_types + '.c.template', + install_header: true, + install_dir: join_paths(pk_pkgincludedir, 'polkit') +) + +sources = enum_sources + files( + 'polkitactiondescription.c', + 'polkitauthority.c', + 'polkitauthorityfeatures.c', + 'polkitauthorizationresult.c', + 'polkitcheckauthorizationflags.c', + 'polkitdetails.c', + 'polkiterror.c', + 'polkitidentity.c', + 'polkitimplicitauthorization.c', + 'polkitpermission.c', + 'polkitsubject.c', + 'polkitsystembusname.c', + 'polkittemporaryauthorization.c', + 'polkitunixgroup.c', + 'polkitunixnetgroup.c', + 'polkitunixprocess.c', + 'polkitunixuser.c' +) + +deps = [glib_dep] + +cflags = '-D_POLKIT_COMPILATION' + +if enable_systemd + sources += 'polkitunixsession-systemd.c' + + deps += libsystemd_dep +else + sources += 'polkitunixsession.c' +endif + +libpolkit_gobject = shared_library( + name, + sources: sources, + version: libversion, + include_directories: top_inc, + dependencies: deps, + c_args: cflags, + link_args: ldflags, + link_depends: symbol_map, + install: true +) + +libpolkit_gobject_dep = declare_dependency( + sources: enum_sources[1], + include_directories: include_directories('.'), + dependencies: glib_dep, + link_with: libpolkit_gobject +) + +pkg.generate( + libraries: libpolkit_gobject, + version: pk_version, + name: name, + description: 'PolicyKit Authorization API', + filebase: name, + subdirs: pk_api_name, + requires: ['gio-2.0 >= 2.18', 'glib-2.0 >= 2.18'], + variables: [ + 'exec_prefix=' + pk_prefix, + 'policydir=' + pk_actiondir, + 'actiondir=' + pk_actiondir, + 'pkcheck_supports_uid=true' + ] +) + +if enable_introspection + libpolkit_gobject_gir = gnome.generate_gir( + libpolkit_gobject, + sources: sources + headers, + extra_args: cflags, + nsversion: pk_gir_version, + namespace: pk_gir_ns, + export_packages: name, + includes: 'Gio-2.0', + header: join_paths('polkit', 'polkit.h'), + install: true + ) +endif diff --git a/src/polkitagent/meson.build b/src/polkitagent/meson.build new file mode 100644 index 0000000..65947f4 --- /dev/null +++ b/src/polkitagent/meson.build @@ -0,0 +1,122 @@ +name = '@0@-agent-@1@'.format(meson.project_name(), pk_api_version) + +enum_headers = files('polkitagentlistener.h') + +headers = enum_headers + files( + 'polkitagent.h', + 'polkitagentsession.h', + 'polkitagenttextlistener.h', + 'polkitagenttypes.h' +) + +install_headers( + headers, + install_dir: join_paths(pk_pkgincludedir, 'polkitagent') +) + +enum_types = 'polkitagentenumtypes' + +enum_sources = gnome.mkenums( + enum_types, + sources: enum_headers, + h_template: enum_types + '.h.template', + c_template: enum_types + '.c.template', + install_header: true, + install_dir: join_paths(pk_pkgincludedir, 'polkitagent') +) + +marshal = 'polkitagentmarshal' + +marshal_sources = gnome.genmarshal( + marshal, + sources: marshal + '.list', + prefix: '_polkit_agent_marshal' +) + +sources = enum_sources + marshal_sources + files( + 'polkitagentlistener.c', + 'polkitagentsession.c', + 'polkitagenttextlistener.c' +) + +deps = [ + expat_dep, + libpolkit_gobject_dep +] + +cflags = [ + '-D_POLKIT_COMPILATION', + '-D_POLKIT_AGENT_COMPILATION', + '-DPACKAGE_PREFIX="@0@"'.format(pk_prefix) +] + +libpolkit_agent = shared_library( + name, + sources: sources, + version: libversion, + include_directories: top_inc, + dependencies: deps, + c_args: cflags, + link_args: ldflags, + link_depends: symbol_map, + install: true +) + +libpolkit_agent_dep = declare_dependency( + sources: enum_sources[1], + include_directories: include_directories('.'), + dependencies: libpolkit_gobject_dep, + link_with: libpolkit_agent +) + +pkg.generate( + libraries: libpolkit_agent, + version: pk_version, + name: name, + description: 'PolicyKit Authentication Agent API', + filebase: name, + subdirs: pk_api_name, + requires: ['polkit-gobject-1'], + variables: 'exec_prefix=' + pk_prefix +) + +if enable_introspection + incs = [ + 'Gio-2.0', + libpolkit_gobject_gir[0] + ] + + cflags = [ + '-D_POLKIT_AGENT_COMPILATION', + '-D_POLKIT_COMPILATION', + ] + + gnome.generate_gir( + libpolkit_agent, + sources: sources + headers, + includes: incs, + extra_args: cflags, + nsversion: pk_gir_version, + namespace: 'PolkitAgent', + export_packages: name, + header: join_paths('polkitagent', 'polkitagent.h'), + install: true + ) +endif + +sources = files( + 'polkitagenthelperprivate.c', + 'polkitagenthelper-@0@.c'.format(auth_fw) +) + +deps = auth_deps + [libpolkit_gobject_dep] + +executable( + '@0@-agent-helper-@1@'.format(meson.project_name(), pk_api_version), + sources, + include_directories: top_inc, + dependencies: deps, + c_args: '-D_POLKIT_COMPILATION', + install: true, + install_dir: pk_pkglibdir +) diff --git a/src/polkitbackend/meson.build b/src/polkitbackend/meson.build new file mode 100644 index 0000000..73a7705 --- /dev/null +++ b/src/polkitbackend/meson.build @@ -0,0 +1,72 @@ +name = '@0@-backend-@1@'.format(meson.project_name(), pk_api_version) + +sources = files( + 'polkitbackendactionlookup.c', + 'polkitbackendactionpool.c', + 'polkitbackendauthority.c', + 'polkitbackendinteractiveauthority.c', + 'polkitbackendjsauthority.cpp' +) + +output = 'initjs.h' + +sources += custom_target( + output, + input: 'init.js', + output: output, + capture: true, + command: [find_program('perl'), join_paths(meson.current_source_dir(), 'toarray.pl'), '@INPUT@', 'init_js'] +) + +deps = [ + expat_dep, + libpolkit_gobject_dep, + mozjs_dep +] + +cflags = [ + '-D_POLKIT_COMPILATION', + '-D_POLKIT_BACKEND_COMPILATION', + '-DPACKAGE_DATA_DIR="@0@"'.format(pk_datadir), + '-DPACKAGE_SYSCONF_DIR="@0@"'.format(pk_sysconfdir) +] + +if enable_systemd + sources += files('polkitbackendsessionmonitor-systemd.c') + + deps += libsystemd_dep +else + sources += files('polkitbackendsessionmonitor.c') +endif + +libpolkit_backend = static_library( + name, + sources: sources, + include_directories: top_inc, + dependencies: deps, + c_args: cflags, + cpp_args: cflags +) + +install_data( + '50-default.rules', + install_dir: join_paths(pk_pkgsysconfdir, 'rules.d') +) + +program = 'polkitd' + +cflags = [ + '-DG_LOG_DOMAIN="@0@-@1@"'.format(program, pk_api_version), + '-DPOLKIT_BACKEND_I_KNOW_API_IS_SUBJECT_TO_CHANGE' +] + +executable( + program, + program + '.c', + include_directories: top_inc, + dependencies: libpolkit_gobject_dep, + c_args: cflags, + link_with: libpolkit_backend, + install: true, + install_dir: pk_pkglibdir +) diff --git a/src/programs/meson.build b/src/programs/meson.build new file mode 100644 index 0000000..0da0dbf --- /dev/null +++ b/src/programs/meson.build @@ -0,0 +1,16 @@ +programs = [ + ['pkexec', auth_deps + [libpolkit_agent_dep]], + ['pkcheck', [libpolkit_agent_dep]], + ['pkaction', [libpolkit_gobject_dep]], + ['pkttyagent', [libpolkit_agent_dep]] +] + +foreach program: programs + executable( + program[0], + program[0] + '.c', + include_directories: top_inc, + dependencies: program[1], + install: true + ) +endforeach diff --git a/src/symbol.map b/src/symbol.map new file mode 100644 index 0000000..2d38225 --- /dev/null +++ b/src/symbol.map @@ -0,0 +1,6 @@ +{ +global: + polkit_*; +local: + *; +}; diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..e4ae801 --- /dev/null +++ b/test/meson.build @@ -0,0 +1,29 @@ +libpolkit_test_helper = static_library( + 'polkit-test-helper', + sources: 'polkittesthelper.c', + include_directories: top_inc, + dependencies: glib_dep +) + +libpolkit_test_helper_dep = declare_dependency( + include_directories: include_directories('.'), + dependencies: glib_dep, + link_with: libpolkit_test_helper +) + +subdir('polkit') +subdir('polkitbackend') + +# FIXME: All mocklibc side is missing +''' +SUBDIRS = mocklibc + +# Use mocklibc to override NSS services for tests +export MOCK_PASSWD := $(abs_top_srcdir)/test/data/etc/passwd +export MOCK_GROUP := $(abs_top_srcdir)/test/data/etc/group +export MOCK_NETGROUP := $(abs_top_srcdir)/test/data/etc/netgroup +export TESTS_ENVIRONMENT := $(abs_top_builddir)/test/mocklibc/bin/mocklibc + +# Include path to mock config files +export POLKIT_TEST_DATA := $(abs_top_srcdir)/test/data +''' diff --git a/test/polkit/meson.build b/test/polkit/meson.build new file mode 100644 index 0000000..d14ceeb --- /dev/null +++ b/test/polkit/meson.build @@ -0,0 +1,23 @@ +test_units = [ + 'polkitunixusertest', + 'polkitunixgrouptest', + 'polkitunixnetgrouptest', + 'polkitidentitytest' +] + +cflags = [ + '-D_POLKIT_COMPILATION', + '-D_POLKIT_BACKEND_COMPILATION' +] + +foreach test_unit: test_units + exe = executable( + test_unit, + test_unit + '.c', + include_directories: src_inc, + dependencies: libpolkit_gobject_dep, + c_args: cflags + ) + + test(test_unit, exe) +endforeach diff --git a/test/polkitbackend/meson.build b/test/polkitbackend/meson.build new file mode 100644 index 0000000..4bcf109 --- /dev/null +++ b/test/polkitbackend/meson.build @@ -0,0 +1,20 @@ +test_unit = 'test-polkitbackendjsauthority' + +cflags = [ + '-D_POLKIT_COMPILATION', + '-D_POLKIT_BACKEND_COMPILATION' +] + +deps = [ + libpolkit_gobject_dep, + libpolkit_test_helper_dep +] + +exe = executable( + test_unit, + test_unit + '.c', + include_directories: top_inc, + dependencies: deps, + c_args: cflags, + link_with: libpolkit_backend +) -- 2.16.1