Requirements
- MacPorts is the recommended way to get the following necessary tools
- ANTLR
- subversion
Here the steps to prepare the build environment using MacPorts:
- install MacPorts as described
- install ANTLR
sudo port install antlr
- create symlinks so the build process will find antlr:
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/lib
sudo mkdir -p /usr/local/include
cd /usr/local/bin
sudo ln -s /opt/local/lib/antlr.jar antlr.jar
cd /usr/local/lib
sudo ln -s /opt/local/lib/libantlr.a libantlr2c++.a
cd /usr/local/include
sudo ln -s /opt/local/include/antlr antlr
- install subversion
sudo port install subversion
Getting the sources
AOSM (http://dll.nu/aosm/) provides the Apple open source projects as git repositories which is very convenient for backporting.
- Check out the Security main project
svn co https://github.com/aosm/Security/tags/mac-os-x-1068 Security
-
Check out the following sub projects into the root directoty of the main project:
Don't forget to add the destination path to the end of the command line (e.g. 'libsecurity_apple_csp')!
If not indicated differently all repositories are checked out at the tag 'mac-os-x-1068', like libsecurity_apple_csp.
Applying the patches
When targetting Snow Leopard you only need to patch libsecurity_ssl.
- you have to move some libsecurity_ssl headers manually before patching (current directory has to be the root directory of the main project):
svn move libsecurity_ssl/Security/* libsecurity_ssl/lib/
- in order to patch libsecurity_comcryption, libsecurity_cryptkit and libsecurity_ssl you have to pass '--strip 3' in the next step!
- apply the patches the following way:
svn patch --strip 2 {path to the patchfile} {path to the subproject; e.g. "libsecurity_apple_csp"}
- patch the CFBundlePriv header to include some missing symbols:
cd /usr/local/include/CoreFoundation
sudo patch --strip 1 <{path to CFBundlePriv.diff}
- apply a patch to DirectoryService:
cd {path to the DirectoryService directory}
svn patch --strip 2 {path to DirectoryService.diff}
Building the sources
You have to build the projects "the Apple way", like DarwinBuild does:
- build a library from DirectoryService and the corresponding headers:
cd {path to the DirectoryService directory}
sudo xcodebuild install -target "API Framework" -target DirectoryServiceMIG -configuration Deployment GCC_VERSION=4.2
- install the needed parts into /usr/local/:
sudo ditto /tmp/DirectoryService.dst/usr/local /usr/local
- create the needed build directories for the Security project:
cd {path to the Security directory}
mkdir -p destroot objroot symroot
- create a symbolic link required by all the projects ('$(pwd)' should result in the full path to the root directory of the main project):
"sudo ln -s $(pwd)/destroot/usr/local/SecurityPieces /usr/local/SecurityPieces"
- repeat this step for all subprojects (some will fail, but you can ignore that) in order to install the headers of all the subprojects into the shared directories created above:
cd {path to the subproject}
"sudo xcodebuild installhdrs DSTROOT=../destroot SYMROOT=../symroot OBJROOT=../objroot -configuration Deployment BUILD_VARIANTS=normal STRIP_INSTALLED_PRODUCT=NO PUBLIC_HEADERS_FOLDER_PATH=/usr/local/SecurityPieces/Headers/Security"
cd ..
- install the headers of the main project into the shared directories (issued from Security directory):
"sudo xcodebuild installhdrs DSTROOT=./destroot SYMROOT=./symroot OBJROOT=./objroot -configuration Deployment BUILD_VARIANTS=normal STRIP_INSTALLED_PRODUCT=NO"
- repeat the above three steps for installing the headers of all the subprojects (none should fail this time)
- now build the subprojects:
cd {path to the subproject}
"sudo xcodebuild install DSTROOT=../destroot SYMROOT=../symroot OBJROOT=../objroot -configuration Deployment BUILD_VARIANTS=normal STRIP_INSTALLED_PRODUCT=NO PUBLIC_HEADERS_FOLDER_PATH=/usr/local/SecurityPieces/Headers/Security GCC_VERSION=4.2"
cd ..
- in case some of the above build steps fail ignore that until you have built all subprojects and then start again, rebuilding the ones that failed (you might need to adjust the order in which you build them)
- finally build the framework:
"sudo xcodebuild install DSTROOT=./destroot SYMROOT=./symroot OBJROOT=./objroot -configuration Deployment BUILD_VARIANTS=normal STRIP_INSTALLED_PRODUCT=NO GCC_VERSION=4.2"
libsecurityd has to be compiled with gcc 4.0 so you have to pass GCC_VERSION=4.0
- you find the resulting framework bundle in its install path in the destroot directory.