default_pre_build &&

if module_is_expired $MODULE && [ "$VERSION" != "`installed_version $MODULE`" ]; then
    set_module_config OLD_VER "`installed_version $MODULE`"
fi &&

cp $SCRIPT_DIRECTORY/mozconfig . &&
export MOZ_OBJDIR="${SOURCE_DIRECTORY}/build-mozilla" &&
mkdir -p ${MOZ_OBJDIR} &&

for flag in $OPTS; do
  echo "ac_add_options $flag" >> mozconfig
done

# Set remoting name to fix the missing wayland icon
export MOZ_APP_REMOTINGNAME=org.mozilla.Thunderbird


# Set BOTAN_VERSION from system-botan
_botan_ver=$(pkg-config --modversion botan-3)
sed -i "s|crypto_backend_version = CONFIG\[\"BOTAN_VERSION\"\]|crypto_backend_version = CONFIG[\"BOTAN_VERSION\"] or \"${_botan_ver}\"|" comm/third_party/rnp/moz.build

sed -e 's|73114a5c28472e77082ad259113ffafb418ed602c1741f26da3e10278b0bf93e|a88d6cc10ec1322b53a8f4c782b5133135ace0fdfcf03d1624b768788e17be0f|' \
    -i third_party/rust/mp4parse/.cargo-checksum.json &&
sed -e 's|880c982df0843cbdff38b9f9c3829a2d863a224e4de2260c41c3ac69e9148ad4|239b3e4d20498f69ed5f94481ed932340bd58cb485b26c35b09517f249d20d11|' \
    -i third_party/rust/bindgen/.cargo-checksum.json &&
# Clear cargo checksums for glslopt - the glibc-2.43 patch modifies files in both
# third_party and comm/third_party copies; clearing is simpler than computing exact hashes
sed -i -e 's/\("files":{\)[^}]*/\1/' \
    third_party/rust/glslopt/.cargo-checksum.json &&
sed -i -e 's/\("files":{\)[^}]*/\1/' \
    comm/third_party/rust/glslopt/.cargo-checksum.json
