]> git.ipfire.org Git - thirdparty/nqptp.git/commitdiff
Build on OpenBSD
authorKlemens Nanni <kn@openbsd.org>
Sat, 27 Jan 2024 00:38:42 +0000 (01:38 +0100)
committerKlemens Nanni <klemens@posteo.de>
Sat, 27 Jan 2024 04:14:22 +0000 (05:14 +0100)
Recognise the system to configure, build and start.
More work is required to actually work with shairport-sync.
Tested on OpenBSD/amd64 7.4-current.

Makefile.am
configure.ac
nqptp-utilities.c
nqptp.c

index d2b399256bd84148f07d75d6abccc9077282260e..ff86fea02018594956f16d4b7e76c71dfbc7d753 100644 (file)
@@ -39,5 +39,3 @@ if INSTALL_FREEBSD_STARTUP
        chmod 555 /usr/local/etc/rc.d/nqptp
 endif
 endif
-
index ff1947f0f942277542ddcd69588ae06e93a0b764..503b805b49a31278df02f15aaa6b8130d6cfa4c4 100644 (file)
@@ -8,6 +8,7 @@ AC_CANONICAL_HOST
 
 build_linux=no
 build_freebsd=no
+build_openbsd=no
 
 # Detect the target system
 case "${host_os}" in
@@ -16,7 +17,10 @@ case "${host_os}" in
         ;;
     freebsd*)
         build_freebsd=yes
-        ;;    
+        ;;
+    openbsd*)
+        build_openbsd=yes
+        ;;
     *)
         AC_MSG_ERROR(["OS $host_os is not supported"])
         ;;
@@ -25,6 +29,7 @@ esac
 # Pass the conditionals to automake
 AM_CONDITIONAL([BUILD_FOR_LINUX], [test "$build_linux" = "yes"])
 AM_CONDITIONAL([BUILD_FOR_FREEBSD], [test "$build_freebsd" = "yes"])
+AM_CONDITIONAL([BUILD_FOR_OPENBSD], [test "$build_openbsd" = "yes"])
 
 if test "x$build_linux" = "xyes" ; then
   AC_DEFINE([CONFIG_FOR_LINUX], 1, [Build for Linux.])
@@ -32,6 +37,9 @@ fi
 if test "x$build_freebsd" = "xyes" ; then
   AC_DEFINE([CONFIG_FOR_FREEBSD], 1, [Build for FreeBSD.])
 fi
+if test "x$build_openbsd" = "xyes" ; then
+  AC_DEFINE([CONFIG_FOR_OPENBSD], 1, [Build for OpenBSD.])
+fi
 
 AC_CHECK_PROGS([GIT], [git])
 if test -n "$GIT" && test -e ".git/index" ; then
@@ -44,7 +52,7 @@ AM_CONDITIONAL([USE_GIT_VERSION], [test -n "$GIT" && test -e ".git/index" ])
 AC_ARG_WITH([systemd-startup],[AS_HELP_STRING([--with-systemd-startup],[install a systemd startup script during a make install])])
 AM_CONDITIONAL([INSTALL_SYSTEMD_STARTUP], [test "x$with_systemd_startup" = "xyes"])
 
-# Check to see if we should include the systemd stuff to define it as a service
+# Check to see if we should include the FreeBSD stuff to define it as a service
 AC_ARG_WITH([freebsd-startup],[AS_HELP_STRING([--with-freebsd-startup],[install a FreeBSD startup script during a make install])])
 AM_CONDITIONAL([INSTALL_FREEBSD_STARTUP], [test "x$with_freebsd_startup" = "xyes"])
 
@@ -58,7 +66,10 @@ AC_PROG_INSTALL
 
 # Checks for libraries.
 AC_CHECK_LIB([pthread],[pthread_create], , AC_MSG_ERROR(pthread library needed))
-AC_CHECK_LIB([rt],[clock_gettime], , AC_MSG_ERROR(librt needed for shared memory library))
+if test "x$build_openbsd" = "xno" ; then
+  # part of libc
+  AC_CHECK_LIB([rt],[clock_gettime], , AC_MSG_ERROR(librt needed for shared memory library))
+fi
 
 # Checks for header files.
 AC_CHECK_HEADERS([arpa/inet.h inttypes.h netdb.h stdlib.h string.h sys/socket.h unistd.h])
index 7c30877584446eba13c64fe279802fb7aef28d7c..cfbd1ee43b5c971ab6fb79e19c834f9363c48872 100644 (file)
@@ -28,7 +28,7 @@
 #include <linux/if_packet.h> // sockaddr_ll
 #endif
 
-#ifdef CONFIG_FOR_FREEBSD
+#if defined(CONFIG_FOR_FREEBSD) || defined(CONFIG_FOR_OPENBSD)
 #include <sys/types.h>
 #include <unistd.h>
 #include <net/if_dl.h>
diff --git a/nqptp.c b/nqptp.c
index a1a3c76a389166b1c2694be86e68538dc071fd82..6af9495f3ca6daf65e137fb4d9c3670b82085b43 100644 (file)
--- a/nqptp.c
+++ b/nqptp.c
@@ -48,7 +48,7 @@
 #include <netdb.h>
 #include <sys/socket.h>
 
-#ifdef CONFIG_FOR_FREEBSD
+#if defined(CONFIG_FOR_FREEBSD) || defined(CONFIG_FOR_OPENBSD)
 #include <netinet/in.h>
 #include <sys/socket.h>
 #endif
@@ -206,7 +206,7 @@ int main(int argc, char **argv) {
     die("failed to set size of shared memory \"%s\".", NQPTP_INTERFACE_NAME);
   }
 
-#ifdef CONFIG_FOR_FREEBSD
+#if defined(CONFIG_FOR_FREEBSD) || defined(CONFIG_FOR_OPENBSD)
   shared_memory = (struct shm_structure *)mmap(NULL, sizeof(struct shm_structure),
                                                PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
 #endif