On non-freestanding builds, including <ucontext.h> on an ARM Darwin
system will produce the following error:
In file included from include/libucontext/bits.h:6:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
usr/include/ucontext.h:51:2: error: The deprecated
ucontext routines require _XOPEN_SOURCE to be defined
Defining this macro on Darwin systems will make the building pass.
The copy for bits.h ran in parallel with the initial CC. sometimes on
CI the build would fail as the file had not arrived by the time
needed. Fix matches meson build process.
When installing a FREESTANDING build, the check for an empty variable
was not being honored because the empty string would evaluate to
nothing. Put the variable expansion in quotes so that we have an empty
string instead.
Changes:
1. `-soname` should be `-install_name` on Darwin
2. Version suffix should placed before extension suffix (libucontext.so.1 -> libucontext.1.dylib)
3. Check for architecture specific include directory, and include it while building
4. `EXPORT_UNPREFIXED` macro shouldn't be set since Darwin don't support aliases
5. Choose correct subdir for arm64
6. Use `-dynamiclib` instead of `-shared` on Darwin for adding version info (`-current_version` and `-compatibility_version`)
This is needed because in libucontext.h we include "libucontext/bits.h".
We therefore need to have bits.h in somepath/libucontext/bits.h. In the
Makefile, somepath/freestanding/bits.h was copied to the right path but
in the meson build system, the include copy happens at the end.
The Makefile on ARMv7l devices (e.g. Raspberry Pi 400 running the
stock Raspbian distro) was failing to deduct the architecture and
empty libraries were being built as a result. Building with Meson
works fine; only building with make generated empty libraries.
Add an override for armv7l -> arm in the Makefile to address this.