From 91e963556344da6571581cdc7933440d5ac6762a Mon Sep 17 00:00:00 2001 From: Michael Norton <26778057+mikenor@users.noreply.github.com> Date: Sun, 31 Mar 2019 15:01:06 -0600 Subject: [PATCH 1/4] Restore cross-platform compatibility Re-implements platform-specific build of compatibility functions. Had been removed by bef563b8a32862e1c487b4e6678384ea8175dc04. --- Makefile | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b4f6aaa..6332556 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,29 @@ BLADERF ?= yes CPPFLAGS += -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\" DIALECT = -std=c11 -CFLAGS += $(DIALECT) -O2 -g -Wall -Werror -W -D_DEFAULT_SOURCE -LIBS = -lpthread -lm -lrt +CFLAGS += $(DIALECT) -O2 -g -Wall -Werror -W +LIBS = -lpthread -lm + +UNAME := $(shell uname) + +ifeq ($(UNAME), Linux) + LIBS += -lrt + CFLAGS += -D_DEFAULT_SOURCE +endif + +ifeq ($(UNAME), Darwin) + ifneq ($(shell sw_vers -productVersion | egrep '^10\.([0-9]|1[01])\.'),) # Mac OS X ver <= 10.11 + CFLAGS += -DMISSING_GETTIME + COMPAT += compat/clock_gettime/clock_gettime.o + endif + CFLAGS += -DMISSING_NANOSLEEP + COMPAT += compat/clock_nanosleep/clock_nanosleep.o +endif + +ifeq ($(UNAME), OpenBSD) + CFLAGS += -DMISSING_NANOSLEEP + COMPAT += compat/clock_nanosleep/clock_nanosleep.o +endif ifeq ($(RTLSDR), yes) SDR_OBJ += sdr_rtlsdr.o From 8a6261d7c2202bc06c869fbd51e5c037f32941c8 Mon Sep 17 00:00:00 2001 From: Michael Norton <26778057+mikenor@users.noreply.github.com> Date: Sun, 31 Mar 2019 15:15:59 -0600 Subject: [PATCH 2/4] Header typedef workaround for newer MacOS versions Newish version of MacOS's time.h already `typedef`s `clockid_t` but doesn't seem to `#define` anything indicating such; as a workaround assume that `#ifdef CLOCK_MONOTONIC` on a Mac means that `clockid_t` has been `typedef`'d. --- compat/clock_gettime/clock_gettime.h | 8 ++++++++ compat/clock_nanosleep/clock_nanosleep.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/compat/clock_gettime/clock_gettime.h b/compat/clock_gettime/clock_gettime.h index 83fdac7..3c4c29b 100644 --- a/compat/clock_gettime/clock_gettime.h +++ b/compat/clock_gettime/clock_gettime.h @@ -3,9 +3,17 @@ #include // Apple-only, but this isn't inclued on other BSDs +#ifdef __OpenBSD__ #ifdef _CLOCKID_T_DEFINED_ #define CLOCKID_T #endif +#endif + +#ifdef __APPLE__ +#ifdef CLOCK_MONOTONIC +#define CLOCKID_T +#endif +#endif #ifndef CLOCKID_T #define CLOCKID_T diff --git a/compat/clock_nanosleep/clock_nanosleep.h b/compat/clock_nanosleep/clock_nanosleep.h index 9a8da5d..34eb801 100644 --- a/compat/clock_nanosleep/clock_nanosleep.h +++ b/compat/clock_nanosleep/clock_nanosleep.h @@ -1,9 +1,17 @@ #ifndef CLOCK_NANOSLEEP_H #define CLOCK_NANOSLEEP_H +#ifdef __OpenBSD__ #ifdef _CLOCKID_T_DEFINED_ #define CLOCKID_T #endif +#endif + +#ifdef __APPLE__ +#ifdef CLOCK_MONOTONIC +#define CLOCKID_T +#endif +#endif #ifndef CLOCKID_T #define CLOCKID_T From a2480a27697b5584f391320d20d99bca90590456 Mon Sep 17 00:00:00 2001 From: Michael Norton <26778057+mikenor@users.noreply.github.com> Date: Sun, 31 Mar 2019 15:21:20 -0600 Subject: [PATCH 3/4] Note about building with bladerf on mac --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a1dd06b..f9190fd 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Binaries are built in the source directory; you will need to arrange to install them (and a method for starting them) yourself. "make BLADERF=no" will disable bladeRF support and remove the dependency on -libbladeRF. +libbladeRF. This may be required on some platforms (e.g. MacOS). "make RTLSDR=no" will disable rtl-sdr support and remove the dependency on librtlsdr. From f497d7481f8709f5a0f92cf73f719cef79c0bac7 Mon Sep 17 00:00:00 2001 From: Michael Norton <26778057+mikenor@users.noreply.github.com> Date: Sun, 31 Mar 2019 17:57:48 -0600 Subject: [PATCH 4/4] Add FreeBSD support FreeBSD support, reworked from earlier pr by @neveragainde --- Makefile | 26 +++++++++++++++++++------- README.md | 4 ++-- compat/compat.h | 3 +++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 6332556..db78ff5 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,5 @@ PROGNAME=dump1090 -RTLSDR ?= yes -BLADERF ?= yes - CPPFLAGS += -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\" DIALECT = -std=c11 @@ -12,8 +9,9 @@ LIBS = -lpthread -lm UNAME := $(shell uname) ifeq ($(UNAME), Linux) - LIBS += -lrt CFLAGS += -D_DEFAULT_SOURCE + LIBS += -lrt + LIBS_USB += -lusb-1.0 endif ifeq ($(UNAME), Darwin) @@ -23,13 +21,27 @@ ifeq ($(UNAME), Darwin) endif CFLAGS += -DMISSING_NANOSLEEP COMPAT += compat/clock_nanosleep/clock_nanosleep.o + LIBS_USB += -lusb-1.0 + BLADERF ?= no endif ifeq ($(UNAME), OpenBSD) CFLAGS += -DMISSING_NANOSLEEP COMPAT += compat/clock_nanosleep/clock_nanosleep.o + LIBS_USB += -lusb-1.0 + BLADERF ?= no endif +ifeq ($(UNAME), FreeBSD) + CFLAGS += -D_DEFAULT_SOURCE + LIBS += -lrt + LIBS_USB += -lusb + BLADERF ?= no +endif + +RTLSDR ?= yes +BLADERF ?= yes + ifeq ($(RTLSDR), yes) SDR_OBJ += sdr_rtlsdr.o CPPFLAGS += -DENABLE_RTLSDR @@ -38,14 +50,14 @@ ifeq ($(RTLSDR), yes) CPPFLAGS += -I$(RTLSDR_PREFIX)/include LDFLAGS += -L$(RTLSDR_PREFIX)/lib else - CFLAGS += $(shell pkg-config --cflags librtlsdr) + CFLAGS += $(shell pkg-config --cflags-only-I librtlsdr) LDFLAGS += $(shell pkg-config --libs-only-L librtlsdr) endif ifeq ($(STATIC), yes) - LIBS_SDR += -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic -lusb-1.0 + LIBS_SDR += -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic $(LIBS_USB) else - LIBS_SDR += -lrtlsdr -lusb-1.0 + LIBS_SDR += -lrtlsdr $(LIBS_USB) endif endif diff --git a/README.md b/README.md index f9190fd..ddc23a8 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Binaries are built in the source directory; you will need to arrange to install them (and a method for starting them) yourself. "make BLADERF=no" will disable bladeRF support and remove the dependency on -libbladeRF. This may be required on some platforms (e.g. MacOS). +libbladeRF. Default is yes on Linux, no on other platforms. "make RTLSDR=no" will disable rtl-sdr support and remove the dependency on -librtlsdr. +librtlsdr. Default is yes. diff --git a/compat/compat.h b/compat/compat.h index 5905e10..f0525bb 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -18,6 +18,9 @@ # define le16toh(x) OSSwapLittleToHostInt16(x) # define le32toh(x) OSSwapLittleToHostInt32(x) +#elif defined(__FreeBSD__) +#include + #else // other platforms # include