1# systemd.m4 - Macros to check for and enable systemd -*- Autoconf -*- 2# 3# Copyright (C) 2014 Luis R. Rodriguez <mcgrof@suse.com> 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, but 11# WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13# General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; If not, see <http://www.gnu.org/licenses/>. 17 18dnl Some optional path options 19AC_DEFUN([AX_SYSTEMD_OPTIONS], [ 20 AC_ARG_WITH(systemd, 21 AS_HELP_STRING([--with-systemd=DIR], 22 [set directory for systemd service files [PREFIX/lib/systemd/system]]), 23 [SYSTEMD_DIR="$withval"],[SYSTEMD_DIR=""]) 24 AC_SUBST(SYSTEMD_DIR) 25 26 AC_ARG_WITH(systemd-modules-load, 27 AS_HELP_STRING([--with-systemd-modules-load=DIR], 28 [set directory for systemd modules load files [PREFIX/lib/modules-load.d/]]), 29 [SYSTEMD_MODULES_LOAD="$withval"], [SYSTEMD_MODULES_LOAD=""]) 30 AC_SUBST(SYSTEMD_MODULES_LOAD) 31 32 AC_ARG_WITH(systemd-sleep, 33 AS_HELP_STRING([--with-systemd-sleep=DIR], 34 [set directory for systemd sleep script files [PREFIX/lib/systemd/system-sleep/]]), 35 [SYSTEMD_SLEEP_DIR="$withval"], [SYSTEMD_SLEEP_DIR=""]) 36 AC_SUBST(SYSTEMD_SLEEP_DIR) 37]) 38 39AC_DEFUN([AX_ENABLE_SYSTEMD_OPTS], [ 40 AX_ARG_DEFAULT_ENABLE([systemd], [Disable systemd support]) 41 AX_SYSTEMD_OPTIONS() 42]) 43 44AC_DEFUN([AX_ALLOW_SYSTEMD_OPTS], [ 45 AX_ARG_DEFAULT_DISABLE([systemd], [Enable systemd support]) 46 AX_SYSTEMD_OPTIONS() 47]) 48 49AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [ 50 AS_IF([test "x$SYSTEMD_DIR" = x], [ 51 dnl In order to use the line below we need to fix upstream systemd 52 dnl to properly ${prefix} for child variables in 53 dnl src/core/systemd.pc.in but this is a bit complex at the 54 dnl moment as they depend on another rootprefix, which can vary 55 dnl from prefix in practice. We provide our own definition as we 56 dnl *know* where systemd will dump this to, but this does limit 57 dnl us to stick to a non custom systemdsystemunitdir, to work 58 dnl around this we provide the additional configure option 59 dnl --with-systemd where you can specify the directory for the unit 60 dnl files. It would also be best to just extend the upstream 61 dnl pkg-config pkg.m4 with an AC_DEFUN() to do this neatly. 62 dnl SYSTEMD_DIR="`$PKG_CONFIG --define-variable=prefix=$PREFIX --variable=systemdsystemunitdir systemd`" 63 SYSTEMD_DIR="\$(prefix)/lib/systemd/system/" 64 ], []) 65 66 AS_IF([test "x$SYSTEMD_DIR" = x], [ 67 AC_MSG_ERROR([SYSTEMD_DIR is unset]) 68 ], []) 69 70 dnl There is no variable for this yet for some reason 71 AS_IF([test "x$SYSTEMD_MODULES_LOAD" = x], [ 72 SYSTEMD_MODULES_LOAD="\$(prefix)/lib/modules-load.d/" 73 ], []) 74 75 AS_IF([test "x$SYSTEMD_MODULES_LOAD" = x], [ 76 AC_MSG_ERROR([SYSTEMD_MODULES_LOAD is unset]) 77 ], []) 78 79 AS_IF([test "x$SYSTEMD_SLEEP_DIR" = x], [ 80 PKG_CHECK_VAR([SYSTEMD_SLEEP_DIR], [systemd], [systemdsleepdir]) 81 ], []) 82 83 AS_IF([test "x$SYSTEMD_SLEEP_DIR" = x], [ 84 AC_MSG_ERROR([SYSTEMD_SLEEP_DIR is unset]) 85 ], []) 86]) 87 88AC_DEFUN([AX_CHECK_SYSTEMD], [ 89 dnl Respect user override to disable 90 AS_IF([test "x$enable_systemd" != "xno"], [ 91 AS_IF([test "x$systemd" = "xy" ], [ 92 AC_DEFINE([HAVE_SYSTEMD], [1], [Systemd available and enabled]) 93 systemd=y 94 AX_CHECK_SYSTEMD_LIBS() 95 ],[ 96 AS_IF([test "x$enable_systemd" = "xyes"], 97 [AC_MSG_ERROR([Unable to find systemd development library])], 98 [systemd=n]) 99 ]) 100 ],[systemd=n]) 101]) 102 103dnl Enables systemd by default and requires a --disable-systemd option flag 104dnl to configure if you want to disable. 105AC_DEFUN([AX_ENABLE_SYSTEMD], [ 106 AX_ENABLE_SYSTEMD_OPTS() 107 AX_CHECK_SYSTEMD() 108]) 109 110dnl Systemd will be disabled by default and requires you to run configure with 111dnl --enable-systemd to look for and enable systemd. 112AC_DEFUN([AX_ALLOW_SYSTEMD], [ 113 AX_ALLOW_SYSTEMD_OPTS() 114 AX_CHECK_SYSTEMD() 115]) 116 117dnl Systemd will be disabled by default but if your build system is detected 118dnl to have systemd build libraries it will be enabled. You can always force 119dnl disable with --disable-systemd 120AC_DEFUN([AX_AVAILABLE_SYSTEMD], [ 121 AX_ALLOW_SYSTEMD_OPTS() 122 AX_CHECK_SYSTEMD() 123]) 124