From 60dbf0bb6825acc505949e6425960ea690f9a42c Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Sat, 25 Feb 2023 15:54:54 +0100 Subject: [PATCH] Fix build with libpgps <= 3.24 using pkg-config Introduce back the fixsource_t struct definition based on libgps version, retrieved from pkg-config. This fixes the build with libgps versions inferior or equal to 3.24 Closes: https://github.com/OLSR/olsrd/pull/122 Co-authored-by: Nicolas Peugnet --- Makefile.inc | 1 + lib/pud/Makefile | 3 +++ lib/pud/src/gpsdclient.h | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/Makefile.inc b/Makefile.inc index 0f4c2ca82..214b353e7 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -113,6 +113,7 @@ BISON ?= bison FLEX ?= flex LDCONFIG ?= /sbin/ldconfig TAGCMD ?= etags +PKG_CONFIG ?= pkg-config # target directories and names DESTDIR ?= diff --git a/lib/pud/Makefile b/lib/pud/Makefile index 28330d923..5546afb27 100644 --- a/lib/pud/Makefile +++ b/lib/pud/Makefile @@ -58,6 +58,9 @@ include $(TOPDIR)/Makefile.inc PUD_NMEALIB_STATICALLY_LINKED ?= CFLAGS += -D_GNU_SOURCE +LIBGPS_VERSION := $(shell $(PKG_CONFIG) --modversion libgps) +CFLAGS += -DLIBGPS_VERSION_MAJOR=$(word 1,$(subst ., ,$(LIBGPS_VERSION))) +CFLAGS += -DLIBGPS_VERSION_MINOR=$(word 2,$(subst ., ,$(LIBGPS_VERSION))) RESOURCESDIR = ./resources NMEALIB_LIB = $(NMEALIB_PATH)/lib diff --git a/lib/pud/src/gpsdclient.h b/lib/pud/src/gpsdclient.h index a51dd2211..e3856e238 100644 --- a/lib/pud/src/gpsdclient.h +++ b/lib/pud/src/gpsdclient.h @@ -60,6 +60,20 @@ struct GpsdConnectionState { struct devconfig_t dev[MAXUSERDEVS]; }; +/** + * describe a data source + * + * Starting with gpsd 3.25, this is now provided in gps.h. + */ +#if LIBGPS_VERSION_MAJOR <= 3 && LIBGPS_VERSION_MINOR <= 24 +struct fixsource_t { + char spec[PATH_MAX]; /* working space, will be modified */ + char *server; /* pointer into spec field */ + char *port; /* pointer into spec field */ + char *device; /* pointer into spec field */ +}; +#endif + /** * The gpsd daemon spec */