##
##  parrot.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 information
Name:         parrot
Summary:      Parrot Virtual Machine
URL:          http://www.parrot.org/
Vendor:       Leo Tötsch et al.
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Language
License:      Artistic/GPL
Version:      7.9.0
Release:      20151120

#   package options
%option       with_pcre    yes
%option       with_gmp     no
%option       with_crypto  no
%option       with_icu     no

#   list of sources
Source0:      ftp://ftp.parrot.org/pub/parrot/releases/supported/%{version}/parrot-%{version}.tar.gz
Patch0:       parrot.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, perl, gcc, flex, bison, make
PreReq:       OpenPKG, openpkg >= 20160101
%if "%{with_gmp}" == "yes"
BuildPreReq:  gmp
PreReq:       gmp
%endif
%if "%{with_pcre}" == "yes"
BuildPreReq:  pcre
PreReq:       pcre
%endif
%if "%{with_crypto}" == "yes"
BuildPreReq:  openssl
PreReq:       openssl
%endif
%if "%{with_icu}" == "yes"
BuildPreReq:  icu
PreReq:       icu
%endif

%description
    Parrot is a virtual machine designed to execute bytecode for
    interpreted languages efficiently. Parrot will be the target for the
    Perl 6 compiler.

%track
    prog parrot = {
        version   = %{version}
        url       = ftp://ftp.parrot.org/pub/parrot/releases/supported/
        regex     = (\d+\.\d+\.\d+)/
    }
    prog parrot:devel = {
        version   = %{version}
        url       = ftp://ftp.parrot.org/pub/parrot/releases/devel/
        regex     = (\d+\.\d+\.\d+)/
    }

%prep
    %setup -q
    %patch -p0

%build
    #   configure program
    %{l_prefix}/bin/perl Configure.pl \
        --prefix=%{l_prefix} \
        --debugging=0 \
        --optimize \
        --cc="%{l_cc}" \
        --ccflags="%{l_cflags -O} %{l_cppflags icu .}" \
        --link="%{l_cc}" \
        --linkflags="%{l_ldflags}" \
        --ld="%{l_cc}" \
        --ldflags="%{l_ldflags}" \
        --lex="%{l_prefix}/bin/flex" \
        --yacc="%{l_prefix}/bin/bison -y" \
        --make="%{l_make}" \
        --libs="" \
%if "%{with_gmp}" != "yes"
        --without-gmp \
%endif
%if "%{with_pcre}" != "yes"
        --without-pcre \
%endif
%if "%{with_crypto}" != "yes"
        --without-crypto \
%endif
%if "%{with_icu}" == "yes"
        --icu-config=%{l_prefix}/bin/icu-config \
%else
        --without-icu \
%endif
        --without-gdbm \
        --without-gettext \
        --without-readline \
        --without-opengl

    #   build program
    %{l_make} %{l_mflags}

%install
    #   install program
    %{l_make} %{l_mflags} install \
        DESTDIR=$RPM_BUILD_ROOT

    #   strip down and adjust installation
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/parrot/blib
    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/doc
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

