File avogadro.spec of Package avogadro

#
# spec file for package avogadro
#
# 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/
#


Name:           avogadro
Version:        1.1.0
Release:        0
Summary:        A Molecular design tool
License:        GPL-2.0
Group:          Productivity/Editors/Other
Url:            http://avogadro.sourceforge.net/wiki/Main_Page
Source0:        http://mesh.dl.sourceforge.net/sourceforge/avogadro/%{name}-%{version}.tar.bz2
Source1:        %{name}.png
Source2:        baselibs.conf
# PATCH-FIX-UPSTREAM return at least some value in a bool function
Patch0:         avogadro-1.1.0-no-return-in-nonvoid-function.patch
# PATCH-FIX-UPSTREAM avoid crash when loading aux - see https://github.com/cryos/avogadro/commit/a4050e8a3f70ddc2bcc75a5b00d26416964b7275.patch
Patch1:         MopacAuxReaderFix.patch
# PATCH-FIX-UPSTREAM always use -fPIC for shlib objects
Patch2:         shlib-pic-flag.patch
BuildRequires:  boost-devel
BuildRequires:  cmake
BuildRequires:  docbook-utils
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  glew-devel
%if 0%{?suse_version} > 1220
BuildRequires:  glu-devel
%endif
BuildRequires:  libeigen2-devel
BuildRequires:  libopenbabel-devel >= 2.3.1
BuildRequires:  libqt4-devel >= 4.5.1
BuildRequires:  python-devel
BuildRequires:  python-numpy-devel
BuildRequires:  python-qt4-devel
BuildRequires:  python-sip-devel
BuildRequires:  xorg-x11-devel
BuildRequires:  xorg-x11-libX11-devel
BuildRequires:  xorg-x11-libXext-devel
BuildRequires:  pkgconfig(glu)
Requires:       libavogadro1 = %{version}
Requires:       openbabel
Requires:       python-numpy
Requires:       python-sip
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{py_requires}

%description
Avogadro is an advanced molecular editor designed
for cross-platform use in computational chemistry,
molecular modeling, bioinformatics, materials science,
and related areas. It offers flexible rendering and
a powerful plugin architecture.

%package -n libavogadro1
Summary:        A Molecular design tool
Group:          Development/Libraries/C and C++
Provides:       libavogadro = %{version}-%{release}

%description -n libavogadro1
This package contains the shared libraries for Avogadro.

Avogadro is an advanced molecular editor designed
for cross-platform use in computational chemistry,
molecular modeling, bioinformatics, materials science,
and related areas. It offers flexible rendering and
a powerful plugin architecture.

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

%description devel
This package contains files to develop applications using
Avogadros libraries.

%package -n python-avogadro
Summary:        A python wrapper to avogadro
Group:          Development/Languages/Python
Requires:       python-numpy
Requires:       python-sip

%description -n python-avogadro
This package contains the python wrapper to Avogadro.

Avogadro is an advanced molecular editor designed
for cross-platform use in computational chemistry,
molecular modeling, bioinformatics, materials science,
and related areas. It offers flexible rendering and
a powerful plugin architecture.

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1

%build
mkdir -p build
cd build
export SUSE_ASNEEDED=0
cmake 	-DCMAKE_INSTALL_PREFIX=%{_prefix} \
	-DENABLE_GLSL=ON \
%if "%{_lib}" == "lib64"
        -DLIB_SUFFIX=64 \
%endif
        -DENABLE_RPATH=OFF \
	-DENABLE_UPDATE_CHECKER=OFF \
	-DENABLE_ZMATRIX_TOOL=ON \
	-DENABLE_PYTHON=ON \
	-DCMAKE_VERBOSE_MAKEFILE=true \
	-DCMAKE_C_FLAGS="%{optflags}" \
	-DCMAKE_CXX_FLAGS="%{optflags}" \
	-DCMAKE_BUILD_TYPE=RelWithDebInfo \
	..

make %{?_smp_mflags}

%install
cd build
%makeinstall

mkdir -p %{buildroot}/%{_datadir}/qt4/mkspecs/
mv %{buildroot}%{_prefix}/features %{buildroot}/%{_datadir}/qt4/mkspecs/
# Create the system menu entry
mkdir -p %{buildroot}%{_datadir}/applications
cat > %{buildroot}%{_datadir}/applications/%{name}.desktop << EOF
[Desktop Entry]
Name=Avogadro
Comment=%{summary}
GenericName=Avogadro
Exec=%{name}
Icon=%{name}
Terminal=0
Categories=KDE;Education;Chemistry;
Type=Application
X-SuSE-translate=false
EOF

# icon
install -D -m644 %{SOURCE1} %{buildroot}%{_datadir}/pixmaps/%{name}.png
%if "%{_lib}" == "lib64"
	mkdir -p %{buildroot}%{python_sitearch}
	if [ ! -e %{buildroot}%{python_sitearch}/Avogadro.so ]; then
	    find %{buildroot} -name 'Avogadro.so' | xargs mv -t %{buildroot}%{python_sitearch}/
        fi
	find %{buildroot}%{_lib} -name "python*" |xargs rm -rf
%endif
%fdupes %{buildroot}%{_datadir}/libavogadro/shaders/
%fdupes %{buildroot}%{_datadir}/%{name}/

%post -n libavogadro1 -p /sbin/ldconfig

%postun -n libavogadro1 -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING
%{_mandir}/man1/avogadro.1.gz
%{_mandir}/man1/avopkg.1.gz
%{_bindir}/avogadro
%{_bindir}/avopkg
%dir %{_datadir}/libavogadro
%{_datadir}/libavogadro/shaders/
%{_datadir}/%{name}/
%{_datadir}/pixmaps/*.png
%{_datadir}/applications/%{name}.desktop
#plugins not libraries
%dir %{_libdir}/avogadro
%dir %{_libdir}/avogadro/1_1
%dir %{_libdir}/avogadro/1_1/colors
%dir %{_libdir}/avogadro/1_1/engines
%dir %{_libdir}/avogadro/1_1/extensions
%dir %{_libdir}/avogadro/1_1/tools
%{_libdir}/avogadro/1_1/*/*.so
%dir %{_datadir}/libavogadro/engineScripts
%dir %{_datadir}/libavogadro/extensionScripts
%{_datadir}/libavogadro/engineScripts/wireframe.py
%{_datadir}/libavogadro/extensionScripts/example.py

%files devel
%defattr(-,root,root,-)
%dir %{_includedir}/avogadro
%{_includedir}/avogadro/*.h
%dir %{_libdir}/avogadro/1_1/cmake
%{_libdir}/libavogadro.so
%{_libdir}/libavogadro_OpenQube.so

%{_libdir}/avogadro/1_1/cmake/*
%{_libdir}/avogadro/1_1/*.cmake
%{_libdir}/avogadro/*.cmake
%{_libdir}/pkgconfig/*.pc
%{_datadir}/qt4/mkspecs/features/avogadro.prf

%files -n libavogadro1
%defattr(-,root,root,-)
%{_libdir}/*.so.*

%files -n python-avogadro
%defattr(-,root,root,-)
# installed with python support
%{python_sitearch}/Avogadro.so

%changelog
openSUSE Build Service is sponsored by