CDI 2.5.4 tarball: pkg-config file contains unexpanded @GRIB_API_LIBS@
Added by Drew Holzworth about 1 month ago
Hi all, when building CDI 2.5.4 from the release tarball, the generated pkg-config file cdi.pc contains the unexpanded token @GRIB_API_LIBS@. This breaks downstream builds that use pkg-config. Modifying acx_options.m4 and regenerating the Autotools files (autoreconf -fi) before running ./configure fixes the issue, indicating the tarball’s pre-generated configure/config.status was produced from macros that did not include the necessary AC_SUBST for GRIB_API_*.
I included a quick and dirty workaround which works for me, though I'm not sure if it's correct in general. Ideally of course it would be nice if this all worked out of the box :).
Environment
CDI: 2.5.4 (tarball from https://code.mpimet.mpg.de/attachments/download/30127/cdi-2.5.4.tar.gz)
OS: x86_64 Linux
Toolchain: glibc/gcc
Steps to reproduce
1. Extract the 2.5.4 tarball.
2. Configure and build normally:
./configure --prefix=/usr --with-netcdf=/usr --with-eccodes=/usr --with-szlib CFLAGS='-g -O2' --enable-iso-c-interface --enable-hirlam-extensions --enable-openmp
make
make DESTDIR=/tmp/pkgroot install
3. Inspect /tmp/pkgroot/usr/lib/pkgconfig/cdi.pc
Actual result: cdi.pc contains an unexpanded token: @GRIB_API_LIBS@
Crucially, the libs line include GRIB_API_LIBS. This causes pkg-config consumers to fail to link.
Expected result: All tokens are substituted.
Analysis
src/pkgconfig/cdi.pc.in references GRIB_API_INCLUDE and GRIB_API_LIBS.
In m4/acx_options.m4, GRIB_API_INCLUDE/GRIB_API_LIBS are not exported
The shipped configure in the 2.5.4 tarball does not include these substitutions, so config.status does not replace @GRIB_API_*@ in cdi.pc.
Workaround
--- cdi-2.5.4.orig/m4/acx_options.m4 2025-11-08 07:01:22.000000000 +1100
+++ cdi-2.5.4/m4/acx_options.m4 2026-01-30 13:42:03.019419101 +1100
@@ -154,6 +154,8 @@
# Compile application with ECCODES library (for GRIB2 support)
ECCODES_INCLUDE=''
ECCODES_LIBS=''
+GRIB_API_INCLUDE=''
+GRIB_API_LIBS=''
AC_ARG_WITH([eccodes],
[AS_HELP_STRING([--with-eccodes=<yes|no|directory>],
[location of ECCODES library for grib2 encoding/decoding (lib and include subdirs)])],
@@ -185,6 +187,8 @@
AC_MSG_RESULT([suppressed])])
AC_SUBST([ECCODES_INCLUDE])
AC_SUBST([ECCODES_LIBS])
+AC_SUBST([GRIB_API_INCLUDE])
+AC_SUBST([GRIB_API_LIBS])
AM_CONDITIONAL([HAVE_LIBGRIB_API],[test "x$with_eccodes" != 'x' -a "x$with_eccodes" != 'xno' ])
# ----------------------------------------------------------------------
# Enable GRIB support
Replies (1)
RE: CDI 2.5.4 tarball: pkg-config file contains unexpanded @GRIB_API_LIBS@ - Added by Uwe Schulzweida 22 days ago
Hi Drew, the configuration name GRIB_API has been replaced by ECCODES in CDO. Unfortunately, the pkg-config file was forgotten in the process. This will be fixed in the next CDO version 2.6.0.
Cheers,
Uwe