%global commit 8238ce568c3ce23e1ad5fbfec55031907bd23f77
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global datestamp 20170316
%global relstring %{datestamp}git%{shortcommit}
Name:           simarrange
Version:        0.0
Release:        19.%{relstring}%{?dist}
Summary:        STL 2D plate packer with collision simulation
License:        AGPLv3+
URL:            https://github.com/kliment/%{name}
Source0:        %{url}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz
BuildRequires:  gcc-c++
BuildRequires:  admesh-devel
BuildRequires:  argtable-devel
BuildRequires:  opencv-devel
BuildRequires:  uthash-devel

%description
Simarrange is a program that simulates collisions between STL meshes in 2D in
order to generate tightly packed sets of parts. It takes a directory of STL
files as input and outputs STL files with combined plates of parts.
The parts are assumed to be in the correct printable orientation already.

%prep
%setup -qn %{name}-%{commit}

# bundling
rm utlist.h

%build
# the build script is one line and would need patching, so just skip it
# TODO update to use Makefile
g++ %{optflags} simarrange.c -o ./%{name} -lm `pkg-config --cflags --libs opencv` \
    -ladmesh -largtable2 -fopenmp -DPARALLEL

%install
install -Dpm0755 ./%{name} %{buildroot}%{_bindir}/%{name}
install -Dpm0644 ./%{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1

%files
%license COPYING
%doc README.md
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.*

%changelog
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.0-19.20170316git8238ce5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.0-18.20170316git8238ce5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Mon Mar 05 2018 Adam Williamson <awilliam@redhat.com> - 0.0-17.20170316git8238ce5
- Rebuild for opencv soname bump

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.0-16.20170316git8238ce5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Tue Dec 26 2017 Miro Hrončok <mhroncok@redhat.com> - 0.0-15.20170316git8238ce5
- Updated to the latest commit
- Rebuilt for new opencv

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.0-14.20170309git3300eb5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.0-13.20170309git3300eb5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Thu Mar 09 2017 Miro Hrončok <mhroncok@redhat.com> - 0.0-12.20150708git315be26
- Update to latest commit
- Rebuilt for new opencv
- Use the %%license tag
- README was renamed

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.0-11.20140729git9500190
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Sat May 14 2016 Miro Hrončok <mhroncok@redhat.com> - 0.0-10.20140729git9500190
- Rebuilt for new opencv (#1230078)

* Thu May 05 2016 Miro Hrončok <mhroncok@redhat.com> - 0.0-9.20140729git9500190
- Rebuilt for new opencv

* Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.0-8.20140729git9500190
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jul 02 2015 Jozef Mlich <jmlich@redhat.com> - 0.0-7.20140729git9500190
- use pkg-config to determine opencv CFLAGS and LIBS instead of hardcoded values

* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0-6.20140729git9500190
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Mon Aug 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0-5.20140729git9500190
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Tue Jul 29 2014 Miro Hrončok <mhroncok@redhat.com> - 0.0-4.20140729git9500190
- Fix date in release tag

* Tue Jul 29 2014 Miro Hrončok <mhroncok@redhat.com> - 0.0-3.20131019git9500190
- Update to new commit

* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0-2.20131019gitd52382f
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Tue Oct 22 2013 Miro Hrončok <mhroncok@redhat.com> - 0.0-1.20131019gitd52382f
- New package