From 6f84dc8b7dcbcac9f0884d4a79164247b6eedacf Mon Sep 17 00:00:00 2001 From: Alberto Fanjul Date: Sat, 28 May 2022 09:59:51 +0200 Subject: [PATCH] Add ENABLE_SYSTEMD config to meson and autotools --- CMakeLists.txt | 2 +- configure.ac | 20 ++++++++++++++++---- meson.build | 8 +++++++- meson_options.txt | 4 ++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9d3453..3edc3dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake set(CMAKE_C_FLAGS "-std=gnu11 ${CMAKE_C_FLAGS}") add_definitions(-D_GNU_SOURCE) -OPTION(ENABLE_SYSTEMD "Enable Systemd support" ON) +OPTION(ENABLE_SYSTEMD "Enable Systemd" ON) find_package(PkgConfig) diff --git a/configure.ac b/configure.ac index bdbce1b..cb4566a 100644 --- a/configure.ac +++ b/configure.ac @@ -45,16 +45,28 @@ AC_ARG_VAR(IP_BINARY, [Path for ip binary]) if test -z "$IP_BINARY"; then IP_BINARY=/bin/ip fi +AC_ARG_ENABLE([disable-systemd], + AS_HELP_STRING([--disable-systemd], [Disable systemd]), [], [use_libsystemd=yes], [Disable systemd using elogind]) AC_DEFINE_UNQUOTED([IP_BINARY], [$IP_BINARY], [Path for ip binary]) # # Mandatory dependencies # -m4_ifdef([PKG_CHECK_MODULES], [ - PKG_CHECK_MODULES([DEPS], [libudev libsystemd > 219]) - PKG_CHECK_MODULES([GLIB], [glib-2.0]) -]) +AS_IF([test "$use_libsystemd" == "yes"], + [ + AC_DEFINE([ENABLE_SYSTEMD], [], [Use systemd]) + m4_ifdef([PKG_CHECK_MODULES], [ + PKG_CHECK_MODULES([DEPS], [libudev libsystemd > 219]) + PKG_CHECK_MODULES([GLIB], [glib-2.0]) + ]) + ], + [ + m4_ifdef([PKG_CHECK_MODULES], [ + PKG_CHECK_MODULES([DEPS], [libudev libelogind]) + PKG_CHECK_MODULES([GLIB], [glib-2.0]) + ]) + ]) AC_CHECK_HEADERS(readline/readline.h,, AC_MSG_ERROR(GNU readline not found)) diff --git a/meson.build b/meson.build index 32beeb7..9b24bdf 100644 --- a/meson.build +++ b/meson.build @@ -32,11 +32,17 @@ if get_option('rely-udev') add_project_arguments('-DRELY_UDEV', language: 'c') endif +if get_option('enable-systemd') + add_project_arguments('-DENABLE_SYSTEMD', language: 'c') + libsystemd = dependency('libsystemd') +else + libsystemd = dependency('libelogind') +endif + add_project_arguments('-DIP_BINARY='+get_option('ip-binary'), language: 'c') glib2 = dependency('glib-2.0') udev = dependency('libudev') -libsystemd = dependency('libsystemd') subdir('src') subdir('res') diff --git a/meson_options.txt b/meson_options.txt index 86a6862..e3a94aa 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -14,3 +14,7 @@ option('ip-binary', type: 'string', value: '/bin/ip', description: 'Path for ip binary') +option('enable-systemd', + type: 'boolean', + value: 'true', + description: 'Enable systemd')