%define ver @RPM_SHORT_VERSION@
%define release @RPM_RELEASE@
%define filelist %{name}-@RPM_SHORT_VERSION@/files.list.%{name}
%define rpm_opt_flags ${RPM_OPT_FLAGS}

Summary:	@RPM_SUMMARY@
Name:		@RPM_NAME@
Version: 	@RPM_SHORT_VERSION@
Release: 	@RPM_RELEASE@
License:	GPL and others, see LICENSES file
Source0: 	kwave-@RPM_FULL_VERSION@.tar.gz
Group:  	Productivity/Multimedia/Sound/Editors
URL:		@RPM_URL@
Vendor: 	@RPM_VENDOR@
BuildRoot: 	@RPM_BUILDROOT@
Prefix:   	@prefix@
Provides:	@RPM_NAME@
Requires: 	libqt-mt.so.3 >= 3.0
Requires: 	kdelibs >= 3.0
Requires:	@RPM_REQUIRE_ID3LIB@ >= 3.8.1
Requires:	libvorbis.so.0 >= 0.2.0
Requires:	libvorbisenc.so.2 >= 2.0.0
Requires:	libogg.so.0 >= 0.4.0
Requires:	@RPM_REQUIRE_LIBMAD@ > 0.14
@LIBAUDIOFILE_REQUIRE@
Requires:	gsl >= 1.4
Requires:	flac
BuildRequires:	flac-devel
BuildRequires:	id3lib-devel >= 3.8.1
BuildRequires:	kdemultimedia3-devel
BuildRequires:	libogg-devel >= 1
BuildRequires:	audiofile > 0.2.3
BuildRequires:	libvorbis >= 1
BuildRequires:	gsl >= 1.4
BuildRequires:	kdesdk3-translate

Conflicts: 	libkwave
Obsoletes: 	libkwave

%description
With Kwave you can edit many sorts of wav-files
including multi-channel files. You are able to
alter and play back each channel on its own.
Kwave also includes many plugins (most are
still under development) to transform the
wave-file in several ways and presents a
graphical view with a complete zoom-and scroll capability.

%prep

%setup
rm -rf "$RPM_BUILD_ROOT"
DESTDIR=""
unset DESTDIR
CONFIGURE_OPTS="--with-install-root=$RPM_BUILD_ROOT \
	--enable-static=yes --enable-shared=yes ${CONFIGURE_OPTS}"
make -f Makefile.dist

%build
DESTDIR=""
unset DESTDIR
make $MAKE_FLAGS

%install
rm -rf "$RPM_BUILD_ROOT"
make DESTDIR="$RPM_BUILD_ROOT" SUID_ROOT="" install

cd "$RPM_BUILD_ROOT"
echo "%defattr(-,root,root)" > "$RPM_BUILD_DIR"/%{filelist}
find . -type d | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' >> "$RPM_BUILD_DIR"/%{filelist}
find . -type f | sed 's,^\.,\%attr(-\,root\,root) \%dir ,' >> "$RPM_BUILD_DIR"/%{filelist}
find . -type l | sed 's,^\.,\%attr(-\,root\,root) \%dir ,' >> "$RPM_BUILD_DIR"/%{filelist}
# remove files/directories that should not get into the package
mv "$RPM_BUILD_DIR"/%{filelist} /tmp/files.lst.tmp
cat /tmp/files.lst.tmp | grep -v /default$ | \
	grep -v /de$ | grep -v /en$ > /tmp/files.list.%{name}
rm -f /tmp/files.lst.tmp

%files -f /tmp/files.list.%{name}

%doc GNU-LICENSE AUTHORS LICENSES CHANGES README TODO kwave.lsm

%clean
rm -Rf "$RPM_BUILD_ROOT"

%post
ldconfig

%postun
ldconfig
