python/Makefile.am: use *_LIBADD, not *_LDFLAGS for LIBS
This fixes over-linking in the built Python modules with various libraries.
*_LIBADD is intended for adding additional libraries for linking, while *_LDFLAGS is for miscellaneous extra flags (possibly user-supplied).
If using -Wl,-as-needed within user-supplied LDFLAGS, it is passed too late (after the library link line) and therefore has no effect.
Notes:
-
Noticed while working on Gentoo's migration to libxcrypt because libxml2's Python modules were linking to libcrypt (and other libraries) unexpectedly.
-
It was suggested we could actually stop linking explicitly with all of Python's libraries / don't copy its LDFLAGS, but this resolves the original issue downstream and is a separate discussion. I couldn't find any clear documentation for/against such a change.
Bug: https://bugs.gentoo.org/798942
Signed-off-by: Sam James sam@gentoo.org