# Needed stuff for Octave.
%global octpkg %{name}
%if 0%{?fedora} || 0%{?rhel} >= 7
# We don't want provides for libs in private dirs.
%global __provides_exclude_from ^%{python2_sitearch}/.*\\.so
%else
# These are not defined on <= el6.
#
# Octave binary API provided
%global octave_api %(octave-config -p API_VERSION || echo 0)}
# Octave Package Directories
%global octshareprefix %{_datadir}/octave
%global octprefix %{octshareprefix}/packages
%global octarchprefix %{_libdir}/octave/packages
%global octpkgdir %{octshareprefix}/%{octpkg}-%{version}
%global octpkglibdir %{octarchprefix}/%{octpkg}-%{version}
%endif
# Needed stuff for Guile.
%{!?el5:%global guile_pkgconf %(pkg-config --list-all | grep guile | sed -e 's! .*$!!g')}
%{!?el5:%global guile_sitedir %(pkg-config --variable=sitedir %{guile_pkgconf})}
# This is a post-release with lot's of improvements.
%global commit 35e63778654f55baafbdf554de58ac3c20220c33
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global commitdate 20130903
%global gitrelease .git%{commitdate}.%{shortcommit}
%global lc_name nlopt
Name: NLopt
Version: 2.4
Release: 2%{gitrelease}%{?dist}
Summary: Open-Source library for nonlinear optimization
%{?el5:Group: System Environment/Libraries}
# The detailed license-breakdown of the sources is:
#
# BSD (2 clause)
# --------------
# util/mt19937ar.c
#
#
# BSD (3 clause)
# --------------
# slsqp/*
#
#
# LGPL (v2 or later)
# ------------------
# luksan/*
#
# MIT/X11 (BSD like)
# ------------------
# api/* auglag/* bobyqa/* cdirect/* cobyla/*
# cquad/* crs/* direct/* esch/* isres/*
# mlsl/* mma/* neldermead/* newuoa/* octave/*
# stogo/* tensor/* test/* util/* (ex. util/mt19937ar.c)
#
#
# Public Domain
# -------------
# praxis/* subplex/*
#
License: BSD and LGPLv2+ and MIT and Public Domain
URL: http://ab-initio.mit.edu/nlopt
Source0: https://github.com/stevengj/%{lc_name}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz
%{?el5:BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)}
BuildRequires: libtool
BuildRequires: ncurses-devel
BuildRequires: octave-devel
%if 0%{?fedora} || 0%{?rhel} >= 6
BuildRequires: guile-devel
BuildRequires: pkgconfig
BuildRequires: swig
%endif
%if 0%{?fedora} || 0%{?rhel} >= 7
BuildRequires: numpy
BuildRequires: python2-devel
BuildRequires: python3-devel
BuildRequires: python3-numpy
%endif
# The "gnulib" is a copylib and has a wildcard-permission from FPC.
# See: https://fedorahosted.org/fpc/ticket/174
Provides: bundled(gnulib)
Provides: %{lc_name} = %{version}-%{release}
Provides: %{lc_name}%{?_isa} = %{version}-%{release}
%description
NLopt is a library for nonlinear local and global optimization, for
functions with and without gradient information. It is designed as
as simple, unified interface and packaging of several free/open-source
nonlinear optimization libraries.
It features bindings for GNU Guile, Octave and Python. This build has
been made with C++-support enabled.
%package devel
Summary: Development files for %{name}
%{?el5:Group: Development/Libraries}
Requires: %{name}%{?_isa} = %{version}-%{release}
Provides: %{lc_name}-devel = %{version}-%{release}
Provides: %{lc_name}-devel%{?_isa} = %{version}-%{release}
%description devel
This package contains development files for %{name}.
%package doc
Summary: Documentation files for %{name}
%{?el5:Group: Documentation}
%{?!el5:BuildArch: noarch}
Provides: %{lc_name}-doc = %{version}-%{release}
%description doc
This package contains documentation files for %{name}.
%if 0%{?fedora} || 0%{?rhel} >= 6
%package -n guile-%{name}
Summary: Guile bindings for %{name}
Requires: guile%{?_isa}
Requires: %{name}%{?_isa} = %{version}-%{release}
Provides: guile-%{lc_name} = %{version}-%{release}
Provides: guile-%{lc_name}%{?_isa} = %{version}-%{release}
%description -n guile-%{name}
This package contains Guile bindings for %{name}.
%package -n guile-%{name}-devel
Summary: Development files of Guile bindings for %{name}
Requires: guile-%{name}%{?_isa} = %{version}-%{release}
Requires: %{name}-devel%{?_isa} = %{version}-%{release}
Provides: guile-%{lc_name}-devel = %{version}-%{release}
Provides: guile-%{lc_name}-devel%{?_isa} = %{version}-%{release}
%description -n guile-%{name}-devel
This package contains Development files
of Guile bindings for %{name}.
%endif
%package -n octave-%{name}
Summary: Octave bindings for %{name}
%{?el5:Group: System Environment/Libraries}
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: octave(api) = %{octave_api}
Requires(post): octave
Requires(postun): octave
Provides: octave-%{lc_name} = %{version}-%{release}
Provides: octave-%{lc_name}%{?_isa} = %{version}-%{release}
%description -n octave-%{name}
This package contains the Octave bindings for %{name}.
%if 0%{?fedora} || 0%{?rhel} >= 7
%package -n python-%{name}
Summary: Python bindings for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
Provides: python-%{lc_name} = %{version}-%{release}
Provides: python-%{lc_name}%{?_isa} = %{version}-%{release}
%description -n python-%{name}
This package contains Python bindings for %{name}.
%package -n python3-%{name}
Summary: Python3 bindings for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
Provides: python3-%{lc_name} = %{version}-%{release}
Provides: python3-%{lc_name}%{?_isa} = %{version}-%{release}
%description -n python3-%{name}
This package contains Python3 bindings for %{name}.
%endif
%prep
%setup -qn %{lc_name}-%{commit}
# Move all %%doc to topdir and append their belonging.
mv -f README.md README
_topdir="`pwd`"
for _dir in `find . -type d | \
sed -e "/\.libs/d" -e "s/\.\///g" -e "/\./d" | sort -u`
do
pushd ${_dir}
for _file in 'AUTHOR*' 'COPY*' 'README*' '*[Pp][Dd][Ff]'
do
for _doc in `find . -name "${_file}"`
do
mv -f ${_doc} ${_topdir}/${_doc}.`echo ${_dir} | sed -e "s/\//_/g"`
done
done
popd
done
# Get rid of obsoleted autotools-macros for el6+.
%{?!el5:sed -i -e 's!^AC_PROG_LIBTOOL!LT_INIT!g' configure.ac}
# On el5 we need to exclude anything SWIG-related.
%{?el5:sed -i -e 's!swig!!g' Makefile.am}
# Bootstrapping once before we create a copy in %%{py3dir}.
touch swig/nlopt.scm.in
autoreconf -fiv
%if 0%{?fedora} || 0%{?rhel} >= 7
# Creating a copy for building the Python3-plugin.
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif
%build
%configure \
--enable-shared \
--enable-maintainer-mode \
--with-cxx \
%if 0%{?fedora} || 0%{?rhel} >= 7
PYTHON=%{__python2} \
%endif
OCT_INSTALL_DIR=%{octpkglibdir}
# Parallel-build might fail because of some race-condition
#make %{?_smp_mflags}
make
%if 0%{?fedora} || 0%{?rhel} >= 7
pushd %{py3dir}
%configure \
--enable-shared \
--enable-maintainer-mode \
--with-cxx \
PYTHON=%{__python3} \
OCT_INSTALL_DIR=%{octpkglibdir}
# Parallel-build might fail because of some race-condition
#make %{?_smp_mflags}
make
%endif
%install
%{?el5:rm -rf %{buildroot}}
make install DESTDIR=%{buildroot}
%if 0%{?fedora} || 0%{?rhel} >= 7
pushd %{py3dir}
make install DESTDIR=%{buildroot}
popd
%endif
# We don't want these static-libs and libtool-dumplings
find %{buildroot} -depth -name '*.*a' -print0 | xargs -0 rm -f
# Python bits need to be arched, but some end-up in %%{python_sitelib}.
%if 0%{?fedora} || 0%{?rhel} >= 7
[[ "%{python2_sitearch}" != "%{python2_sitelib}" ]] && \
mv -f %{buildroot}%{python2_sitelib}/* %{buildroot}%{python2_sitearch}
[[ "%{python3_sitearch}" != "%{python3_sitelib}" ]] && \
mv -f %{buildroot}%{python3_sitelib}/* %{buildroot}%{python3_sitearch}
%endif
# Setup octave stuff properly.
mkdir -p %{buildroot}%{octpkgdir}/packinfo
mv %{buildroot}%{octpkglibdir}/*.m %{buildroot}%{octpkgdir}
chmod 0755 %{buildroot}%{octpkglibdir}/*.oct
install -pm 0644 COPYING %{buildroot}%{octpkgdir}/packinfo
cat > %{buildroot}%{octpkgdir}/packinfo/DESCRIPTION << EOF
NLopt is a library for nonlinear local and global optimization, for
functions with and without gradient information. It is designed as
as simple, unified interface and packaging of several free/open-source
nonlinear optimization libraries.
EOF
cat > %{buildroot}%{octpkgdir}/packinfo/on_uninstall.m << EOF
function on_uninstall (desc)
error ('Can not uninstall %s installed by the redhat package manager', desc.name);
endfunction
EOF
%check
pushd test
make check
popd
%if 0%{?fedora} || 0%{?rhel} >= 7
pushd %{py3dir}/test
make check
popd
%endif
%clean
%{?el5:rm -rf %{buildroot}}
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%if 0%{?fedora} || 0%{?rhel} >= 6
%post -n guile-%{name} -p /sbin/ldconfig
%postun -n guile-%{name} -p /sbin/ldconfig
%endif
%if 0%{?fedora} || 0%{?rhel} >= 7
%post -n octave-%{name}
%octave_cmd pkg rebuild
%preun -n octave-%{name}
%octave_pkg_preun
%postun -n octave-%{name}
%octave_cmd pkg rebuild
%else
%post -n octave-%{name}
octave -H -q --no-window-system --no-site-file --eval "pkg rebuild"
%preun -n octave-%{name}
rm -f %{octpkgdir}/packinfo/on_uninstall.m
if [ -e %{octpkgdir}/packinfo/on_uninstall.m.orig ]
then
mv -f %{octpkgdir}/packinfo/on_uninstall.m.orig %{octpkgdir}/packinfo/on_uninstall.m
cd %{octpkgdir}/packinfo
octave -H -q --no-window-system --no-site-file --eval "l=pkg('list');on_uninstall(l{cellfun(@(x)strcmp(x.name,'%{octpkg}'),l)});"
fi
%postun -n octave-%{name}
octave -H -q --no-window-system --no-site-file --eval "pkg rebuild"
%endif
%files
%doc ChangeLog COPY* NEWS
%{_libdir}/lib%{lc_name}_cxx.so.*
%files devel
%doc %{_mandir}/man3/*
%{_includedir}/*
%{_libdir}/lib%{lc_name}_cxx.so
%{_libdir}/pkgconfig/%{lc_name}.pc
%files doc
%doc AUTHOR* ChangeLog COPY* NEWS README* TODO *.[Pp][Dd][Ff].*
%if 0%{?fedora} || 0%{?rhel} >= 6
%files -n guile-%{name}
%{_libdir}/lib%{lc_name}_cxx_guile.so.*
%{guile_sitedir}/*
%files -n guile-%{name}-devel
%{_libdir}/lib%{lc_name}_cxx_guile.so
%endif
%files -n octave-%{name}
%{octpkglibdir}
%{octpkgdir}
%if 0%{?fedora} || 0%{?rhel} >= 7
%files -n python-%{name}
%{python2_sitearch}/*
%files -n python3-%{name}
%{python3_sitearch}/*.so*
%{python3_sitearch}/*.py*
%{python3_sitearch}/__pycache__/*.py*
%endif
%changelog
* Wed Oct 02 2013 Björn Esser <bjoern.esser@gmail.com> - 2.4-2.git20130903.35e6377
- adaptions for new Python-guidelines
* Thu Sep 19 2013 Björn Esser <bjoern.esser@gmail.com> - 2.4-1.git20130903.35e6377
- Initial rpm release (#1004209)