%define name dosemu
%define version @PACKAGE_VERSION@
%define release 1

Summary: DOSEMU stands for DOS Emulation, and enables Linux to run DOS programs
Name: %{name}
Version: %{version}
Release: %{release}
Source: %{name}-%{version}.tgz
Source1: %{name}-freedos-bin.tgz
License: GPL
Group: System/Emulators
Buildroot: %{_tmppath}/%{name}-root
BuildPrereq: bison flex
%description
DOSEMU is a user-level program which uses certain special features
of the Linux kernel and the 80386 processor to run MS-DOS/FreeDOS/
DR-DOS, DOS programs, and many DPMI applications in what we in the
biz call a `DOS box'.
%prep
%setup -q

%build
./configure --prefix=%{_prefix} --mandir=%{_mandir} --libdir=%{_libdir} --with-fdtarball=%{_sourcedir}/dosemu-freedos-bin.tgz
make

%install
%{__rm} -rf %{buildroot}
mkdir -p %{buildroot}/%{_bindir}
make DESTDIR=%{buildroot} install

%clean
%{__rm} -rf %{buildroot}

%pre
if [ -f /etc/dosemu.users ]; then
  echo "Deprecating /etc/dosemu.users: moving to /etc/dosemu/dosemu.users"
  echo "Please use /etc/dosemu/dosemu.users instead (if necessary)."
  mv /etc/dosemu.users /etc/dosemu/dosemu.users
fi
if [ -f /etc/dosemu.conf ]; then
  echo "Deprecating /etc/dosemu.conf: moving to /etc/dosemu/dosemu.conf"
  echo "Please use /etc/dosemu/dosemu.conf instead."
  mv /etc/dosemu.conf /etc/dosemu/dosemu.conf
fi

%files
%defattr(-,root,root)
%{_bindir}/dosemu.bin
%{_bindir}/dosemu
%{_bindir}/mkfatimage
%{_bindir}/mkfatimage16
%{_bindir}/midid
%{_bindir}/dosdebug
%{_bindir}/xdosemu
%{_mandir}/man1/midid.1*
%{_mandir}/man1/mkfatimage16.1*
%{_mandir}/man1/dosdebug.1*
%{_mandir}/man1/dosemu.1*
%{_mandir}/man1/dosemu.bin.1*
%{_mandir}/man1/xdosemu.1*
%{_mandir}/ru/man1/mkfatimage16.1*
%{_mandir}/ru/man1/dosdebug.1*
%{_mandir}/ru/man1/dosemu.1*
%{_mandir}/ru/man1/dosemu.bin.1*
%{_mandir}/ru/man1/xdosemu.1*
%dir %{_libdir}/dosemu
%{_libdir}/dosemu/libplugin*.so
%dir %{_datadir}/dosemu
%{_datadir}/dosemu/commands
%{_datadir}/dosemu/freedos
%{_datadir}/dosemu/drive_z
%{_datadir}/dosemu/keymap
%{_datadir}/dosemu/Xfonts
%dir %{_datadir}/doc/dosemu
%doc %{_datadir}/doc/dosemu/COPYING
%doc %{_datadir}/doc/dosemu/COPYING.DOSEMU
%doc %{_datadir}/doc/dosemu/README.bindist
%doc %{_datadir}/doc/dosemu/README.txt
%doc %{_datadir}/doc/dosemu/README-tech.txt
%doc %{_datadir}/doc/dosemu/dosemu-HOWTO.txt
%doc %{_datadir}/doc/dosemu/sound-usage.txt
%doc %{_datadir}/doc/dosemu/announce
%doc %{_datadir}/doc/dosemu/EMUfailure.txt
%doc %{_datadir}/doc/dosemu/NOVELL-HOWTO.txt
%doc %{_datadir}/doc/dosemu/README.gdb
%doc %{_datadir}/doc/dosemu/DANG.txt
%doc %{_datadir}/doc/dosemu/NEWS
%doc %{_datadir}/doc/dosemu/THANKS
%dir %{_sysconfdir}/dosemu
%config(noreplace) %{_sysconfdir}/dosemu/dosemu.conf
%dir %{_sysconfdir}/dosemu/drives
%config(noreplace) %{_sysconfdir}/dosemu/drives/c
%config(noreplace) %{_sysconfdir}/dosemu/drives/d
%config(noreplace) %{_sysconfdir}/dosemu/dosemu.users
%config(noreplace) %{_sysconfdir}/dosemu/global.conf
