+# TODO:
+# - update to 21.6
+# - executable should be sgid games?
+Summary: Superior chess program by Bob Hyatt for Unix systems
+Summary(pl.UTF-8): Jeden z lepszych programów szachowych dla uniksów autorstwa Boba Hyatta
Name: crafty
-Version: 18.9
-Release: 2
+Version: 20.1
+Release: 1
License: GPL
Group: Applications/Games
-Summary: Superior chess program by Bob Hyatt for Unix systems.
-Icon: xchess.gif
-Source0: ftp://ftp.cis.uab.edu/pub/hyatt/v18/%{name}-%{version}.tar.gz
-# Source0-md5: 439b591eb48957ce50bfd31f9bada8fb
-Source1: ftp://ftp.cis.uab.edu/pub/hyatt/%{name}.faq
-# Source1-md5: f744727e291b6dec7e7c69bb3586b6dd
-Source2: ftp://ftp.cis.uab.edu/pub/hyatt/read.me
-# Source2-md5: ce9a5e014d23f36c2540628ba0dc1c0b
-Source3: ftp://ftp.cis.uab.edu/pub/hyatt/common/start.pgn.gz
-# Source3-md5: c3c54b29351408298e3c7548f4faed93
-Source4: ftp://ftp.cis.uab.edu/pub/hyatt/v18/%{name}.doc.ascii
-# Source4-md5: 5fd73027a1de1674763562e1987197ba
-Source5: ftp://ftp.cis.uab.edu/pub/hyatt/doc/%{name}.doc.ps
-# Source5-md5: 6cef69aa2f9ea1ceb74b6c14edc8291f
+Source0: ftp://ftp.cis.uab.edu/pub/hyatt/source/%{name}-%{version}.zip
+# Source0-md5: 1d88571c150544c3ed25247127bfc5bd
+Source1: ftp://ftp.cis.uab.edu/pub/hyatt/documentation/%{name}.doc.ascii
+# NoSource1-md5: 5fd73027a1de1674763562e1987197ba
+Source2: ftp://ftp.cis.uab.edu/pub/hyatt/documentation/%{name}.doc.ps
+# Source2-md5: 6cef69aa2f9ea1ceb74b6c14edc8291f
+Source3: %{name}.desktop
+Source4: xchess.png
+Source5: %{name}-misc.tar.bz2
+Source6: %{name}-bitmaps.tar.gz
Patch0: %{name}-paths.patch
+Patch1: %{name}-Makefile.patch
+Patch2: %{name}-MDK.patch
+URL: http://www.limunltd.com/crafty/
+BuildRequires: libstdc++-devel
Provides: chessprogram
-ExcludeArch: axp
+Provides: chess_backend
+Suggests: xboard
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%define specflags -fomit-frame-pointer
%description
Crafty is a Unix chess program, distributed as source by its author,
Bob Hyatt. The program plays at about 2200 strength and frequently
beats GNU Chess on the same hardware.
+%description -l pl.UTF-8
+Crafty to uniksowy program szachowy rozpowszechniany w postaci
+źródłowej przez autora - Boba Hyatta. Program gra z siłą około 2200 i
+często wygrywa z GNU Chess na tym samym sprzęcie.
+
%prep
-%setup -q -c -T -a 0
-%patch -p1
-cp ${SOURCE2} README
-cp ${SOURCE1} .
-cp ${SOURCE4} ${SOURCE5} .
-cp ${SOURCE3} . ; gzip -d start.pgn.gz
+%setup -q -a5 -a6
+%patch0 -p1
+%patch1 -p1
+%patch2 -p0
+mv doc/read.me README
+mv doc/* .
+mv bitmaps/README.bitmaps .
+rm -f bitmaps/gifs.tar
+cp %{SOURCE1} %{SOURCE2} .
+
+%{__perl} -pi -e 's@.*machine/builtins.*@@' chess.h
%build
-%{__make} linux-elf
-mkdir -p %{_prefix}/lib/games/crafty
-touch %{_prefix}/lib/games/crafty/book.lrn %{_prefix}/lib/games/crafty/position.{bin,lrn}
-./crafty << _END_
-books create start.pgn 60
-quit
-_END_
+asmobj=""
+optarch=""
+target="LINUX"
+%ifarch %{ix86}
+optarch="-DUSE_ASSEMBLY_A -DUSE_ASSEMBLY_B"
+asmobj="X86-elf.o"
+%endif
+%ifarch alpha
+target="ALPHA"
+%endif
+%{__make} crafty-make \
+ target="$target" \
+ CC="%{__cc}" \
+ CXX="%{__cxx}" \
+ CFLAGS="%{rpmcflags} -Wall -pipe -D_REENTRANT" \
+ LDFLAGS="%{rpmldflags} -lpthread" \
+ opt="-DCOMPACT_ATTACKS -DUSE_ATTACK_FUNCTIONS $optarch -DFAST" \
+ asm="$asmobj"
+
+sh make_books
+# use large opening book
+mv large_book.bin book.bin
%install
rm -rf $RPM_BUILD_ROOT
-install -d %{_prefix}/lib/games/crafty
-install -m 02755 -g games crafty %{_bindir}/crafty
-install -m 0644 -g games books.bin %{_prefix}/lib/games/crafty/books.bin
+install -d $RPM_BUILD_ROOT{%{_bindir},%{_mandir}/man6,%{_desktopdir},%{_pixmapsdir}} \
+ $RPM_BUILD_ROOT{%{_datadir}/%{name}/{bitmaps,sound,tb},/var/lib/%{name}}
+
+install crafty $RPM_BUILD_ROOT%{_bindir}
+install xcrafty $RPM_BUILD_ROOT%{_bindir}
+install speak $RPM_BUILD_ROOT%{_bindir}/crafty-speak
+
+install book.bin books.bin crafty.hlp $RPM_BUILD_ROOT%{_datadir}/%{name}
+install bitmaps/* $RPM_BUILD_ROOT%{_datadir}/%{name}/bitmaps
+install tb/*.emd $RPM_BUILD_ROOT%{_datadir}/%{name}/tb
+
+install crafty.6 $RPM_BUILD_ROOT%{_mandir}/man6
+echo ".so crafty.6" > $RPM_BUILD_ROOT%{_mandir}/man6/xcrafty.6
+
+install %{SOURCE3} $RPM_BUILD_ROOT%{_desktopdir}
+install %{SOURCE4} $RPM_BUILD_ROOT%{_pixmapsdir}
+
+touch $RPM_BUILD_ROOT/var/lib/%{name}/book.lrn \
+ $RPM_BUILD_ROOT/var/lib/%{name}/position.{bin,lrn}
-%post
-touch /usr/lib/games/crafty/book.lrn /usr/lib/games/crafty/position.{bin,lrn}
-chgrp games /usr/lib/games/crafty/book.lrn \
- /usr/lib/games/crafty/position.{bin,lrn}
-chmod g+w /usr/lib/games/crafty/book.lrn \
- /usr/lib/games/crafty/position.{bin,lrn}
+for file in book.lrn position.{bin,lrn}; do
+ ln -s /var/lib/%{name}/$file $RPM_BUILD_ROOT%{_datadir}/%{name}/$file
+done
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%doc crafty.faq
-%doc crafty.doc.ascii
-%doc crafty.doc.ps
-%doc README
-%dir %{_prefix}/lib/games/crafty
-%attr(755,root,root) %{_bindir}/crafty
-%{_prefix}/lib/games/crafty/books.bin
+%doc crafty.doc* crafty.faq README* small.txt start.pgn tournament.howto
+%attr(755,root,root) %{_bindir}/crafty*
+%attr(755,root,root) %{_bindir}/xcrafty
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}/*.bin
+%{_datadir}/%{name}/*.hlp
+%{_datadir}/%{name}/*.lrn
+%dir %{_datadir}/%{name}/bitmaps
+%{_datadir}/%{name}/bitmaps/*.bm
+%{_datadir}/%{name}/bitmaps/*.gif
+%dir %{_datadir}/%{name}/tb
+%{_datadir}/%{name}/tb/*.emd
+%dir /var/lib/%{name}
+%attr(660,root,games) %config(noreplace) %verify(not md5 mtime size) /var/lib/%{name}/book.lrn
+%attr(660,root,games) %config(noreplace) %verify(not md5 mtime size) /var/lib/%{name}/position.bin
+%attr(660,root,games) %config(noreplace) %verify(not md5 mtime size) /var/lib/%{name}/position.lrn
+%{_mandir}/man6/*.6*
+%{_desktopdir}/*.desktop
+%{_pixmapsdir}/*