From ed0cf6e522c310d56b35e988aded0bd66e77dd6a Mon Sep 17 00:00:00 2001 From: Julio Faracco Date: Mon, 24 Aug 2020 16:52:30 -0300 Subject: [PATCH] Remove Autotools config files and replace them by Meson Some containers (in special CentOS 8), there is a problem with Automake. The NetworkManager fails to compile due to a bug. Since it has some problems, it would be a nice opportunity to migrate to Meson build system. Signed-off-by: Julio Faracco --- Makefile.am | 315 -------------------------- autogen.sh | 23 -- configure.ac | 172 -------------- meson.build | 305 +++++++++++++++++++++++++ meson_options.txt | 6 + po/meson.build | 24 ++ rpm/NetworkManager-anyconnect.spec.in | 1 + 7 files changed, 336 insertions(+), 510 deletions(-) delete mode 100644 Makefile.am delete mode 100755 autogen.sh delete mode 100644 configure.ac create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 po/meson.build diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 90082c5..0000000 --- a/Makefile.am +++ /dev/null @@ -1,315 +0,0 @@ -AUTOMAKE_OPTIONS = subdir-objects - -DISTCHECK_CONFIGURE_FLAGS = \ - --enable-more-warnings=yes - -libexec_PROGRAMS = - -noinst_LTLIBRARIES = - -EXTRA_DIST = - -CLEANFILES = - -check_programs = - -noinst_PROGRAMS = - -SUBDIRS = \ - . \ - po - -plugindir = $(libdir)/NetworkManager -plugin_LTLIBRARIES = - -dbusservicedir = $(datadir)/dbus-1/system.d -dbusservice_DATA = nm-anyconnect-service.conf - -nmvpnservicedir = $(NM_VPN_SERVICE_DIR) -nmvpnservice_DATA = nm-anyconnect-service.name - -uidir = $(datadir)/gnome-vpn-properties/anyconnect -ui_DATA = - -############################################################################### - -shared_sources = \ - shared/nm-utils/nm-shared-utils.c - -############################################################################### - -src_cppflags = \ - -DBINDIR=\"$(bindir)\" \ - -DPREFIX=\""$(prefix)"\" \ - -DSYSCONFDIR=\""$(sysconfdir)"\" \ - -DLIBDIR=\""$(libdir)"\" \ - -DLIBEXECDIR=\""$(libexecdir)"\" \ - -DLOCALSTATEDIR=\""$(localstatedir)"\" \ - -DDATADIR=\"$(datadir)\" \ - -DNM_ANYCONNECT_LOCALEDIR=\"$(datadir)/locale\" \ - -DG_LOG_DOMAIN=\"nm-anyconnect\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DEFAULT \ - -I$(srcdir)/shared \ - $(GLIB_CFLAGS) \ - $(LIBNM_CFLAGS) - -noinst_LTLIBRARIES += src/libnm-utils.la - -src_libnm_utils_la_SOURCES = $(shared_sources) -src_libnm_utils_la_CPPFLAGS = $(src_cppflags) -src_libnm_utils_la_LIBADD = \ - $(GLIB_LIBS) \ - $(LIBNM_LIBS) - -libexec_PROGRAMS += src/nm-anyconnect-service - -src_nm_anyconnect_service_CPPFLAGS = $(src_cppflags) -src_nm_anyconnect_service_LDFLAGS = \ - -Wl,--version-script="$(srcdir)/linker-script-binary.ver" -src_nm_anyconnect_service_LDADD = \ - src/libnm-utils.la \ - $(GLIB_LIBS) \ - $(LIBNM_LIBS) -EXTRA_src_nm_anyconnect_service_DEPENDENCIES = \ - linker-script-binary.ver - -############################################################################### - -properties/resources.h: properties/gresource.xml - $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir)/properties --generate-header --internal - -properties/resources.c: properties/gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/properties --generate-dependencies $(srcdir)/properties/gresource.xml) - $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $< --target=$@ --sourcedir=$(srcdir)/properties --generate-source --internal - -CLEANFILES += \ - properties/resources.c \ - properties/resources.h - -EXTRA_DIST += \ - properties/gresource.xml - -plugin_sources = \ - properties/nm-anyconnect-editor-plugin.c \ - properties/nm-anyconnect-editor-plugin.h - -editor_sources = \ - properties/resources.c \ - properties/resources.h \ - properties/nm-anyconnect-editor.c \ - properties/nm-anyconnect-editor.h - -properties_cppflags = \ - -DICONDIR=\""$(datadir)/pixmaps"\" \ - -DLOCALEDIR=\"$(datadir)/locale\" \ - -I$(srcdir)/shared \ - $(GLIB_CFLAGS) - -############################################################################### - -noinst_LTLIBRARIES += properties/libnm-vpn-plugin-anyconnect-utils.la - -properties_libnm_vpn_plugin_anyconnect_utils_la_SOURCES = \ - $(shared_sources) - -properties_libnm_vpn_plugin_anyconnect_utils_la_CPPFLAGS = \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_BASE \ - -DNM_PLUGIN_DIR=\"$(NM_PLUGIN_DIR)\" \ - $(properties_cppflags) \ - $(LIBNM_CFLAGS) - -properties_libnm_vpn_plugin_anyconnect_utils_la_LIBADD = \ - $(LIBNM_LIBS) \ - $(DL_LIBS) - -noinst_LTLIBRARIES += properties/libnm-vpn-plugin-anyconnect-core.la - -properties_libnm_vpn_plugin_anyconnect_core_la_SOURCES = \ - shared/nm-utils/nm-vpn-plugin-utils.c \ - shared/nm-utils/nm-vpn-plugin-utils.h \ - shared/nm-utils/nm-vpn-plugin-macros.h \ - $(plugin_sources) - -properties_libnm_vpn_plugin_anyconnect_core_la_CPPFLAGS = \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_BASE \ - -DNM_PLUGIN_DIR=\"$(NM_PLUGIN_DIR)\" \ - $(properties_cppflags) \ - $(LIBNM_CFLAGS) - -properties_libnm_vpn_plugin_anyconnect_core_la_LIBADD = \ - properties/libnm-vpn-plugin-anyconnect-utils.la \ - $(LIBNM_LIBS) \ - $(DL_LIBS) - -plugin_LTLIBRARIES += properties/libnm-vpn-plugin-anyconnect.la - -properties_libnm_vpn_plugin_anyconnect_la_SOURCES = -properties_libnm_vpn_plugin_anyconnect_la_LIBADD = \ - properties/libnm-vpn-plugin-anyconnect-core.la -properties_libnm_vpn_plugin_anyconnect_la_LDFLAGS = \ - -avoid-version \ - -Wl,--version-script=$(srcdir)/properties/libnm-vpn-plugin-anyconnect.ver - -############################################################################### - -if WITH_GNOME -plugin_LTLIBRARIES += properties/libnm-vpn-plugin-anyconnect-editor.la -endif - -properties_libnm_vpn_plugin_anyconnect_editor_la_SOURCES = \ - $(editor_sources) - -properties_libnm_vpn_plugin_anyconnect_editor_la_CPPFLAGS = \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR \ - $(properties_cppflags) \ - $(GTK_CFLAGS) \ - $(LIBNM_CFLAGS) \ - $(LIBNMA_CFLAGS) - -properties_libnm_vpn_plugin_anyconnect_editor_la_LIBADD = \ - properties/libnm-vpn-plugin-anyconnect-utils.la \ - $(GLIB_LIBS) \ - $(GTK_LIBS) \ - $(LIBNM_LIBS) \ - $(LIBNMA_LIBS) - -properties_libnm_vpn_plugin_anyconnect_editor_la_LDFLAGS = \ - -avoid-version \ - -Wl,--version-script=$(srcdir)/properties/libnm-vpn-plugin-anyconnect-editor.ver - -############################################################################### - -if WITH_LIBNM_GLIB -noinst_LTLIBRARIES += properties/libnm-anyconnect-properties-core.la -endif - -properties_libnm_anyconnect_properties_core_la_SOURCES = \ - $(shared_sources) \ - $(plugin_sources) \ - $(editor_sources) - -properties_libnm_anyconnect_properties_core_la_CPPFLAGS = \ - -DNETWORKMANAGER_COMPILATION='NM_NETWORKMANAGER_COMPILATION_LIB|NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_UTIL' \ - $(properties_cppflags) \ - $(GTK_CFLAGS) \ - $(LIBNM_GLIB_CFLAGS) \ - $(LIBNM_GTK_CFLAGS) - -properties_libnm_anyconnect_properties_core_la_LIBADD = \ - $(GLIB_LIBS) \ - $(GTK_LIBS) \ - $(LIBNM_GLIB_LIBS) \ - $(LIBNM_GTK_LIBS) - - -if WITH_LIBNM_GLIB -plugin_LTLIBRARIES += properties/libnm-anyconnect-properties.la -endif - -properties_libnm_anyconnect_properties_la_SOURCES = -properties_libnm_anyconnect_properties_la_LIBADD = \ - properties/libnm-anyconnect-properties-core.la -properties_libnm_anyconnect_properties_la_LDFLAGS = \ - -avoid-version \ - -Wl,--version-script=$(srcdir)/properties/libnm-anyconnect-properties.ver - -EXTRA_DIST += \ - properties/libnm-vpn-plugin-anyconnect.ver \ - properties/libnm-vpn-plugin-anyconnect-editor.ver \ - properties/libnm-anyconnect-properties.ver \ - properties/nm-anyconnect-dialog.ui - -############################################################################### - -if WITH_GNOME -libexec_PROGRAMS += auth-dialog/nm-anyconnect-auth-dialog -endif - -auth_dialog_nm_anyconnect_auth_dialog_SOURCES = \ - $(shared_sources) \ - auth-dialog/main.c -auth_dialog_nm_anyconnect_auth_dialog_CPPFLAGS = \ - -DICONDIR=\""$(datadir)/pixmaps"\" \ - -DBINDIR=\""$(bindir)"\" \ - -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ - -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_DEFAULT \ - -I$(srcdir)/shared \ - $(GLIB_CFLAGS) \ - $(GTK_CFLAGS) \ - $(LIBNM_CFLAGS) \ - $(LIBNMA_CFLAGS) \ - $(LIBSECRET_CFLAGS) -auth_dialog_nm_anyconnect_auth_dialog_LDFLAGS = \ - -Wl,--version-script="$(srcdir)/linker-script-binary.ver" -auth_dialog_nm_anyconnect_auth_dialog_LDADD = \ - $(GLIB_LIBS) \ - $(GTK_LIBS) \ - $(LIBNM_LIBS) \ - $(LIBNMA_LIBS) \ - $(LIBSECRET_LIBS) -EXTRA_auth_dialog_nm_anyconnect_auth_dialog_DEPENDENCIES = \ - linker-script-binary.ver - -############################################################################### - -if WITH_LIBNM_GLIB -# Install a file with full path to plugins for an old gnome-shell -# https://bugzilla.gnome.org/show_bug.cgi?id=693590 -install-data-hook: - mkdir -p $(DESTDIR)$(sysconfdir)/NetworkManager/VPN - sed -e "1s|^|# This file is obsoleted by a file in $(NM_VPN_SERVICE_DIR)\n\n|" \ - -e 's|[@]LIBEXECDIR[@]|$(libexecdir)|g' \ - -e 's|[@]PLUGINDIR[@]|@NM_PLUGIN_DIR@|g' \ - <$(srcdir)/nm-anyconnect-service.name.in \ - >$(DESTDIR)$(sysconfdir)/NetworkManager/VPN/nm-anyconnect-service.name - -uninstall-hook: - rm -f $(DESTDIR)$(sysconfdir)/NetworkManager/VPN/nm-anyconnect-service.name -endif - -appdatadir = $(datadir)/metainfo -appdata_files = $(appdata_in_files:.xml.in=.xml) -if WITH_GNOME -appdata_DATA = $(appdata_files) -endif -appdata_in_files = appdata/network-manager-anyconnect.metainfo.xml.in -@INTLTOOL_XML_RULE@ - -nm-anyconnect-service.name: $(srcdir)/nm-anyconnect-service.name.in - $(AM_V_GEN) sed -e 's|[@]LIBEXECDIR[@]|$(libexecdir)|g' \ - -e 's|[@]PLUGINDIR[@]/|@NM_PLUGIN_DIR_NAME_FILE@|g' \ - $^ >$@ - -EXTRA_DIST += \ - linker-script-binary.ver \ - nm-anyconnect-service.name.in \ - $(dbusservice_DATA) \ - $(appdata_in_files) \ - $(appdata_files) \ - intltool-extract.in \ - intltool-merge.in \ - intltool-update.in \ - \ - shared/README \ - shared/nm-utils/gsystem-local-alloc.h \ - shared/nm-utils/nm-glib.h \ - shared/nm-utils/nm-macros-internal.h \ - shared/nm-utils/nm-shared-utils.c \ - shared/nm-utils/nm-shared-utils.h \ - shared/nm-utils/nm-test-utils.h \ - shared/nm-default.h \ - shared/nm-service-defines.h \ - \ - rpm/NetworkManager-anyconnect.spec \ - README.md \ - $(NULL) - -CLEANFILES += \ - $(nmvpnservice_DATA) \ - $(appdata_files) - -DISTCLEANFILES = \ - intltool-extract \ - intltool-merge \ - intltool-update - -ACLOCAL_AMFLAGS = -I m4 diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 0f8d7c2..0000000 --- a/autogen.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# Run this to generate all the initial makefiles, etc. - -srcdir=`dirname $0` -test -z "$srcdir" && srcdir=. -REQUIRED_AUTOMAKE_VERSION=1.9 -PKG_NAME=NetworkManager-anyconnect - -(test -f $srcdir/configure.ac \ - && test -f $srcdir/auth-dialog/main.c) || { - echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" - echo " top-level $PKG_NAME directory" - exit 1 -} - -(cd $srcdir; - autoreconf --install --symlink && - intltoolize --force && - autoreconf && - ./configure --enable-maintainer-mode $@ -) - - diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 159eba0..0000000 --- a/configure.ac +++ /dev/null @@ -1,172 +0,0 @@ -AC_PREREQ(2.52) - -AC_INIT(NetworkManager-anyconnect, - 1.2.1, - https://gitlab.gnome.org/GNOME/NetworkManager-anyconnect/issues, - NetworkManager-anyconnect) -AM_INIT_AUTOMAKE([1.9 tar-ustar no-dist-gzip dist-xz -Wno-portability]) -AM_MAINTAINER_MODE -AM_SILENT_RULES([yes]) - -AC_CONFIG_HEADERS([config.h]) - -dnl -dnl Require programs -dnl -AC_PROG_CC -AC_GNU_SOURCE -AM_PROG_CC_C_O -AC_PROG_INSTALL -AC_PROG_LIBTOOL -AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources) - -AC_CHECK_PROG([has_file], file, yes, no) -if test x$has_file = xno ; then - AC_MSG_ERROR(["file" utility not found.]) -fi - -AC_CHECK_PROG([has_find], find, yes, no) -if test x$has_find = xno ; then - AC_MSG_ERROR(["find" utility not found.]) -fi - -AC_CONFIG_MACRO_DIR([m4]) - -dnl Prefer gcc-* variants; the ones libtool would choose don't work with LTO -AC_CHECK_TOOLS(AR, [gcc-ar ar], false) -AC_CHECK_TOOLS(RANLIB, [gcc-ranlib ranlib], :) - -LT_INIT([disable-static]) - -dnl -dnl Required headers -dnl -AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h paths.h sys/ioctl.h sys/time.h syslog.h unistd.h) - -dnl -dnl Checks for typedefs, structures, and compiler characteristics. -dnl -AC_TYPE_MODE_T -AC_TYPE_PID_T -AC_HEADER_TIME - -dnl -dnl Checks for library functions. -dnl -AC_PROG_GCC_TRADITIONAL -AC_FUNC_MEMCMP -AC_CHECK_FUNCS(select socket uname) - -GIT_SHA_RECORD(NM_GIT_SHA) - -AC_SEARCH_LIBS([dlopen], [dl dld], [], [ac_cv_search_dlopen=]) -AC_SUBST([DL_LIBS], "$ac_cv_search_dlopen") - -dnl ensure that when the Automake generated makefile calls aclocal, -dnl it honours the $ACLOCAL_FLAGS environment variable -ACLOCAL_AMFLAGS="\${ACLOCAL_FLAGS}" -if test -n "$ac_macro_dir"; then - ACLOCAL_AMFLAGS="-I $ac_macro_dir $ACLOCAL_AMFLAGS" -fi -AC_SUBST([ACLOCAL_AMFLAGS]) - -dnl -dnl GNOME support -dnl -AC_ARG_WITH(gnome, AS_HELP_STRING([--without-gnome], [Build NetworkManager-anyconnect without GNOME support, e.g. vpn service only]), [], [with_gnome_specified=no]) -AC_ARG_WITH(libnm-glib, AS_HELP_STRING([--with-libnm-glib], [Build NetworkManager-anyconnect with libnm-glib compatibility (deprecated)]), [], [with_libnm_glib_specified=no]) -if test "$with_libnm_glib_specified" != no -a "$with_libnm_glib" != no; then - if test "$with_gnome_specified" != no -a "$with_gnome" == no; then - AC_MSG_ERROR(Building --with-libnm-glib conflicts with --without-gnome) - fi -fi -if test "$with_gnome" != no; then - with_gnome=yes -fi -if test "$with_libnm_glib_specified" == no; then - with_libnm_glib=no -fi -if test "$with_libnm_glib" != yes; then - with_libnm_glib=no -fi -AM_CONDITIONAL(WITH_GNOME, test "$with_gnome" != no) -AM_CONDITIONAL(WITH_LIBNM_GLIB, test "$with_libnm_glib" != no) - -AC_ARG_ENABLE(absolute-paths, AS_HELP_STRING([--enable-absolute-paths], [Use absolute paths to in .name files. Useful for development. (default is no)])) - -GETTEXT_PACKAGE=NetworkManager-anyconnect -AC_SUBST(GETTEXT_PACKAGE) -AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package]) - -IT_PROG_INTLTOOL([0.35]) -AM_GLIB_GNU_GETTEXT - -PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32) -GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32" - -if test x"$with_gnome" != xno; then - PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.4) - GTK_CFLAGS="$GTK_CFLAGS -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_4" - - PKG_CHECK_MODULES(LIBNMA, libnma >= 1.7.0) - PKG_CHECK_MODULES(LIBSECRET, libsecret-1 >= 0.18) - - if test x"$with_libnm_glib" != xno; then - PKG_CHECK_MODULES(LIBNM_GTK, libnm-gtk >= 1.7.0) - PKG_CHECK_MODULES(LIBNM_GLIB, - NetworkManager >= 1.7.0 - libnm-util >= 1.7.0 - libnm-glib >= 1.7.0 - libnm-glib-vpn >= 1.7.0); - - LIBNM_GLIB_CFLAGS="$LIBNM_GLIB_CFLAGS -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_2" - LIBNM_GLIB_CFLAGS="$LIBNM_GLIB_CFLAGS -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_2" - fi -fi - -PKG_CHECK_MODULES(LIBNM, libnm >= 1.7.0) -LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_8" -LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_8" - -NM_VPN_SERVICE_DIR=`$PKG_CONFIG --define-variable prefix='\${prefix}' --variable vpnservicedir libnm` -AC_SUBST(NM_VPN_SERVICE_DIR) - -NM_COMPILER_WARNINGS([yes]) -NM_LTO -NM_LD_GC - -NM_PLUGIN_DIR="$libdir/NetworkManager" -AC_SUBST(NM_PLUGIN_DIR) -if test x"$enable_absolute_paths" == x"yes"; then - NM_PLUGIN_DIR_NAME_FILE="$NM_PLUGIN_DIR/" -else - enable_absolute_paths=no - NM_PLUGIN_DIR_NAME_FILE="" -fi -AC_SUBST(NM_PLUGIN_DIR_NAME_FILE) - -dnl -dnl Distribution version string -dnl -AC_ARG_WITH(dist-version, AS_HELP_STRING([--with-dist-version=], [Define the custom version (like distribution package name and revision)]), ac_distver=$withval, ac_distver="") -if ! test x"$ac_distver" = x""; then - AC_DEFINE_UNQUOTED(DIST_VERSION, "$ac_distver", [Define the distribution version string]) -fi - -AC_CONFIG_FILES([ -Makefile -po/Makefile.in -rpm/NetworkManager-anyconnect.spec -]) -AC_OUTPUT - -echo "" -echo "Build configuration: " -echo " --with-gnome=$with_gnome" -echo " --with-libnm-glib=$with_libnm_glib" -echo " --enable-absolute-paths=$enable_absolute_paths" -echo " --enable-more-warnings=$set_more_warnings" -echo " --enable-lto=$enable_lto" -echo " --enable-ld-gc=$enable_ld_gc" -echo "" diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..9652b66 --- /dev/null +++ b/meson.build @@ -0,0 +1,305 @@ +project('NetworkManager-anyconnect', 'c', version : '1.2.1') + +# Directories +prefix = get_option('prefix') +bindir = get_option('bindir') +datadir = join_paths(prefix, get_option('datadir')) +desktopdir = join_paths(datadir, 'applications') +includedir = get_option('includedir') +libdir = get_option('libdir') +libexecdir = join_paths(prefix, get_option('libexecdir')) +localedir = get_option('localedir') +systemddir = join_paths(datadir, 'dbus-1', 'system.d') + +if build_machine.cpu_family() == 'x86_64' + libdir64 = join_paths(prefix, 'lib64/') +else + libdir64 = libdir +endif + +plugindir = join_paths(libdir64, 'NetworkManager/') + +conf = configuration_data() + +as_version = meson.project_version() +as_name = meson.project_name() + +conf.set_quoted('VERSION', as_version) +conf.set_quoted('PACKAGE_VERSION', as_version) +conf.set_quoted('PACKAGE_NAME', as_name) +conf.set_quoted('PACKAGE_TARNAME', as_name) +conf.set_quoted('PACKAGE', as_name) +conf.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.gnome.org/GNOME/NetworkManager-anyconnect/issues') +conf.set_quoted('PACKAGE_STRING', as_name + ' ' + as_version) + +glib_compile_resources = find_program('glib-compile-resources', required: true) +file_prog = find_program('file', required : true) +find_prog = find_program('find', required : true) + +gettext_progs = [ + 'msgfmt', + 'msgmerge', + 'xgettext', + 'sed', + 'gawk', +] +foreach name : gettext_progs + prog = find_program(name, required: true) +# set_variable('@0@_prog'.format(name), prog) +endforeach + +conf.set_quoted('GETTEXT_PACKAGE', as_name) +conf.set_quoted('LOCALEDIR', join_paths(datadir, 'locale')) +conf.set_quoted('NM_ANYCONNECT_LOCALEDIR', join_paths(datadir, 'locale')) +conf.set_quoted('NM_PLUGIN_DIR', join_paths(libdir, 'NetworkManager')) +conf.set_quoted('G_LOG_DOMAIN', 'nm-anyconnect') + +cc = meson.get_compiler('c') + +headers = [ + 'dlfcn.h', + 'fcntl.h', + 'inttypes.h', + 'locale.h', + 'memory.h', + 'unistd.h', + 'paths.h', + 'stdlib.h', + 'stdint.h', + 'strings.h', + 'string.h', + 'syslog.h', + 'sys/ioctl.h', + 'sys/stat.h', + 'sys/time.h', + 'sys/types.h', +] + +foreach name : headers + if cc.has_header(name) + conf.set('HAVE_@0@'.format(name.underscorify().to_upper()), 1) + endif +endforeach + +if cc.has_header('stdlib.h') and cc.has_header('stddef.h') + conf.set('STDC_HEADERS', 1) +endif + +if cc.has_header('sys/time.h') and cc.has_header('time.h') + conf.set('TIME_WITH_SYS_TIME', 1) +endif + +functions = [ + 'dcgettext', + 'gettext', + 'select', + 'socket', + 'uname', + 'bind_textdomain_codeset', +] + +foreach function : functions + if cc.has_function(function) + conf.set('HAVE_@0@'.format(function.to_upper()), 1) + endif +endforeach + +deps = [] + +dlopen = cc.find_library('dl', required: true) +if not dlopen.found() + error('Unable to find dlfcn.h') +endif + +code = '''#include +int main () { + return LC_MESSAGES; +} +''' +r = cc.compiles(code, name : 'LC_MESSAGE check') +if r + conf.set('HAVE_LC_MESSAGES', 1) +endif + +if get_option('with-libnm-glib') and not get_option('with_gnome') + error('Building --with-libnm-glib conflicts with --without-gnome') +endif + +libnm = dependency('libnm', required: true) +glib2 = dependency('glib-2.0', required: true) + +deps = [libnm, glib2, dlopen] + +if get_option('with-gnome') + conf.set('GDK_VERSION_MIN_REQUIRED', 'GDK_VERSION_3_4') + gtk3 = dependency('gtk+-3.0', required: true, version: '>= 3.4') + libnma = dependency('libnma', required: true, version: '>= 1.7.0') + libsecret = dependency('libsecret-1', required: true, version: '>= 0.18') + + if get_option('with-libnm-glib') + libnm_gtk = dependency('libnm-gtk', required: true, version: '>= 1.7.0') + nm = dependency('NetworkManager', required: true, version: '>= 1.7.0') + libnm_util = dependency('libnm-util', required: true, version: '>= 1.7.0') + libnm_glib = dependency('libnm-glib', required: true, version: '>= 1.7.0') + libnm_glib_vpn = dependency('libnm-glib-vpn', required: true, version: '>= 1.7.0') + + conf.set('NM_VERSION_MIN_REQUIRED', 'NM_VERSION_1_2') + conf.set('NM_VERSION_MAX_ALLOWED', 'NM_VERSION_1_2') + + deps += [libnm_gtk, nm, libnm_util, libnm_glib, libnm_glib_vpn] + + endif + + deps += [gtk3, libnma, libsecret] + +endif + +conf.set('_GNU_SOURCE', 1) +# Always defined to indicate that i18n is enabled +conf.set('ENABLE_NLS', 1) +conf.set('NETWORKMANAGER_COMPILATION', 'NM_NETWORKMANAGER_COMPILATION_DEFAULT|NM_NETWORKMANAGER_COMPILATION_LIB_EDITOR') + +test_args = [ + '-Wunknown-warning-option', + '-Wdeclaration-after-statement', + '-Wfloat-equal', + '-Wformat-nonliteral', + '-Wformat-security', + '-Wimplicit-fallthrough', + '-Wimplicit-function-declaration', + '-Winit-self', + '-Wlogical-op', + '-Wmissing-declarations', + '-Wmissing-include-dirs', + '-Wmissing-prototypes', + '-Wpointer-arith', + '-Wshadow', + '-Wshift-negative-value', + '-Wstrict-prototypes', + '-Wundef', + '-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', + '-Wunknown-attributes', + '-Wtypedef-redefinition', + '-Warray-bounds', + '-Wparentheses-equality', + '-Wunused-value', + '-Wmissing-braces', +] +cc = meson.get_compiler('c') +foreach arg: test_args + if cc.has_argument(arg) + add_project_arguments(arg, language : 'c') + endif +endforeach + +if get_option('enable-more-warnings') == 'yes' or get_option('enable-more-warnings') == 'error' + if cc.has_argument('-Wextra') + add_project_arguments('-Wextra', language : 'c') + endif + + if cc.has_argument('-Wall') + add_project_arguments('-Wall', language : 'c') + endif + + if get_option('enable-more-warnings') == 'error' and cc.has_argument('-Werror') + add_project_arguments('-Werror', language : 'c') + endif +endif + +if get_option('enable-lto') + if cc.has_argument('-flto') + add_project_arguments('-flto', language : 'c') + endif +endif + +if get_option('enable-ld-gc') + link_gc = '-Wl,--gc-sections' + if cc.has_argument('-fdata-sections') and cc.has_argument('-ffunction-sections') and cc.links('int main () { return 0; }', name: link_gc, args: link_gc) + add_project_arguments('-fdata-sections', language : 'c') + add_project_arguments('-ffunction-sections', language : 'c') + add_project_arguments('-Wl,--gc-sections', language : 'c') + else + error('Disable garbage collector due to unsupported compiler flags.') + endif +endif + +gnome = import('gnome') + +asresources = gnome.compile_resources( + 'nm-anyconnect-dialog.ui', 'properties/gresource.xml', + source_dir : 'properties', + c_name : 'as') + +# glib-compile-resources +glib_resources_path = join_paths(meson.build_root(), 'properties/') +r = run_command('mkdir', glib_resources_path) +if r.returncode() != 0 + message('Could not compile glib resources:') + message(r.stderr().strip()) +endif + +r = run_command('glib-compile-resources', '--target', join_paths(glib_resources_path, 'resources.h'), '--sourcedir=properties/', '--generate-header', 'properties/gresource.xml') +if r.returncode() != 0 + message('Could not compile glib resources:') + error(r.stderr().strip()) +endif + +r = run_command('glib-compile-resources', '--target', join_paths(glib_resources_path, 'resources.c'), '--sourcedir=properties/', '--generate-source', 'properties/gresource.xml') +if r.returncode() != 0 + message('Could not compile glib resources:') + error(r.stderr().strip()) +endif + +# Generating appdata +service_name = custom_target ('nm-anyconnect-service-name', + output: 'nm-anyconnect-service.name', + input: 'nm-anyconnect-service.name.in', + command: ['sed', '-e', 's|[@]LIBEXECDIR[@]|' + libexecdir + '|g', '-e', 's|[@]PLUGINDIR[@]/|' + plugindir + '|g', '@INPUT@'], + capture: true, + install: true, + install_dir: join_paths(prefix, 'lib', 'NetworkManager' , 'VPN/')) + +install_data('nm-anyconnect-service.conf', install_dir: systemddir) +install_data('appdata/network-manager-anyconnect.metainfo.xml.in', rename: 'network-manager-anyconnect.metainfo.xml', install_dir: join_paths(datadir, 'metainfo/')) + + +configuration_inc = include_directories('.') +shared_inc = include_directories('shared/') + +# Compiling Network Manager Service +nm_anyconnect_service_src = ['src/nm-anyconnect-service.c'] + +shared_utils_inc = include_directories('shared/nm-utils/') +shared_utils_src = ['shared/nm-utils/nm-shared-utils.c', 'shared/nm-utils/nm-vpn-plugin-utils.c'] + +nm_anyconnect_service_exe = executable('nm-anyconnect-service', sources: nm_anyconnect_service_src + shared_utils_src, dependencies: deps, include_directories: [configuration_inc, shared_inc, shared_utils_inc], install: true, install_dir: libexecdir) + +# Compiling auth-dialog +nm_anyconnect_auth_dialog_src = ['auth-dialog/main.c'] + +nm_anyconnect_auth_dialog_exe = executable('nm-anyconnect-auth-dialog', sources: nm_anyconnect_auth_dialog_src + shared_utils_src, dependencies: deps, include_directories: [configuration_inc, shared_inc, shared_utils_inc], install: true, install_dir: libexecdir) + +# Compiling SO libraries +plugin_src = ['properties/nm-anyconnect-editor-plugin.c'] + +editor_src = [join_paths(glib_resources_path, 'resources.c'), join_paths(glib_resources_path, 'resources.h'), 'properties/nm-anyconnect-editor.c'] + +nm_vpn_plugin_anyconnect_core_src = ['shared/nm-utils/nm-vpn-plugin-utils.c'] + +nm_vpn_plugin_anyconnect_so = shared_library('nm-vpn-plugin-anyconnect', sources: nm_vpn_plugin_anyconnect_core_src + plugin_src, dependencies: deps, include_directories: [configuration_inc, shared_inc, shared_utils_inc], install: true, install_dir: plugindir) + +nm_vpn_plugin_anyconnect_editor_so = shared_library('nm-vpn-plugin-anyconnect-editor', sources: editor_src, dependencies: deps, include_directories: [configuration_inc, shared_inc, shared_utils_inc], install: true, install_dir: plugindir) + +# Adding translations +subdir('po/') + +# Generating config.h +configure_file(output : 'config.h', + configuration : conf) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..1ecc8a5 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,6 @@ +option('with-gnome', type: 'boolean', value: true, description: 'Build NetworkManager-anyconnect without GNOME support, e.g. vpn service only') +option('with-libnm-glib', type: 'boolean', value: false, description: 'Build NetworkManager-anyconnect with libnm-glib compatibility (deprecated)') +option('enable-absolute-paths', type: 'boolean', value: false, description: 'Use absolute paths to in .name files. Useful for development. (default is no)') +option('enable-more-warnings', type: 'string', value: 'yes', description: 'Enable more warnings from compiler (possible values: no/yes/error)') +option('enable-lto', type: 'boolean', value: false, description: 'Enable Link Time Optimization for smaller size (default: no)') +option('enable-ld-gc', type: 'boolean', value: true, description: 'Enable garbage collection of unused symbols on linking (default: yes)') diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..3ce84aa --- /dev/null +++ b/po/meson.build @@ -0,0 +1,24 @@ +i18n = import('i18n') + +potfiles_conf = configuration_data() +potfiles_conf.set('SRCDIR', '') +potfiles_conf.set('BUILDDIR', '') + +potfiles = configure_file( + input: 'POTFILES.in', + output: 'POTFILES', + configuration: potfiles_conf, +) + +i18n.gettext( + meson.project_name(), + args: [ + '--add-comments=TRANSLATORS:', + '--directory=@0@'.format(meson.source_root()), + '--directory=@0@'.format(meson.build_root()), + '--files-from=@0@'.format(meson.current_build_dir() / 'POTFILES'), + '--package-version=@0@'.format(meson.project_version()), + '--sort-output', + ], + preset: 'glib', +) diff --git a/rpm/NetworkManager-anyconnect.spec.in b/rpm/NetworkManager-anyconnect.spec.in index be87568..5cf4da4 100644 --- a/rpm/NetworkManager-anyconnect.spec.in +++ b/rpm/NetworkManager-anyconnect.spec.in @@ -14,6 +14,7 @@ Group: System Environment/Base Source: @PACKAGE@-@VERSION@.tar.xz +BuildRequires: meson BuildRequires: NetworkManager-libnm-devel >= 1:1.2.0 BuildRequires: glib2-devel BuildRequires: libtool intltool gettext