Commit 03637ad8 authored by Inigo Martínez's avatar Inigo Martínez Committed by Thomas Haller

build: add initial support for 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.

[thaller@redhat.com: rebased patch and adjusted for iwd support]

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00022.html
parent e96fabfc
#!/usr/bin/env python3
import errno
import os
import sys
for location in sys.argv[1:]:
if os.path.isfile(location):
sys.exit(0)
sys.exit(errno.ENOENT)
# FIXME: nmcli-completion should be renamed to nmcli
install_data(
'nmcli-completion',
install_dir: join_paths(nm_datadir, 'bash-completion', 'completions')
)
sources = files(
'agent.c',
'common.c',
'connections.c',
'devices.c',
'general.c',
'nmcli.c',
'polkit-agent.c',
'settings.c',
'utils.c'
)
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
libnm_dep,
libnmc_dep,
libnmc_base_dep,
readline_dep
]
cflags = [
'-DG_LOG_DOMAIN="nmcli"',
'-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir)
]
ldflags = []
if have_version_script
ldflags += '-Wl,--version-script,@0@'.format(linker_script_binary)
endif
if enable_polkit_agent
sources += nm_polkit_listener
deps += polkit_agent_dep
endif
executable(
'nmcli',
sources + [libnm_core_enums_h],
include_directories: incs,
dependencies: deps,
c_args: cflags,
link_args: ldflags,
link_depends: linker_script_binary,
install: true,
install_dir: nm_bindir
)
common_inc = include_directories('.')
nm_polkit_listener = files('nm-polkit-listener.c')
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
libnm_dep
]
cflags = [
'-DG_LOG_DOMAIN="libnmc"',
'-DNMLOCALEDIR="@0@"'.format(nm_localedir)
]
sources = shared_utils + files(
'nm-client-utils.c',
'nm-secret-agent-simple.c',
'nm-vpn-helpers.c'
)
libnmc_base = static_library(
'nmc-base',
sources: sources + [libnm_core_enums_h],
include_directories: incs,
dependencies: deps,
c_args: common_cflags
)
libnmc_base_dep = declare_dependency(
link_with: libnmc_base,
include_directories: common_inc
)
sources = shared_meta_setting + files(
'nm-meta-setting-access.c',
'nm-meta-setting-desc.c'
)
settings_docs = 'settings-docs.c'
# FIXME: there is a problem with the generated file
#if enable_introspection
if false
settings_docs_source = custom_target(
settings_docs,
input: nm_property_docs,
output: settings_docs,
command: [xsltproc, '--output', '@OUTPUT@', join_paths(meson.current_source_dir(), 'settings-docs.xsl'), '@INPUT@']
)
# FIXME: if enabled the check happens even if the settings_docs_source is not set
'''
if get_option('check_settings_docs')
res = run_command(find_program('cmp'), '-s', settings_docs + '.in', settings_docs_source.full_path())
if res.returncode() != 0
message('The generated file ' + settings_docs_source.full_path() + ' differs from the source file ' + settings_docs + '.in' + '. You probably should copy the generated file over to the source file. You can skip this test by setting -Dcheck_settings_docs=false')
endif
endif
'''
else
settings_docs_source = configure_file(
input: settings_docs + '.in',
output: settings_docs,
configuration: configuration_data()
)
endif
sources += settings_docs_source
libnmc = static_library(
'nmc',
sources: sources + [libnm_core_enums_h],
include_directories: incs,
dependencies: deps,
c_args: common_cflags,
link_with: libnmc_base,
link_depends: settings_docs_source
)
libnmc_dep = declare_dependency(
link_with: libnmc,
include_directories: common_inc
)
if (enable_introspection or enable_nmtui) and enable_tests
subdir('tests')
endif
test_unit = 'test-general'
name = 'client-' + test_unit
deps += [
libnmc_dep,
libnmc_base_dep
]
exe = executable(
name,
test_unit + '.c',
include_directories: incs,
dependencies: deps,
c_args: cflags
)
test(name, exe)
name = 'nm-online'
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
libnm_dep
]
cflags = [
'-DG_LOG_DOMAIN="@0@"'.format(name),
'-DNMLOCALEDIR="@0@"'.format(nm_localedir)
]
ldflags = []
if have_version_script
ldflags += '-Wl,--version-script,@0@'.format(linker_script_binary)
endif
executable(
name,
[name + '.c', libnm_core_enums_h],
include_directories: incs,
dependencies: deps,
c_args: cflags,
link_args: ldflags,
link_depends: linker_script_binary,
install: true,
install_dir: nm_bindir
)
subdir('common')
if enable_nmcli
subdir('cli')
endif
if enable_nmtui
subdir('tui')
endif
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
newt_dep
]
cflags = ['-DG_LOG_DOMAIN="nmtui"']
subdir('newt')
sources = files(
'nm-editor-bindings.c',
'nm-editor-utils.c',
'nmt-address-list.c',
'nmt-connect-connection-list.c',
'nmt-device-entry.c',
'nmt-edit-connection-list.c',
'nmt-editor.c',
'nmt-editor-grid.c',
'nmt-editor-page.c',
'nmt-editor-page-device.c',
'nmt-editor-section.c',
'nmt-ip-entry.c',
'nmt-mac-entry.c',
'nmt-mtu-entry.c',
'nmt-page-bond.c',
'nmt-page-bridge.c',
'nmt-page-bridge-port.c',
'nmt-page-dsl.c',
'nmt-page-ethernet.c',
'nmt-page-infiniband.c',
'nmt-page-ip4.c',
'nmt-page-ip6.c',
'nmt-page-ip-tunnel.c',
'nmt-page-ppp.c',
'nmt-page-team.c',
'nmt-page-team-port.c',
'nmt-page-vlan.c',
'nmt-page-wifi.c',
'nmt-password-dialog.c',
'nmt-password-fields.c',
'nmt-route-editor.c',
'nmt-route-entry.c',
'nmt-route-table.c',
'nmt-slave-list.c',
'nmtui.c',
'nmtui-connect.c',
'nmtui-edit.c',
'nmtui-hostname.c',
'nmt-utils.c',
'nmt-widget-list.c'
)
deps += [
libnm_dep,
libnmc_base_dep,
libnmt_newt_dep
]
cflags += '-DLOCALEDIR="@0@"'.format(nm_localedir)
ldflags = []
if have_version_script
ldflags += '-Wl,--version-script,@0@'.format(linker_script_binary)
endif
executable(
'nmtui',
sources + [libnm_core_enums_h],
include_directories: incs,
dependencies: deps,
c_args: cflags,
link_args: ldflags,
link_depends: linker_script_binary,
install: true,
install_dir: nm_bindir
)
sources = files(
'nmt-newt-button-box.c',
'nmt-newt-button.c',
'nmt-newt-checkbox.c',
'nmt-newt-component.c',
'nmt-newt-container.c',
'nmt-newt-entry.c',
'nmt-newt-entry-numeric.c',
'nmt-newt-form.c',
'nmt-newt-grid.c',
'nmt-newt-hacks.c',
'nmt-newt-label.c',
'nmt-newt-listbox.c',
'nmt-newt-popup.c',
'nmt-newt-section.c',
'nmt-newt-separator.c',
'nmt-newt-stack.c',
'nmt-newt-textbox.c',
'nmt-newt-toggle-button.c',
'nmt-newt-utils.c',
'nmt-newt-widget.c'
)
libnmt_newt = static_library(
'nmt-newt',
sources: sources + [libnm_core_enums_h],
include_directories: incs,
dependencies: deps,
c_args: cflags
)
libnmt_newt_dep = declare_dependency(
link_with: libnmt_newt,
include_directories: include_directories('.')
)
/* Define if building universal (internal helper macro) */
#mesondefine AC_APPLE_UNIVERSAL_BUILD
/* Path to ConsoleKit database */
#mesondefine CKDB_PATH
/* Define to path of dhclient binary */
#mesondefine DHCLIENT_PATH
/* Define to path of dhcpcanon binary */
#mesondefine DHCPCANON_PATH
/* Define to path of dhcpcd binary */
#mesondefine DHCPCD_PATH
/* Define if dhcpcd supports IPv6 (6.x+) */
#mesondefine DHCPCD_SUPPORTS_IPV6
/* Define to path of dnsmasq binary */
#mesondefine DNSMASQ_PATH
/* Define to path of unbound dnssec-trigger-script */
#mesondefine DNSSEC_TRIGGER_SCRIPT
/* Gettext package */
#mesondefine GETTEXT_PACKAGE
/* Define to 1 if you have the declaration of `explicit_bzero', and to 0 if
you don't. */
#mesondefine HAVE_DECL_EXPLICIT_BZERO
/* has getrandom */
#mesondefine HAVE_GETRANDOM
/* Define if you have libaudit support */
#mesondefine HAVE_LIBAUDIT
/* Define to 1 if libsystemd is available */
#mesondefine HAVE_LIBSYSTEMD
/* Define if nl80211 has critical protocol support */
#mesondefine HAVE_NL80211_CRITICAL_PROTOCOL_CMDS
/* Define to 1 if you have the `secure_getenv' function. */
#mesondefine HAVE_SECURE_GETENV
/* Define if you have SELinux support */
#mesondefine HAVE_SELINUX
/* Define to 1 if you have the <sys/auxv.h> header file. */
#mesondefine HAVE_SYS_AUXV_H
/* Define if systemd support is available */
#mesondefine HAVE_SYSTEMD
/* Define if you have VLAN_FLAG_LOOSE_BINDING */
#mesondefine HAVE_VLAN_FLAG_LOOSE_BINDING
/* Define if you have Linux Wireless Extensions support */
#mesondefine HAVE_WEXT
/* Define to 1 if you have the `__secure_getenv' function. */
#mesondefine HAVE___SECURE_GETENV
/* Enable Gentoo hostname persist method */
#mesondefine HOSTNAME_PERSIST_GENTOO
/* Enable Slackware hostname persist method */
#mesondefine HOSTNAME_PERSIST_SLACKWARE
/* Enable SuSE hostname persist method */
#mesondefine HOSTNAME_PERSIST_SUSE
/* Define to path of iptables binary */
#mesondefine IPTABLES_PATH
/* Define to path of the kernel firmware directory */
#mesondefine KERNEL_FIRMWARE_DIR
/* Path to netconfig */
#mesondefine NETCONFIG_PATH
/* The default value of the logging.audit configuration option */
#mesondefine NM_CONFIG_DEFAULT_LOGGING_AUDIT
/* Default configuration option for logging.backend */
#mesondefine NM_CONFIG_DEFAULT_LOGGING_BACKEND
/* The default value of the auth-polkit configuration option */
#mesondefine NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT
/* Default configuration option for main.dhcp setting */
#mesondefine NM_CONFIG_DEFAULT_MAIN_DHCP
/* Default configuration option for main.plugins setting */
#mesondefine NM_CONFIG_DEFAULT_MAIN_PLUGINS
/* Default value for main.rc-manager setting */
#mesondefine NM_CONFIG_DEFAULT_MAIN_RC_MANAGER
/* Define the distribution version string */
#mesondefine NM_DIST_VERSION
/* Define if more asserts are enabled */
#mesondefine NM_MORE_ASSERTS
/* Define if more debug logging is enabled */
#mesondefine NM_MORE_LOGGING
/* Define to the full name and version of this package. */
#mesondefine PACKAGE_STRING
/* Path to resolvconf */
#mesondefine RESOLVCONF_PATH
/* Define to 1 if ConsoleKit is available */
#mesondefine SESSION_TRACKING_CONSOLEKIT
/* Define to 1 if libelogin is available */
#mesondefine SESSION_TRACKING_ELOGIND
/* Define to 1 if libsystemd-login is available */
#mesondefine SESSION_TRACKING_SYSTEMD
/* The size of `dev_t', as computed by sizeof. */
#mesondefine SIZEOF_DEV_T
/* The size of `time_t', as computed by sizeof. */
#mesondefine SIZEOF_TIME_T
/* Define to 1 to use ConsoleKit2 suspend api */
#mesondefine SUSPEND_RESUME_CONSOLEKIT
/* Define to 1 to use elogind suspend api */
#mesondefine SUSPEND_RESUME_ELOGIND
/* Define to 1 to use systemd suspend api */
#mesondefine SUSPEND_RESUME_SYSTEMD
/* Define to 1 to use UPower suspend api */
#mesondefine SUSPEND_RESUME_UPOWER
/* Define to 1 if libsystemd-journald is available */
#mesondefine SYSTEMD_JOURNAL
/* Define to path to system CA certificates */
#mesondefine SYSTEM_CA_PATH
/* Define python path for test binary */
#mesondefine TEST_NM_PYTHON
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
/* sys/random.h is usable */
#mesondefine USE_SYS_RANDOM_H
/* Version number of package */
#mesondefine VERSION
/* Define if you have Bluez 5 libraries */
#mesondefine WITH_BLUEZ5_DUN
/* Define if you want connectivity checking support */
#mesondefine WITH_CONCHECK
/* Define if you have dhclient */
#mesondefine WITH_DHCLIENT
/* Define if you have dhcpcanon */
#mesondefine WITH_DHCPCANON
/* Define if you have dhcpcd */
#mesondefine WITH_DHCPCD
/* Define for libnm to prevent GIR from loading libnm-glib */
#mesondefine WITH_FAKE_TYPELIBS
/* Define if JANSSON is enabled */
#mesondefine WITH_JANSSON
/* Define if JSON validation in libnm is enabled */
#mesondefine WITH_JSON_VALIDATION
/* Define if you have libpsl */
#mesondefine WITH_LIBPSL
/* Define if you have oFono support (experimental) */
#mesondefine WITH_OFONO
/* whether to compile polkit support */
#mesondefine WITH_POLKIT
/* Define if you have polkit agent */
#mesondefine WITH_POLKIT_AGENT
/* Define if you have PPP support */
#mesondefine WITH_PPP
/* Whether compilation of ibft setting plugin is enabled */
#mesondefine WITH_SETTINGS_PLUGIN_IBFT
/* Define if you have Wi-Fi support */
#mesondefine WITH_WIFI
/* Define if you have iwd support */
#mesondefine WITH_IWD
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
# endif
#endif
/* Define to 1 if on MINIX. */
#mesondefine _MINIX
/* Define whether the compiler support gcc __auto_type */
#mesondefine _NM_CC_SUPPORT_AUTO_TYPE
/* Define whether the compiler supports C11 _Generic() */
#mesondefine _NM_CC_SUPPORT_GENERIC
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#mesondefine _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#mesondefine _POSIX_SOURCE
/* Define to `int' if <sys/types.h> does not define. */
#mesondefine pid_t
data_conf = configuration_data()
data_conf.set('bindir', nm_bindir)
data_conf.set('libexecdir', nm_libexecdir)
data_conf.set('sbindir', nm_sbindir)
data_conf.set('sysconfdir', nm_sysconfdir)
data_conf.set('DISTRO_NETWORK_SERVICE', (enable_ifcfg_rh ? 'network.service' : ''))
data_conf.set('NM_MODIFY_SYSTEM_POLICY', (enable_modify_system ? 'yes' : 'auth_admin_keep'))
server = 'server.conf'
configure_file(
input: server + '.in',
output: server,
install: true,
install_dir: join_paths(nm_datadir, 'doc', nm_name, 'examples'),
configuration: data_conf
)
if install_systemd_unit_dir
services = [
['NetworkManager-dispatcher.service', systemd_system_unit_dir],
['NetworkManager.service', systemd_system_unit_dir],
['org.freedesktop.NetworkManager.service', dbus_sys_dir]
]
if have_systemd_200
services += [['NetworkManager-wait-online.service', systemd_system_unit_dir]]
else
services += [['NetworkManager-wait-online-systemd-pre200.service', systemd_system_unit_dir]]
endif
foreach service: services
configure_file(
input: service[0] + '.in',
output: service[0],
install: true,
install_dir: service[1],
configuration: data_conf
)
endforeach
if enable_ovs
install_data(
'NetworkManager-ovs.conf',
install_dir: join_paths(systemd_system_unit_dir, 'NetworkManager.service.d')
)
endif
endif
if install_udev_dir
data = files(
'84-nm-drivers.rules',
'85-nm-unmanaged.rules'
)
install_data(
data,
install_dir: join_paths(udev_dir, 'rules.d')
)
endif
if enable_polkit
policy = 'org.freedesktop.NetworkManager.policy'
policy_in = configure_file(
input: policy + '.in.in',
output: policy + '.in',
configuration: data_conf
)
custom_target(
policy,
input: policy_in,
output: policy,
command: intltool_xml_cmd,
install: true,
install_dir: polkit_dir
)
endif
dispatcher_inc = include_directories('.')
name = 'nm-dispatcher'
service_conf = configuration_data()
service_conf.set('sbindir', nm_sbindir)
service_conf.set('sysconfdir', nm_sysconfdir)
service_conf.set('localstatedir', nm_localstatedir)
service_conf.set('libexecdir', nm_libexecdir)
service = 'org.freedesktop.nm_dispatcher.service'
configure_file(
input: service + '.in',
output: service,
install: true,
install_dir: dbus_sys_dir,
configuration: service_conf
)
install_data(
'nm-dispatcher.conf',
install_dir: dbus_conf_dir
)
sources = files('nm-dispatcher-utils.c')
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
libnm_dep
]
cflags = [
'-DLIBEXECDIR="@0@"'.format(nm_libexecdir),
'-DSYSCONFDIR="@0@"'.format(nm_sysconfdir),
'-DNMCONFDIR="@0@"'.format(nm_pkgconfdir)
]
libnm_dispatcher_core = static_library(
name + '-core',
sources: sources,
include_directories: incs,
dependencies: deps,
c_args: cflags
)
sources = files('nm-dispatcher.c')
sources += gnome.gdbus_codegen(
'nmdbus-dispatcher',
name + '.xml',
interface_prefix: 'org.freedesktop',
namespace: 'NMDBus'
)
ldflags = []
if have_version_script
ldflags += '-Wl,--version-script,@0@'.format(linker_script_binary)
endif
executable(
name,
sources,
include_directories: incs,
dependencies: deps,
c_args: cflags,
link_with: libnm_dispatcher_core,
link_args: ldflags,
link_depends: linker_script_binary,
install: true,