Enhance build-system to perfectly support OpenBSD and macOS

Studying the source material on OpenBSD[0], it is written that

	Quite a few ports need tweaks to build shared libraries correctly
	anyways. Remember that building shared libraries should be done with

		$ cc -shared -fpic|-fPIC -o libfoo.so.4.5 obj1 obj2

	Trying to rename the library after the fact to adjust the version
	number does not work: ELF libraries use some extra magic to set the
	library internal name, so you must link it with the correct version
	the first time.

Thus, it is necessary to directly compile into $(SONAME), which is
changed to in this commit.

The magic flags for macOS were taken from [1]. It sets up the linker
such that it automatically respects semantic versioning and will load
any library with a smaller compatible version (e.g. same minor-version).

Additionally, both OpenBSD and macOS have smarter linkers than Linux
and don't need symlinks from varying versions to work right. Thus a
flag SOSYMLINK was added to enable toggling this from the config.mk.

For convenience, the best-practices for each platform are added to
the config.mk in a commented-out form, saving everybody some time.

[0]:https://www.openbsd.org/faq/ports/specialtopics.html#SharedLibs
[1]:https://begriffs.com/posts/2021-07-04-shared-libraries.html#linking

Signed-off-by: Laslo Hunhold <dev@frign.de>
2 files changed