From 6a9700a58c52b18e3499ca808099f3452aec8825 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 3 Aug 2020 14:57:31 +0800 Subject: [PATCH] If no explicit library settings are given, try to detect what SDRs to support based on what pkg-config knows about. --- Makefile | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b8f03ca..a58dacd 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,22 @@ PROGNAME=dump1090 -RTLSDR ?= yes -BLADERF ?= yes -HACKRF ?= yes +# 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 CPPFLAGS += -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\" @@ -47,7 +61,14 @@ ifeq ($(HACKRF), yes) LIBS_SDR += $(shell pkg-config --libs libhackrf) endif -all: dump1090 view1090 +all: showconfig dump1090 view1090 + +showconfig: + @echo "Building with:" >&2 + @echo " Version string: $(DUMP1090_VERSION)" >&2 + @echo " RTLSDR support: $(RTLSDR)" >&2 + @echo " BladeRF support: $(BLADERF)" >&2 + @echo " HackRF support: $(HACKRF)" >&2 %.o: %.c *.h $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@