6f9fb8d
# 'libmp.so' from 'gmp' conflicts with same library provided by this package.
6f9fb8d
# mp's libraries are so installed in a private directory on epel6.
6f9fb8d
# https://lists.centos.org/pipermail/centos-devel/2016-June/014820.html
6f9fb8d
73b966d
%if 0%{?fedora}
73b966d
%global with_jacop	1
73b966d
%global with_gecode	1
73b966d
%else
73b966d
%global with_jacop	0
423456a
%global with_gecode	1
73b966d
%endif
423456a
da28855
%if 0%{?rhel} && 0%{?rhel} < 7
da28855
%{!?__global_ldflags: %global __global_ldflags -Wl,-z,relro}
73b966d
%endif
423456a
6f9fb8d
%global  checkout   1f39801af085656e4bf72250356a3a70d5d98e73
6f9fb8d
%global  date       20161124
6f9fb8d
73b966d
Name: mp
99d83ec
Version: 3.1.0
9b5e2e2
Release: 7.%{date}git%(echo %{checkout} | cut -c-6)%{?dist}
73b966d
License: MIT and BSD
73b966d
Summary: An open-source library for mathematical programming
73b966d
URL: https://github.com/ampl/mp
6f9fb8d
Source0: https://github.com/ampl/mp/archive/%{checkout}.zip#/%{name}-%{checkout}.zip
6f9fb8d
Source1: %{name}.module.in
6f9fb8d
Patch0:  %{name}-strtod.patch
1097061
# https://bugzilla.redhat.com/show_bug.cgi?id=1333344
6f9fb8d
Patch2:	 %{name}-%{version}-jni.patch
da28855
9b5e2e2
%if 0%{?rhel} && 0%{?rhel} >= 7
9b5e2e2
Requires: config(environment-modules)
9b5e2e2
%else
73b966d
Requires: environment(modules)
9b5e2e2
%endif
9b5e2e2
73b966d
BuildRequires: atlas-devel
73b966d
%if 0%{?rhel}
d4779a7
BuildRequires: cmake3
73b966d
%else
73b966d
BuildRequires: cmake
73b966d
%endif
423456a
%if %{with_gecode}
73b966d
BuildRequires: gecode-devel
423456a
%endif
423456a
%if %{with_jacop}
73b966d
BuildRequires: jacop
73b966d
BuildRequires: java-devel
423456a
%endif
423456a
# Need git to satisfy a cmake test if building modules (gsl)
da28855
BuildRequires: git, gdb
73b966d
BuildRequires: chrpath
73b966d
BuildRequires: gsl-devel
6f9fb8d
BuildRequires: gcc-c++
73b966d
BuildRequires: doxygen
73b966d
BuildRequires: python-sphinx
73b966d
BuildRequires: python-virtualenv
Paulo Andrade 2c003e2
#BuildRequires:	python-sphinx-latex
73b966d
BuildRequires: unixODBC-devel
423456a
423456a
%description
423456a
An open-source library for mathematical programming.
423456a
Features
423456a
  * Reusable high-performance .nl reader
423456a
  * Efficient type-safe C++ API for connecting solvers to AMPL and
423456a
    other systems: source
423456a
  * Interfaces to solvers supporting AMPL extensions for logic and
423456a
    constraint programming:
423456a
      * IBM ILOG CPLEX and CPLEX CP Optimizer (ilogcp)
423456a
      * Gecode
423456a
      * JaCoP
423456a
  * Interfaces to the following solvers:
423456a
      * LocalSolver
423456a
      * Sulum
423456a
  * Interfaces to other solvers via AMPL Solver Library
423456a
  * Cross-platform build support with CMake and continuous
423456a
    integration systems. This includes third-party solvers and
423456a
    libraries (COIN-OR solvers with CMake support are available
423456a
    in the ampl/coin repository).
423456a
  * AMPLGSL, an AMPL function library providing access to the GNU
423456a
    Scientific Library (GSL) functions. See the AMPLGSL
423456a
    documentation.
423456a
  * Database support on Linux and MacOS X. See Database and
423456a
    spreadsheet connection guide.
423456a
  * SMPSWriter, a converter from deterministic equivalent of a
423456a
    two-stage stochastic programming (SP) problem written in AMPL
423456a
    to an SP problem in SMPS format.
