diff --git a/.gitignore b/.gitignore index 880497d4..9db5e937 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ build-aux autom4te.cache ell src/iwd +src/iwd.service client/iwctl monitor/iwmon tools/hwsim diff --git a/Makefile.am b/Makefile.am index daf0510f..3fc6db96 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,7 +64,9 @@ ell_sources = ell/ell.h ell/private.h ell/missing.h \ ell_libell_internal_la_SOURCES = $(ell_sources) -bin_PROGRAMS = src/iwd +bin_PROGRAMS = + +libexec_PROGRAMS = src/iwd src_iwd_SOURCES = src/main.c linux/nl80211.h \ src/netdev.h src/netdev.c \ @@ -104,6 +106,13 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h \ src_iwd_LDADD = ell/libell-internal.la -ldl +if SYSTEMD_SERVICE +src_iwd_DEPENDENCIES = src/iwd.service + +systemd_unitdir = @SYSTEMD_UNITDIR@ +systemd_unit_DATA = src/iwd.service +endif + if CLIENT bin_PROGRAMS += client/iwctl @@ -275,11 +284,14 @@ if BUILD_DOCS dist_man_MANS = $(manual_pages) endif -EXTRA_DIST = src/genbuiltin doc/main.conf $(manual_pages:.1=.txt) +EXTRA_DIST = src/genbuiltin src/iwd.service.in \ + doc/main.conf $(manual_pages:.1=.txt) AM_CFLAGS = -fvisibility=hidden -DISTCHECK_CONFIGURE_FLAGS = --disable-dbus-policy +CLEANFILES = src/iwd.service + +DISTCHECK_CONFIGURE_FLAGS = --disable-dbus-policy --disable-systemd-service DISTCLEANFILES = $(BUILT_SOURCES) $(unit_tests) $(manual_pages) @@ -309,6 +321,13 @@ ell/unit/test_data: Makefile fi \ done > $@ +SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \ + $(SED) -e 's,@libexecdir\@,$(libexecdir),g' \ + < $< > $@ + +%.service: %.service.in Makefile + $(SED_PROCESS) + %.1: %.txt $(AM_V_GEN)$(A2X) --doctype manpage --format manpage $(srcdir)/$< diff --git a/configure.ac b/configure.ac index 9560439a..b3a7fd41 100644 --- a/configure.ac +++ b/configure.ac @@ -122,6 +122,24 @@ if (test "${enable_dbus_policy}" != "no" && test -z "${path_dbus_datadir}"); the fi AC_SUBST(DBUS_DATADIR, [${path_dbus_datadir}]) +AC_ARG_ENABLE([systemd-service], AC_HELP_STRING([--disable-systemd-service], + [don't install systemd service file]), + [enable_systemd_service=${enableval}]) +AM_CONDITIONAL(SYSTEMD_SERVICE, test "${enable_systemd_service}" != "no") + +AC_ARG_WITH([systemd-unitdir], AC_HELP_STRING([--with-systemd-unitdir=DIR], + [path to systemd unit directory]), + [path_systemd_unitdir=${withval}]) +if (test "${enable_systemd_service}" != "no" && test -z "${path_systemd_unitdir}"); then + AC_MSG_CHECKING([systemd unit directory]) + path_systemd_unitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" + if (test -z "${path_systemd_unitdir}"); then + AC_MSG_ERROR([systemd unit directory is required]) + fi + AC_MSG_RESULT([${path_systemd_unitdir}]) +fi +AC_SUBST(SYSTEMD_UNITDIR, [${path_systemd_unitdir}]) + AC_ARG_ENABLE([docs], AC_HELP_STRING([--enable-docs], [build documentation and manual pages]), [enable_docs=${enableval}]) diff --git a/src/iwd.service.in b/src/iwd.service.in new file mode 100644 index 00000000..50fbf6af --- /dev/null +++ b/src/iwd.service.in @@ -0,0 +1,9 @@ +[Unit] +Description=Wireless service + +[Service] +ExecStart=@libexecdir@/iwd +LimitNPROC=1 + +[Install] +WantedBy=network-pre.target