build: versioned `libm` - symlink `libpthread` - fix symlinks
a) There is no apparent reason to use an unversioned libm.so when setting USE_SYSTEM_LIBM = 1, and on some distributions, libm.so is a valid linker script thus failing julia at runtime with the following error:
could not load library "libm"
/lib/x86_64-linux-gnu/libm.so: invalid ELF header
E.g. on ubuntu 22.04:
$ cat /lib/x86_64-linux-gnu/libm.so
/* GNU ld script
*/
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /lib/x86_64-linux-gnu/libm.so.6 AS_NEEDED ( /lib/x86_64-linux-gnu/libmvec.so.1 ) )
We already use versioned compiler support libraries (CSL), so versioning libm makes it consistent with CSL.
When using glibc, try to detect the ABI version in Makefile as it is currently done for libgfortran, falling back to version 6 (unchanged since 1997) if needed.
b) When setting USE_SYSTEM_CSL = 1, also try to symlink libpthread as it is listed in the private libs. Is there a reason not to do this ?
c) Also, prevent nesting symlinks resulting in a copy error on make install when the destination already exists and multiple make commands have been thrown before.
Tested locally using USE_SYSTEM_LIBM = 1 and USE_SYSTEM_CSL = 1: test suite is green.