
# SURFER_COMPAT has a different meaning here, in macOS it means that the build is for
# x86_64, not ARM64. 
unset MOZ_STDCXX_COMPAT

ac_add_options --disable-dmd

export MOZ_MACBUNDLE_ID=${appId}
export MOZ_MACBUNDLE_NAME="Zen Browser.app"

if test "$SURFER_COMPAT" = "true"; then
    export MOZ_PGO=1
    ac_add_options MOZ_PGO=1
    ac_add_options --target=x86_64-apple-darwin

    ac_add_options --enable-wasm-avx
    ac_add_options --enable-optimize="-march=nehalem -mtune=haswell -O3 -w"

    export CFLAGS="-O3 -march=nehalem"
    export CPPFLAGS="-O3 -march=nehalem"
    export CXXFLAGS="-O3 -march=nehalem"
    export LDFLAGS="-Wl,-O3 -march=nehalem"
    export RUSTFLAGS="-Ctarget-cpu=nehalem -C codegen-units=1"
else
    ac_add_options --target=aarch64-apple-darwin

    ac_add_options --enable-optimize="-O3 -mcpu=apple-m1 -march=armv8.3-a+simd"

    # As of Clang 13, the default is -mcpu=apple-m1 when using a aarch64-apple-macos target,
    # but we're using apple64-apple-darwin, which defaults to -mcpu=apple-a7, which disables
    # a bunch of # performance-enabling CPU features.
    export CFLAGS="-O3 -march=armv8.3-a+simd -mcpu=apple-m1"
    export CPPFLAGS="-O3 -march=armv8.3-a+simd -mcpu=apple-m1"
    export CXXFLAGS="-O3 -march=armv8.3-a+simd -mcpu=apple-m1"
    export LDFLAGS="-Wl,-O3 -march=armv8.3-a+simd -mcpu=apple-m1"
    export RUSTFLAGS="-C target-feature=+v8.3a -C codegen-units=1 -Ctarget-cpu=apple-m1"
fi
export VERBOSE=1

# Enable polly for macos, since they have a more stable set of GPU drivers,
# unlike Linux, which has a lot of different drivers.
export POLLY="-mllvm -polly -mllvm -polly-2nd-level-tiling -mllvm -polly-loopfusion-greedy -mllvm -polly-pattern-matching-based-opts -mllvm -polly-position=before-vectorizer -mllvm -polly-vectorizer=stripmine"
