From f11609a017c05262096a394346fd1b122a02dccf Mon Sep 17 00:00:00 2001 From: Jairaj Solanki Date: Fri, 23 Jan 2026 16:31:25 +0530 Subject: [PATCH 1/2] build: Add systemd service file installation support Add autotools support for systemd service file installation. The service file is installed to /lib/systemd/system/ during 'make install' when systemd is detected via pkg-config. Changes: - configure.ac: Add systemd detection with --with-systemdsystemunitdir option - Makefile.am: Add conditional service file installation - time-daemon.service: Add service file to repository For system install: ./configure && make && sudo make install For local builds: ./configure --prefix=$(pwd)/install --without-systemdsystemunitdir Signed-off-by: Jairaj Solanki --- Makefile.am | 5 +++++ configure.ac | 20 ++++++++++++++++++++ time-daemon.service | 15 +++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 time-daemon.service diff --git a/Makefile.am b/Makefile.am index 2da0f9d..9ea4094 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,3 +21,8 @@ bin_PROGRAMS = time_daemon time_daemon_SOURCES = time_daemon.c time_service_v01.c time_daemon_LDADD = $(requiredlibs) time_daemon_LDFLAGS = -lpthread @GLIB_LIBS@ + +# Systemd service file installation +if HAVE_SYSTEMD +systemdsystemunit_DATA = time-daemon.service +endif diff --git a/configure.ac b/configure.ac index 1833f14..b1e554b 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,26 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16, dummy=yes, AC_MSG_ERROR(GLib >= 2.16 i GLIB_LIBS="$GLIB_LIBS $GTHREAD_LIBS" AC_SUBST(GLIB_LIBS) +# Check for systemd +AC_ARG_WITH([systemdsystemunitdir], + [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])], + [], + [with_systemdsystemunitdir=auto]) + +AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [ + def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) + + AS_IF([test "x$def_systemdsystemunitdir" = "x"], + [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], + [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]) + with_systemdsystemunitdir=no], + [with_systemdsystemunitdir="$def_systemdsystemunitdir"])]) + +AS_IF([test "x$with_systemdsystemunitdir" != "xno"], + [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]) + +AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) + AC_CONFIG_FILES([ \ Makefile \ ]) diff --git a/time-daemon.service b/time-daemon.service new file mode 100644 index 0000000..a21cbe2 --- /dev/null +++ b/time-daemon.service @@ -0,0 +1,15 @@ +[Unit] +Description=Time Services Daemon + +[Service] +Type=simple +ExecStart=/usr/bin/time_daemon +Restart=on-failure +StateDirectory=time + +# Device access for RTC (read-only) +DeviceAllow=/dev/rtc0 r +DevicePolicy=closed + +[Install] +WantedBy=multi-user.target From c6a8eea99c3de58054cbccf4901530cc592ccddd Mon Sep 17 00:00:00 2001 From: Jairaj Solanki Date: Fri, 23 Jan 2026 17:13:17 +0530 Subject: [PATCH 2/2] Release version 0.1.1 - Update version from 1.0.0 to 0.1.1 in configure.ac - Update build_script.sh to use sudo for make install Signed-off-by: Jairaj Solanki --- build_script.sh | 7 ++++++- configure.ac | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build_script.sh b/build_script.sh index 23fc85f..7a92f12 100755 --- a/build_script.sh +++ b/build_script.sh @@ -50,7 +50,12 @@ echo "Running configure.." echo "Running make.." make || { echo "make failed"; exit 1; } -make install || { echo "make install failed"; exit 1; } +# Use sudo only if not running as root +if [ "$(id -u)" -eq 0 ]; then + make install || { echo "make install failed"; exit 1; } +else + sudo make install || { echo "make install failed"; exit 1; } +fi FILES_TO_CLEAN=( aclocal.m4 configure ar-lib config.h config.h.in config.log config.status libtool diff --git a/configure.ac b/configure.ac index b1e554b..3f4806d 100644 --- a/configure.ac +++ b/configure.ac @@ -3,8 +3,8 @@ # Requires autoconf tool later than 2.61 AC_PREREQ(2.61) -# Initialize the qmi-framework package version 1.0.0 -AC_INIT([time-services],1.0.0) +# Initialize the qmi-framework package version 0.1.1 +AC_INIT([time-services],0.1.1) # Does not strictly follow GNU Coding standards AM_INIT_AUTOMAKE([foreign]) # Disables auto rebuilding of configure, Makefile.ins