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 33AC_DEFUN([AX_ENABLE_SYSTEMD_OPTS], [ 34 AX_ARG_DEFAULT_ENABLE([systemd], [Disable systemd support]) 35 AX_SYSTEMD_OPTIONS() 36]) 37 38AC_DEFUN([AX_ALLOW_SYSTEMD_OPTS], [ 39 AX_ARG_DEFAULT_DISABLE([systemd], [Enable systemd support]) 40 AX_SYSTEMD_OPTIONS() 41]) 42 43AC_DEFUN([AX_CHECK_SYSTEMD_LIBS], [ 44 AS_IF([test "x$SYSTEMD_DIR" = x], [ 45 dnl In order to use the line below we need to fix upstream systemd 46 dnl to properly ${prefix} for child variables in 47 dnl src/core/systemd.pc.in but this is a bit complex at the 48 dnl moment as they depend on another rootprefix, which can vary 49 dnl from prefix in practice. We provide our own definition as we 50 dnl *know* where systemd will dump this to, but this does limit 51 dnl us to stick to a non custom systemdsystemunitdir, to work 52 dnl around this we provide the additional configure option 53 dnl --with-systemd where you can specify the directory for the unit 54 dnl files. It would also be best to just extend the upstream 55 dnl pkg-config pkg.m4 with an AC_DEFUN() to do this neatly. 56 dnl SYSTEMD_DIR="`$PKG_CONFIG --define-variable=prefix=$PREFIX --variable=systemdsystemunitdir systemd`" 57 SYSTEMD_DIR="\$(prefix)/lib/systemd/system/" 58 ], []) 59 60 AS_IF([test "x$SYSTEMD_DIR" = x], [ 61 AC_MSG_ERROR([SYSTEMD_DIR is unset]) 62 ], []) 63 64 dnl There is no variable for this yet for some reason 65 AS_IF([test "x$SYSTEMD_MODULES_LOAD" = x], [ 66 SYSTEMD_MODULES_LOAD="\$(prefix)/lib/modules-load.d/" 67 ], []) 68 69 AS_IF([test "x$SYSTEMD_MODULES_LOAD" = x], [ 70 AC_MSG_ERROR([SYSTEMD_MODULES_LOAD is unset]) 71 ], []) 72]) 73 74AC_DEFUN([AX_CHECK_SYSTEMD], [ 75 dnl Respect user override to disable 76 AS_IF([test "x$enable_systemd" != "xno"], [ 77 AS_IF([test "x$systemd" = "xy" ], [ 78 AC_DEFINE([HAVE_SYSTEMD], [1], [Systemd available and enabled]) 79 systemd=y 80 AX_CHECK_SYSTEMD_LIBS() 81 ],[ 82 AS_IF([test "x$enable_systemd" = "xyes"], 83 [AC_MSG_ERROR([Unable to find systemd development library])], 84 [systemd=n]) 85 ]) 86 ],[systemd=n]) 87]) 88 89dnl Enables systemd by default and requires a --disable-systemd option flag 90dnl to configure if you want to disable. 91AC_DEFUN([AX_ENABLE_SYSTEMD], [ 92 AX_ENABLE_SYSTEMD_OPTS() 93 AX_CHECK_SYSTEMD() 94]) 95 96dnl Systemd will be disabled by default and requires you to run configure with 97dnl --enable-systemd to look for and enable systemd. 98AC_DEFUN([AX_ALLOW_SYSTEMD], [ 99 AX_ALLOW_SYSTEMD_OPTS() 100 AX_CHECK_SYSTEMD() 101]) 102 103dnl Systemd will be disabled by default but if your build system is detected 104dnl to have systemd build libraries it will be enabled. You can always force 105dnl disable with --disable-systemd 106AC_DEFUN([AX_AVAILABLE_SYSTEMD], [ 107 AX_ALLOW_SYSTEMD_OPTS() 108 AX_CHECK_SYSTEMD() 109]) 110