More hacking on the Makefile to get it working nicely on both jessie + wheezy.

This commit is contained in:
Oliver Jowett 2016-09-16 17:16:28 +01:00
parent b213ab9a50
commit bef563b8a3
3 changed files with 22 additions and 45 deletions

View file

@ -1,56 +1,33 @@
#
# When building a package or installing otherwise in the system, make
# sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local
#
PROGNAME=dump1090
ifndef DUMP1090_VERSION
DUMP1090_VERSION=$(shell git describe --tags --match=v*)
CC=gcc -std=c1x
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
ifdef PREFIX
BINDIR=$(PREFIX)/bin
SHAREDIR=$(PREFIX)/share/$(PROGNAME)
EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\"
ifneq ($(HTMLPATH),"")
CPPFLAGS += -DHTMLPATH=\"$(HTMLPATH)\"
endif
CPPFLAGS+=-DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\"
CFLAGS+=-O2 -g -Wall -Werror -W
LIBS=-lpthread -lm
CFLAGS += -O2 -g -Wall -Werror -W -D_DEFAULT_SOURCE
LIBS = -lpthread -lm -lrt
ifeq ($(STATIC), yes)
LIBS_RTL=-Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic -lusb-1.0
LIBS_RTLSDR = -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic -lusb-1.0
else
LIBS_RTL=-lrtlsdr -lusb-1.0
endif
CC=gcc
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
LIBS+=-lrt
CFLAGS+=-std=c11 -D_DEFAULT_SOURCE
endif
ifeq ($(UNAME), Darwin)
# TODO: Putting GCC in C11 mode breaks things.
CFLAGS+=-std=c11 -DMISSING_GETTIME -DMISSING_NANOSLEEP
COMPAT+=compat/clock_gettime/clock_gettime.o compat/clock_nanosleep/clock_nanosleep.o
endif
ifeq ($(UNAME), OpenBSD)
CFLAGS+= -DMISSING_NANOSLEEP
COMPAT+= compat/clock_nanosleep/clock_nanosleep.o
LIBS_RTLSDR = -lrtlsdr -lusb-1.0
endif
all: dump1090 view1090
%.o: %.c *.h
$(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRACFLAGS) -c $< -o $@
dump1090: LDFLAGS += `pkg-config --libs-only-L librtlsdr`
dump1090.o: CFLAGS += `pkg-config --cflags librtlsdr`
$(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 $(COMPAT)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_RTL)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_RTLSDR)
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)
@ -65,7 +42,7 @@ test: cprtests
./cprtests
cprtests: cpr.o cprtests.o
$(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRACFLAGS) -g -o $@ $^ -lm
$(CC) $(CPPFLAGS) $(CFLAGS) -g -o $@ $^ -lm
crctests: crc.c crc.h
$(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRACFLAGS) -g -DCRCDEBUG -o $@ $<
$(CC) $(CPPFLAGS) $(CFLAGS) -g -DCRCDEBUG -o $@ $<

View file

@ -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 -- 'EXTRACFLAGS=-DHTMLPATH=\"/usr/share/$(SRCNAME)/html\" -DMODES_DUMP1090_VARIANT=\"$(SRCNAME)\"' STATIC=yes PKG_CONFIG_PATH=rtl-sdr-build/install/lib/pkgconfig
dh_auto_build -- HTMLPATH=/usr/share/$(SRCNAME)/html DUMP1090_VERSION=$(DUMP1090_VERSION) STATIC=yes RTLSDR_PREFIX=rtl-sdr-build/install
override_dh_install:
dh_install

4
debian/rules vendored
View file

@ -14,11 +14,11 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
export DUMP1090_VERSION=$(shell dpkg-parsechangelog | sed -n 's/^Version: /v/p')
DUMP1090_VERSION=$(shell dpkg-parsechangelog | sed -n 's/^Version: /v/p')
SRCNAME=$(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
override_dh_auto_build:
dh_auto_build -- 'EXTRACFLAGS=-DHTMLPATH=\"/usr/share/$(SRCNAME)/html\" -DMODES_DUMP1090_VARIANT=\"$(SRCNAME)\"'
dh_auto_build -- HTMLPATH=/usr/share/$(SRCNAME)/html DUMP1090_VERSION=$(DUMP1090_VERSION) RTLSDR_PREFIX=/usr
override_dh_install:
dh_install