]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Add support for OpenBSD compilation
authorMike Brady <mike@openbsd.localdomain>
Fri, 9 Feb 2018 20:38:55 +0000 (20:38 +0000)
committerMike Brady <mike@openbsd.localdomain>
Fri, 9 Feb 2018 20:38:55 +0000 (20:38 +0000)
Makefile.am
common.c
common.h
configure.ac
definitions.h
player.c
shairport.c

index 48ef77aa0c22af0c8a2927a43a43bd34dbfda76c..b3bffb6dbd1ffc577035d7ba4a3f177dddc442e6 100644 (file)
@@ -9,9 +9,13 @@ shairport_sync_SOURCES = shairport.c rtsp.c mdns.c mdns_external.c common.c rtp.
 AM_CFLAGS = -Wno-multichar -DSYSCONFDIR=\"$(sysconfdir)\"
 if BUILD_FOR_FREEBSD
   AM_CPPFLAGS = -I/usr/local/include -Wno-multichar -DSYSCONFDIR=\"$(sysconfdir)\" -O2
+else
+if BUILD_FOR_OPENBSD
+  AM_CPPFLAGS = -I/usr/local/include -Wno-multichar -DSYSCONFDIR=\"$(sysconfdir)\"
 else
   AM_CPPFLAGS = -Wno-multichar -DSYSCONFDIR=\"$(sysconfdir)\"
 endif
+endif
 
 if USE_APPLE_ALAC
   shairport_sync_SOURCES += apple_alac.cpp
index e8cc16ac86ceb4f752b211dd9e77a48a20ec7b58..80f9c60e2f712ba85fe20fb84f6c1ad57a6e3395 100644 (file)
--- a/common.c
+++ b/common.c
@@ -683,7 +683,7 @@ double vol2attn(double vol, long max_db, long min_db) {
 
 uint64_t get_absolute_time_in_fp() {
   uint64_t time_now_fp;
-#ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN
+#ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN_AND_OPENBSD
   struct timespec tn;
   // can't use CLOCK_MONOTONIC_RAW as it's not implemented in OpenWrt
   clock_gettime(CLOCK_MONOTONIC, &tn);
index 24f37676dcb95901e739599e608ad96f03f7695e..addccafb8ff2e9a48fda948dd9e69cdc598c0f4b 100644 (file)
--- a/common.h
+++ b/common.h
 #include "definitions.h"
 #include "mdns.h"
 
-#if defined(__APPLE__) && defined(__MACH__)
-/* Apple OSX and iOS (Darwin). ------------------------------ */
-#include <TargetConditionals.h>
-#if TARGET_OS_MAC == 1
-/* OSX */
-#define COMPILE_FOR_OSX 1
-#endif
-#endif
-
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__)
-/* Linux and FreeBSD */
-#define COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN 1
-#endif
-
 // struct sockaddr_in6 is bigger than struct sockaddr. derp
 #ifdef AF_INET6
 #define SOCKADDR struct sockaddr_storage
index b72ee60539a572e53f83f760bd70e6642a09717c..1c91659ab1de434940d4ee12b02899effd4a5a5d 100644 (file)
@@ -28,8 +28,15 @@ if test "x${with_os}" = xlinux -o "x${with_os}" = xfreebsd ; then
  AC_CHECK_LIB([rt],[clock_gettime], , AC_MSG_ERROR(librt needed))
 fi
 
+if test "x${with_os}" = xopenbsd ; then
+ AC_CHECK_LIB([c],[clock_gettime], , AC_MSG_ERROR(libc needed))
+fi
+
 AM_CONDITIONAL([BUILD_FOR_FREEBSD], [test "x${with_os}" = xfreebsd ])
 
+AM_CONDITIONAL([BUILD_FOR_OPENBSD], [test "x${with_os}" = xopenbsd ])
+
+
 ##### Some build systems are not fully using pkg-config, so we can use the flag ${with_pkg_config} on a case-by-case basis
 ##### to control how to deal with them
 
@@ -52,7 +59,8 @@ AC_MSG_RESULT(>>Including libpopt)
 if  test "x${with_pkg_config}" = xyes ; then
   PKG_CHECK_MODULES(
       [POPT], [popt],
-      [LIBS="${POPT_LIBS} ${LIBS}"
+      [CFLAGS="${POPT_CFLAGS} ${CFLAGS}"
+      LIBS="${POPT_LIBS} ${LIBS}"
        AC_DEFINE([HAVE_LIBPOPT],[1],[Define to 1 if you have popt])])
 else
   AC_CHECK_LIB([popt],[poptGetContext], , AC_MSG_ERROR(libpopt needed))
index 5fe42b41e980f1f8628c6a3bb64242dfaa5433fa..bde920bea62affc071c8bec1ce803a5203a011cd 100644 (file)
@@ -19,9 +19,8 @@
 #endif
 #endif
 
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__)
-/* Linux and FreeBSD */
-#define COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN 1
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
+#define COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN_AND_OPENBSD 1
 #endif
 
 // struct sockaddr_in6 is bigger than struct sockaddr. derp
index 8530f444615c1ede90a18900d665031c5136ccb5..5079103c924257b71bb65bc33f0500cd54703c71 100644 (file)
--- a/player.c
+++ b/player.c
@@ -1124,7 +1124,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
       time_to_wait_for_wakeup_fp *= 4 * 352;      // four full 352-frame packets
       time_to_wait_for_wakeup_fp /= 3;            // four thirds of a packet time
 
-#ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN
+#ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN_AND_OPENBSD
       uint64_t time_of_wakeup_fp = local_time_now + time_to_wait_for_wakeup_fp;
       uint64_t sec = time_of_wakeup_fp >> 32;
       uint64_t nsec = ((time_of_wakeup_fp & 0xffffffff) * 1000000000) >> 32;
@@ -1380,7 +1380,7 @@ static void *player_thread_func(void *arg) {
   if (rc)
     debug(1, "Error initialising vol_mutex.");
 // set the flowcontrol condition variable to wait on a monotonic clock
-#ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN
+#ifdef COMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN_AND_OPENBSD
   pthread_condattr_t attr;
   pthread_condattr_init(&attr);
   pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); // can't do this in OS X, and don't need it.
index effc4cca91cc14f6325ed83c8f4cf37b71986574..9a4a5f94c37e116e0f3b771d4cb651d5f0c87bba 100644 (file)
@@ -2,7 +2,7 @@
  * Shairport, an Apple Airplay receiver
  * Copyright (c) James Laird 2013
  * All rights reserved.
- * Modifications (c) Mike Brady 2014--2017
+ * Modifications (c) Mike Brady 2014--2018
  *
  * Permission is hereby granted, free of charge, to any person
  * obtaining a copy of this software and associated documentation
@@ -31,6 +31,7 @@
 #include <libconfig.h>
 #include <libgen.h>
 #include <memory.h>
+#include <sys/socket.h>
 #include <net/if.h>
 #include <popt.h>
 #include <stdio.h>