Commit 1c1168d4 authored by Iñigo Martínez's avatar Iñigo Martínez Committed by Thomas Haller

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.

https://bugzilla.gnome.org/show_bug.cgi?id=788146
parent d1b7b6a8
......@@ -153,6 +153,8 @@ iconscalable_DATA = \
icons/scalable/nm-no-connection.svg
EXTRA_DIST += $(iconscalable_DATA)
EXTRA_DIST += icons/meson.build
###############################################################################
shared_files = \
......@@ -160,7 +162,6 @@ shared_files = \
shared/nm-utils/nm-shared-utils.h \
$(NULL)
noinst_LTLIBRARIES += src/utils/libutils-libnm.la
src_utils_libutils_libnm_la_CPPFLAGS = \
......@@ -213,6 +214,8 @@ src_utils_tests_test_utils_LDADD = \
$(GTK_LIBS) \
$(LIBNM_LIBS)
EXTRA_DIST += src/utils/meson.build
###############################################################################
src/wireless-security/ws-resources.h: src/wireless-security/ws.gresource.xml
......@@ -325,7 +328,8 @@ EXTRA_DIST += \
src/wireless-security/ws-wep-key.ui \
src/wireless-security/ws-wpa-eap.ui \
src/wireless-security/ws-wpa-psk.ui \
src/wireless-security/ws.gresource.xml
src/wireless-security/ws.gresource.xml \
src/wireless-security/meson.build
###############################################################################
......@@ -456,6 +460,7 @@ EXTRA_DIST += \
src/libnm-gtk/check-exports.sh \
src/libnm-gtk/wifi.ui \
src/libnm-gtk/nm.gresource.xml \
src/libnm-gtk/meson.build \
\
src/libnm-gtk/tests/iso3166-test.xml \
src/libnm-gtk/tests/serviceproviders-test.xml \
......@@ -586,7 +591,8 @@ EXTRA_DIST += \
src/libnma/wifi.ui \
src/libnma/nma-pkcs11-token-login-dialog.ui \
src/libnma/nma-pkcs11-cert-chooser-dialog.ui \
src/libnma/nma.gresource.xml
src/libnma/nma.gresource.xml \
src/libnma/meson.build
###############################################################################
......@@ -747,7 +753,8 @@ EXTRA_DIST += \
src/connection-editor/ce-ppp-auth-methods.ui \
src/connection-editor/nm-connection-editor.ui \
src/connection-editor/nm-connection-list.ui \
src/connection-editor/ce.gresource.xml
src/connection-editor/ce.gresource.xml \
src/connection-editor/meson.build
###############################################################################
......@@ -850,7 +857,8 @@ EXTRA_DIST += \
src/8021x.ui \
src/gsm-unlock.ui \
src/info.ui \
src/applet.gresource.xml
src/applet.gresource.xml \
src/meson.build
###############################################################################
......@@ -864,6 +872,7 @@ EXTRA_DIST += \
shared/nm-utils/nm-vpn-editor-plugin-call.h \
shared/nm-default.h \
shared/nm-libnm-compat.h \
shared/meson.build \
$(NULL)
###############################################################################
......@@ -872,6 +881,8 @@ man_MANS += \
man/nm-applet.1 \
man/nm-connection-editor.1
EXTRA_DIST += man/meson.build
###############################################################################
DOC_MODULE = libnma
......@@ -923,7 +934,15 @@ EXTRA_DIST += \
intltool-merge.in \
intltool-update.in \
Makefile.glib \
autogen.sh
autogen.sh \
meson.build \
meson_options.txt \
meson_post_install.py \
config.h.meson \
gtkdocentities.ent.in \
\
po/meson.build
autostartdir = $(sysconfdir)/xdg/autostart
autostart_in_files = nm-applet.desktop.in
......
/* Gettext package */
#mesondefine GETTEXT_PACKAGE
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
#mesondefine HAVE_BIND_TEXTDOMAIN_CODESET
/* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the
CoreFoundation framework. */
#mesondefine HAVE_CFLOCALECOPYCURRENT
/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in
the CoreFoundation framework. */
#mesondefine HAVE_CFPREFERENCESCOPYAPPVALUE
/* Define to 1 if you have the `dcgettext' function. */
#mesondefine HAVE_DCGETTEXT
/* Define to 1 if you have the <dlfcn.h> header file. */
#mesondefine HAVE_DLFCN_H
/* Define if the GNU gettext() function is already present or preinstalled. */
#mesondefine HAVE_GETTEXT
/* Define to 1 if you have the <inttypes.h> header file. */
#mesondefine HAVE_INTTYPES_H
/* Define if your <locale.h> file defines LC_MESSAGES. */
#mesondefine HAVE_LC_MESSAGES
/* Define if you have libnotify 0.7 or later */
#mesondefine HAVE_LIBNOTIFY_07
/* Define to 1 if you have the <locale.h> header file. */
#mesondefine HAVE_LOCALE_H
/* Define to 1 if you have the <memory.h> header file. */
#mesondefine HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#mesondefine HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#mesondefine HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#mesondefine HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#mesondefine HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#mesondefine HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#mesondefine HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#mesondefine HAVE_UNISTD_H
/* ISO codes prefix */
#mesondefine ISO_CODES_PREFIX
/* git commit id of the original source code version */
#mesondefine NMA_GIT_SHA
/* Define if more asserts are enabled */
#mesondefine NM_MORE_ASSERTS
/* Name of package */
#mesondefine PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#mesondefine PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#mesondefine PACKAGE_NAME
/* Define to the full name and version of this package. */
#mesondefine PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#mesondefine PACKAGE_TARNAME
/* Define to the home page for this package. */
#mesondefine PACKAGE_URL
/* Define to the version of this package. */
#mesondefine PACKAGE_VERSION
/* 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
/* Version number of package */
#mesondefine VERSION
/* Enable using libappindicator */
#mesondefine WITH_APPINDICATOR
/* Define if Gcr is available */
#mesondefine WITH_GCR
/* Define if Jansson is available */
#mesondefine WITH_JANSSON
/* Define if libselinux is available */
#mesondefine WITH_SELINUX
/* Define if you have ModemManager/WWAN support */
#mesondefine WITH_WWAN
/* Define to 1 if on MINIX. */
#mesondefine _MINIX
/* 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
<!ENTITY package @PACKAGE@>
<!ENTITY package_bugreport @PACKAGE_BUGREPORT@>
<!ENTITY package_name @PACKAGE_NAME@>
<!ENTITY package_string @PACKAGE_STRING@>
<!ENTITY package_tarname @PACKAGE_TARNAME@>
<!ENTITY package_url @PACKAGE_URL@>
<!ENTITY package_version @PACKAGE_VERSION@>
icons_16 = [
'nm-device-wired.png',
'nm-no-connection.png',
'nm-vpn-standalone-lock.png'
]
icons_22 = [
'nm-adhoc.png',
'nm-device-wired.png',
'nm-device-wwan.png',
'nm-mb-roam.png',
'nm-no-connection.png',
'nm-secure-lock.png',
'nm-signal-00.png',
'nm-signal-100.png',
'nm-signal-25.png',
'nm-signal-50.png',
'nm-signal-75.png',
'nm-stage01-connecting01.png',
'nm-stage01-connecting02.png',
'nm-stage01-connecting03.png',
'nm-stage01-connecting04.png',
'nm-stage01-connecting05.png',
'nm-stage01-connecting06.png',
'nm-stage01-connecting07.png',
'nm-stage01-connecting08.png',
'nm-stage01-connecting09.png',
'nm-stage01-connecting10.png',
'nm-stage01-connecting11.png',
'nm-stage02-connecting01.png',
'nm-stage02-connecting02.png',
'nm-stage02-connecting03.png',
'nm-stage02-connecting04.png',
'nm-stage02-connecting05.png',
'nm-stage02-connecting06.png',
'nm-stage02-connecting07.png',
'nm-stage02-connecting08.png',
'nm-stage02-connecting09.png',
'nm-stage02-connecting10.png',
'nm-stage02-connecting11.png',
'nm-stage03-connecting01.png',
'nm-stage03-connecting02.png',
'nm-stage03-connecting03.png',
'nm-stage03-connecting04.png',
'nm-stage03-connecting05.png',
'nm-stage03-connecting06.png',
'nm-stage03-connecting07.png',
'nm-stage03-connecting08.png',
'nm-stage03-connecting09.png',
'nm-stage03-connecting10.png',
'nm-stage03-connecting11.png',
'nm-tech-3g.png',
'nm-tech-cdma-1x.png',
'nm-tech-edge.png',
'nm-tech-evdo.png',
'nm-tech-gprs.png',
'nm-tech-hspa.png',
'nm-tech-lte.png',
'nm-tech-umts.png',
'nm-vpn-active-lock.png',
'nm-vpn-connecting01.png',
'nm-vpn-connecting02.png',
'nm-vpn-connecting03.png',
'nm-vpn-connecting04.png',
'nm-vpn-connecting05.png',
'nm-vpn-connecting06.png',
'nm-vpn-connecting07.png',
'nm-vpn-connecting08.png',
'nm-vpn-connecting09.png',
'nm-vpn-connecting10.png',
'nm-vpn-connecting11.png',
'nm-vpn-connecting12.png',
'nm-vpn-connecting13.png',
'nm-vpn-connecting14.png',
'nm-wwan-tower.png'
]
icons_32 = [
'nm-device-wired.png',
'nm-no-connection.png'
]
icons_48 = ['nm-device-wireless.png']
icons_scalable = [
'nm-device-wired.svg',
'nm-no-connection.svg'
]
icons = [
# local dir, install dir, files
['16', '16x16', icons_16],
['22', '22x22', icons_22],
['32', '32x32', icons_32],
['48', '48x48', icons_48],
['scalable', 'scalable', icons_scalable]
]
foreach icon: icons
icon_dir = join_paths(nma_datadir, 'icons', 'hicolor', icon[1], 'apps')
foreach name: icon[2]
install_data(
join_paths(icon[0], name),
install_dir: icon_dir
)
endforeach
endforeach
mans = [
'nm-applet.1',
'nm-connection-editor.1'
]
man1_dir = join_paths(nma_mandir, 'man1')
foreach man: mans
configure_file(
input: man + '.in',
output: man,
install: true,
install_dir: man1_dir,
# FIXME: empty configuration
configuration: configuration_data()
)
endforeach
project(
'nm-applet', 'c',
version: '1.8.3',
license: 'GPL2+',
default_options: [
'b_lundef=true',
'buildtype=debugoptimized',
'c_std=gnu99',
'warning_level=1'
],
meson_version: '>= 0.42.0'
)
nma_long_name = 'network-manager-applet'
nma_version = meson.project_version()
version_array = nma_version.split('.')
nma_major_version = version_array[0].to_int()
nma_minor_version = version_array[1].to_int()
nma_micro_version = version_array[2].to_int()
nma_gir_version = '1.0'
nma_gir_prefix = 'NMA'
nma_gir_ns = 'NMA'
nma_gtk_gir_ns = 'NMGtk'
nma_prefix = get_option('prefix')
nma_bindir = join_paths(nma_prefix, get_option('bindir'))
nma_datadir = join_paths(nma_prefix, get_option('datadir'))
nma_includedir = join_paths(nma_prefix, get_option('includedir'))
nma_libdir = join_paths(nma_prefix, get_option('libdir'))
nma_libexecdir = join_paths(nma_prefix, get_option('libexecdir'))
nma_localedir = join_paths(nma_prefix, get_option('localedir'))
nma_mandir = join_paths(nma_prefix, get_option('mandir'))
nma_sysconfdir = join_paths(nma_prefix, get_option('sysconfdir'))
nma_appdir = join_paths(nma_datadir, 'applications')
nma_autostartdir = join_paths(nma_sysconfdir, 'xdg', 'autostart')
nma_icondir = join_paths(nma_datadir, 'icons')
soversion = 0
current = 0
revision = 0
libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
nma_debug = get_option('buildtype').contains('debug')
cc = meson.get_compiler('c')
config_h = configuration_data()
# defines
set_defines = [
# package
['PACKAGE', nma_long_name],
['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=NetworkManager'],
['PACKAGE_NAME', meson.project_name()],
['PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), nma_version)],
['PACKAGE_TARNAME', nma_long_name],
['PACKAGE_URL', ''],
['PACKAGE_VERSION', nma_version],
['VERSION', nma_version],
# i18n
['GETTEXT_PACKAGE', meson.project_name()]
]
foreach define: set_defines
config_h.set_quoted(define[0], define[1])
endforeach
res = run_command(find_program('git'), 'rev-parse', '--verify', '-q', 'HEAD')
config_h.set_quoted('NMA_GIT_SHA', res.stdout().strip())
# headers
check_headers = [
['HAVE_DLFCN_H', 'dlfcn.h'],
['HAVE_INTTYPES_H', 'inttypes.h'],
['HAVE_LOCALE_H', 'locale.h'],
['HAVE_MEMORY_H', 'memory.h'],
['HAVE_STDINT_H', 'stdint.h'],
['HAVE_STDLIB_H', 'stdlib.h'],
['HAVE_STRINGS_H', 'strings.h'],
['HAVE_STRING_H', 'string.h'],
['HAVE_SYS_STAT_H', 'sys/stat.h'],
['HAVE_SYS_TYPES_H', 'sys/types.h'],
['HAVE_UNISTD_H', 'unistd.h']
]
foreach header: check_headers
config_h.set(header[0], cc.has_header(header[1]))
endforeach
# functions
check_functions = [
# i18n
['HAVE_DCGETTEXT', 'dcgettext'],
['HAVE_GETTEXT', 'gettext'],
['HAVE_ICONV', 'iconv']
]
if host_machine.system().contains('darwin')
check_functions += [
['HAVE_CFLOCALECOPYCURRENT', 'CFLocaleCopyCurrent'],
['HAVE_CFPREFERENCESCOPYAPPVALUE', 'CFPreferencesCopyAppValue']
]
endif
foreach func: check_functions
config_h.set(func[0], cc.has_function(func[1]))
endforeach
# symbols
check_symbols = [
# i18n
['HAVE_LC_MESSAGES', 'locale.h', 'LC_MESSAGES'],
['HAVE_BIND_TEXTDOMAIN_CODESET', 'libintl.h', 'bind_textdomain_codeset']
]
foreach symbol: check_symbols
config_h.set(symbol[0], cc.has_header_symbol(symbol[1], symbol[2]))
endforeach
# types
check_types = [
# type, header, fallback type
['pid_t', 'sys/types.h', 'int']
]
foreach type: check_types
if not cc.has_type(type[0], prefix: '#include<@0@>'.format(type[1]))
config_h.set(type[0], type[2])
endif
endforeach
# compiler flags
common_flags = ['-DHAVE_CONFIG_H']
common_ldflags = []
enable_ld_gc = get_option('enable-ld-gc')
if enable_ld_gc
test_cflags = [
'-fdata-sections',
'-ffunction-sections',
]
test_ldflags = ['-Wl,--gc-sections']
foreach cflag: test_cflags + test_ldflags
assert(cc.has_argument(cflag), 'Unused symbol eviction requested but not supported. Use -Denable-ld-gc=false to build without it.')
endforeach
common_flags += test_cflags
common_ldflags += test_ldflags
endif
if nma_debug
test_cflags = [
'-Wdeclaration-after-statement',
'-Wfloat-equal',
'-Wformat=2',
'-Wimplicit-fallthrough',
'-Winit-self',
'-Wmissing-declarations',
'-Wmissing-include-dirs',
'-Wmissing-prototypes',
'-Wno-duplicate-decl-specifier',
'-Wno-format-truncation',
'-Wno-format-y2k',
'-Wno-missing-field-initializers',
'-Wno-pragmas',
'-Wno-sign-compare',
'-Wno-unused-but-set-variable',
'-Wno-unused-parameter',
'-Wshadow',
'-Wstrict-prototypes',
'-Wundef'
]
foreach cflag: test_cflags
if cc.has_argument(cflag)
common_flags += [cflag]
endif
endforeach
endif
add_project_arguments(common_flags, language: 'c')
add_project_link_arguments(common_ldflags, language: 'c')
ldflag = '-Wl,--version-script'
have_version_script = host_machine.system().contains('linux') and cc.has_argument(ldflag)
linker_script_ver = join_paths(meson.source_root(), 'linker-script-binary.ver')
# Check for iso-codes for country names translation
enable_iso_codes = get_option('enable-iso-codes')
message('whether to disable iso-codes at build-time: ' + enable_iso_codes.to_string())
if enable_iso_codes
iso_codes_dep = dependency('iso-codes')
str = 'Consider installing the package or adjusting the PKG_CONFIG_PATH environment variable.\n'
str += 'You can also disable build-time check for \'iso-codes\' via -Denable-iso-codes=false'
assert(iso_codes_dep.found(), str)
iso_3166 = iso_codes_dep.get_pkgconfig_variable('domains').contains('iso_3166')
message('whether iso-codes has iso_3166 domain: ' + iso_3166.to_string())
config_h.set_quoted('ISO_CODES_PREFIX', iso_codes_dep.get_pkgconfig_variable('prefix'))
else
config_h.set_quoted('ISO_CODES_PREFIX', nma_prefix)
endif
gio_dep = dependency('gio-2.0', version: '>= 2.38')
gmodule_export_dep = dependency('gmodule-export-2.0')
libsecret_dep = dependency('libsecret-1', version: '>= 0.18')
m_dep = cc.find_library('m')
# Check for gtk+
gtk_req_version = '>= 3.4'
gtk_dep = declare_dependency(
dependencies: dependency('gtk+-3.0', version: gtk_req_version),
compile_args: [
'-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_4',
'-DGTK_VERSION_MAX_ALLOWED=GTK_VERSION_3_4'
]
)
# Check for gudev
gudev_dep = dependency('gudev-1.0', version: '>= 147')
# Check for libnotify >= 0.7
libnotify_dep = dependency('libnotify', version: '>= 0.4.3')
config_h.set10('HAVE_LIBNOTIFY_07', libnotify_dep.found() and libnotify_dep.version().version_compare('>= 0.7'),
description: 'Define if you have libnotify 0.7 or later')
# API documentation
nm_req_version = '>= 1.7'
deps = [
gio_dep,
gmodule_export_dep,
dependency('libnm', version: nm_req_version)
]
cflags = [
'-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_38',
'-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_38',
'-DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_8',
'-DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_8'
]
libnm_dep = declare_dependency(
dependencies: deps,
compile_args: cflags
)
enable_libnm_gtk = get_option('enable-libnm-gtk')
if enable_libnm_gtk
deps = [
gio_dep,
gmodule_export_dep,
dependency('libnm-glib', version: nm_req_version),
dependency('libnm-glib-vpn', version: nm_req_version),
dependency('libnm-util', version: nm_req_version),
dependency('NetworkManager', version: nm_req_version)
]
cflags = [
'-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_38',
'-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_38',
'-DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_4',
'-DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_4'
]
libnm_glib_dep = declare_dependency(
dependencies: deps,
compile_args: cflags
)
endif
enable_appindicator = get_option('enable-appindicator')
if enable_appindicator
appindicator_dep = dependency('appindicator3-0.1')
dbusmenu_dep = dependency('dbusmenu-gtk3-0.4', version: '>= 16.04.0')
endif
config_h.set('WITH_APPINDICATOR', enable_appindicator)
# ModemManager1 with libmm-glib for WWAN support
enable_wwan = get_option('enable-wwan')
if enable_wwan
mm_glib_dep = dependency('mm-glib', required: false)
assert(mm_glib_dep.found(), 'libmm-glib is needed for WWAN support. Use -Denable-wwan=false to build without it.')
endif
config_h.set10('WITH_WWAN', enable_wwan)
# SELinux
enable_selinux = get_option('enable-selinux')
if enable_selinux
libselinux_dep = dependency('libselinux', required: false)
assert(libselinux_dep.found(), 'libselinux is needed for SELinux label support in configuration editor. Use -Denable-selinux=false to build without it.')
endif
config_h.set10('WITH_SELINUX', enable_selinux)
# Jansson for team configuration editing