Skip to content

Commit

Permalink
Merge pull request #13 from SDRplay/api3
Browse files Browse the repository at this point in the history
Fix MacOS builds and add OpenBSD build support
  • Loading branch information
SDRplay authored Aug 7, 2023
2 parents e320bd5 + d115633 commit 972fa7f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SDRPLAY_CFLAGS=-DSDRPLAY
endif

CPPFLAGS+=-DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\"
CFLAGS+= -O3 -Wall -Wextra -pedantic -W -fcommon
CFLAGS+= -O2 -g -Wall -Werror -W
CFLAGS+=$(SDRPLAY_CFLAGS)
LIBS=$(SDRPLAY_LIBS) $(LIBS_RTL) -lsdrplay_api -lpthread -lm -lrtlsdr
CC=gcc
Expand All @@ -39,11 +39,23 @@ UNAME := $(shell uname)

ifeq ($(UNAME), Linux)
LIBS+=-lrt
CFLAGS+=-std=c11 -D_DEFAULT_SOURCE
endif
ifeq ($(UNAME), Darwin)
# TODO: Putting GCC in C11 mode breaks things.
CFLAGS+=-std=c11
UNAME_R := $(shell uname -r)
ifeq ($(shell expr "$(UNAME_R)" : '1[012345]\.'),3)
CFLAGS+=-std=c11 -DMISSING_GETTIME -DMISSING_NANOSLEEP
COMPAT+=compat/clock_gettime/clock_gettime.o compat/clock_nanosleep/clock_nanosleep.o
else
# Darwin 16 (OS X 10.12) supplies clock_gettime() and clockid_t
CFLAGS+=-std=c11 -DMISSING_NANOSLEEP -DCLOCKID_T
COMPAT+=compat/clock_nanosleep/clock_nanosleep.o
endif
endif

ifeq ($(UNAME), OpenBSD)
CFLAGS+= -DMISSING_NANOSLEEP
COMPAT+= compat/clock_nanosleep/clock_nanosleep.o
endif

all: dump1090 view1090
Expand Down
4 changes: 4 additions & 0 deletions compat/clock_gettime/clock_gettime.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include <mach/mach_time.h>

#ifdef _CLOCKID_T_DEFINED_
#define CLOCKID_T
#endif

#ifndef CLOCKID_T
#define CLOCKID_T
typedef enum
Expand Down
5 changes: 4 additions & 1 deletion compat/clock_nanosleep/clock_nanosleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
* http://www.gnu.org/copyleft/gpl.html *
***********************************************************************/

#include "clock_nanosleep.h"
#include <errno.h> // for errno, EINVAL
#include <time.h> // for nanosleep, NULL

#include "clock_nanosleep.h"
#ifdef MISSING_GETTIME
#include "../clock_gettime/clock_gettime.h" // for clock_gettime
#endif

int clock_nanosleep(clockid_t id, int flags, const struct timespec *ts,
struct timespec *ots) {
Expand Down
4 changes: 4 additions & 0 deletions compat/clock_nanosleep/clock_nanosleep.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef CLOCK_NANOSLEEP_H
#define CLOCK_NANOSLEEP_H

#ifdef _CLOCKID_T_DEFINED_
#define CLOCKID_T
#endif

#ifndef CLOCKID_T
#define CLOCKID_T
typedef enum
Expand Down
13 changes: 8 additions & 5 deletions compat/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

#if defined(__APPLE__)

/* implementations of clock_gettime, clock_nanosleep */

#include "clock_gettime/clock_gettime.h"
#include "clock_nanosleep/clock_nanosleep.h"

/*
* Mach endian conversion
*/
Expand All @@ -29,4 +24,12 @@

#endif

#ifdef MISSING_NANOSLEEP
#include "clock_nanosleep/clock_nanosleep.h"
#endif

#ifdef MISSING_GETTIME
#include "clock_gettime/clock_gettime.h"
#endif

#endif //COMPAT_UTIL_H

0 comments on commit 972fa7f

Please sign in to comment.