From 7700cd90d3a7037398818dfc61cd8d83831e7e25 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Mon, 30 Jan 2017 21:55:20 +0000 Subject: [PATCH] Build/packaging work for the bladeRF --- Makefile | 40 ++++++++++++++++++++++++++----------- debian-wheezy/rules | 2 +- debian/control | 4 ++-- debian/dump1090-fa.postinst | 3 +++ debian/rules | 2 +- sdr.c | 3 --- 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 942042e..a7d4c04 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,11 @@ PROGNAME=dump1090 +RTLSDR ?= yes +BLADERF ?= yes + CC=gcc CPPFLAGS += -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\" -ifneq ($(RTLSDR_PREFIX),"") - CPPFLAGS += -I$(RTLSDR_PREFIX)/include - LDFLAGS += -L$(RTLSDR_PREFIX)/lib -endif - ifneq ($(HTMLPATH),"") CPPFLAGS += -DHTMLPATH=\"$(HTMLPATH)\" endif @@ -16,21 +14,39 @@ DIALECT = -std=c11 CFLAGS += $(DIALECT) -O2 -g -Wall -Werror -W -D_DEFAULT_SOURCE LIBS = -lpthread -lm -lrt -ifeq ($(STATIC), yes) -LIBS_RTLSDR = -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic -lusb-1.0 -else -LIBS_RTLSDR = -lrtlsdr -lusb-1.0 +ifeq ($(RTLSDR), yes) + SDR_OBJ += sdr_rtlsdr.o + CPPFLAGS += -DENABLE_RTLSDR + + ifdef RTLSDR_PREFIX + CPPFLAGS += -I$(RTLSDR_PREFIX)/include + LDFLAGS += -L$(RTLSDR_PREFIX)/lib + 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 + endif endif -LIBS_RTLSDR += -lbladeRF +ifeq ($(BLADERF), yes) + SDR_OBJ += sdr_bladerf.o + CPPFLAGS += -DENABLE_BLADERF + CFLAGS += $(shell pkg-config --cflags libbladeRF) + LIBS_SDR += $(shell pkg-config --libs libbladeRF) +endif all: dump1090 view1090 %.o: %.c *.h $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ -dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o crc.o demod_2400.o stats.o cpr.o icao_filter.o track.o util.o convert.o sdr_ifile.o sdr_rtlsdr.o sdr_bladerf.o sdr.o $(COMPAT) - $(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_RTLSDR) -lncurses +dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o crc.o demod_2400.o stats.o cpr.o icao_filter.o track.o util.o convert.o sdr_ifile.o sdr.o $(SDR_OBJ) $(COMPAT) + $(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_SDR) -lncurses view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o crc.o stats.o cpr.o icao_filter.o track.o util.o $(COMPAT) $(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) -lncurses diff --git a/debian-wheezy/rules b/debian-wheezy/rules index e27a224..944454c 100755 --- a/debian-wheezy/rules +++ b/debian-wheezy/rules @@ -22,7 +22,7 @@ install_rtlsdr: cd rtl-sdr-build && cmake ../rtl-sdr -DCMAKE_INSTALL_PREFIX=./install && make install override_dh_auto_build: install_rtlsdr - dh_auto_build -- DIALECT=-std=gnu1x HTMLPATH=/usr/share/$(SRCNAME)/html DUMP1090_VERSION=$(DUMP1090_VERSION) STATIC=yes RTLSDR_PREFIX=rtl-sdr-build/install + dh_auto_build -- RTLSDR=yes BLADERF=no DIALECT=-std=gnu1x HTMLPATH=/usr/share/$(SRCNAME)/html DUMP1090_VERSION=$(DUMP1090_VERSION) STATIC=yes RTLSDR_PREFIX=rtl-sdr-build/install override_dh_auto_test: dh_auto_test -- DIALECT=-std=gnu1x diff --git a/debian/control b/debian/control index 1ee5bdb..bac874a 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: dump1090-fa Section: embedded Priority: extra Maintainer: Oliver Jowett -Build-Depends: debhelper(>=9), librtlsdr-dev, libusb-1.0-0-dev, pkg-config, dh-systemd, libncurses5-dev +Build-Depends: debhelper(>=9), librtlsdr-dev, libusb-1.0-0-dev, pkg-config, dh-systemd, libncurses5-dev, libbladerf-dev Standards-Version: 3.9.3 Homepage: https://github.com/mutability/dump1090 Vcs-Git: https://github.com/mutability/dump1090.git @@ -19,7 +19,7 @@ Description: transitional dummy package for dump1090 Package: dump1090-fa Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, lighttpd +Depends: ${shlibs:Depends}, ${misc:Depends}, libbladerf1(>=2016.06), libbladerf-udev, adduser, lighttpd Replaces: dump1090 (<< 3.0) Breaks: dump1090 (<< 3.0) Description: ADS-B Ground Station System for RTL-SDR diff --git a/debian/dump1090-fa.postinst b/debian/dump1090-fa.postinst index 8bb872d..5608149 100644 --- a/debian/dump1090-fa.postinst +++ b/debian/dump1090-fa.postinst @@ -31,6 +31,9 @@ case "$1" in adduser --system --home /usr/share/$NAME --no-create-home --quiet "$RUNAS" fi + # plugdev required for bladeRF USB access + adduser "$RUNAS" plugdev + # set up lighttpd echo "Enabling lighttpd integration.." >&2 lighty-enable-mod dump1090-fa || true diff --git a/debian/rules b/debian/rules index 8e9e082..e8279ea 100755 --- a/debian/rules +++ b/debian/rules @@ -20,7 +20,7 @@ ifeq ($(DEB_HOST_ARCH),armhf) endif override_dh_auto_build: - dh_auto_build -- HTMLPATH=/usr/share/$(DEB_SOURCE)/html DUMP1090_VERSION=$(DEB_VERSION) RTLSDR_PREFIX=/usr + dh_auto_build -- RTLSDR=yes BLADERF=yes HTMLPATH=/usr/share/$(DEB_SOURCE)/html DUMP1090_VERSION=$(DEB_VERSION) override_dh_install: dh_install diff --git a/sdr.c b/sdr.c index a437f9b..f37d3e8 100644 --- a/sdr.c +++ b/sdr.c @@ -20,9 +20,6 @@ #include "dump1090.h" -#define ENABLE_RTLSDR -#define ENABLE_BLADERF - #include "sdr_ifile.h" #ifdef ENABLE_RTLSDR # include "sdr_rtlsdr.h"