We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5085

Summary: pkg-config file suboptimal when SDL built with --disable-shared or -DSDL_SHARED=no
Product: SDL Reporter: James Le Cuirot <chewi>
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: build: Merge pkg-config Libs.private into Libs for static-only builds
build: Don't duplicate Libs in Libs.private in pkg-config file

Description James Le Cuirot 2020-04-12 12:37:15 UTC
Created attachment 4301 [details]
build: Merge pkg-config Libs.private into Libs for static-only builds

A project being built entirely statically will call pkg-config with --static, which utilises the Libs.private field. Conversely it will not use --static when not being built entirely statically, even if there is only a static build of SDL available. This will most likely cause the build to fail due to underlinking unless we merge the Libs fields.

This is what the Meson build system does when it generates pkg-config files. This also also follows the behaviour of sdl2-config.

At the same time, the runtime linker flags are not applicable to static-only builds so only add them for shared builds.
Comment 1 James Le Cuirot 2020-04-12 12:38:22 UTC
Created attachment 4302 [details]
build: Don't duplicate Libs in Libs.private in pkg-config file

A second closely-related patch:

pkg-config already prepends Libs to Libs.private when you specify --static so there's no need to duplicate them. Most other projects don't do this.
Comment 2 Sam Lantinga 2020-04-13 15:11:24 UTC
These patches are in, thanks!
https://hg.libsdl.org/SDL/rev/89a457159af4
https://hg.libsdl.org/SDL/rev/fc03d19926ed