423456a
73b966d
%package devel
73b966d
Summary: Development files for %{name}
73b966d
Group: Development/Libraries
73b966d
Requires: %{name}%{?_isa} = %{version}-%{release}
423456a
73b966d
%description devel
423456a
This package contains the header files and development documentation
423456a
for %{name}.
423456a
423456a
%prep
6f9fb8d
%setup -q -n %{name}-%{checkout}
302a83e
%patch0 -p1
6f9fb8d
1097061
%patch2 -p1 -b .jni
6f9fb8d
423456a
%if %{with_jacop}
423456a
ln -s %{_javadir}/jacop/jacop.jar thirdparty/jacop/jacop-`rpm -q --qf "%%{VERSION}" jacop`.jar
423456a
%endif
423456a
423456a
%build
a66ce6b
%if 0%{?fedora} > 20 || 0%{?rhel} > 6
a66ce6b
export LIBS="-lgsl -L%{_libdir}/atlas -lsatlas"
a66ce6b
%else
73b966d
export LIBS="-lgsl -L%{_libdir}/atlas -lcblas -latlas"
a66ce6b
%endif
a66ce6b
da28855
mkdir build && pushd build
423456a
%if %{with_gecode}
73b966d
BUILD="gecode"
423456a
%endif
423456a
%if %{with_jacop}
423456a
BUILD="$BUILD,jacop"
423456a
%endif
423456a
BUILD="$BUILD,gsl,smpswriter"
6f9fb8d
%if 0%{?rhel} && 0%{?rhel} < 7
da28855
export CFLAGS="%{optflags} -Wl,-z,relro -fPIC -pie -Wl,-z,now -DNDEBUG"
da28855
export CXXFLAGS="%{optflags} -Wl,-z,relro -fPIC -pie -Wl,-z,now -DNDEBUG"
73b966d
export LDFLAGS="%{__global_ldflags} -fPIC -pie -Wl,-z,now"
d4779a7
%cmake3 -DCMAKE_INSTALL_PREFIX:PATH=%{_libdir}/%{name} \
73b966d
 -DCMAKE_SHARED_LINKER_FLAGS="%{__global_ldflags} -Wl,-z,now -fPIC -pie -Wl,--as-needed" \
da28855
 -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags} -Wl,-z,relro -fPIC -pie -Wl,-z,now -DNDEBUG" \
da28855
 -DCMAKE_C_FLAGS_RELEASE:STRING="" \
da28855
 -DCMAKE_SKIP_INSTALL_RPATH:BOOL=YES -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
73b966d
 -DCMAKE_SKIP_RPATH:BOOL=NO \
73b966d
 -DBUILD_SHARED_LIBS=ON	-DBUILD=$BUILD ..
d4779a7
%endif
d4779a7
%if 0%{?rhel} && 0%{?rhel} >= 7
d4779a7
export CFLAGS="%{optflags} -Wl,-z,relro -fPIC -pie -Wl,-z,now -DNDEBUG"
d4779a7
export CXXFLAGS="%{optflags} -Wl,-z,relro -fPIC -pie -Wl,-z,now -DNDEBUG"
d4779a7
export LDFLAGS="%{__global_ldflags} -fPIC -pie -Wl,-z,now"
d4779a7
%cmake3 -DCMAKE_INSTALL_PREFIX:PATH=%{_libdir}/%{name} \
d4779a7
 -DCMAKE_SHARED_LINKER_FLAGS="%{__global_ldflags} -Wl,-z,now -fPIC -pie -Wl,--as-needed" \
d4779a7
 -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags} -Wl,-z,relro -fPIC -pie -Wl,-z,now -DNDEBUG" \
d4779a7
 -DCMAKE_C_FLAGS_RELEASE:STRING="" \
d4779a7
 -DCMAKE_SKIP_INSTALL_RPATH:BOOL=YES -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
d4779a7
 -DCMAKE_SKIP_RPATH:BOOL=NO \
d4779a7
 -DBUILD_SHARED_LIBS=ON	-DBUILD=$BUILD ..
d4779a7
%endif
d4779a7
%if 0%{?fedora}
d4779a7
%cmake -DCMAKE_INSTALL_PREFIX:PATH=%{_libdir}/%{name} \
73b966d
 -DCMAKE_SHARED_LINKER_FLAGS="%{__global_ldflags} -Wl,--as-needed" \
