Skip to content

Commit

Permalink
Add ENABLE_SYSTEMD config to meson and autotools
Browse files Browse the repository at this point in the history
  • Loading branch information
albfan committed Oct 16, 2022
1 parent 915b2fa commit cecbb5f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 17 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,29 @@ 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])
])
])
AS_IF([test "$use_libsystemd" == "yes"],

AC_CHECK_HEADERS(readline/readline.h,, AC_MSG_ERROR(GNU readline not found))

Expand Down
8 changes: 7 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 4 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit cecbb5f

Please sign in to comment.