Fix merge conflicts, clean up the Makefile

This commit is contained in:
Oliver Jowett 2020-08-07 14:28:00 +08:00
commit 1174841f71
5 changed files with 96 additions and 25 deletions

View File

@ -1,36 +1,77 @@
PROGNAME=dump1090 PROGNAME=dump1090
# Try to autodetect available libraries if no explicit setting was used
ifndef RTLSDR
ifdef RTLSDR_PREFIX
RTLSDR := yes
else
RTLSDR := $(shell pkg-config --exists librtlsdr && echo "yes" || echo "no")
endif
endif
ifndef BLADERF
BLADERF := $(shell pkg-config --exists libbladeRF && echo "yes" || echo "no")
endif
ifndef HACKRF
HACKRF := $(shell pkg-config --exists libhackrf && echo "yes" || echo "no")
endif
ifndef LIMESDR
LIMESDR := $(shell pkg-config --exists LimeSuite && echo "yes" || echo "no")
endif
DUMP1090_VERSION ?= unknown DUMP1090_VERSION ?= unknown
CPPFLAGS += -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\" CPPFLAGS += -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\"
DIALECT = -std=c11 DIALECT = -std=c11
CFLAGS += $(DIALECT) -O3 -g -Wall -Wmissing-declarations -Werror -W -D_DEFAULT_SOURCE -fno-common CFLAGS += $(DIALECT) -O3 -g -Wall -Wmissing-declarations -Werror -W -D_DEFAULT_SOURCE -fno-common
LIBS = -lpthread -lm -lrt LIBS = -lpthread -lm
SDR_OBJ = sdr.o fifo.o sdr_ifile.o SDR_OBJ = sdr.o fifo.o sdr_ifile.o
# Try to autodetect available libraries via pkg-config if no explicit setting was used
PKGCONFIG=$(shell pkg-config --version >/dev/null 2>&1 && echo "yes" || echo "no")
ifeq ($(PKGCONFIG), yes)
ifndef RTLSDR
ifdef RTLSDR_PREFIX
RTLSDR := yes
else
RTLSDR := $(shell pkg-config --exists librtlsdr && echo "yes" || echo "no")
endif
endif
ifndef BLADERF
BLADERF := $(shell pkg-config --exists libbladeRF && echo "yes" || echo "no")
endif
ifndef HACKRF
HACKRF := $(shell pkg-config --exists libhackrf && echo "yes" || echo "no")
endif
ifndef LIMESDR
LIMESDR := $(shell pkg-config --exists LimeSuite && echo "yes" || echo "no")
endif
else
# pkg-config not available. Only use explicitly enabled libraries.
RTLSDR ?= no
BLADERF ?= no
HACKRF ?= no
LIMESDR ?= no
endif
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
CFLAGS += -D_DEFAULT_SOURCE
LIBS += -lrt
LIBS_USB += -lusb-1.0
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
LIBS_USB += -lusb-1.0
endif
ifeq ($(UNAME), OpenBSD)
CFLAGS += -DMISSING_NANOSLEEP
COMPAT += compat/clock_nanosleep/clock_nanosleep.o
LIBS_USB += -lusb-1.0
endif
ifeq ($(UNAME), FreeBSD)
CFLAGS += -D_DEFAULT_SOURCE
LIBS += -lrt
LIBS_USB += -lusb
endif
RTLSDR ?= yes
BLADERF ?= yes
ifeq ($(RTLSDR), yes) ifeq ($(RTLSDR), yes)
SDR_OBJ += sdr_rtlsdr.o SDR_OBJ += sdr_rtlsdr.o
CPPFLAGS += -DENABLE_RTLSDR CPPFLAGS += -DENABLE_RTLSDR
@ -38,9 +79,9 @@ ifeq ($(RTLSDR), yes)
ifdef RTLSDR_PREFIX ifdef RTLSDR_PREFIX
CPPFLAGS += -I$(RTLSDR_PREFIX)/include CPPFLAGS += -I$(RTLSDR_PREFIX)/include
ifeq ($(STATIC), yes) ifeq ($(STATIC), yes)
LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic -lusb-1.0 LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic $(LIBS_USB)
else else
LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -lrtlsdr -lusb-1.0 LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -lrtlsdr $(LIBS_USB)
endif endif
else else
CFLAGS += $(shell pkg-config --cflags librtlsdr) CFLAGS += $(shell pkg-config --cflags librtlsdr)

View File

@ -90,3 +90,14 @@ libhackrf.
``make LIMESDR=no`` will disable LimeSDR support and remove the dependency on ``make LIMESDR=no`` will disable LimeSDR support and remove the dependency on
libLimeSuite. libLimeSuite.
## Building on OSX
Minimal testing, YMMV.
```
$ brew install librtlsdr
$ brew install pkg-config
$ make
```

View File

@ -3,9 +3,17 @@
#include <mach/mach_time.h> // Apple-only, but this isn't inclued on other BSDs #include <mach/mach_time.h> // Apple-only, but this isn't inclued on other BSDs
#ifdef __OpenBSD__
#ifdef _CLOCKID_T_DEFINED_ #ifdef _CLOCKID_T_DEFINED_
#define CLOCKID_T #define CLOCKID_T
#endif #endif
#endif
#ifdef __APPLE__
#ifdef CLOCK_MONOTONIC
#define CLOCKID_T
#endif
#endif
#ifndef CLOCKID_T #ifndef CLOCKID_T
#define CLOCKID_T #define CLOCKID_T

View File

@ -1,9 +1,17 @@
#ifndef CLOCK_NANOSLEEP_H #ifndef CLOCK_NANOSLEEP_H
#define CLOCK_NANOSLEEP_H #define CLOCK_NANOSLEEP_H
#ifdef __OpenBSD__
#ifdef _CLOCKID_T_DEFINED_ #ifdef _CLOCKID_T_DEFINED_
#define CLOCKID_T #define CLOCKID_T
#endif #endif
#endif
#ifdef __APPLE__
#ifdef CLOCK_MONOTONIC
#define CLOCKID_T
#endif
#endif
#ifndef CLOCKID_T #ifndef CLOCKID_T
#define CLOCKID_T #define CLOCKID_T

View File

@ -18,6 +18,9 @@
# define le16toh(x) OSSwapLittleToHostInt16(x) # define le16toh(x) OSSwapLittleToHostInt16(x)
# define le32toh(x) OSSwapLittleToHostInt32(x) # define le32toh(x) OSSwapLittleToHostInt32(x)
#elif defined(__FreeBSD__)
#include <sys/endian.h>
#else // other platforms #else // other platforms
# include <endian.h> # include <endian.h>