#
# spec file for package @PROJECTNAME@
#
# Copyright (c) 2014 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/
#


Name:           @PROJECTNAME@
Version:        @VERSION@
Release:        0
Source:         @PROJECTNAME@-%{version}.tar.bz2

BuildRequires:  boost-devel
BuildRequires:  cmake >= 2.8
BuildRequires:  gcc-c++
BuildRequires:  pkg-config

Url:            @URL@
Summary:        @SUMMARY@
License:        LGPL-2.1 or LGPL-3.0
Group:          System/Libraries

%description
@DESCRIPTION@

%package -n @PROJECTNAME@@SONAME_MAJOR@

Provides:       yast2-libyui = 2.42.0
Obsoletes:      yast2-libyui < 2.42.0
Requires:       yui_backend = 6

Url:            @URL@
Summary:        @PROJECTNAME_UC@ - @SUMMARY@
Group:          System/Libraries

%description -n @PROJECTNAME@@SONAME_MAJOR@
@DESCRIPTION@


%package devel

Requires:       boost-devel
Requires:       glibc-devel
Requires:       libstdc++-devel
Requires:       @PROJECTNAME@@SONAME_MAJOR@ = %{version}

Url:            @URL@
Summary:        @PROJECTNAME_UC@ header files
Group:          Development/Languages/C and C++

%description devel
@DESCRIPTION@

This can be used independently of YaST for generic (C++) applications.
This package has very few dependencies.


%prep
%setup -q -n @PROJECTNAME@-%{version}

%build

./bootstrap.sh

export CFLAGS="$RPM_OPT_FLAGS -DNDEBUG $(getconf LFS_CFLAGS)"
export CXXFLAGS="$RPM_OPT_FLAGS -DNDEBUG $(getconf LFS_CFLAGS)"

mkdir build
cd build

%if %{?_with_debug:1}%{!?_with_debug:0}
cmake .. \
        -DPREFIX=%{_prefix} \
        -DDOC_DIR=%{_docdir} \
        -DLIB_DIR=%{_lib} \
        -DCMAKE_BUILD_TYPE=RELWITHDEBINFO
%else
cmake .. \
        -DPREFIX=%{_prefix} \
        -DDOC_DIR=%{_docdir} \
        -DLIB_DIR=%{_lib} \
        -DCMAKE_BUILD_TYPE=RELEASE
%endif

make %{?jobs:-j%jobs}

%install
cd build
make install DESTDIR="$RPM_BUILD_ROOT"
install -m0755 -d $RPM_BUILD_ROOT/%{_docdir}/@PROJECTNAME@@SONAME_MAJOR@/
install -m0755 -d $RPM_BUILD_ROOT/%{_libdir}/@BASELIB@
install -m0644 ../COPYING* $RPM_BUILD_ROOT/%{_docdir}/@PROJECTNAME@@SONAME_MAJOR@/

%clean
rm -rf "$RPM_BUILD_ROOT"

%post -n @PROJECTNAME@@SONAME_MAJOR@ -p /sbin/ldconfig

%postun -n @PROJECTNAME@@SONAME_MAJOR@ -p /sbin/ldconfig

%files -n @PROJECTNAME@@SONAME_MAJOR@
%defattr(-,root,root)
%dir %{_libdir}/@BASELIB@
%dir %{_datadir}/@PROJECTNAME@
%{_libdir}/lib*.so.*
%doc %dir %{_docdir}/@PROJECTNAME@@SONAME_MAJOR@
%doc %{_docdir}/@PROJECTNAME@@SONAME_MAJOR@/COPYING*

%files devel
%defattr(-,root,root)
%dir %{_docdir}/@PROJECTNAME@@SONAME_MAJOR@
%{_libdir}/lib*.so
%{_prefix}/include/yui
%{_libdir}/pkgconfig/@PROJECTNAME@.pc
%{_libdir}/cmake/@PROJECTNAME@
%{_datadir}/@PROJECTNAME@/buildtools
%doc %{_docdir}/@PROJECTNAME@@SONAME_MAJOR@/examples

%changelog
