## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# ASL upstream has not tagged any releases, so we use a git checkout
%global commit     97e10747f47fea0db03c55c9d6b8294f0b3393bf
%global date       20241202
%global forgeurl   https://github.com/ampl/asl

Name:           asl
Version:        20241111
Summary:        AMPL Solver Library

%forgemeta

# AMPL files are licensed with BSD-3-Clause.
# NETLIB files are licensed with SMLNJ.
License:        BSD-3-Clause AND SMLNJ
Release:        %autorelease
URL:            %{forgeurl}
VCS:            git:%{forgeurl}.git
Source:         %{forgesource}
# Build the C++ interface as a shared library instead of a static library
Patch:          %{name}-shared.patch
# Do not override Fedora architecture flags
Patch:          %{name}-arch-flags.patch
# Declare functions as functions, not as variables
Patch:          %{name}-prototype.patch

BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran

%description
The AMPL Solver Library is an interface used to access a variety of
solvers from AMPL code.

%package        devel
Summary:        Header files and library links for asl
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    devel
Header files and library links for building projects that use
%{name}.

%prep
%forgeautosetup -p1

%conf
# Fix install location of ampl-asl-config
sed -i 's,share/,lib/cmake/,' CMakeLists.txt

# Fix install location on 64-bit platforms
if [ "%{_lib}" != "lib" ]; then
  sed -i '/DESTINATION/s/lib/%{_lib}/g' CMakeLists.txt
fi

export CFLAGS="%{build_cflags} -DIGNORE_BOGUS_WARNINGS"
export CXXFLAGS="%{build_cxxflags} -DIGNORE_BOGUS_WARNINGS"
%cmake \
  -DBUILD_CPP:BOOL=ON \
  -DBUILD_EXAMPLES:BOOL=OFF \
  -DBUILD_MT_LIBS:BOOL=ON \
  -DBUILD_SHARED_LIBS:BOOL=ON \
  -DGENERATE_ARITH:BOOL=ON

%build
%cmake_build

%install
%cmake_install

# mp needs uninstalled files
cp -p src/solvers/{dvalue.hd,fg_read.c} %{buildroot}%{_includedir}/asl
cp -p src/solvers2/fg_read.c %{buildroot}%{_includedir}/asl2

# Save space by not duplicating header files between asl and asl2
%fdupes %{buildroot}%{_includedir}

%files
%doc README.md
%license LICENSE LICENSE.2
%{_libdir}/libasl.so.0*
%{_libdir}/libasl-mt.so.0*
%{_libdir}/libasl2.so.0*
%{_libdir}/libasl2-mt.so.0*
%{_libdir}/libaslcpp.so.0*

%files devel
%{_includedir}/asl/
%{_includedir}/asl2/
%{_includedir}/aslcpp/
%{_libdir}/libasl.so
%{_libdir}/libasl-mt.so
%{_libdir}/libasl2.so
%{_libdir}/libasl2-mt.so
%{_libdir}/libaslcpp.so
%{_libdir}/cmake/ampl-asl/

%changelog
## START: Generated by rpmautospec
* Tue Dec 03 2024 Jerry James <loganjerry@gmail.com> - 20241111-1
- Version 20241111
- Drop upstreamed fenv patch
- Use fdupes instead of hardlink
- Move configuration steps to %%conf

* Wed Jul 17 2024 Fedora Release Engineering <releng@fedoraproject.org> - 20240106-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Tue Jul 16 2024 Jerry James <loganjerry@gmail.com> - 20240106-2
- Minor spec file simplifications

* Thu Feb 22 2024 Jerry James <loganjerry@gmail.com> - 20240106-1
- Initial RPM

* Sat Feb 17 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-55
- Unretirement releng request: https://pagure.io/releng/issue/11961

* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-54
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-53
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-52
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Wed Dec 16 2020 Tom Stellard <tstellar@redhat.com> - 1.42-51
- Add BuildRequires: make

* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-50
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-49
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-48
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-47
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Mon Jan 28 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.42-46
- Remove obsolete Group tag

* Tue Jul 24 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.42-45
- Add missing BuildRequires on gcc

* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-44
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jul 10 2018 Jason Tibbitts <tibbs@math.uh.edu> - 1.42-43
- Remove needless use of %%defattr

* Tue May 22 2018 Eric Smith <brouhaha@fedoraproject.org> - 1.42-42
- Update to latest upstream.

* Mon Apr 30 2018 Eric Smith <brouhaha@fedoraproject.org> - 1.42-41
- Update to latest upstream.

* Fri Mar 30 2018 Eric Smith <brouhaha@fedoraproject.org> - 1.42-40
- Update Makefile-DESTDIR patch.

