public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] build: Allow systemd unit build without libsystemd
@ 2025-12-08  1:24 Achill Gilgenast
  2025-12-08  3:46 ` [BlueZ] " bluez.test.bot
  2025-12-08 11:57 ` [PATCH BlueZ] " Bastien Nocera
  0 siblings, 2 replies; 5+ messages in thread
From: Achill Gilgenast @ 2025-12-08  1:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Achill Gilgenast

Decouples libsystemd and systemd units from the same option and allows
installation of services without systemd.pc by manually specifying the
directories.

This is useful in Alpine Linux where we don't ship systemd, but allow
systemd services to be subpackaged for downstream distributions like
postmarketOS.
---
I'm by far no expert in autotools or bluez and how specific components
are best categorized, so please let me know your feedback.
---
 Makefile.am    |  6 +++++-
 Makefile.mesh  |  4 +++-
 Makefile.obexd |  2 +-
 Makefile.tools |  4 ++--
 configure.ac   | 21 +++++++++++++++------
 5 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e152ae64853c..d3cdb2890d32 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,13 +49,17 @@ conf_DATA += profiles/network/network.conf
 state_DATA =
 endif
 
-if SYSTEMD
+if SYSTEMD_SYSTEMUNITS
 systemdsystemunitdir = $(SYSTEMD_SYSTEMUNITDIR)
 systemdsystemunit_DATA = src/bluetooth.service
+endif
 
+if SYSTEMD_USERUNITS
 systemduserunitdir = $(SYSTEMD_USERUNITDIR)
 systemduserunit_DATA =
+endif
 
+if SYSTEMD_UNITS
 dbussystembusdir = $(DBUS_SYSTEMBUSDIR)
 dbussystembus_DATA = src/org.bluez.service
 endif
diff --git a/Makefile.mesh b/Makefile.mesh
index e4c9fa6a32e6..e9998a9cdd75 100644
--- a/Makefile.mesh
+++ b/Makefile.mesh
@@ -6,8 +6,10 @@ dbus_DATA += mesh/bluetooth-mesh.conf
 conf_DATA += mesh/mesh-main.conf
 endif
 
-if SYSTEMD
+if SYSTEMD_SYSTEMUNITS
 systemdsystemunit_DATA += mesh/bluetooth-mesh.service
+endif
+if SYSTEMD_UNITS
 dbussystembus_DATA += mesh/org.bluez.mesh.service
 endif
 
diff --git a/Makefile.obexd b/Makefile.obexd
index 7ad74e1286b6..25aa8feb73d1 100644
--- a/Makefile.obexd
+++ b/Makefile.obexd
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 if OBEX
 
-if SYSTEMD
+if SYSTEMD_USERUNITS
 systemduserunit_DATA += obexd/src/obex.service
 
 obexd-add-service-symlink:
diff --git a/Makefile.tools b/Makefile.tools
index 561b03d0b95b..72dffe7cd005 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -74,7 +74,7 @@ pkglibexec_PROGRAMS += tools/btmon-logger
 tools_btmon_logger_SOURCES = tools/btmon-logger.c
 tools_btmon_logger_LDADD = src/libshared-mainloop.la
 
-if SYSTEMD
+if SYSTEMD_SYSTEMUNITS
 systemdsystemunit_DATA += tools/bluetooth-logger.service
 endif
 endif
@@ -340,7 +340,7 @@ tools_hex2hcd_SOURCES = tools/hex2hcd.c tools/missing.h
 
 tools_mpris_proxy_SOURCES = tools/mpris-proxy.c
 tools_mpris_proxy_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
-if SYSTEMD
+if SYSTEMD_USERUNITS
 systemduserunit_DATA += tools/mpris-proxy.service
 endif
 
diff --git a/configure.ac b/configure.ac
index 16b81aca37e6..2d9352b59557 100644
--- a/configure.ac
+++ b/configure.ac
@@ -352,29 +352,38 @@ AC_ARG_WITH([systemdsystemunitdir],
 			AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
 			[path to systemd system unit directory]),
 					[path_systemunitdir=${withval}])
-if (test "${enable_systemd}" != "no" && test -z "${path_systemunitdir}"); then
+if (test "${enable_systemd}" != "no" -o -z "${path_systemunitdir}"); then
 	AC_MSG_CHECKING([systemd system unit dir])
-	path_systemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"
 	if (test -z "${path_systemunitdir}"); then
-		AC_MSG_ERROR([systemd system unit directory is required])
+		path_systemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"
+		if (test -z "${path_systemunitdir}"); then
+			AC_MSG_ERROR([systemd system unit directory is required])
+		fi
 	fi
 	AC_MSG_RESULT([${path_systemunitdir}])
 fi
 AC_SUBST(SYSTEMD_SYSTEMUNITDIR, [${path_systemunitdir}])
+AM_CONDITIONAL(SYSTEMD_SYSTEMUNITS, test "${path_systemunitdir}" != "")
 
 AC_ARG_WITH([systemduserunitdir],
 			AS_HELP_STRING([--with-systemduserunitdir=DIR],
 			[path to systemd user unit directory]),
 					[path_userunitdir=${withval}])
-if (test "${enable_systemd}" != "no" && test -z "${path_userunitdir}"); then
+if (test "${enable_systemd}" != "no" -o -z "${path_userunitdir}"); then
 	AC_MSG_CHECKING([systemd user unit dir])
-	path_userunitdir="`$PKG_CONFIG --variable=systemduserunitdir systemd`"
 	if (test -z "${path_userunitdir}"); then
-		AC_MSG_ERROR([systemd user unit directory is required])
+		path_userunitdir="`$PKG_CONFIG --variable=systemduserunitdir systemd`"
+		if (test -z "${path_userunitdir}"); then
+			AC_MSG_ERROR([systemd user unit directory is required])
+		fi
 	fi
 	AC_MSG_RESULT([${path_userunitdir}])
 fi
 AC_SUBST(SYSTEMD_USERUNITDIR, [${path_userunitdir}])
+AM_CONDITIONAL(SYSTEMD_USERUNITS, test "${path_userunitdir}" != "")
+
+AM_CONDITIONAL(SYSTEMD_UNITS, (test "${path_systemunitdir}" != "" || test "${path_userunitdir}" != ""))
+
 
 AC_ARG_ENABLE(datafiles, AS_HELP_STRING([--disable-datafiles],
 			[do not install configuration and data files]),
-- 
2.52.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-12  9:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-08  1:24 [PATCH BlueZ] build: Allow systemd unit build without libsystemd Achill Gilgenast
2025-12-08  3:46 ` [BlueZ] " bluez.test.bot
2025-12-08 11:57 ` [PATCH BlueZ] " Bastien Nocera
2025-12-09 14:25   ` Achill Gilgenast
2026-01-12  9:50     ` Bastien Nocera

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox