TOOLCHAIN_DIR=/var/tmp/dist/macosx-toolchain

# ld needs libLTO.so from llvm
mk_add_options "export LD_LIBRARY_PATH=$TOOLCHAIN_DIR/clang/lib"

CROSS_CCTOOLS_PATH=$TOOLCHAIN_DIR/cctools
CROSS_SYSROOT=$TOOLCHAIN_DIR/MacOSX10.11.sdk
CROSS_PRIVATE_FRAMEWORKS=$CROSS_SYSROOT/System/Library/PrivateFrameworks
HARDENING_FLAGS="-Werror=format -Werror=format-security -fstack-protector-strong -D_FORTIFY_SOURCE=2"
FLAGS="-target x86_64-apple-darwin -B $CROSS_CCTOOLS_PATH/bin -isysroot $CROSS_SYSROOT $HARDENING_FLAGS"

export CC="$TOOLCHAIN_DIR/clang/bin/clang $FLAGS"
export CXX="$TOOLCHAIN_DIR/clang/bin/clang++ $FLAGS"
export LLVMCONFIG=$TOOLCHAIN_DIR/clang/bin/llvm-config
export LDFLAGS="-Wl,-syslibroot,$CROSS_SYSROOT -Wl,-pie"
export BINDGEN_CFLAGS="$FLAGS"
export TOOLCHAIN_PREFIX=$CROSS_CCTOOLS_PATH/bin/x86_64-apple-darwin-
export DSYMUTIL="$TOOLCHAIN_DIR/clang/bin/dsymutil"

export HOST_CFLAGS="-g"
export HOST_CXXFLAGS="-g"
export HOST_LDFLAGS="-g"

ac_add_options --target=x86_64-apple-darwin
export MACOS_SDK_DIR=$CROSS_SYSROOT
export MACOS_PRIVATE_FRAMEWORKS_DIR=$CROSS_PRIVATE_FRAMEWORKS

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-macos
mk_add_options MOZ_APP_DISPLAYNAME="Tor Browser"
export MOZILLA_OFFICIAL=1

ac_add_options --enable-application=browser
ac_add_options --enable-strip
ac_add_options --enable-official-branding
ac_add_options --enable-optimize
ac_add_options --disable-debug

ac_add_options --enable-tor-browser-data-outside-app-dir
ac_add_options --enable-tor-browser-update
ac_add_options --enable-verify-mar

ac_add_options --disable-crashreporter
ac_add_options --disable-webrtc
ac_add_options --disable-parental-controls
ac_add_options --disable-tests
# Let's make sure no preference is enabling either Adobe's or Google's CDM.
ac_add_options --disable-eme
ac_add_options --enable-proxy-bypass-protection

# Disable telemetry
ac_add_options MOZ_TELEMETRY_REPORTING=
