File vgmstream.spec of Package vgmstream

# manually increase this whenever abi may have changed, since there is no upstream versioning
%define soversion 1

Name: vgmstream
Version: 0
Release: 0
License: ISC
Summary: Library for decoding various streamed audio formats used in video games
Url: http://sourceforge.net/projects/vgmstream
Group: Development/Libraries/C and C++
Source: %{name}-%{version}.tar.gz
BuildRequires: libvorbis-devel libogg-devel automake autoconf libtool zlib-devel
BuildRequires: pkg-config
BuildRequires: pkgconfig(libavcodec)
BuildRequires: pkgconfig(libavformat)
BuildRequires: pkgconfig(libavutil)
BuildRequires: pkgconfig(libswresample)
BuildRequires: mpg123-devel

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Recommends: libvgmstream


%description
This is vgmstream, a library for playing streamed audio from video games.
It is very much under development. There are two end-user bits: a command
line decoder called "%{name}", and a Winamp plugin called "in_vgmstream".
There is also a plugin for an outdated version of audacious available.
This package only provides the command line decoder.

%package -n libvgmstream%{soversion}
Summary:        Shared library for %{name}
Group:          Development/Libraries/C and C++

%description -n libvgmstream%{soversion}
Shared library for %{name}

%package        devel
Summary:        Development files for %{name}
Group:          Development/Libraries/C and C++
Requires:       libvgmstream%{soversion} = %{version}
Requires:       libvorbis-devel
Requires:       libogg-devel
Requires:       zlib-devel
Requires:       mpg123-devel

%description    devel
Development files for %{name}

%package        devel-static
Summary:        Static library for %{name}
Group:          Development/Libraries/C and C++
Requires:       libvgmstream%{soversion} = %{version}
Requires:       %{name}-devel

%description    devel-static
Development files for %{name}

%prep
%setup -q
mv readme.txt README
sed -i "s/default\ is\ dump.wav/default\ is\ infile.wav/" test/test.c
sed -i "s/outfilename\ \=\ \"dump.wav\"\;/outfilename\ \=\ strcat\(argv\[optind\]\,\".wav\"\);/" test/test.c

# vgmstream uses bundled copies of includes of 3rd party libs of some arbitrary version
# to avoid api / abi breakes, get rid of them, as we have our own versioned includes
cd ext_includes
rm -rf ogg
rm -rf vorbis
rm -rf libavutil
rm -rf libavcodec
rm -rf libavformat
rm -f g719.h g7221.h maiatrac3plus.h mpg123.h pstdint.h

%build
cd src
export  CFLAGS="-fPIC -I../ext_includes "`pkg-config --cflags libavformat libavcodec libavutil`" -DUSE_ALLOCA -DVGM_USE_FFMPEG %{optflags}"
export LDFLAGS="-lvgmstream "`pkg-config --libs libavformat libavcodec libavutil`" "`pkg-config --libs vorbis vorbisfile`" "`pkg-config --libs libmpg123`" -lpthread -lm"
make %{?_smp_mflags} libvgmstream.a

export SOVERSION="%{soversion}"
make %{?_smp_mflags} libvgmstream.so

cd ../test
gcc -fPIC -DUSE_ALLOCA -DVGM_USE_FFMPEG -DVERSION=\"%{version}\" test.c -I../ext_includes -L../src `echo $CFLAGS` `echo $LDFLAGS` -o %{name}

%install
cd test
install -m 0755 -D %{name} %{buildroot}/%{_bindir}/%{name}

cd ..
install -Dm 0644 src/libvgmstream.a %{buildroot}%{_libdir}/libvgmstream.a
install -m 0644 src/libvgmstream.so.%{soversion} %{buildroot}%{_libdir}/libvgmstream.so.%{soversion}
ln -s %{_libdir}/libvgmstream.so.%{soversion} %{buildroot}%{_libdir}/libvgmstream.so

mkdir -p %{buildroot}%{_includedir}/vgmstream/
install -m 0644 src/streamfile.h src/streamtypes.h src/vgmstream.h src/util.h src/formats.h %{buildroot}%{_includedir}/vgmstream/
install -m 0644 ext_includes/clHCA.h %{buildroot}%{_includedir}/vgmstream/

install -d ext_includes/coding/ %{buildroot}%{_includedir}/vgmstream/coding/
install -m 0644 src/coding/*.h %{buildroot}%{_includedir}/vgmstream/coding/


%post  -n libvgmstream%{soversion} -p /sbin/ldconfig

%postun  -n libvgmstream%{soversion} -p /sbin/ldconfig


%files
%defattr(-,root,root)
%doc README COPYING
%{_bindir}/%{name}

%files devel-static
%defattr(-,root,root)
%{_libdir}/libvgmstream.a

%files devel
%defattr(-,root,root)
%{_includedir}/vgmstream/
%{_libdir}/libvgmstream.so

%files -n libvgmstream%{soversion}
%defattr(-,root,root)
%{_libdir}/libvgmstream.so.*
openSUSE Build Service is sponsored by