# generated by cabal-rpm-2.3.2
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Haskell/

%global pkg_name libriscv
%global pkgver %{pkg_name}-%{version}
%{?haskell_setup}

# testsuite missing deps: bv tasty tasty-hunit

Name:           ghc-%{pkg_name}
Version:        0.1.0.0
Release:        1%{?dist}
Summary:        A versatile, flexible and executable formal model for the RISC-V architecture

License:        MIT
URL:            https://hackage.haskell.org/package/libriscv
# Begin cabal-rpm sources:
Source0:        https://hackage.haskell.org/package/%{pkgver}/%{pkgver}.tar.gz
# End cabal-rpm sources
Patch0:         bytestring-ver-fix.patch
# Begin cabal-rpm deps:
BuildRequires:  ghc-rpm-macros
BuildRequires:  ghc-Cabal-devel
BuildRequires:  ghc-array-devel
BuildRequires:  ghc-base-devel
BuildRequires:  ghc-bv-devel
BuildRequires:  ghc-bytestring-devel
BuildRequires:  ghc-containers-devel
BuildRequires:  ghc-exceptions-devel
BuildRequires:  ghc-extra-devel
BuildRequires:  ghc-file-embed-devel
BuildRequires:  ghc-filepath-devel
BuildRequires:  ghc-freer-simple-devel
BuildRequires:  ghc-melf-devel
BuildRequires:  ghc-optparse-applicative-devel
BuildRequires:  ghc-parameterized-utils-devel
BuildRequires:  ghc-template-haskell-devel
BuildRequires:  ghc-transformers-devel
BuildRequires:  ghc-yaml-devel
%if %{with ghc_prof}
BuildRequires:  ghc-array-prof
BuildRequires:  ghc-base-prof
BuildRequires:  ghc-bv-prof
BuildRequires:  ghc-bytestring-prof
BuildRequires:  ghc-containers-prof
BuildRequires:  ghc-exceptions-prof
BuildRequires:  ghc-extra-prof
BuildRequires:  ghc-file-embed-prof
BuildRequires:  ghc-filepath-prof
BuildRequires:  ghc-freer-simple-prof
BuildRequires:  ghc-melf-prof
BuildRequires:  ghc-optparse-applicative-prof
BuildRequires:  ghc-parameterized-utils-prof
BuildRequires:  ghc-template-haskell-prof
BuildRequires:  ghc-transformers-prof
BuildRequires:  ghc-yaml-prof
%endif
# End cabal-rpm deps

Packager:       Owen Zimmerman <owen@fyralabs.com>

%description
A formal model for the <https://riscv.org/ RISC-V> /Instruction Set
Architecture/ (ISA). Contrary to other Haskell RISC-V ISA models, like
<https://github.com/GaloisInc/grift GRIFT> or
<https://github.com/mit-plv/riscv-semantics riscv-semantics>, LibRISCV is
specifically tailored to the creation of custom ISA interpreters. To this end,
it is designed for flexibility, allowing a versatile representation of
instruction operands. For example, instruction operands can be
<https://en.wikipedia.org/wiki/Satisfiability_modulo_theories SMT> expressions
for <https://doi.org/10.48550/arXiv.2404.04132 symbolic execution> of binary
code.

LibRISCV abstractly describes instruction semantics using an /Embedded Domain
Specific Language/ (EDSL) with <https://doi.org/10.1145/2887747.2804319 free(r)
monads>. This Haskell library is intended to build custom interpreters for this
free monad. The entry point for this purpose is the
'LibRISCV.Semantics.buildAST' function which obtains the free monad AST based
on an entry address. The entry address can be obtained from a provided ELF
loader implementation, this "Loader" module is also responsible for loading
binary instructions into a provided memory implementation. Refer to provided
example interpreters in the <https://github.com/agra-uni-bremen/libriscv GitHub
repository> for practical usage instruction. More detailed information on
LibRISCV and its concepts is also available in a
<https://doi.org/10.1007/978-3-031-38938-2_2 TFP'23 publication>.


%package devel
Summary:        Haskell %{pkg_name} library development files
Provides:       %{name}-static = %{version}-%{release}
Provides:       %{name}-static%{?_isa} = %{version}-%{release}
%if %{defined ghc_version}
Requires:       ghc-compiler = %{ghc_version}
%endif
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description devel
This package provides the Haskell %{pkg_name} library development files.


%if %{with haddock}
%package doc
Summary:        Haskell %{pkg_name} library documentation
BuildArch:      noarch
Requires:       ghc-filesystem

%description doc
This package provides the Haskell %{pkg_name} library documentation.
%endif


%if %{with ghc_prof}
%package prof
Summary:        Haskell %{pkg_name} profiling library
Requires:       %{name}-devel%{?_isa} = %{version}-%{release}
Supplements:    (%{name}-devel and ghc-prof)

%description prof
This package provides the Haskell %{pkg_name} profiling library.
%endif


%prep
# Begin cabal-rpm setup:
%setup -q -n %{pkgver}
%patch -P0 -p1
# End cabal-rpm setup


%build
# Begin cabal-rpm build:
%ghc_lib_build
# End cabal-rpm build


%install
# Begin cabal-rpm install
%ghc_lib_install
# End cabal-rpm install


%files -f %{name}.files
# Begin cabal-rpm files:
%license LICENSE.txt
%{_datadir}/%{pkgver}
# End cabal-rpm files


%files devel -f %{name}-devel.files
%{_bindir}/riscv-tiny


%if %{with haddock}
%files doc -f %{name}-doc.files
%license LICENSE.txt
%endif


%if %{with ghc_prof}
%files prof -f %{name}-prof.files
%endif


%changelog
* Tue Apr 28 2026 Owen Zimmerman <owen@fyralabs.com> - 0.1.0.0-1
- Initial commit
