Try to respect CFLAGS/CPPFLAGS as far as possible; move required extra flags into a separate var.
This means you can, in theory, completely override CFLAGS/CPPFLAGS without also having to provide all the internal flags that the Makefile usually detects. $ make CFLAGS=-qwerty [...] cc -I. -DMODES_DUMP1090_VERSION=\"unknown\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\" -D_DEFAULT_SOURCE -DENABLE_CPUFEATURES -Icpu_features/include -DENABLE_RTLSDR -DENABLE_BLADERF -DENABLE_HACKRF -DENABLE_LIMESDR -DSTARCH_MIX_X86 -qwerty -std=c11 -fno-common -Wall -Wmissing-declarations -Werror -W -I/usr/include/ -I/usr/include/libusb-1.0 -I/usr/include/ -I/usr/include/ -I/usr/include/libusb-1.0 -c dump1090.c -o dump1090.o Should fix #161
This commit is contained in:
parent
bc72177c8b
commit
b645f7d4f2
68
Makefile
68
Makefile
|
|
@ -2,10 +2,10 @@ PROGNAME=dump1090
|
||||||
|
|
||||||
DUMP1090_VERSION ?= unknown
|
DUMP1090_VERSION ?= unknown
|
||||||
|
|
||||||
CPPFLAGS += -I. -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\"
|
CFLAGS ?= -O3 -g
|
||||||
|
DUMP1090_CFLAGS := -std=c11 -fno-common -Wall -Wmissing-declarations -Werror -W
|
||||||
|
DUMP1090_CPPFLAGS := -I. -DMODES_DUMP1090_VERSION=\"$(DUMP1090_VERSION)\" -DMODES_DUMP1090_VARIANT=\"dump1090-fa\"
|
||||||
|
|
||||||
DIALECT = -std=c11
|
|
||||||
CFLAGS += $(DIALECT) -O3 -g -Wall -Wmissing-declarations -Werror -W -D_DEFAULT_SOURCE -fno-common
|
|
||||||
LIBS = -lpthread -lm
|
LIBS = -lpthread -lm
|
||||||
SDR_OBJ = cpu.o sdr.o fifo.o sdr_ifile.o dsp/helpers/tables.o
|
SDR_OBJ = cpu.o sdr.o fifo.o sdr_ifile.o dsp/helpers/tables.o
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ UNAME ?= $(HOST_UNAME)
|
||||||
ARCH ?= $(HOST_ARCH)
|
ARCH ?= $(HOST_ARCH)
|
||||||
|
|
||||||
ifeq ($(UNAME), Linux)
|
ifeq ($(UNAME), Linux)
|
||||||
CPPFLAGS += -D_DEFAULT_SOURCE
|
DUMP1090_CPPFLAGS += -D_DEFAULT_SOURCE
|
||||||
LIBS += -lrt
|
LIBS += -lrt
|
||||||
LIBS_USB += -lusb-1.0
|
LIBS_USB += -lusb-1.0
|
||||||
LIBS_CURSES := -lncurses
|
LIBS_CURSES := -lncurses
|
||||||
|
|
@ -55,10 +55,10 @@ endif
|
||||||
|
|
||||||
ifeq ($(UNAME), Darwin)
|
ifeq ($(UNAME), Darwin)
|
||||||
ifneq ($(shell sw_vers -productVersion | egrep '^10\.([0-9]|1[01])\.'),) # Mac OS X ver <= 10.11
|
ifneq ($(shell sw_vers -productVersion | egrep '^10\.([0-9]|1[01])\.'),) # Mac OS X ver <= 10.11
|
||||||
CPPFLAGS += -DMISSING_GETTIME
|
DUMP1090_CPPFLAGS += -DMISSING_GETTIME
|
||||||
COMPAT += compat/clock_gettime/clock_gettime.o
|
COMPAT += compat/clock_gettime/clock_gettime.o
|
||||||
endif
|
endif
|
||||||
CPPFLAGS += -DMISSING_NANOSLEEP
|
DUMP1090_CPPFLAGS += -DMISSING_NANOSLEEP
|
||||||
COMPAT += compat/clock_nanosleep/clock_nanosleep.o
|
COMPAT += compat/clock_nanosleep/clock_nanosleep.o
|
||||||
LIBS_USB += -lusb-1.0
|
LIBS_USB += -lusb-1.0
|
||||||
LIBS_CURSES := -lncurses
|
LIBS_CURSES := -lncurses
|
||||||
|
|
@ -66,21 +66,21 @@ ifeq ($(UNAME), Darwin)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNAME), OpenBSD)
|
ifeq ($(UNAME), OpenBSD)
|
||||||
CPPFLAGS += -DMISSING_NANOSLEEP
|
DUMP1090_CPPFLAGS += -DMISSING_NANOSLEEP
|
||||||
COMPAT += compat/clock_nanosleep/clock_nanosleep.o
|
COMPAT += compat/clock_nanosleep/clock_nanosleep.o
|
||||||
LIBS_USB += -lusb-1.0
|
LIBS_USB += -lusb-1.0
|
||||||
LIBS_CURSES := -lncurses
|
LIBS_CURSES := -lncurses
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNAME), FreeBSD)
|
ifeq ($(UNAME), FreeBSD)
|
||||||
CPPFLAGS += -D_DEFAULT_SOURCE
|
DUMP1090_CPPFLAGS += -D_DEFAULT_SOURCE
|
||||||
LIBS += -lrt
|
LIBS += -lrt
|
||||||
LIBS_USB += -lusb
|
LIBS_USB += -lusb
|
||||||
LIBS_CURSES := -lncurses
|
LIBS_CURSES := -lncurses
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNAME), NetBSD)
|
ifeq ($(UNAME), NetBSD)
|
||||||
CFLAGS += -D_DEFAULT_SOURCE
|
DUMP1090_CPPFLAGS += -D_DEFAULT_SOURCE
|
||||||
LIBS += -lrt
|
LIBS += -lrt
|
||||||
LIBS_USB += -lusb-1.0
|
LIBS_USB += -lusb-1.0
|
||||||
LIBS_CURSES := -lcurses
|
LIBS_CURSES := -lcurses
|
||||||
|
|
@ -90,7 +90,7 @@ CPUFEATURES ?= no
|
||||||
|
|
||||||
ifeq ($(CPUFEATURES),yes)
|
ifeq ($(CPUFEATURES),yes)
|
||||||
include Makefile.cpufeatures
|
include Makefile.cpufeatures
|
||||||
CPPFLAGS += -DENABLE_CPUFEATURES -Icpu_features/include
|
DUMP1090_CPPFLAGS += -DENABLE_CPUFEATURES -Icpu_features/include
|
||||||
endif
|
endif
|
||||||
|
|
||||||
RTLSDR ?= yes
|
RTLSDR ?= yes
|
||||||
|
|
@ -98,10 +98,10 @@ BLADERF ?= yes
|
||||||
|
|
||||||
ifeq ($(RTLSDR), yes)
|
ifeq ($(RTLSDR), yes)
|
||||||
SDR_OBJ += sdr_rtlsdr.o
|
SDR_OBJ += sdr_rtlsdr.o
|
||||||
CPPFLAGS += -DENABLE_RTLSDR
|
DUMP1090_CPPFLAGS += -DENABLE_RTLSDR
|
||||||
|
|
||||||
ifdef RTLSDR_PREFIX
|
ifdef RTLSDR_PREFIX
|
||||||
CPPFLAGS += -I$(RTLSDR_PREFIX)/include
|
DUMP1090_CPPFLAGS += -I$(RTLSDR_PREFIX)/include
|
||||||
ifeq ($(STATIC), yes)
|
ifeq ($(STATIC), yes)
|
||||||
LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic $(LIBS_USB)
|
LIBS_SDR += -L$(RTLSDR_PREFIX)/lib -Wl,-Bstatic -lrtlsdr -Wl,-Bdynamic $(LIBS_USB)
|
||||||
else
|
else
|
||||||
|
|
@ -115,7 +115,7 @@ ifeq ($(RTLSDR), yes)
|
||||||
RTLSDR_CFLAGS := $(shell pkg-config --cflags librtlsdr)
|
RTLSDR_CFLAGS := $(shell pkg-config --cflags librtlsdr)
|
||||||
RTLSDR_CFLAGS := $(filter-out -std=%,$(RTLSDR_CFLAGS))
|
RTLSDR_CFLAGS := $(filter-out -std=%,$(RTLSDR_CFLAGS))
|
||||||
RTLSDR_CFLAGS := $(filter-out -I/,$(RTLSDR_CFLAGS))
|
RTLSDR_CFLAGS := $(filter-out -I/,$(RTLSDR_CFLAGS))
|
||||||
CFLAGS += $(RTLSDR_CFLAGS)
|
DUMP1090_CFLAGS += $(RTLSDR_CFLAGS)
|
||||||
|
|
||||||
# some linux librtlsdr packages return a bare -L with no path in --libs
|
# some linux librtlsdr packages return a bare -L with no path in --libs
|
||||||
# which horribly confuses things because it eats the next option on the command line
|
# which horribly confuses things because it eats the next option on the command line
|
||||||
|
|
@ -130,22 +130,22 @@ endif
|
||||||
|
|
||||||
ifeq ($(BLADERF), yes)
|
ifeq ($(BLADERF), yes)
|
||||||
SDR_OBJ += sdr_bladerf.o
|
SDR_OBJ += sdr_bladerf.o
|
||||||
CPPFLAGS += -DENABLE_BLADERF
|
DUMP1090_CPPFLAGS += -DENABLE_BLADERF
|
||||||
CFLAGS += $(shell pkg-config --cflags libbladeRF)
|
DUMP1090_CFLAGS += $(shell pkg-config --cflags libbladeRF)
|
||||||
LIBS_SDR += $(shell pkg-config --libs libbladeRF)
|
LIBS_SDR += $(shell pkg-config --libs libbladeRF)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HACKRF), yes)
|
ifeq ($(HACKRF), yes)
|
||||||
SDR_OBJ += sdr_hackrf.o
|
SDR_OBJ += sdr_hackrf.o
|
||||||
CPPFLAGS += -DENABLE_HACKRF
|
DUMP1090_CPPFLAGS += -DENABLE_HACKRF
|
||||||
CFLAGS += $(shell pkg-config --cflags libhackrf)
|
DUMP1090_CFLAGS += $(shell pkg-config --cflags libhackrf)
|
||||||
LIBS_SDR += $(shell pkg-config --libs libhackrf)
|
LIBS_SDR += $(shell pkg-config --libs libhackrf)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(LIMESDR), yes)
|
ifeq ($(LIMESDR), yes)
|
||||||
SDR_OBJ += sdr_limesdr.o
|
SDR_OBJ += sdr_limesdr.o
|
||||||
CPPFLAGS += -DENABLE_LIMESDR
|
DUMP1090_CPPFLAGS += -DENABLE_LIMESDR
|
||||||
CFLAGS += $(shell pkg-config --cflags LimeSuite)
|
DUMP1090_CFLAGS += $(shell pkg-config --cflags LimeSuite)
|
||||||
LIBS_SDR += $(shell pkg-config --libs LimeSuite)
|
LIBS_SDR += $(shell pkg-config --libs LimeSuite)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -157,31 +157,33 @@ endif
|
||||||
ifneq ($(CPUFEATURES),yes)
|
ifneq ($(CPUFEATURES),yes)
|
||||||
# need to be able to detect CPU features at runtime to enable any non-standard compiler flags
|
# need to be able to detect CPU features at runtime to enable any non-standard compiler flags
|
||||||
STARCH_MIX := generic
|
STARCH_MIX := generic
|
||||||
CPPFLAGS += -DSTARCH_MIX_GENERIC
|
DUMP1090_CPPFLAGS += -DSTARCH_MIX_GENERIC
|
||||||
else
|
else
|
||||||
ifeq ($(ARCH),x86_64)
|
ifeq ($(ARCH),x86_64)
|
||||||
# AVX, AVX2
|
# AVX, AVX2
|
||||||
STARCH_MIX := x86
|
STARCH_MIX := x86
|
||||||
CPPFLAGS += -DSTARCH_MIX_X86
|
DUMP1090_CPPFLAGS += -DSTARCH_MIX_X86
|
||||||
else ifeq ($(findstring aarch,$(ARCH)),aarch)
|
else ifeq ($(findstring aarch,$(ARCH)),aarch)
|
||||||
STARCH_MIX := aarch64
|
STARCH_MIX := aarch64
|
||||||
CPPFLAGS += -DSTARCH_MIX_AARCH64
|
DUMP1090_CPPFLAGS += -DSTARCH_MIX_AARCH64
|
||||||
else ifeq ($(findstring arm64,$(ARCH)),arm64)
|
else ifeq ($(findstring arm64,$(ARCH)),arm64)
|
||||||
# Apple calls this arm64, not aarch64
|
# Apple calls this arm64, not aarch64
|
||||||
STARCH_MIX := aarch64
|
STARCH_MIX := aarch64
|
||||||
CPPFLAGS += -DSTARCH_MIX_AARCH64
|
DUMP1090_CPPFLAGS += -DSTARCH_MIX_AARCH64
|
||||||
else ifeq ($(findstring arm,$(ARCH)),arm)
|
else ifeq ($(findstring arm,$(ARCH)),arm)
|
||||||
# ARMv7 NEON
|
# ARMv7 NEON
|
||||||
STARCH_MIX := arm
|
STARCH_MIX := arm
|
||||||
CPPFLAGS += -DSTARCH_MIX_ARM
|
DUMP1090_CPPFLAGS += -DSTARCH_MIX_ARM
|
||||||
else
|
else
|
||||||
STARCH_MIX := generic
|
STARCH_MIX := generic
|
||||||
CPPFLAGS += -DSTARCH_MIX_GENERIC
|
DUMP1090_CPPFLAGS += -DSTARCH_MIX_GENERIC
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
all: showconfig dump1090 view1090 starch-benchmark
|
all: showconfig dump1090 view1090 starch-benchmark
|
||||||
|
|
||||||
STARCH_COMPILE := $(CC) $(CPPFLAGS) $(CFLAGS) -c
|
ALL_CCFLAGS := $(CPPFLAGS) $(DUMP1090_CPPFLAGS) $(CFLAGS) $(DUMP1090_CFLAGS)
|
||||||
|
|
||||||
|
STARCH_COMPILE := $(CC) $(ALL_CCFLAGS) -c
|
||||||
include dsp/generated/makefile.$(STARCH_MIX)
|
include dsp/generated/makefile.$(STARCH_MIX)
|
||||||
|
|
||||||
showconfig:
|
showconfig:
|
||||||
|
|
@ -195,7 +197,7 @@ showconfig:
|
||||||
@echo " LimeSDR support: $(LIMESDR)" >&2
|
@echo " LimeSDR support: $(LIMESDR)" >&2
|
||||||
|
|
||||||
%.o: %.c *.h
|
%.o: %.c *.h
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
$(CC) $(ALL_CCFLAGS) -c $< -o $@
|
||||||
|
|
||||||
dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o demod_2400.o stats.o cpr.o icao_filter.o track.o util.o convert.o ais_charset.o adaptive.o $(SDR_OBJ) $(COMPAT) $(CPUFEATURES_OBJS) $(STARCH_OBJS)
|
dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o demod_2400.o stats.o cpr.o icao_filter.o track.o util.o convert.o ais_charset.o adaptive.o $(SDR_OBJ) $(COMPAT) $(CPUFEATURES_OBJS) $(STARCH_OBJS)
|
||||||
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_SDR) $(LIBS_CURSES)
|
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_SDR) $(LIBS_CURSES)
|
||||||
|
|
@ -216,25 +218,25 @@ test: cprtests
|
||||||
./cprtests
|
./cprtests
|
||||||
|
|
||||||
cprtests: cpr.o cprtests.o
|
cprtests: cpr.o cprtests.o
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -g -o $@ $^ -lm
|
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm
|
||||||
|
|
||||||
crctests: crc.c crc.h
|
crctests: crc.c crc.h
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -g -DCRCDEBUG -o $@ $<
|
$(CC) $(ALL_CCFLAGS) -g -DCRCDEBUG -o $@ $<
|
||||||
|
|
||||||
benchmarks: oneoff/convert_benchmark
|
benchmarks: oneoff/convert_benchmark
|
||||||
oneoff/convert_benchmark
|
oneoff/convert_benchmark
|
||||||
|
|
||||||
oneoff/convert_benchmark: oneoff/convert_benchmark.o convert.o util.o dsp/helpers/tables.o cpu.o $(CPUFEATURES_OBJS) $(STARCH_OBJS)
|
oneoff/convert_benchmark: oneoff/convert_benchmark.o convert.o util.o dsp/helpers/tables.o cpu.o $(CPUFEATURES_OBJS) $(STARCH_OBJS)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -g -o $@ $^ -lm -lpthread
|
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm -lpthread
|
||||||
|
|
||||||
oneoff/decode_comm_b: oneoff/decode_comm_b.o comm_b.o ais_charset.o
|
oneoff/decode_comm_b: oneoff/decode_comm_b.o comm_b.o ais_charset.o
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -g -o $@ $^ -lm
|
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm
|
||||||
|
|
||||||
oneoff/dsp_error_measurement: oneoff/dsp_error_measurement.o dsp/helpers/tables.o cpu.o $(CPUFEATURES_OBJS) $(STARCH_OBJS)
|
oneoff/dsp_error_measurement: oneoff/dsp_error_measurement.o dsp/helpers/tables.o cpu.o $(CPUFEATURES_OBJS) $(STARCH_OBJS)
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -g -o $@ $^ -lm
|
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm
|
||||||
|
|
||||||
oneoff/uc8_capture_stats: oneoff/uc8_capture_stats.o
|
oneoff/uc8_capture_stats: oneoff/uc8_capture_stats.o
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -g -o $@ $^ -lm
|
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm
|
||||||
|
|
||||||
starchgen:
|
starchgen:
|
||||||
dsp/starchgen.py .
|
dsp/starchgen.py .
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,19 @@
|
||||||
|
|
||||||
CPUFEATURES_UNAME ?= $(UNAME)
|
CPUFEATURES_UNAME ?= $(UNAME)
|
||||||
CPUFEATURES_ARCH ?= $(ARCH)
|
CPUFEATURES_ARCH ?= $(ARCH)
|
||||||
|
CPUFEATURES_CFLAGS ?= $(CFLAGS)
|
||||||
|
|
||||||
CPUFEATURES_OBJS := cpu_features/src/filesystem.o cpu_features/src/stack_line_reader.o cpu_features/src/string_view.o
|
CPUFEATURES_OBJS := cpu_features/src/filesystem.o cpu_features/src/stack_line_reader.o cpu_features/src/string_view.o
|
||||||
CPUFEATURES_CFLAGS := -std=c99 -O -g -DSTACK_LINE_READER_BUFFER_SIZE=1024 -DNDEBUG
|
CPUFEATURES_EXTRA_CFLAGS := -std=c99
|
||||||
|
CPUFEATURES_EXTRA_CPPFLAGS := -DSTACK_LINE_READER_BUFFER_SIZE=1024 -DNDEBUG -Icpu_features/include
|
||||||
|
|
||||||
ifeq ($(CPUFEATURES_UNAME),Linux)
|
ifeq ($(CPUFEATURES_UNAME),Linux)
|
||||||
CPUFEATURES_OBJS += cpu_features/src/hwcaps.o
|
CPUFEATURES_OBJS += cpu_features/src/hwcaps.o
|
||||||
CPUFEATURES_CFLAGS += -DHAVE_STRONG_GETAUXVAL
|
CPUFEATURES_EXTRA_CPPFLAGS += -DHAVE_STRONG_GETAUXVAL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CPUFEATURES_UNAME),Darwin)
|
ifeq ($(CPUFEATURES_UNAME),Darwin)
|
||||||
CPUFEATURES_CFLAGS += -DHAVE_SYSCTLBYNAME
|
CPUFEATURES_EXTRA_CPPFLAGS += -DHAVE_SYSCTLBYNAME
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CPUFEATURES_ARCH),x86_64)
|
ifeq ($(CPUFEATURES_ARCH),x86_64)
|
||||||
|
|
@ -33,5 +35,4 @@ ifneq (,$(findstring aarch64,$(CPUFEATURES_ARCH)))
|
||||||
CPUFEATURES_OBJS += cpu_features/src/cpuinfo_aarch64.o
|
CPUFEATURES_OBJS += cpu_features/src/cpuinfo_aarch64.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(CPUFEATURES_OBJS): override CFLAGS := $(CPUFEATURES_CFLAGS)
|
$(CPUFEATURES_OBJS): override ALL_CCFLAGS := $(CPUFEATURES_CPPFLAGS) $(CPUFEATURES_EXTRA_CPPFLAGS) $(CPUFEATURES_CFLAGS) $(CPUFEATURES_EXTRA_CFLAGS)
|
||||||
$(CPUFEATURES_OBJS): override CPPFLAGS := -Icpu_features/include
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue