##
##  nqp.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_opkg  2025.08
%define       V_dist  2025.08

#   package information
Name:         nqp
Summary:      Not Quite Perl (NQP)
URL:          https://github.com/perl6/nqp
Vendor:       The Perl Foundation
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Language
License:      Artistic
Version:      %{V_opkg}
Release:      20250829

#   package options
%option       with_parrot  no

#   list of sources
Source0:      https://github.com/perl6/nqp/releases/download/%{V_dist}/nqp-%{V_dist}.tar.gz

#   build information
Prefix:       %{l_prefix}
BuildRoot:    %{l_buildroot}
BuildPreReq:  OpenPKG, openpkg >= 20160101, perl
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  moarvm >= 2023.05
PreReq:       moarvm >= 2023.05
%if "%{with_parrot}" == "yes"
BuildPreReq:  parrot
PreReq:       parrot
%endif
AutoReq:      no
AutoReqProv:  no

%description
    Not Quite Perl (NQP) is a compiler for quickly generating PIR
    routines from Perl6-like code. The key feature of NQP is that it's
    designed to be a very small compiler (as compared with, say, perl6
    or Rakudo) and is focused on being a high-level way to create
    compilers and libraries for virtual machines (such as the Parrot
    Virtual Machine). Unlike a full-fledged implementation of Perl 6,
    NQP strives to have as small a runtime footprint as it can, while
    still providing a Perl 6 object model and regular expression engine
    for the virtual machine.

%track
    prog nqp = {
        version   = %{V_dist}
        url       = https://github.com/perl6/nqp/releases
        regex     = tree/(\d+\.\d+)
    }

%prep
    %setup -q

%build
    export CC="%{l_cc}"
    export CFLAGS="%{l_cflags}"
    %{l_prefix}/bin/perl Configure.pl \
        --prefix=%{l_prefix} \
%if "%{with_parrot}" == "yes"
        --with-parrot=%{l_prefix}/bin/parrot \
        --with-moar=%{l_prefix}/bin/moar \
        --backends=moar,parrot
%else
        --with-moar=%{l_prefix}/bin/moar \
        --backends=moar
%endif
    %{l_make} %{l_mflags -O}

%install
    %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

