File yosys.spec of Package yosys

#
# spec file for package yosys
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%bcond_without tests

Name:           yosys
Version:        0.57
Release:        0
Summary:        Yosys open synthesis suite
Group:          Productivity/Scientific/Electronics
License:        ISC
URL:            https://yosyshq.net/yosys/
Source0:        https://github.com/YosysHQ/yosys/archive/refs/tags/yosys-%{version}.tar.gz
Patch1:         yosys-use-system-cxxopts.patch
Patch2:         yosys-use-python311.patch
Patch3:         yosys-use-gcc13.patch
BuildRequires:  bison >= 3.6
BuildRequires:  cxxopts-devel
BuildRequires:  flex
%if 0%{?suse_version} < 1600 && 0%{?sle_version} >= 150500
BuildRequires:  gcc13-c++
BuildRequires:  python311-base
%else
BuildRequires:  gcc-c++ >= 13
BuildRequires:  python3-base
%endif
BuildRequires:  readline-devel
BuildRequires:  tcl-devel
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(libffi)
%if %{with_tests}
BuildRequires:  gtkwave
BuildRequires:  yosys-abc = %{version}
BuildRequires:  iverilog
%endif
Requires:       yosys-abc = %{version}
Requires:       %{name}-data = %{version}
# Disable 32bit archs, tests fail
ExcludeArch:    %{ix86} %{arm}

%description
A framework for RTL synthesis tools. It currently has extensive
Verilog-2005 support and provides a basic set of synthesis
algorithms for various application domains.

%package data
Summary:        Data files for Yosys
Group:          Productivity/Scientific/Electronics
BuildArch:      noarch

%description data
Architecture independent data files for Yosys

%package devel
Summary:        Development files for Yosys
BuildArch:      noarch
Requires:       %{name} = %{version}

%description devel
Development headers and helpers for Yosys.

%prep
%setup -q -n yosys-%{version}
%patch -P 1 -p1
%if 0%{?suse_version} < 1600 && 0%{?sle_version} >= 150500
%patch -P 2 -p1
%patch -P 3 -p1
%endif

%build
%make_build CONFIG=gcc ABCEXTERNAL=%{_bindir}/yosys-abc \
  STRIP=%{_bindir}/true \
  PREFIX=%{_prefix} \
  BINDIR=%{_bindir} \
  LIBDIR=%{_libdir}

%install
%make_install CONFIG=gcc ABCEXTERNAL=%{_bindir}/yosys-abc \
  STRIP=%{_bindir}/true \
  PREFIX=%{_prefix} \
  BINDIR=%{_bindir} \
  LIBDIR=%{_libdir}

# Fix shebang
sed -i -e '1 s/env python3/python3/' %{buildroot}%{_bindir}/yosys-smtbmc

%check
# Note: In case the TS fails, try running with EXTRA_FLAGS="-v"
make CONFIG=gcc ABCEXTERNAL=%{_bindir}/yosys-abc EXTRA_FLAGS="" SEED=314159265359 test


%files
%license COPYING
%doc CHANGELOG README.md
%{_bindir}/yosys
%{_bindir}/yosys-filterlib
%{_bindir}/yosys-smtbmc
%{_bindir}/yosys-witness

%files data
%{_datadir}/yosys
%exclude %{_datadir}/yosys/include

%files devel
%{_bindir}/yosys-config
%{_datadir}/yosys/include

%changelog
openSUSE Build Service is sponsored by