##
##  perl-comp.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.
##

#   versions of individual parts
%define       V_perl                 5.22
%define       V_compress_raw_zlib    2.213
%define       V_compress_raw_bzip2   2.213
%define       V_compress_raw_lzma    2.213
%define       V_compress_lzo         1.08
%define       V_compress_lzf         3.8
%define       V_io_compress          2.213
%define       V_io_compress_lzop     2.213
%define       V_io_compress_lzf      2.213
%define       V_io_compress_lzma     2.213
%define       V_compress_bzip2       2.28
%define       V_io_zlib              1.14

#   package information
Name:         perl-comp
Summary:      Perl Modules for use with Compression
URL:          http://www.cpan.org/
Vendor:       Perl Community
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        BASE
Group:        Perl
License:      GPL/Artistic
Version:      %{V_perl}
Release:      20240829

#   list of sources
Source0:      http://www.cpan.org/authors/id/P/PM/PMQS/Compress-Raw-Zlib-%{V_compress_raw_zlib}.tar.gz
Source1:      http://www.cpan.org/authors/id/P/PM/PMQS/Compress-Raw-Bzip2-%{V_compress_raw_bzip2}.tar.gz
Source2:      http://www.cpan.org/authors/id/P/PM/PMQS/Compress-Raw-Lzma-%{V_compress_raw_lzma}.tar.gz
Source3:      http://www.cpan.org/authors/id/M/MF/MFX/Compress-LZO-%{V_compress_lzo}.tar.gz
Source4:      http://www.cpan.org/authors/id/M/ML/MLEHMANN/Compress-LZF-%{V_compress_lzf}.tar.gz
Source5:      http://www.cpan.org/authors/id/P/PM/PMQS/IO-Compress-%{V_io_compress}.tar.gz
Source6:      http://www.cpan.org/authors/id/P/PM/PMQS/IO-Compress-Lzop-%{V_io_compress_lzop}.tar.gz
Source7:      http://www.cpan.org/authors/id/P/PM/PMQS/IO-Compress-Lzf-%{V_io_compress_lzf}.tar.gz
Source8:      http://www.cpan.org/authors/id/P/PM/PMQS/IO-Compress-Lzma-%{V_io_compress_lzma}.tar.gz
Source9:      http://www.cpan.org/authors/id/R/RU/RURBAN/Compress-Bzip2-%{V_compress_bzip2}.tar.gz
Source10:     http://www.cpan.org/authors/id/T/TO/TOMHUGHES/IO-Zlib-%{V_io_zlib}.tar.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, perl >= %{V_perl}, perl-openpkg >= %{V_perl}-20040126
PreReq:       OpenPKG, openpkg >= 20160101, perl >= %{V_perl}
BuildPreReq:  bzip2, zlib, lzo, xz
PreReq:       bzip2, zlib, lzo, xz

%description
    Perl modules for use with Compression:
    - Compress::Raw::Zlib (%{V_compress_raw_zlib})
    - Compress::Raw::Bzip2 (%{V_compress_raw_bzip2})
    - Compress::Raw::Lzma (%{V_compress_raw_lzma})
    - Compress::LZO (%{V_compress_lzo})
    - Compress::LZF (%{V_compress_lzf})
    - IO::Compress (%{V_io_compress})
    - IO::Compress::Lzop (%{V_io_compress_lzop})
    - IO::Compress::Lzf (%{V_io_compress_lzf})
    - IO::Compress::Lzma (%{V_io_compress_lzma})
    - Compress::Bzip2 (%{V_compress_bzip2})
    - IO::Zlib (%{V_io_zlib})

