File squish.spec of Package squish

#
# spec file for package squish
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define		somajor 1
%define 	sominor 0
Name:           squish
Version:        1.10
Release:        0
Summary:        Texture compression for NVIDIA cards
License:        MIT
Group:          Development/Libraries/C and C++
Url:            http://code.google.com/p/libsquish/
# PATCH-FIX-UPSTREAM squish-1.10.diff
Patch0:         squish-1.10.diff
# PATCH-FIX-UPSTREAM squish-1.10.gcc43.diff
Patch1:         squish-1.10.gcc43.diff
Source0:        http://libsquish.googlecode.com/files/squish-%{version}.tar.gz
BuildRequires:  gcc-c++
BuildRequires:  make
BuildRequires:  pkg-config
BuildRequires:  sed
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
    This extension provides additional texture compression functionality
    specific to S3's S3TC format (called DXTC in Microsoft's DirectX API),
    subject to all the requirements and limitations described by the extension
    GL_ARB_texture_compression.

    This extension supports DXT1, DXT3, and DXT5 texture compression formats.
    For the DXT1 image format, this specification supports an RGB-only mode
    and a special RGBA mode with single-bit "transparent" alpha.

%package -n lib%{name}%{somajor}
Summary:        Texture compression for NVIDIA cards
Group:          Development/Libraries/C and C++

%description -n lib%{name}%{somajor}
This extension provides additional texture compression functionality
specific to S3's S3TC format (called DXTC in Microsoft's DirectX API),
subject to all the requirements and limitations described by the extension
GL_ARB_texture_compression.

This extension supports DXT1, DXT3, and DXT5 texture compression formats.
For the DXT1 image format, this specification supports an RGB-only mode
and a special RGBA mode with single-bit "transparent" alpha.

%package devel
Summary:        Development files for %{name}
Group:          Development/Libraries/C and C++
Requires:       lib%{name}%{somajor} = %{version}

%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%prep
%setup -q -n squish-%{version}
%patch0 -p 0
%patch1 -p 1
%ifarch x86_64
sed -i.bak -e 's@/lib@/lib64@' Makefile
%endif

cat <<EOF >>Makefile
shared: lib%{name}.so.%{somajor}.%{sominor}

lib%{name}.so.%{somajor}.%{sominor}: \$(OBJ)
	gcc -shared -Wl,-soname,liss.so.%{somajor} \\
		-o lib%{name}.so.%{somajor}.%{sominor} \$(OBJ)
EOF

%build
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects

%ifarch x86_64
make %{?_smp_mflags} CPPFLAGS="%{optflags} -fPIC" shared
rm -f *.o
make %{?_smp_mflags} CPPFLAGS="%{optflags} -g"
%else
make %{?_smp_mflags} CPPFLAGS="%{optflags} -mtune=pentium4 -fPIC" shared
rm -f *.o
make %{?_smp_mflags} CPPFLAGS="%{optflags} -mtune=pentium4 -g"
%endif

%install
install -d %{buildroot}%{_includedir}
install -d %{buildroot}%{_libdir}
make install INSTALL_DIR=%{buildroot}/usr
for l in lib%{name}; do
    strip $l.so.%{somajor}.%{sominor}
    install $l.so.%{somajor}.%{sominor} \
    	    %{buildroot}/%{_libdir}/$l.so.%{somajor}.%{sominor}
    (cd %{buildroot}/%{_libdir} && \
     ln -s $l.so.%{somajor}.%{sominor} $l.so.%{somajor} && \
     ln -s $l.so.%{somajor} $l.so)
done

install -d %{buildroot}/%{_libdir}/pkgconfig
cat >%{buildroot}/%{_libdir}/pkgconfig/squish.pc <<EOF
# variables
prefix=%{_prefix}
exec_prefix=%{_prefix}
includedir=%{_includedir}
libdir=%{_libdir}

Name: squish
Description: Texture compression for NVIDIA cards
Version: %{version}
Libs: -L\${libdir} -lsquish
Cflags: -I\${includedir}
EOF

%post -n lib%{name}%{somajor} -p /sbin/ldconfig

%postun -n lib%{name}%{somajor} -p /sbin/ldconfig

%files -n lib%{name}%{somajor}
%defattr(-,root,root,-)
%doc README
%{_libdir}/*.so.*

%files devel
%defattr(644,root,root,-)
%doc
%{_includedir}/*
%{_libdir}/*.a
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc

%changelog
openSUSE Build Service is sponsored by