I am trying to compile my own copy of Apple's Security.framework, specifically version 55471.14.18, which was included in OS X 10.9.5 and whose source code can be downloaded from https://opensource.apple.com/tarballs/Security/Security-55471.14.18.tar.gz.
I'm using a copy of Mac OS X 10.9.5 in a VM. Xcode 6.2 has been installed, and xcode-select --install
has separately been run to acquire system headers.
The readme file included in the source download says:
To build this project in a Darwin environment (as opposed to building in-house at Apple), use the Darwin buildstyle. If you're building with Xcode, select "Darwin" from the "Active Build Style" popup. If you're building from the command line, specify the build style like so:
% xcodebuild -buildstyle Darwin install
But when I run the given command, I'm told:
xcodebuild: error: option '-buildstyle' is no longer supported
Since my copy of Xcode was current at the time this code was released, I'm not sure what to make of this error. I decided to ignore it and press on with just a standard xcodebuild
command.
The first problem I ran into was easy to fix, but makes me worried I'm missing something larger. The compiler complains:
/Users/Jonathan/Desktop/Security-55471.14.18/libsecurity_utilities/lib/macho++.cpp:39:18: error:
unused variable 'MAX_ARCH_COUNT' [-Werror,-Wunused-const-variable]
static const int MAX_ARCH_COUNT = 100;
Since the variable is reportedly unused anyway, I just opened the file and commented out the line static const int MAX_ARCH_COUNT = 100;
.
Unfortunately, this is where I ran into a brick wall. Xcodebuild seems to want all sorts of headers that are not on my system or included in the project. For instance:
/Users/Jonathan/Desktop/Security-55471.14.18/libsecurity_utilities/lib/mach++.cpp:33:10: fatal error:
'bootstrap_priv.h' file not found
#include <bootstrap_priv.h>
These headers are also open source, and I know where to find them! Bootstrap_priv.h, for example, is part of launchd; the OS X 10.9.5 version can be downloaded from https://opensource.apple.com/tarballs/launchd/launchd-842.92.1.tar.gz
However, I do not understand where I'm supposed to put these headers in order for the compiler to find them! Things I've tried:
- Copying the launchd project to /usr/include/
- Copying the launchd project to the root of the security project
- Copying just Bootstrap_priv.h to /usr/include/
- Copying just bootstrap_priv.h to the root of the security project
- Copying just bootstrap_priv.h to the project directory/libsecurity_utilities/lib/
That last attempt actually did let me get past the error (and to see the next missing header, IOPMLibPrivate.h
), but I'm quite sure it's not what I'm supposed to do! As I keep adding headers to random places within the project, other source files get stuck finding headers I've already copied elsewhere. Some of the headers themselves get stuck this way, expecting a different relative path for dependencies than what the main project seems to need.
I am feeling extremely out of my depth here! Where are these header files actually supposed to go, and what is the meaning of that -buildstyle
option I'm supposed to include but which can't be run? None of this appears to be documented anywhere!
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/chrono
so that could be worth a try. Also there's this way to add include paths to the compiler: stackoverflow.com/questions/5846804/… but all this seems off-topic and good for stackoverflow