Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building on Darwin/macOS #271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alebcay
Copy link

@alebcay alebcay commented Mar 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant