From 34bfe1031798a617c2628b4f011320c2dc0b976e Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Wed, 17 Apr 2019 11:58:59 +0800 Subject: [PATCH] Rework use of pkg-config to work around librtlsdr packaging bugs in ubuntu disco --- Makefile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index b4f6aaa..10388fe 100644 --- a/Makefile +++ b/Makefile @@ -15,16 +15,20 @@ ifeq ($(RTLSDR), yes) ifdef RTLSDR_PREFIX CPPFLAGS += -I$(RTLSDR_PREFIX)/include - LDFLAGS += -L$(RTLSDR_PREFIX)/lib + ifeq ($(STATIC), yes) + LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic -lusb-1.0 + else + LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -lrtlsdr -lusb-1.0 + endif else CFLAGS += $(shell pkg-config --cflags librtlsdr) - LDFLAGS += $(shell pkg-config --libs-only-L librtlsdr) - endif - - ifeq ($(STATIC), yes) - LIBS_SDR += -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic -lusb-1.0 - else - LIBS_SDR += -lrtlsdr -lusb-1.0 + # some packaged .pc files are massively broken, try to handle it + RTLSDR_LFLAGS := $(shell pkg-config --libs-only-L librtlsdr) + ifeq ($(RTLSDR_LFLAGS),-L) + LIBS_SDR += $(shell pkg-config --libs-only-l --libs-only-other librtlsdr) + else + LIBS_SDR += $(shell pkg-config --libs librtlsdr) + endif endif endif