From ba5a66731b9b532a601ad5b3d7dd6b941d1d1917 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Wed, 12 Jan 2022 09:15:14 +0100 Subject: [PATCH] configure: Add --with-systemd option The option enables disabling installation of systemd unit file or setting a different path for systemd unit file. --- Makefile.in | 9 ++++---- configure | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 38 +++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 4 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4161124..4cf40d7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -56,6 +56,7 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ top_srcdir = @top_srcdir@ +unitdir = @unitdir@ BUILDROOT = $(DSTROOT)$(RPM_BUILD_ROOT)$(DESTDIR) @@ -130,10 +131,10 @@ install: all echo "Installing launchd service to $(BUILDROOT)/Library/LaunchDaemons..."; \ $(INSTALL) -d -m 755 $(BUILDROOT)/Library/LaunchDaemons; \ $(INSTALL) -c -m 644 org.msweet.lprint.plist $(BUILDROOT)/Library/LaunchDaemons; \ - else \ - echo "Installing systemd service to $(BUILDROOT)$(sysconfdir)/systemd/system..."; \ - $(INSTALL) -d -m 755 $(BUILDROOT)$(sysconfdir)/systemd/system; \ - $(INSTALL) -c -m 644 lprint.service $(BUILDROOT)$(sysconfdir)/systemd/system; \ + elif test x$unitdir != x; then \ + echo "Installing systemd service to $(BUILDROOT)$(unitdir)..."; \ + $(INSTALL) -d -m 755 $(BUILDROOT)$(unitdir); \ + $(INSTALL) -c -m 644 lprint.service $(BUILDROOT)$(unitdir); \ fi diff --git a/configure b/configure index 249946c..7c5b496 100755 --- a/configure +++ b/configure @@ -619,6 +619,7 @@ ac_subst_vars='LTLIBOBJS LIBOBJS OPTIM CSFLAGS +unitdir CUPSCONFIG PKGCONFIG INSTALL @@ -688,6 +689,7 @@ enable_option_checking enable_debug enable_maintainer enable_sanitizer +with_systemd with_ldflags ' ac_precious_vars='build_alias @@ -1327,6 +1329,7 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-systemd=PATH install systemd service file, default=yes --with-ldflags=... Specify additional LDFLAGS Some influential environment variables: @@ -2349,6 +2352,14 @@ LDFLAGS="${LDFLAGS:=}" LIBS="${LIBS:=}" +if test $prefix = NONE +then : + + prefix=$ac_default_prefix + +fi + + @@ -3874,6 +3885,59 @@ then : fi + + +# Check whether --with-systemd was given. +if test ${with_systemd+y} +then : + withval=$with_systemd; + case $withval in #( + yes) : + + with_systemd=yes + unitdir=${prefix}/lib/systemd/system + ;; #( + no) : + + with_systemd=no + ;; #( + *) : + + with_systemd=yes + unitdir=$withval + ;; +esac + +else $as_nop + + with_systemd=yes + unitdir=${prefix}/lib/systemd/system + +fi + + + +if test `uname` != "Darwin" && test x$with_systemd = xyes +then : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for systemd unit directory" >&5 +printf %s "checking for systemd unit directory... " >&6; } + if test x$unitdir != x +then : + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $unitdir" >&5 +printf "%s\n" "$unitdir" >&6; } + +else $as_nop + + as_fn_error $? "Path to the unit dir is empty." "$LINENO" 5 + +fi + +fi + + if test x$enable_debug = xyes then : diff --git a/configure.ac b/configure.ac index cfb4090..9421478 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,12 @@ LDFLAGS="${LDFLAGS:=}" LIBS="${LIBS:=}" +dnl Figure out prefix - needed for systemd unit dir +AS_IF([test $prefix = NONE], [ + prefix=$ac_default_prefix +], []) + + dnl Standard programs... AC_PROG_CC AC_PROG_RANLIB @@ -110,6 +116,38 @@ AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [turn on debugging, defa AC_ARG_ENABLE([maintainer], AS_HELP_STRING([--enable-maintainer], [turn on maintainer mode, default=no])) AC_ARG_ENABLE([sanitizer], AS_HELP_STRING([--enable-sanitizer], [build with AddressSanitizer, default=no])) + +AC_ARG_WITH([systemd], AS_HELP_STRING([--with-systemd[=PATH]], [install systemd service file, default=yes]), +[ + AS_CASE([$withval], [yes], [ + with_systemd=yes + unitdir=${prefix}/lib/systemd/system + ], [no], [ + with_systemd=no + ], [ + with_systemd=yes + unitdir=$withval + ]) +], [ + with_systemd=yes + unitdir=${prefix}/lib/systemd/system +]) + + +dnl Substitute unitdir macro if we aren't on Darwin and want systemd... +AS_IF([test `uname` != "Darwin" && test x$with_systemd = xyes], [ + AC_MSG_CHECKING([for systemd unit directory]) + AS_IF([test x$unitdir != x], [ + AC_SUBST([unitdir]) + AC_MSG_RESULT([$unitdir]) + ], + [ + AC_MSG_ERROR([Path to the unit dir is empty.]) + ]) +], +[]) + + AS_IF([test x$enable_debug = xyes], [ OPTIM="-g" CSFLAGS="" -- 2.34.1