#!/bin/bash
cd "$(dirname "$0")"
OS_X_VERSION=$(sw_vers -productVersion | cut -d. -f1,2)
FW_DIR="$PWD/../Frameworks/$OS_X_VERSION"

# On 10.6, DYLD_FRAMEWORK_PATH overrides framework search for all processes.
# Set it as the primary framework search path so Safari loads our custom
# JavaScriptCore, WebCore, and WebKit frameworks instead of the system ones.
export DYLD_FRAMEWORK_PATH="$FW_DIR"

# JSC is in PrivateFrameworks — found by @loader_path from our frameworks,
# but NOT redirected by DYLD_FRAMEWORK_PATH (avoids breaking system WebKit2).
export DYLD_LIBRARY_PATH="$FW_DIR"
export DYLD_FALLBACK_FRAMEWORK_PATH="/System/Library/Frameworks:/Library/Frameworks"
export DYLD_FALLBACK_LIBRARY_PATH="/usr/lib:/usr/local/lib"

exec "/Applications/Safari.app/Contents/MacOS/Safari"
