default_pre_build &&
cd "$SOURCE_DIRECTORY" &&

if [[ $WPA_RELEASE == "stable" ]]; then
  apply_patch_dir krack &&

  if [[ $CONFIG_TLS == "openssl" ]] && [[ $(get_spell_provider $SPELL SSL) == "libressl" ]]; then
    patch -p1 < "$SPELL_DIRECTORY/eloop.patch" &&
    patch -p1 < "$SPELL_DIRECTORY/libressl.patch"
  fi
fi &&

cd wpa_supplicant &&

sed -i "s|/usr/local|$INSTALL_ROOT/usr|g" Makefile &&

if is_depends_enabled $SPELL dbus; then
  if [[ $WPA_RELEASE == legacy ]]; then
    sed -i "s|=/sbin|=$INSTALL_ROOT/sbin|g" dbus-wpa_supplicant.service
  elif [[ $WPA_RELEASE == devel ]]; then
    sed -i "s|=/sbin|=$INSTALL_ROOT/sbin|g" \
           dbus/fi.epitest.hostap.WPASupplicant.service
  fi
fi &&

cd "$SOURCE_DIRECTORY" &&

if [[ -z $QTDIR ]] && is_depends_enabled $SPELL qt-x11; then
  . "$INSTALL_ROOT/etc/profile.d/qt.sh"
fi
