This is an alternative approach to #266 / #268. The goal was to try and introduce support for building dynamic libraries on macOS with minimal adjustment to the existing makefile.
Detect platform using uname. This doesn't support cross-compiling, but is probably sufficient to start.
The dynamic library naming convention differs between Darwin and other platforms. With ELF, the naming convention is libfoo.so.1 or libfoo.so.1.2.3, with the version being appended after the extension .so. With Mach-O (Darwin), the naming convention is libfoo.1.dylib or libfoo.1.2.3.dylib, with the version being between the library name and the extension .dylib.
The version suffix (e.g. 4 from libmonocypher.so.4) has been extracted out into its own variable, SOVER.
The extension suffix (e.g. so or dylib) is chosen conditionally per platform; SONAME is constructed conditionally per platform.
Different linker flags are needed for a dynamic library on macOS/Darwin. The platform-specific linker flags are contained in new variable SOFLAGS.
The install-lib target has been expanded into install-header, install-static-lib, install-so, and install-dylib targets. The install-lib target itself will trigger install-header and install-static-lib targets (common targets) and choose one of install-so or install-dylib as appropriate.
I hope that this strikes a reasonable balance between not adding too much cruft while not breaking any existing use cases. Open to any suggestions or concerns.
This is an alternative approach to #266 / #268. The goal was to try and introduce support for building dynamic libraries on macOS with minimal adjustment to the existing makefile.
uname
. This doesn't support cross-compiling, but is probably sufficient to start.libfoo.so.1
orlibfoo.so.1.2.3
, with the version being appended after the extension.so
. With Mach-O (Darwin), the naming convention islibfoo.1.dylib
orlibfoo.1.2.3.dylib
, with the version being between the library name and the extension.dylib
.4
fromlibmonocypher.so.4
) has been extracted out into its own variable,SOVER
.so
ordylib
) is chosen conditionally per platform;SONAME
is constructed conditionally per platform.SOFLAGS
.install-lib
target has been expanded intoinstall-header
,install-static-lib
,install-so
, andinstall-dylib
targets. Theinstall-lib
target itself will triggerinstall-header
andinstall-static-lib
targets (common targets) and choose one ofinstall-so
orinstall-dylib
as appropriate.I hope that this strikes a reasonable balance between not adding too much cruft while not breaking any existing use cases. Open to any suggestions or concerns.