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] 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