prefix="$INSTALL_ROOT"/usr &&
etcdir="$INSTALL_ROOT/etc/refind.d" &&
datarootdir="$prefix/share" &&
datadir="$datarootdir/$SPELL" &&
docdir="$datarootdir"/doc/"$SPELL" &&
mandir="$datarootdir"/man &&
sbindir="$prefix"/sbin &&

install -v -d \
	"$datadir"/refind/icons \
	"$datadir"/{images,fonts,banners} \
	"$docdir"/{Styles,refind} \
	"$etcdir"/keys \
	"$mandir"/man8 \
	"$sbindir" &&

install -v -m444 docs/man/*.8 "$mandir"/man8/ &&
install -v -m444 *.txt "$docdir"/ &&
install -v -m444 docs/refind/* "$docdir"/refind/ &&
install -v -m444 docs/Styles/*.css "$docdir"/Styles/ &&

install -v -m555 mkrlconf mvrefind refind-mkdefault "$sbindir" &&
install -v -m555 refind-install  "$datadir"/ &&
ln -v -r -s "$datadir"/refind-install "$sbindir"/ &&

install -v -m444 icons/*.png icons/README "$datadir"/refind/icons/ &&
install -v -m444 images/* "$datadir"/images/ &&
install -v -m444 fonts/* "$datadir"/fonts/ &&
install -v -m444 banners/* "$datadir"/banners/ &&
for d in refind/tools_{x64,ia32} drivers_{x64,ia32}; do
  [ -d "$d" ] || continue
  install -v -d "$datadir/refind/${d#refind/}" &&
  install -v -m444 "$d"/* "$datadir/refind/${d#refind/}/" || exit 1
done &&
install -v -m444 refind/*.efi refind.conf-sample "$datadir"/refind/ &&
install -v -m444 keys/* "$etcdir"/keys/