* Fri Mar 30 2018 Eric Smith <brouhaha@fedoraproject.org> - 1.42-39
- Update to latest upstream. Update s390x sysdefs.h patch. Build without
  German documentation for EPEL7.

* Thu Mar 01 2018 Eric Smith <spacewar@gmail.com> - 1.42-38
- Update to latest upstream snapshot.

* Wed Feb 14 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.42-37
- Remove %%clean section

* Tue Feb 13 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.42-36
- Remove BuildRoot definition

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-35
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-34
- Rebuilt for
  https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-33
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Thu Mar 09 2017 Eric Smith <brouhaha@fedoraproject.org> - 1.42-32
- Update to latest upstream.

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.42-31
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Mon Jan 09 2017 Dan Horák <dan@danny.cz> - 1.42-30
- update the sysdefs patch for s390(x) and ia64

* Sun Jan 08 2017 Eric Smith <brouhaha@fedoraproject.org> - 1.42-29
- Update to latest upstream snapshot. Add patch for CDP180[456] scal
  instruction.

* Mon Aug 01 2016 Eric Smith <brouhaha@fedoraproject.org> - 1.42-28
- Update to latest upstream snapshot.

* Wed Feb 03 2016 Dennis Gilmore <dennis@ausil.us> - 1.42-27
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Jun 17 2015 Dennis Gilmore <dennis@ausil.us> - 1.42-26
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Wed Mar 04 2015 Eric Smith <brouhaha@fedoraproject.org> - 1.42-25
- Update to latest upstream snapshot.

* Thu Sep 18 2014 Marcin Juszkiewicz <mjuszkiewicz@redhat.com> - 1.42-24
- Added AArch64 definitions

* Sat Aug 30 2014 Eric Smith <brouhaha@fedoraproject.org> - 1.42-23
- Update to latest upstream snapshot.

* Fri Aug 15 2014 Peter Robinson <pbrobinson@fedoraproject.org> - 1.42-22
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sat Jun 07 2014 Dennis Gilmore <dennis@ausil.us> - 1.42-21
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Sun Mar 09 2014 Eric Smith <brouhaha@fedoraproject.org> - 1.42-20
- Update to latest upstream. Fixes problem with quoting.

* Thu Mar 06 2014 Eric Smith <brouhaha@fedoraproject.org> - 1.42-19
- Update to latest upstream Fixed problem buidling on EL6.

* Wed Mar 05 2014 Eric Smith <brouhaha@fedoraproject.org> - 1.42-18
- Update to latest upstream snapshot.

* Thu Aug 15 2013 Eric Smith <brouhaha@fedoraproject.org> - 1.42-17
- Updated to latest upstream snapshot.

* Sat Aug 03 2013 Dennis Gilmore <dennis@ausil.us> - 1.42-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Thu Jun 06 2013 Eric Smith <brouhaha@fedoraproject.org> - 1.42-15
- Update to latest upstream.

* Wed Feb 13 2013 Dennis Gilmore <dennis@ausil.us> - 1.42-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Mon Oct 29 2012 Eric Smith <eric@brouhaha.com> - 1.42-13
- Updated to latest upstream.

* Sat Oct 27 2012 Eric Smith <eric@brouhaha.com> - 1.42-12
- Updated to latest upstream.

* Wed Jul 18 2012 Dennis Gilmore <dennis@ausil.us> - 1.42-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Thu Jun 07 2012 Eric Smith <eric@brouhaha.com> - 1.42-10
- Update to latest upstream.

* Sun Jan 22 2012 Eric Smith <eric@brouhaha.com> - 1.42-8
- Update to latest upstream snapshot.

* Thu Jan 12 2012 Dennis Gilmore <dennis@ausil.us> - 1.42-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Fri Nov 11 2011 Eric Smith <eric@brouhaha.com> - 1.42-6
- Update to latest upstream.

* Tue Feb 08 2011 Dennis Gilmore <dennis@ausil.us> - 1.42-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Mon Jan 03 2011 Eric Smith <eric@localhost.localdomain> - 1.42-4
- * Sun Jan 02 2011 Eric Smith <eric@brouhaha.com> 1.42-0.6.bld79 - updated
  to latest upstream snapshot - upstream has removed doc_DE/dina4.sty, so
  we no longer need to use a cleaned tarball

* Wed Jul 28 2010 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.42-3
- dist-git conversion

* Sat Apr 24 2010 Eric Smith <brouhaha@fedoraproject.org> - 1.42-2
- rebuilding because cvs-import.sh somehow missed one patch for F-12

* Sat Apr 24 2010 Eric Smith <brouhaha@fedoraproject.org> - 1.42-1
- use cleaned source tarball until upstream removes doc_DE/dina4.sty -
  removed strcpy() patch
## END: Generated by rpmautospec