# Cannot do a parallel build
%global _smp_ncpus_max 1

Name:           microscheme
Version:        0.9.4
Release:        1%{?dist}
Summary:        A functional programming language for the Arduino

License:        MIT
URL:            https://ryansuchocki.github.io/microscheme/
Source0:        https://github.com/ryansuchocki/microscheme/archive/v%{version}/%{name}-%{version}.tar.gz

BuildRequires:  avrdude
BuildRequires:  avr-gcc
BuildRequires:  avr-libc
BuildRequires:  dos2unix
BuildRequires:  gcc
BuildRequires:  make
BuildRequires:  xxd
Requires:  avrdude
Requires:  avr-gcc
Requires:  avr-libc

%description
Microscheme, or (ms) for short, is a functional programming language for the
Arduino, and for Atmel 8-bit AVR microcontrollers in general. Microscheme is
a subset of Scheme, in the sense that every valid (ms) program is also a valid
Scheme program (with the exception of Arduino hardware-specific primitives).
The (ms) compiler performs function inlining, and features an aggressive
tree-shaker, eliminating unused top-level definitions. Microscheme has a robust
FFI (Foreign Function Interface) meaning that C code may be invoked directly
from (ms) programs. Therefore, the power of the existing wealth of Arduino
libraries is available within Microscheme.

%package doc
Summary:   A functional programming language for the Arduino
BuildArch:  noarch

%description doc
Example microscheme programs and dissertation describing the original
implementation.

%prep
%autosetup
# Use Fedora build flags
sed -i "s/gcc/\$\(CC\)/g" makefile
sed -i "s/-Wall -Wextra -Werror/-fpie \$\(CFLAGS\)/g" makefile
# Use linux line endings
dos2unix examples/*.ms

%build
%make_build build

%install
mkdir -p %{buildroot}%{_bindir}/
install -m755 microscheme %{buildroot}%{_bindir}/

%check
./microscheme examples/BLINK.ms

%files
%license LICENSE
%{_bindir}/microscheme

%files doc
%license LICENSE
%doc examples/*.ms
%doc docs/static/dissertation.pdf

%changelog
* Tue Dec 05 2023 Benson Muite <benson_muite@emailplus.org> - 0.9.4-1
- Initial package