File openCOLLADA.spec of Package openCOLLADA

#
# spec file for package openCOLLADA
#
# Copyright (c) 2015 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/
#


%global sover 0.2
%global commit 3335ac164e68b2512a40914b14c74db260e6ff7d
%global shortcommit 3335ac1
%global upname OpenCOLLADA
%global libname lib%{upname}0
Name:           openCOLLADA
Version:        1_%{shortcommit}
Release:        0
Summary:        Collada 3D import and export libraries
License:        MIT
Group:          System/Libraries
Url:            https://collada.org/mediawiki/index.php/OpenCOLLADA
## https://github.com/KhronosGroup/OpenCOLLADA/archive/%%{commit}/
Source0:        %{upname}-%{shortcommit}.tar.bz2
# PATCH-FIX-UPSTREAM use proper paths in cmake for install
Patch0:         opencollada-cmake.patch
# PATCH-FIX-UPSTREAM add missing includes
Patch1:         opencollada-includes.patch
# PATCH-FIX-UPSTREAM link to required libraries
Patch2:         opencollada-no-undefined.patch
BuildRequires:  cmake
BuildRequires:  dos2unix
BuildRequires:  fftw-devel
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig(libpcre)
BuildRequires:  pkgconfig(libpcrecpp)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(zlib)

%description
COLLADA is a royalty-free XML schema that enables digital asset
exchange within the interactive 3D industry.
OpenCOLLADA is a Google summer of code opensource project providing
libraries for 3D file interchange between applications like blender.
COLLADABaseUtils          Utils used by many of the other projects
COLLADAFramework          Datamodel used to load COLLADA files
COLLADAStreamWriter       Sources (Library to write COLLADA files)
COLLADASaxFrameworkLoader Library that loads COLLADA files in a sax
                          like manner into the framework data model
COLLADAValidator          XML validator for COLLADA files, based on
                          the COLLADASaxFrameworkLoader
GeneratedSaxParser        Library used to load xml files in the way
                          used by COLLADASaxFrameworkLoader

%package -n %{libname}
Summary:        Collada 3D import and export libraries
Group:          System/Libraries

%description -n %{libname}
COLLADA is a royalty-free XML schema that enables digital asset
exchange within the interactive 3D industry.
OpenCOLLADA is a Google summer of code opensource project providing
libraries for 3D file interchange between applications like blender.
COLLADABaseUtils          Utils used by many of the other projects
COLLADAFramework          Datamodel used to load COLLADA files
COLLADAStreamWriter       Sources (Library to write COLLADA files)
COLLADASaxFrameworkLoader Library that loads COLLADA files in a sax
                          like manner into the framework data model
COLLADAValidator          XML validator for COLLADA files, based on
                          the COLLADASaxFrameworkLoader
GeneratedSaxParser        Library used to load xml files in the way
                          used by COLLADASaxFrameworkLoader

%package        doc
Summary:        Developer documentation for %{name}
Group:          Documentation
Requires:       %{libname} = %{version}
BuildArch:      noarch

%description doc
This package provides documentation for %{name}.

%package        devel
Summary:        Include files for openCOLLADA development
Group:          Development/Libraries
Requires:       %{libname} = %{version}

%description devel
This package provides the include files necessary to build and
develop with the %{name} export and import libraries.

%package        utils
Summary:        XML validator for COLLADA files
Group:          Development/Tools
Requires:       %{libname} = %{version}

%description utils
XML validator for COLLADA files, based on the COLLADASaxFrameworkLoader.

%prep
%setup -q -n %{upname}-%{commit}
%patch0 -p1 -b .cmake
%patch1 -p0 -b .includes
%patch2 -p1 -b .undefined

# Remove unused bundled libraries
rm -rf Externals/{Cg,expat,lib3ds,LibXML,MayaDataModel,pcre,zlib,zziplib}

# Add some docs, need to fix eol encoding with dos2unix in some files.
find ./ -name .project -delete
cp -pf COLLADAStreamWriter/README README.COLLADAStreamWriter
cp -pf COLLADAStreamWriter/LICENSE ./

iconv -f ISO_8859-1 -t utf-8 COLLADAStreamWriter/AUTHORS > \
  COLLADAStreamWriter/AUTHORS.tmp
touch -r COLLADAStreamWriter/AUTHORS COLLADAStreamWriter/AUTHORS.tmp
mv COLLADAStreamWriter/AUTHORS.tmp COLLADAStreamWriter/AUTHORS

dos2unix -f -k README.COLLADAStreamWriter
dos2unix -f -k LICENSE
dos2unix -f -k README
find htdocs/ -name *.php -exec dos2unix -f {} \;
find htdocs/ -name *.css -exec dos2unix -f {} \;

%build
%cmake \
       -DUSE_STATIC=OFF \
       -DUSE_SHARED=ON \
       -Dsoversion=%{sover}

make %{?_smp_mflags}

%install
%cmake_install

# Manually install binary
mkdir -p %{buildroot}%{_bindir}/
install -p -m 0755 build/bin/* %{buildroot}%{_bindir}/

# Install MathMLSolver headers
mkdir -p %{buildroot}%{_includedir}/MathMLSolver
cp -a Externals/MathMLSolver/include/* %{buildroot}%{_includedir}/MathMLSolver/

%post -n %{libname} -p /sbin/ldconfig

%postun -n %{libname} -p /sbin/ldconfig

%files -n %{libname}
%defattr(-,root,root)
%doc README LICENSE README.COLLADAStreamWriter COLLADAStreamWriter/AUTHORS
%{_libdir}/lib*.so.%{sover}

%files doc
%defattr(-,root,root)
%doc htdocs/

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

%files utils
%defattr(-,root,root)
%{_bindir}/*

%changelog