Skip to content

build: add Libs/Cflags to libzpc.pc and fix libdir substitution - #51

Open
plusky wants to merge 1 commit into
opencryptoki:libzpc-1.5.yfrom
plusky:pkgconfig-libs-cflags
Open

build: add Libs/Cflags to libzpc.pc and fix libdir substitution#51
plusky wants to merge 1 commit into
opencryptoki:libzpc-1.5.yfrom
plusky:pkgconfig-libs-cflags

Conversation

@plusky

@plusky plusky commented Sep 4, 2026

Copy link
Copy Markdown

libzpc.pc is installed with no Libs: and no Cflags:, so pkg-config --libs libzpc returns nothing for a package that does ship a linkable shared library. A consumer built with gcc $(pkg-config --cflags --libs libzpc) prog.c gets no library on the link line and fails with undefined references to zpc_*. libdir and includedir are declared in the template and then never referenced by any field.

This is reachable in practice: SUSE Linux Enterprise ships libzpc-devel from the 1.x line (1.3.0 on SLE 15 SP7, 1.5.0 on SLE 16.0) and the shipped .pc has this shape. Tracked downstream as https://bugzilla.suse.com/show_bug.cgi?id=1279335.

Two hunks, because the one-liner alone would be wrong:

  1. libzpc.pc.in gains Libs: -L${libdir} -lzpc and Cflags: -I${includedir}.
  2. include(GNUInstallDirs) moves above configure_file(libzpc.pc.in ...). It currently runs after, so @CMAKE_INSTALL_LIBDIR@ and @CMAKE_INSTALL_INCLUDEDIR@ expand to nothing unless the caller passes -DCMAKE_INSTALL_LIBDIR / -DCMAKE_INSTALL_INCLUDEDIR. Distro builds usually do, which is why the shipped libdir looks correct, but a plain cmake -DCMAKE_INSTALL_PREFIX=/usr does not — and then the new Libs: line would point at ${exec_prefix}/.

Before, plain cmake -DCMAKE_INSTALL_PREFIX=/usr:

libdir=${exec_prefix}/
includedir=${prefix}/

Name: libzpc
Description: IBM Z Protected-key Crypto library
Version: 1.5.0

After, same invocation:

libdir=${exec_prefix}/lib64
includedir=${prefix}/include

Name: libzpc
Description: IBM Z Protected-key Crypto library
Version: 1.5.0
Libs: -L${libdir} -lzpc
Cflags: -I${includedir}

$ pkg-config --cflags --libs libzpc
 -lzpc

(-L/usr/lib64 and -I/usr/include are correctly elided by pkg-config as default search paths.)

Targeted at libzpc-1.5.y rather than main: on main, e91faa1 removed the shared-library, header and pkg-config installs, so libzpc.pc.in is no longer used there and this fix would be a no-op.

No API or ABI change. No regression test added — the project's test suite is a gtest binary for the library API and has no hook for checking generated build metadata; happy to add one if you'd like it somewhere.

libzpc.pc shipped without Libs: and Cflags:, so `pkg-config --libs libzpc`
returned nothing and consumers linked without -lzpc. libdir and includedir
were declared and then never referenced by any field.

configure_file() also ran before include(GNUInstallDirs), so
@CMAKE_INSTALL_LIBDIR@/@CMAKE_INSTALL_INCLUDEDIR@ expanded empty unless the
caller set them on the command line — move the include first, otherwise
${libdir} in the new Libs: line is wrong for a plain build.

No API or ABI change.

Link: https://bugzilla.suse.com/show_bug.cgi?id=1279335
Signed-off-by: Martin Pluskal <martin@pluskal.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant