User landonf wrote this patchset to allow baseline Mac OS X support.

Howdy,

The patches here add support for building on Mac OS X; with these changes, all included tests (executed via `make check’) pass on both Mac OS X and FreeBSD.

I don’t anticipate an immediate merge, but I wanted to go ahead and open this to allow for comment.

This patchset primarily consists of:

  • Adding compatibility shims for BSD-specific or later POSIX functionality that Mac OS X doesn’t support (see compat/)
  • Adding pkg_macho.c with support for Mach-O binary analysis.

For pkg_macho.c, I used BSD-licensed Mach-O parsing code written for MacPorts‘ shared library/executable analysis (external/libmachista).

The primarily outstanding issues I have yet to tackle:

  • Making sure I didn’t miss any style(9) bugs.
  • Finishing shared library analysis handling (marked with MACTODO in pkg_macho.c):
    • Universal binary handling. I’m currently stuffing the architecture(s) supported by libraries into their library paths, as a file suffix. This is not the final solution, but I haven’t decided how to tackle this yet.
    • dyld specific features:
      • Required/compatibility version fields that must match between the linking image and linked library.
      • Relative library path handling via dyld‘s @loader_path, @executable_path, etc.

Cheers!

Check out the patch from GitHub here: https://github.com/freebsd/pkg/pull/1113