%global         svn_rev  1115
%global         nonfree  0
%global         free     1

%if 0%{nonfree}
# "Monkey's Audio Source Code License Agreement" is nonfree license.
%global         with_mac  --with-mac
%endif

%if 0%{free}
# The following packages are free license (patent issue).
%global         with_mpeg --with-mpeg
%global         with_lavc --with-lavc
%global         with_lame --with-lame
%endif

Name:           aqualung
Version:        0.9
Release:        0.5.svn%{svn_rev}%{?dist}
Summary:        Music Player for GNU/Linux

Group:          Applications/Multimedia
License:        GPLv2+
URL:            http://aqualung.factorial.hu/
# run ./aqualung-snapshot.sh to get this
Source0:        %{name}-export-r%{svn_rev}.tar.bz2
Source1:        %{name}.desktop
Source10:       aqualung-snapshot.sh
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Patch0:         aqualung-metadata-encode-v2.patch
Patch1:         aqualung-socket-test.patch

# autogen.sh
BuildRequires:  autoconf automake pkgconfig gettext

# GUI
BUildRequires:  glib2-devel gtk2-devel atk-devel cairo-devel pango-devel
BuildRequires:  pixman-devel libpng-devel zlib-devel
BuildRequires:  fontconfig-devel freetype-devel libxml2-devel

# Desktop
BuildRequires:  desktop-file-utils

# Output
BuildRequires:  alsa-lib-devel
BuildRequires:  jack-audio-connection-kit-devel
BuildRequires:  pulseaudio-lib-devel
BuildRequires:  libsamplerate-devel

# Encode/Decode
BuildRequires:  libsndfile-devel
BuildRequires:  flac-devel
BuildRequires:  libvorbis-devel
BuildRequires:  liboggz-devel
BuildRequires:  speex-devel
%{?with_mpeg:BuildRequires:  libmad-devel}
BuildRequires:  libmodplug-devel
BuildRequires:  libmpcdec-devel
%{?with_mac:BuildRequires:  mac-devel}
%{?with_lavc:BuildRequires:  ffmpeg-devel}
%{?with_lame:BuildRequires:  lame-devel}
BuildRequires:  wavpack-devel
BuildRequires:  liblrdf-devel

# CD
BuildRequires:  libcdio-devel
BuildRequires:  libcddb-devel

# Others
BuildRequires:  libusb-devel
BuildRequires:  libifp-devel
BuildRequires:  lua-devel

%description
Aqualung is an advanced music player originally targeted at the GNU/Linux
operating system. It plays audio CDs, internet radio streams and podcasts as
well as soundfiles in just about any audio format and has the feature of
inserting no gaps between adjacent tracks.

%prep
%setup -q -n %{name}-export-r%{svn_rev}
%patch0 -p1 -b .meta
%patch1 -p1 -b .sock

%build
./autogen.sh
%configure \
    --without-sndio \
    --with-oss \
    --with-alsa \
    --with-jack \
    --with-pulse \
    --with-src \
    --with-sndfile \
    --with-flac \
    --with-ogg \
    --with-vorbisenc \
    --with-speex \
    %{!?with_mpeg: --without-mpeg} %{?with_mpeg} \
    --with-mod \
    --with-mpc \
    %{!?with_mac:  --without-mac} %{?with_mac} \
    %{!?with_lavc: --without-lavc} %{?with_lavc} \
    %{!?with_lame: --without-lame} %{?with_lame} \
    --with-wavpack \
    --with-ladspa \
    --with-cdda \
    --with-cddb \
    --with-ifp \
    --with-systray \
    --with-loop \
    --with-podcast \
    --with-lua

# Fix lib64 path
%{__sed} -i 's@/usr/lib/@%{_libdir}/@g' src/plugin.c

%{__make} %{?_smp_mflags}

%install
%{__rm} -rf %{buildroot}
%{__make} install DESTDIR=%{buildroot} INSTALL="%{__install} -p -c"

%{__chmod} a+x %{buildroot}%{_datadir}/%{name}/doc/split.sh

desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE1}

%{__install} -d -m 755 %{buildroot}%{_datadir}/pixmaps
%{__install} -D -m 644 -p src/img/icon_48.png \
    %{buildroot}%{_datadir}/pixmaps/%{name}.png

%find_lang %{name}

%clean
rm -rf %{buildroot}


%post
update-desktop-database &> /dev/null || :

%postun
update-desktop-database &> /dev/null || :


%files -f %{name}.lang
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog README COPYING
%{_bindir}/%{name}
%{_datadir}/%{name}/*
%{_datadir}/man/man1/%{name}.*
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.png

%changelog
* Tue Feb 2 2010 Akio Idehara <zbe64533 at gmail.com> 0.9-0.5.svn1115
- Disable mac support. This is mac's the license issue.

* Mon Feb 1 2010 Akio Idehara <zbe64533 at gmail.com> 0.9-0.4.svn1115
- Add post/postun.

* Mon Feb 1 2010 Akio Idehara <zbe64533 at gmail.com> 0.9-0.3.svn1115
- Update to SVN r1115.

* Sun Jan 31 2010 Akio Idehara <zbe64533 at gmail.com> 0.9-0.2.svn1109
- Change Socket test routine.

* Sat Jan 23 2010 Akio Idehara <zbe64533 at gmail.com> 0.9-0.1.svn1109
- Initial RPM release