%track
    prog perl-comp:Compress-Raw-Zlib = {
        version   = %{V_compress_raw_zlib}
        url       = http://www.cpan.org/authors/id/P/PM/PMQS/
        regex     = Compress-Raw-Zlib-(__VER__)\.tar\.gz
    }
    prog perl-comp:Compress-Raw-Bzip2 = {
        version   = %{V_compress_raw_bzip2}
        url       = http://www.cpan.org/authors/id/P/PM/PMQS/
        regex     = Compress-Raw-Bzip2-(__VER__)\.tar\.gz
    }
    prog perl-comp:Compress-Raw-Lzma = {
        version   = %{V_compress_raw_lzma}
        url       = http://www.cpan.org/authors/id/P/PM/PMQS/
        regex     = Compress-Raw-Lzma-(__VER__)\.tar\.gz
    }
    prog perl-comp:Compress-LZO = {
        version   = %{V_compress_lzo}
        url       = http://www.cpan.org/authors/id/M/MF/MFX/
        regex     = Compress-LZO-(__VER__)\.tar\.gz
    }
    prog perl-comp:Compress-LZF = {
        version   = %{V_compress_lzf}
        url       = http://www.cpan.org/authors/id/M/ML/MLEHMANN/
        regex     = Compress-LZF-(__VER__)\.tar\.gz
    }
    prog perl-comp:IO-Compress = {
        version   = %{V_io_compress}
        url       = http://www.cpan.org/authors/id/P/PM/PMQS/
        regex     = IO-Compress-(__VER__)\.tar\.gz
    }
    prog perl-comp:IO-Compress-Lzop = {
        version   = %{V_io_compress_lzop}
        url       = http://www.cpan.org/authors/id/P/PM/PMQS/
        regex     = IO-Compress-Lzop-(__VER__)\.tar\.gz
    }
    prog perl-comp:IO-Compress-Lzf = {
        version   = %{V_io_compress_lzf}
        url       = http://www.cpan.org/authors/id/P/PM/PMQS/
        regex     = IO-Compress-Lzf-(__VER__)\.tar\.gz
    }
    prog perl-comp:IO-Compress-Lzma = {
        version   = %{V_io_compress_lzma}
        url       = http://www.cpan.org/authors/id/P/PM/PMQS/
        regex     = IO-Compress-Lzma-(__VER__)\.tar\.gz
    }
    prog perl-comp:Compress-Bzip2 = {
        version   = %{V_compress_bzip2}
        url       = http://www.cpan.org/authors/id/R/RU/RURBAN/
        regex     = Compress-Bzip2-(__VER__)\.tar\.gz
    }
    prog perl-comp:IO-Zlib = {
        version   = %{V_io_zlib}
        url       = http://www.cpan.org/authors/id/T/TO/TOMHUGHES/
        regex     = IO-Zlib-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -c
    %setup -q -T -D -a 1
    %setup -q -T -D -a 2
    %setup -q -T -D -a 3
    %setup -q -T -D -a 4
    %setup -q -T -D -a 5
    %setup -q -T -D -a 6
    %setup -q -T -D -a 7
    %setup -q -T -D -a 8
    %setup -q -T -D -a 9
    %setup -q -T -D -a 10

%build

%install
    %{l_prefix}/bin/perl-openpkg prepare

    #   build XS-based Compress::Raw::Zlib
    BUILD_ZLIB=0 \
    ZLIB_INCLUDE=%{l_prefix}/include \
    ZLIB_LIB=%{l_prefix}/lib \
    %{l_prefix}/bin/perl-openpkg -d Compress-Raw-Zlib-%{V_compress_raw_zlib} \
        configure build install

    #   build XS-based Compress::Raw::Bzip2
    BUILD_BZIP2=0 \
    BZIP2_INCLUDE=%{l_prefix}/include \
    BZIP2_LIB=%{l_prefix}/lib \
    %{l_prefix}/bin/perl-openpkg -d Compress-Raw-Bzip2-%{V_compress_raw_bzip2} \
        configure build install

    #   build XS-based Compress::Raw::Lzma
    BUILD_LIBLZMA=0 \
    LIBLZMA_INCLUDE=%{l_prefix}/include \
    LIBLZMA_LIB=%{l_prefix}/lib \
    %{l_prefix}/bin/perl-openpkg -d Compress-Raw-Lzma-%{V_compress_raw_lzma} \
        configure build install

    #   build XS-based Compress::LZO
    %{l_shtool} subst \
        -e 's:^#\($LZO_INCLUDE[^=]*\)=.*:\1= "%{l_cppflags lzo}";:' \
        -e 's:^#\($LZO_LIB[^=]*\)=.*:\1= "%{l_ldflags}";:' \
        Compress-LZO-%{V_compress_lzo}/Makefile.PL
    %{l_prefix}/bin/perl-openpkg -d Compress-LZO-%{V_compress_lzo} \
        configure build install

    #   build regular modules
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE4}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE5}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE6}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE7}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE8}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE9}  configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE10}  configure build install

    %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} `cat perl-openpkg-files`

%files -f files

%clean

