Blob Blame History Raw
%global commit		35060ba2a59f2b0f0fd622ed9df678f142f846ed
%global shortcommit	%(c=%{commit}; echo ${c:0:7})

%global with_gecode	1

%global with_jacop	1

Name:		mp
Version:	1.3.0
Release:	7%{?dist}
License:	MIT and BSD
Summary:	An open-source library for mathematical programming
URL:		https://github.com/ampl/mp
Source0:	https://github.com/ampl/mp/archive/%{commit}/mp-%{commit}.tar.gz
Source1:	mp.module.in
Requires:	environment-modules
BuildRequires:	atlas-devel
BuildRequires:	cmake
%if %{with_gecode}
BuildRequires:	gecode-devel
%endif
%if %{with_jacop}
BuildRequires:	jacop
BuildRequires:	java-devel
%endif
# Need git to satisfy a cmake test if building modules (gsl)
BuildRequires:	git
BuildRequires:	gsl-devel
BuildRequires:	doxygen
BuildRequires:	python-sphinx
#BuildRequires:	python-sphinx-latex
BuildRequires:	unixODBC-devel
# https://github.com/ampl/mp/issues/25
Patch0:		%{name}-fpinit.patch
# https://github.com/ampl/mp/commit/0b53c90a9bc823463ae6b818ba5798c175b69540
Patch1:		%{name}-endian.patch

%description
An open-source library for mathematical programming.
Features
  * Reusable high-performance .nl reader
  * Efficient type-safe C++ API for connecting solvers to AMPL and
    other systems: source
  * Interfaces to solvers supporting AMPL extensions for logic and
    constraint programming:
      * IBM ILOG CPLEX and CPLEX CP Optimizer (ilogcp)
      * Gecode
      * JaCoP
  * Interfaces to the following solvers:
      * LocalSolver
      * Sulum
  * Interfaces to other solvers via AMPL Solver Library
  * Cross-platform build support with CMake and continuous
    integration systems. This includes third-party solvers and
    libraries (COIN-OR solvers with CMake support are available
    in the ampl/coin repository).
  * AMPLGSL, an AMPL function library providing access to the GNU
    Scientific Library (GSL) functions. See the AMPLGSL
    documentation.
  * Database support on Linux and MacOS X. See Database and
    spreadsheet connection guide.
  * SMPSWriter, a converter from deterministic equivalent of a
    two-stage stochastic programming (SP) problem written in AMPL
    to an SP problem in SMPS format.

%package	devel
Summary:	Development files for %{name}
Group:		Development/Libraries
Requires:	%{name}%{?_isa} = %{version}-%{release}

%description	devel
This package contains the header files and development documentation
for %{name}.

%prep
%setup -q -n %{name}-%{commit}
%if %{with_jacop}
ln -s %{_javadir}/jacop/jacop.jar thirdparty/jacop/jacop-`rpm -q --qf "%%{VERSION}" jacop`.jar
%endif
%patch0 -p1
%patch1 -p1

%build
%if 0%{?fedora} > 20 || 0%{?rhel} > 6
export LIBS="-lgsl -L%{_libdir}/atlas -lsatlas"
%else
export LIBS="-lgsl L%{_libdir}/atlas -lcblas -latlas"
%endif

mkdir build
pushd build
BUILD=breathe
%if %{with_gecode}
BUILD="$BUILD,gecode"
%endif
%if %{with_jacop}
BUILD="$BUILD,jacop"
%endif
BUILD="$BUILD,gsl,smpswriter"
    %cmake						\
	-DCMAKE_INSTALL_PREFIX:PATH=%{_libdir}/%{name}		\
	-DCMAKE_SHARED_LINKER_FLAGS="%{__global_ldflags} -Wl,--as-needed" \
	-DBUILD_SHARED_LIBS=ON				\
	-DBUILD=$BUILD					\
	..
    make %{?_smp_mflags}
    make doc
popd

%install
make -C build install DESTDIR=%{buildroot}

mkdir -p %{buildroot}%{_datadir}/Modules/modulefiles
sed 's#@BINDIR@#'%{_libdir}/%{name}'#g;' < %{SOURCE1} > \
    %{buildroot}%{_datadir}/Modules/modulefiles/%{name}-%{_arch}
rm -r %{buildroot}%{_libdir}/%{name}/share
mv %{buildroot}%{_libdir}/%{name}/include %{buildroot}%{_prefix}
rm %{buildroot}%{_libdir}/%{name}/lib/*.a
mv %{buildroot}%{_libdir}/%{name}/lib/*.so* %{buildroot}%{_libdir}
mkdir -p %{buildroot}%{_docdir}/%{name}
cp -p README.rst %{buildroot}%{_docdir}/%{name}
mv %{buildroot}%{_libdir}/%{name}/doc/* %{buildroot}%{_docdir}/%{name}
rmdir %{buildroot}%{_libdir}/%{name}/lib/
rm -fr %{buildroot}%{_libdir}/%{name}/doc/

%check
make -C build test

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%doc %dir %{_docdir}/%{name}
%license LICENSE.rst
%doc %{_docdir}/%{name}/README.rst
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/bin
%{_libdir}/*.so.*
%{_datadir}/Modules/modulefiles/%{name}-%{_arch}

%files		devel
%doc %{_docdir}/%{name}
%exclude %{_docdir}/%{name}/README.rst
%{_libdir}/*.so
%{_includedir}/asl
%{_includedir}/mp

%changelog
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sun Jun 14 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-6
- Rebuild for new gecode.

* Sat May 02 2015 Kalev Lember <kalevlember@gmail.com> - 1.3.0-5
- Rebuilt for GCC 5 C++11 ABI change

* Sun Feb 22 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-4
- Add recomended extra libs for gsl.

* Wed Jan 28 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-3
- Enable the jacop interface.
- Use a better patch for non x86 fpinit (#1186162)
- Correct check on bigendian.

* Fri Jan 23 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-2
- Use the license macro for the LICENSE.rst file (#1181793#c3)
- environment-modules is a Requires not BuildRequires (#1181793#c3)

* Tue Jan 13 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-1
- Update package to use new 1.3.0 release

* Mon Dec 22 2014 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - v20141006-4
- Update to version that works with rawide gecode
- Add jacop support, works but disabled, missing from rawhide
- Build smpswriter

* Fri Dec 19 2014 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - v20141006-3
- Switch to newer git commit as base of package
- Add conditional to build gecode
- Build documentation

* Wed Dec 17 2014 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - v20141006-2
- Use environment-modules to follow upstream conventions.

* Sat Dec 13 2014 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - v20141006-1
- Initial mp spec.