_google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM

_mozilla_api_key=16674381-f021-49de-8622-3021c5942aff

mkdir $SRC/mozbuild

mkdir "$KAYNAKLAR_DEPO/rust" || true
export CARGO_HOME="$KAYNAKLAR_DEPO/rust"

# https://bugzilla.mozilla.org/show_bug.cgi?id=1530052
patch -Np1 -i ../0001-Use-remoting-name-for-GDK-application-names.patch

echo -n "$_google_api_key" >google-api-key
echo -n "$_mozilla_api_key" >mozilla-api-key

  cat >.mozconfig <<END
ac_add_options --enable-default-toolkit=cairo-gtk3
ac_add_options --enable-application=browser
unset export MOZ_TELEMETRY_REPORTING
ac_add_options --prefix=/usr
ac_add_options --libdir=/usr/lib
ac_add_options --enable-optimize

export CC=clang
export CXX=clang++
export AR=llvm-ar
export NM=llvm-nm
export RANLIB=llvm-ranlib

# Branding
ac_add_options --enable-official-branding
ac_add_options --enable-update-channel=release
ac_add_options --with-distribution-id=org.milislinux

# Keys
ac_add_options --with-google-location-service-api-keyfile=${PWD@Q}/google-api-key
ac_add_options --with-google-safebrowsing-api-keyfile=${PWD@Q}/google-api-key
ac_add_options --with-mozilla-api-keyfile=${PWD@Q}/mozilla-api-key

# System libraries
ac_add_options --with-system-nspr
ac_add_options --with-system-nss
ac_add_options --with-system-bz2
ac_add_options --with-system-jpeg
ac_add_options --with-system-zlib
ac_add_options --with-system-libevent
ac_add_options --with-system-icu
# XXX: the system's libpng doesn't have APNG support
ac_add_options --without-system-png
ac_add_options --enable-system-pixman
ac_add_options --enable-system-sqlite
ac_add_options --enable-system-ffi

# Features
ac_add_options --enable-alsa
ac_add_options --enable-jack
ac_add_options --enable-startup-notification
ac_add_options --disable-crashreporter
ac_add_options --disable-gconf
ac_add_options --disable-updater
ac_add_options --disable-profiling
ac_add_options --disable-tests
ac_add_options --disable-elf-hack
END

mkdir -p third_party/rust/libloading/.deps
export LDFLAGS+=" -Wl,-rpath=/usr/lib/firefox"
export MOZ_NOSPAM=1
export MOZBUILD_STATE_PATH="$SRC/mozbuild"
export MOZ_MAKE_FLAGS="${MAKEJOBS}"

rm -f old-configure
SHELL=/bin/bash ./mach build
