# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

if test "$ZEN_RELEASE"; then
    if test "$SURFER_COMPAT" = "x86_64"; then
        ac_add_options --target=x86_64-pc-linux
        ac_add_options --enable-eme=widevine

        # Enable Profile Guided Optimization
        if ! test "$ZEN_GA_DISABLE_PGO"; then
            if test "$ZEN_GA_GENERATE_PROFILE"; then
                mk_add_options "export MOZ_AUTOMATION_PACKAGE_GENERATED_SOURCES=0"
                ac_add_options --enable-profile-generate=cross
            else
                ac_add_options --enable-profile-use=cross
                ac_add_options --with-pgo-profile-path="$(echo ~)/artifact/merged.profdata"
                ac_add_options --with-pgo-jarlog="$(echo ~)/artifact/en-US.log"
            fi
        fi
    elif test "$SURFER_COMPAT" = "aarch64"; then
        ac_add_options --target=aarch64-linux-gnu

        # override LTO settings
        export MOZ_LTO=cross,thin
        ac_add_options --enable-lto=cross,thin
    fi

    # Disable DMD and ELF hacks, enable linker lld
    ac_add_options --enable-linker=lld
    ac_add_options --disable-elf-hack

    # Stripping options for release builds
    ac_add_options --enable-install-strip
    ac_add_options --enable-strip
    export STRIP_FLAGS="--strip-debug --strip-unneeded"
fi
