File cgal.spec of Package cgal

#
# spec file for package cgal
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2014 Ioda-Net Sàrl, Charmoille, Switzerland.
#
# 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/
#

#
#@TODO : clarify and split licence correctly, GPL & LGPL 3+ version
#@TODO : split package in coherent parts
#@TODO : rename parts (inspirated by sfcgal packaging)
#@TODO : ask for rename and take into account the obsolete existant thing. like libcgal deps

%define _soname 10
%define _soversion 10.0.3
%define _sourcename CGAL
%define _libname libCGAL%{_soname}

Name:           cgal
Version:        4.4
Release:        0
License:        GPL-3.0+ and LGPL-3.0+
Summary:        Computational Geometry Algorithms Library
Url:            http://www.cgal.org/
Group:          Productivity/Graphics/CAD
# Keep this stable link latestfile and 2743=CGAL no form fill-up needed
Source0:        https://gforge.inria.fr/frs/download.php/latestfile/2743/%{_sourcename}-%{version}.tar.xz
Source1:        https://gforge.inria.fr/frs/download.php/latestfile/2743/%{_sourcename}-%{version}-doc_html.tar.xz
Source2:	cgal-rpmlintrc
BuildRequires:  blas
BuildRequires:  boost-devel >= 1.39
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gmp-devel
BuildRequires:  lapack
BuildRequires:  libqt4-devel
BuildRequires:  mpfr-devel
BuildRequires:  xz
BuildRequires:  zlib-devel
Requires:       libcgal-devel = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
CGAL is a collaborative effort of several sites in Europe and
Israel. The goal is to make the most important of the solutions and
methods developed in computational geometry available to users in
industry and academia in a C++ library. The goal is to provide easy
access to useful, reliable geometric algorithms.

CGAL is used in various areas needing geometric computation, such as: 
computer graphics, scientific visualization, computer aided design 
and modeling, geographic information systems, molecular biology, 
medical imaging, robotics and motion planning, mesh generation, 
numerical methods.

%package -n %{_libname}
License:        GPL-3.0+ and LGPL-3.0+
Summary:        Computational Geometry Algorithms Library
Group:          Productivity/Graphics/CAD

%description -n %{_libname}
Libraries for CGAL applications.
CGAL is a collaborative effort of several sites in Europe and
Israel. The goal is to make the most important of the solutions and
methods developed in computational geometry available to users in
industry and academia in a C++ library. The goal is to provide easy
access to useful, reliable geometric algorithms.

%package devel
License:        GPL-3.0+ and LGPL-3.0+ and BSL-1.0
Summary:        Development files and tools for CGAL applications
Group:          Development/Libraries
Requires:       %{_libname} = %{version}
Requires:       blas
Requires:       boost-devel
Requires:       cmake
Requires:       gmp-devel
Requires:       lapack
Requires:       mpfr-devel
Requires:       qt-devel
Requires:       zlib-devel
#For compatibility with package looking for our old name
Provides:       libcgal-devel = %{version}

%description devel
This package provides the headers files and tools you may need to
develop applications using CGAL.

%package demo-examples-devel
License:        GPL-3.0+ and LGPL-3.0+ and BSL-1.0 and MIT
Summary:        Example & demo files for CGAL library usage
Group:          Development/Libraries
Requires:       %{name}-devel = %{version}
%if 0%{?suse_version} >= 1210
BuildArch:      noarch
%endif

%description demo-examples-devel
This package provides the sources of examples and demos of
CGAL algorithms. You can study them, compile and test CGAL
library.

%package doc
Summary:        Documentation CGAL algorithms
Group:          Documentation/HTML
%if 0%{?suse_version} >= 1210
BuildArch:      noarch
%endif

%description doc
This package provides the documentation for CGAL algorithms.

%prep
%setup -q -n CGAL-%{version}
tar -xJf %{S:1} 

%build
%if 0%{?suse_version} >= 1310
# Make things more secure, but only on new version
 export LDFLAGS="-Wl,-z,relro,-z,now -pie"
 export CFLAGS="%{optflags} -fPIE -pie"
 export CXXFLAGS="%{optflags} -fPIE -pie"
 %cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
   -DCGAL_INSTALL_LIB_DIR=%{_lib} \
   -DCMAKE_BUILD_TYPE=Release \
   ..
 make VERBOSE=1 %{?_smp_mflags}
%else
 mkdir build
 pushd build
 cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
   -DCGAL_INSTALL_LIB_DIR=%{_lib} \
   -DCMAKE_BUILD_TYPE=Release \
   ..
 make VERBOSE=1 %{?_smp_mflags}
 popd
%endif

# Unfortunately take +6600sec locally.
# So we just deliver the source code in cgal package.
#  -DWITH_examples=true \
#  -DWITH_demos=true \

%install
%fdupes doc_html
pushd build
make VERBOSE=1 DESTDIR=%{buildroot} %{?_smp_mflags} install 
# We don't build them so source install is made by hand
# make VERBOSE=1 DESTDIR=%%{buildroot} %%{?_smp_mflags} demos
# make VERBOSE=1 DESTDIR=%%{buildroot} %%{?_smp_mflags} examples
popd

install -d %{buildroot}/%{_datadir}/CGAL/examples
install -d %{buildroot}/%{_datadir}/CGAL/demo
cp -a examples/* %{buildroot}/%{_datadir}/CGAL/examples
cp -a demo/* %{buildroot}/%{_datadir}/CGAL/demo

# Clean doc wrongly placed by make install
rm -rfv %{buildroot}/%{_datadir}/doc/CGAL-%{version}

%if 0%{?suse_version}
%fdupes %{buildroot}/%{_datadir}
%endif


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

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

%files -n %{_libname}
%defattr(-,root,root,-)
%doc AUTHORS CHANGES LICENSE*
%{_libdir}/libCGAL.so.%{_soversion}
%{_libdir}/libCGAL.so.%{_soname}
%{_libdir}/libCGAL_Core.so.%{_soversion}
%{_libdir}/libCGAL_Core.so.%{_soname}
%{_libdir}/libCGAL_ImageIO.so.%{_soversion}
%{_libdir}/libCGAL_ImageIO.so.%{_soname}
%{_libdir}/libCGAL_Qt4.so.%{_soversion}
%{_libdir}/libCGAL_Qt4.so.%{_soname}

%files devel
%defattr(-,root,root,-)
%doc AUTHORS CHANGES LICENSE*
%{_includedir}/CGAL
%{_libdir}/libCGAL.so
%{_libdir}/libCGAL_Core.so
%{_libdir}/libCGAL_ImageIO.so
%{_libdir}/libCGAL_Qt4.so
%{_libdir}/CGAL
%{_bindir}/*
%exclude %{_bindir}/cgal_make_macosx_app
%{_mandir}/man1/cgal_create_cmake_script.1*

%files demo-examples-devel
%defattr(-,root,root,-)
%doc AUTHORS CHANGES LICENSE*
%{_datadir}/CGAL

%files doc
%defattr(-,root,root,-)
%doc AUTHORS CHANGES LICENSE*
%doc doc_html

%changelog
openSUSE Build Service is sponsored by