# $Id$
# Authority: matthias

%define desktop_vendor rpmforge

Summary: Transport Tycoon Deluxe clone
Name: openttd
Version: 0.4.7
Release: 1
License: GPL
Group: Amusements/Games
URL: http://www.openttd.org/
Source: http://dl.sf.net/openttd/openttd-%{version}-source.tar.bz2
Patch0: openttd-0.4.7-nostrip.patch
Patch1: openttd-0.4.7-emptyprefix.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: zlib-devel, libpng-devel, SDL-devel, desktop-file-utils

%description
OpenTTD is a clone of the Microprose game "Transport Tycoon Deluxe", a popular
game originally written by Chris Sawyer. It attempts to mimic the original
game as closely as possible while extending it with new features.

OpenTTD requires the original version of Transport Tycoon Deluxe data files in
order to function. Please refer to the readme for more information.


%prep
%setup
%patch0 -p1 -b .nostrip
%patch1 -p1 -b .emptyprefix

# Create desktop file
%{__cat} > %{name}.desktop << 'EOF'
[Desktop Entry]
Name=OpenTTD
Comment=Open clone of the original Transport Tycoon Deluxe
Exec=openttd
Icon=openttd.64.png
Terminal=false
Type=Application
Categories=Application;Game;
Encoding=UTF-8
EOF


%build
%{__cat} > Makefile.config << 'EOF'
UNIX=1
WITH_ZLIB=1
WITH_PNG=1
WITH_SDL=1
RELEASE=%{version}
WITH_NETWORK=1
INSTALL=1
PREFIX=
BINARY_DIR=%{_bindir}
DATA_DIR=%{_datadir}/openttd
ICON_DIR=%{_datadir}/pixmaps
PERSONAL_DIR=.openttd
USE_HOMEDIR=1
VERBOSE=1
BASECFLAGS=%{optflags}
EOF
%{__make} %{?_smp_mflags} \


%install
%{__rm} -rf %{buildroot}

# Bogus file, make install fails if nothing is found in "scenario/"
touch scenario/bogus

%{__make} install DESTDIR="%{buildroot}"

# End of life for the bogus file created above
%{__rm} -f %{buildroot}%{_datadir}/openttd/scenario/bogus

# Touch ghost'ed original proprietary files that the game requires
touch %{buildroot}%{_datadir}/openttd/data/{sample.cat,trg{1,c,h,i,t}r.grf}

# Install man page
%{__install} -D -p -m 0644 docs/openttd.6 %{buildroot}%{_mandir}/man6/openttd.6

# Install desktop file
desktop-file-install \
    --vendor %{desktop_vendor} \
    --dir %{buildroot}%{_datadir}/applications \
    %{name}.desktop


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


%files
%defattr(-, root, root, 0755)
%doc changelog.txt COPYING known-bugs.txt readme.txt
%doc docs/console.txt docs/Manual.txt docs/multiplayer.txt
%{_bindir}/openttd
%{_datadir}/applications/*%{name}.desktop
%{_datadir}/openttd/
%ghost %{_datadir}/openttd/data/sample.cat
%ghost %{_datadir}/openttd/data/trg*r.grf
%{_datadir}/pixmaps/openttd.32.xpm
%{_datadir}/pixmaps/openttd.64.png
%{_mandir}/man6/openttd.6*


%changelog
* Wed Apr  5 2006 Matthias Saou <http://freshrpms.net/> 0.4.7-1
- Initial RPM release.