%global pkgvers 4
%global scdate0 20210112
%global schash0 1632b4b450cbd3e5b6bdc9bf92c96cadde6a01b9
%global branch0 master
%global source0 https://github.com/ax3ghazy/cu-gr.git

%global sshort0 %{expand:%%{lua:print(('%{schash0}'):sub(1,8))}}

Name:           cu-gr
Version:        1.1
Release:        %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist}
Summary:        VLSI global routing tool
License:        BSD

URL:            https://github.com/ax3ghazy/cu-gr

BuildRequires:  git cmake gcc-c++ vim-common
BuildRequires:  boost-devel lef-devel def-devel

%global __cmake_in_source_build 1

%description
CUGR is a VLSI global routing tool.


%prep
%setup -T -c -n %{name}
git clone --depth 1 -n -b %{branch0} %{source0} .
git fetch --depth 1 origin %{schash0}
git reset --hard %{schash0}
git log --format=fuller


%build
rm -rf ./rsyn/lib/linux
sed -i -e '/\-static/d' src/CMakeLists.txt
sed -i -e 's|Boost_USE_STATIC_LIBS ON|Boost_USE_STATIC_LIBS OFF|' src/CMakeLists.txt
sed -i -e 's|iccad19gr def|iccad19gr def pthread|' src/CMakeLists.txt
xxd -i src/flute/POST9.dat > src/flute/POST9.c
xxd -i src/flute/POWV9.dat > src/flute/POWV9.c
# unused (conflict with boost)
sed -i -e '/for_each_dimension/d' rsyn/src/rsyn/util/dim.h

mkdir build
pushd build
%cmake ../src -Wno-dev \
       -DCMAKE_SKIP_RPATH=ON \
       -DCMAKE_VERBOSE_MAKEFILE=OFF \
       -DCMAKE_BUILD_TYPE=RelWithDebInfo
%cmake_build
popd

%install
mkdir -p %{buildroot}%{_bindir}
install -m 0755 build/iccad19gr %{buildroot}%{_bindir}/


%files
%license LICENSE
%doc README.md
%{_bindir}/*

%changelog
* Thu Aug 05 2021 Cristian Balint <cristian.balint@gmail.com>
- github update releases