cd "${BUILD_DIRECTORY}" &&

mk_source_dir "${SOURCE_DIRECTORY}" &&

message "${MESSAGE_COLOR}unxz ${SOURCE_CACHE}/${SOURCE}${DEFAULT_COLOR}" &&
unxz -k "${SOURCE_CACHE}/${SOURCE}" &&
SOURCE="${SOURCE%.xz}" &&
unpack_file "" &&

message "${MESSAGE_COLOR}rm ${SOURCE_CACHE}/${SOURCE}${DEFAULT_COLOR}" &&
rm "${SOURCE_CACHE}/${SOURCE}" &&

SOURCE="${SOURCE}.xz" &&

cd "${SOURCE_DIRECTORY}" &&
apply_patch_dir patches &&

if ! is_depends_enabled ${SPELL} $(get_spell_provider ${SPELL} LIBELF); then
  sedit "s:libelf --:nolibelf --:" configure
fi &&

if ! is_depends_enabled ${SPELL} libselinux; then
  sedit "s:libselinux --:nolibselinux --:" configure
fi &&

if ! is_depends_enabled ${SPELL} libmnl; then
  sedit "s:libmnl --: nolibmnl --:" configure
fi &&

if ! is_depends_enabled ${SPELL} ipset; then
  sedit "/ip_set\.h/d" configure
fi &&

if ! is_depends_enabled ${SPELL} iptables; then
  sedit "/xtables\.h/d" configure &&
  sedit "s:xtables --:noxtables --:" configure
fi &&

if ! is_depends_enabled ${SPELL} db; then
  sedit "/db_185\.h/d" configure
fi
