Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate sdl2-config and AM_PATH_SDL2 #6467

Merged
merged 2 commits into from
Oct 31, 2022

Conversation

smcv
Copy link
Contributor

@smcv smcv commented Oct 31, 2022

If we deprecate these in SDL 2.x, then developers of dependent projects will have had some advance warning before they're removed in SDL 3 (which I think should only install ${libdir}/pkgconfig/sdl3.pc and ${libdir}/cmake/SDL3/*.cmake, with no replacement for ${bindir}/sdl2-config or ${datadir}/aclocal/sdl2.m4).

  • sdl2-config.in: Deprecate sdl2-config

    Library-specific foo-config scripts duplicate very similar logic across
    various different projects, and tend to break cross-compiling, multilib
    (gcc -m32), Debian/Ubuntu multiarch and so on by only being able to have
    one sdl2-config at a time as the first one in the PATH.

    The direct replacement is pkg-config(1) or a compatible reimplementation
    like pkgconf(1), which relies on each library installing declarative
    metadata, like SDL's sdl2.pc (available since at least 2.0.0) and
    centralizes the logic into the pkg-config/pkgconf tool.

    Most uses of sdl2-config --foo can be replaced by something similar
    to ${PKG_CONFIG:-pkg-config} --foo sdl2. Instead of adding a custom
    sdl2-config to the PATH or using its --prefix or --exec-prefix options,
    users of a custom installation prefix can use any of pkg-config's
    non-SDL-specific ways to influence the result, for example setting
    PKG_CONFIG_PATH, PKG_CONFIG_SYSROOT_DIR or PKG_CONFIG_LIBDIR environment
    variables, or setting the PKG_CONFIG environment variable to point to
    a wrapper script.

    For Autotools specifically, the replacement for AM_PATH_SDL2 (which
    will be officially deprecated in a subsequent commit) is
    PKG_CHECK_MODULES.

    CMake has its own semi-declarative mechanism for dependency discovery,
    "config packages", and the SDL build already installs a config
    package. There's a good example of using a config package to discover
    SDL in cmake/test/.

    Meson natively supports pkg-config, and already uses it in preference
    to sdl2-config.

    Other build systems can run pkg-config instead of sdl2-config,
    preferably checking the PKG_CONFIG environment variable first.
    https://github.com/ioquake/ioq3 is a good example of a project doing
    this correctly.

    Helps: Deprecate sdl2-config and AM_PATH_SDL2, at least on Unix #6140, On Windows, sdl2-config should be written in something other than bash #3516

  • sdl2.m4: Deprecate AM_PATH_SDL2 in favour of PKG_CHECK_MODULES

    AM_PATH_SDL2 doesn't add much beyond PKG_CHECK_MODULES, and having a
    special m4 macro for every library that you might depend on scales
    poorly.

    The macro does add special support for macOS frameworks, but that feature
    was broken for around 6 years without anyone noticing (sdl2.m4 support for macOS frameworks probably broken #6141), and is
    likely to be only rarely useful according to comments on sdl2.m4 support for macOS frameworks probably broken #6141.

    Resolves: Deprecate sdl2-config and AM_PATH_SDL2, at least on Unix #6140

Existing Issue(s)

#6140

Library-specific foo-config scripts duplicate very similar logic across
various different projects, and tend to break cross-compiling, multilib
(gcc -m32), Debian/Ubuntu multiarch and so on by only being able to have
one sdl2-config at a time as the first one in the PATH.

The direct replacement is pkg-config(1) or a compatible reimplementation
like pkgconf(1), which relies on each library installing declarative
metadata, like SDL's sdl2.pc (available since at least 2.0.0) and
centralizes the logic into the pkg-config/pkgconf tool.

Most uses of `sdl2-config --foo` can be replaced by something similar
to `${PKG_CONFIG:-pkg-config} --foo sdl2`. Instead of adding a custom
sdl2-config to the PATH or using its --prefix or --exec-prefix options,
users of a custom installation prefix can use any of pkg-config's
non-SDL-specific ways to influence the result, for example setting
PKG_CONFIG_PATH, PKG_CONFIG_SYSROOT_DIR or PKG_CONFIG_LIBDIR environment
variables, or setting the PKG_CONFIG environment variable to point to
a wrapper script.

For Autotools specifically, the replacement for AM_PATH_SDL2 (which
will be officially deprecated in a subsequent commit) is
PKG_CHECK_MODULES.

CMake has its own semi-declarative mechanism for dependency discovery,
"config packages", and the SDL build already installs a config
package. There's a good example of using a config package to discover
SDL in `cmake/test/`.

Meson natively supports pkg-config, and already uses it in preference
to sdl2-config.

Other build systems can run pkg-config instead of sdl2-config,
preferably checking the PKG_CONFIG environment variable first.
https://github.com/ioquake/ioq3 is a good example of a project doing
this correctly.

Helps: libsdl-org#6140, libsdl-org#3516
Signed-off-by: Simon McVittie <smcv@collabora.com>
AM_PATH_SDL2 doesn't add much beyond PKG_CHECK_MODULES, and having a
special m4 macro for every library that you might depend on scales
poorly.

The macro does add special support for macOS frameworks, but that feature
was broken for around 6 years without anyone noticing (libsdl-org#6141), and is
likely to be only rarely useful according to comments on libsdl-org#6141.

Resolves: libsdl-org#6140
Signed-off-by: Simon McVittie <smcv@collabora.com>
@slouken slouken merged commit a66cb8c into libsdl-org:main Oct 31, 2022
@sezero
Copy link
Contributor

sezero commented Nov 7, 2022

Should we revert this one? C.f.: #6494

@slouken
Copy link
Collaborator

slouken commented Nov 7, 2022

Let's leave this as-is for now, and revisit with SDL3.

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.

Deprecate sdl2-config and AM_PATH_SDL2, at least on Unix
3 participants