73b966d
 -DCMAKE_SKIP_INSTALL_RPATH:BOOL=YES \
73b966d
 -DCMAKE_SKIP_RPATH:BOOL=NO \
73b966d
 -DBUILD_SHARED_LIBS=ON	-DBUILD=$BUILD ..
73b966d
%endif
73b966d
make %{?_smp_mflags}
73b966d
73b966d
## Documentation needs online connection to upstream
73b966d
## and Sphinx 1.1.3
73b966d
#make doc
423456a
popd
423456a
423456a
%install
73b966d
#m%%ake_install
423456a
423456a
mkdir -p %{buildroot}%{_datadir}/Modules/modulefiles
423456a
sed 's#@BINDIR@#'%{_libdir}/%{name}'#g;' < %{SOURCE1} > \
febb841
    %{buildroot}%{_datadir}/Modules/modulefiles/%{name}-%{_arch}
73b966d
73b966d
mkdir -p %{buildroot}%{_libdir}/%{name}/bin
73b966d
mkdir -p %{buildroot}%{_includedir}/asl
73b966d
cp -a  include %{buildroot}%{_prefix}
73b966d
install -pm 644 src/asl/*.h %{buildroot}%{_includedir}/asl
73b966d
install -pm 644 src/asl/solvers/*.h build/src/asl/*.h %{buildroot}%{_includedir}/asl
302a83e
302a83e
# Required by coin-or-Couenne
302a83e
install -pm 644 src/asl/solvers/{opcode,r_opn}.hd  %{buildroot}%{_includedir}/asl
302a83e
73b966d
install -pm 755 build/bin/amplgsl.dll %{buildroot}%{_libdir}/%{name}/bin
73b966d
install -pm 755 build/bin/ampltabl.dll %{buildroot}%{_libdir}/%{name}/bin
73b966d
install -pm 755 build/bin/arithchk %{buildroot}%{_libdir}/%{name}/bin
73b966d
install -pm 755 build/bin/cp.dll %{buildroot}%{_libdir}/%{name}/bin
73b966d
install -pm 755 build/bin/fullbit.dll %{buildroot}%{_libdir}/%{name}/bin
73b966d
install -pm 755 build/bin/gecode %{buildroot}%{_libdir}/%{name}/bin
73b966d
install -pm 755 build/bin/gjh %{buildroot}%{_libdir}/%{name}/bin
73b966d
%if %{with_jacop}
73b966d
install -pm 755 build/bin/jacop %{buildroot}%{_libdir}/%{name}/bin
73b966d
%endif
73b966d
install -pm 755 build/bin/smpswriter %{buildroot}%{_libdir}/%{name}/bin
73b966d
install -pm 755 build/bin/simpbit.dll %{buildroot}%{_libdir}/%{name}/bin
73b966d
install -pm 755 build/bin/tableproxy%{__isa_bits} %{buildroot}%{_libdir}/%{name}/bin
73b966d
73b966d
## Fix symbolic links
da28855
## On epel6 'mp' conflicts with 'gmp'
da28855
## We need to install libraries in a private lib directory
da28855
da28855
%if 0%{?rhel} && 0%{?rhel} < 7
da28855
install -pm 755 build/bin/libasl.so* %{buildroot}%{_libdir}/%{name}
da28855
ln -sf %{_libdir}/%{name}/libasl.so.%{version} %{buildroot}%{_libdir}/%{name}/libasl.so.3
da28855
ln -sf %{_libdir}/%{name}/libasl.so.%{version} %{buildroot}%{_libdir}/%{name}/libasl.so
da28855
da28855
install -pm 755 build/bin/libmp.so* %{buildroot}%{_libdir}/%{name}
da28855
ln -sf %{_libdir}/%{name}/libmp.so.%{version} %{buildroot}%{_libdir}/%{name}/libmp.so.3
da28855
ln -sf %{_libdir}/%{name}/libmp.so.%{version} %{buildroot}%{_libdir}/%{name}/libmp.so
da28855
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/libasl.so.%{version}
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/amplgsl.dll
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/ampltabl.dll
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/cp.dll
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/fullbit.dll
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/gecode
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/gjh
da28855
%if %{with_jacop}
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/jacop
da28855
%endif
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/smpswriter
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/simpbit.dll
da28855
chrpath --replace %{_libdir}/%{name} %{buildroot}%{_libdir}/%{name}/bin/tableproxy%{__isa_bits}
da28855
%endif
da28855
da28855
%if 0%{?fedora} || 0%{?rhel} >= 7
da28855
install -pm 755 build/bin/libasl.so* %{buildroot}%{_libdir}
da28855
ln -sf libasl.so.%{version} %{buildroot}%{_libdir}/libasl.so.3
da28855
ln -sf libasl.so.%{version} %{buildroot}%{_libdir}/libasl.so
da28855
da28855
install -pm 755 build/bin/libmp.so* %{buildroot}%{_libdir}
da28855
ln -sf libmp.so.%{version} %{buildroot}%{_libdir}/libmp.so.3
da28855
ln -sf libmp.so.%{version} %{buildroot}%{_libdir}/libmp.so
73b966d
73b966d
chrpath --delete %{buildroot}%{_libdir}/libasl.so.%{version}
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/amplgsl.dll
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/ampltabl.dll
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/arithchk
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/cp.dll
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/fullbit.dll
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/gecode
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/gjh
73b966d
%if %{with_jacop}
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/jacop
73b966d
%endif
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/smpswriter
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/simpbit.dll
73b966d
chrpath --delete %{buildroot}%{_libdir}/%{name}/bin/tableproxy%{__isa_bits}
da28855
%endif
da28855
##
423456a
da28855
## Some tests fail on EPEL6 ppc64
da28855
# https://github.com/ampl/mp/issues/101
423456a
%check
73b966d
pushd build
da28855
%if 0%{?rhel} && 0%{?rhel} > 6
517d77c
ctest3 --force-new-ctest-process --parallel %{?_smp_mflags} -I 4,15,,1,17,28
da28855
%endif
da28855
%if 0%{?rhel} && 0%{?rhel} < 7
6f9fb8d
# https://github.com/ampl/mp/issues/103
d4779a7
ctest3 --force-new-ctest-process --parallel %{?_smp_mflags} -I 4,15,,1,17,28
da28855
%endif
da28855
%if 0%{?fedora}
517d77c
ctest --force-new-ctest-process --parallel %{?_smp_mflags} -I 4,15,,1,17,28
73b966d
%endif
423456a
423456a
%post -p /sbin/ldconfig
423456a
%postun -p /sbin/ldconfig
423456a
423456a
%files
73b966d
%doc README.rst
423456a
%license LICENSE.rst
da28855
%dir %{_libdir}/%{name}
da28855
%{_libdir}/%{name}/bin/
da28855
%if 0%{?rhel} && 0%{?rhel} < 7
da28855
%{_libdir}/%{name}/*.so.*
da28855
%endif
da28855
%if 0%{?fedora} || 0%{?rhel} >= 7
423456a
%{_libdir}/*.so.*
da28855
%endif
423456a
%{_datadir}/Modules/modulefiles/%{name}-%{_arch}
423456a
73b966d
%files devel
da28855
%if 0%{?rhel} && 0%{?rhel} < 7
da28855
%{_libdir}/%{name}/*.so
da28855
%endif
da28855
%if 0%{?fedora} || 0%{?rhel} >= 7
423456a
%{_libdir}/*.so
da28855
%endif
423456a
%{_includedir}/asl
423456a
%{_includedir}/mp
423456a
423456a
%changelog
9b5e2e2
* Sun Feb 26 2017 Antonio Trande <sagitter@fedoraproject.org.com> - 3.1.0-7.20160810git1f3980
9b5e2e2
- Fix environment-modules required on epel7
517d77c
- Skip gsl-test always (upstream issue #103)
9b5e2e2
feeb574
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.1.0-6.20161124git1f3980
feeb574
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
feeb574
d4779a7
* Thu Nov 24 2016 Antonio Trande <sagitter@fedoraproject.org.com> - 3.1.0-5.20160810git1f3980
d4779a7
- Skip gsl-test on epel6 (upstream issue #103)
d4779a7
6f9fb8d
* Thu Nov 24 2016 Antonio Trande <sagitter@fedoraproject.org.com> - 3.1.0-4.20160810git1f3980
6f9fb8d
- Update to commit #1f3980 (fmt updated to 3.0.1)
6f9fb8d
- Patched for PPC64
6f9fb8d
da28855
* Thu Jun 30 2016 Antonio Trande <sagitter@fedoraproject.org.com> - 3.1.0-3
da28855
- Fix cmake version for EPEL
da28855
- libmp installed in a private lib directory on epel6
da28855
- Pached to remove gtest
da28855
- Set to disable tests on EPEL6
da28855
1097061
* Thu May 05 2016 Dan HorĂ¡k <dan[at]danny.cz> - 3.1.0-2
1097061
- fix build on secondary arches (thirdparty/benchmark) (#1333344)
1097061
- fix JNI detection (#1333344)
1097061
99d83ec
* Wed Mar 30 2016 Antonio Trande <sagitter@fedoraproject.org.com> - 3.1.0-1
99d83ec
- Update to 3.1.0
99d83ec
302a83e
* Wed Mar 16 2016 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 3.0.1-0.2
302a83e
- Avoid incorrect system detection and use of strtod_ASL wrapper
302a83e
- Install extra headers required by coin-or-Couenne
302a83e
73b966d
* Fri Mar 04 2016 Antonio Trande <sagitter@fedoraproject.org.com> - 3.0.1-0.1
73b966d
- Update to 3.0.1 prerelease (commit #9fdb514)
73b966d
73b966d
* Thu Mar 03 2016 Antonio Trande <sagitter@fedoraproject.org.com> - 3.0.0-1
73b966d
- Update to 3.0.0
73b966d
73b966d
* Wed Mar 02 2016 Antonio Trande <sagitter@fedoraproject.org.com> - 2.1.1-0.2
73b966d
- Built with cmake3 on EPEL
73b966d
73b966d
* Tue Mar 01 2016 Antonio Trande <sagitter@fedoraproject.org.com> - 2.1.1-0.1
73b966d
- Update to 2.1.0
73b966d
- Dropped old patches for 1.3.0
73b966d
- Jacop support disabled on EPEL
73b966d
- Patched for GCC6
73b966d
- Patched for GSL-2.1
73b966d
- fpinit patched for ARM 
73b966d
Orion Poplawski 9c0d7d9
* Mon Feb 22 2016 Orion Poplawski <orion@cora.nwra.com> - 1.3.0-10
73b966d
- Rebuild for gsl 2.1 
Orion Poplawski 9c0d7d9
ba3f783
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.0-9
ba3f783
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
ba3f783
Orion Poplawski 28e34f1
* Wed Jan 6 2016 Orion Poplawski <orion@cora.nwra.com> - 1.3.0-8
Orion Poplawski 28e34f1
- Require environment(modules)
Orion Poplawski 28e34f1
8236891
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.0-7
8236891
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
8236891
274e945
* Sun Jun 14 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-6
274e945
- Rebuild for new gecode.
274e945
7654787
* Sat May 02 2015 Kalev Lember <kalevlember@gmail.com> - 1.3.0-5
7654787
- Rebuilt for GCC 5 C++11 ABI change
7654787
a66ce6b
* Sun Feb 22 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-4
a66ce6b
- Add recomended extra libs for gsl.
a66ce6b
Paulo Andrade 069dff6
* Wed Jan 28 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-3
4af1ec4
- Enable the jacop interface.
Paulo Andrade 069dff6
- Use a better patch for non x86 fpinit (#1186162)
Paulo Andrade 2c003e2
- Correct check on bigendian.
4af1ec4
423456a
* Fri Jan 23 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-2
423456a
- Use the license macro for the LICENSE.rst file (#1181793#c3)
423456a
- environment-modules is a Requires not BuildRequires (#1181793#c3)
423456a
423456a
* Tue Jan 13 2015 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - 1.3.0-1
423456a
- Update package to use new 1.3.0 release
423456a
423456a
* Mon Dec 22 2014 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - v20141006-4
423456a
- Update to version that works with rawide gecode
423456a
- Add jacop support, works but disabled, missing from rawhide
423456a
- Build smpswriter
423456a
423456a
* Fri Dec 19 2014 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - v20141006-3
423456a
- Switch to newer git commit as base of package
423456a
- Add conditional to build gecode
423456a
- Build documentation
423456a
423456a
* Wed Dec 17 2014 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - v20141006-2
423456a
- Use environment-modules to follow upstream conventions.
423456a
423456a
* Sat Dec 13 2014 pcpa <paulo.cesar.pereira.de.andrade@gmail.com> - v20141006-1
423456a
- Initial mp spec.
99d83ec