##
##  perl-locale.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_i18n_langtags                0.35
%define       V_encode                       3.21
%define       V_encode_newlines              0.04
%define       V_encode_registry              0.13
%define       V_encode_locale                1.05
%define       V_libintl_perl                 1.33
%define       V_gettext                      1.07
%define       V_locale_po                    0.21
%define       V_locale_maketext              1.33
%define       V_locale_maketext_fuzzy        0.11
%define       V_locale_maketext_lexicon      1.00
%define       V_locale_maketext_simple       0.21
%define       V_locale_codes                 3.78
%define       V_locale_subcountry            2.07
%define       V_locale_keyedtext             1.73.0
%define       V_text_iconv                   1.7
%define       V_unicode_eastasianwidth       12.0
%define       V_text_unidecode               1.30

#   package information
Name:         perl-locale
Summary:      Perl Locale Modules
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:      20240308

#   list of sources
Source0:      http://www.cpan.org/modules/by-module/I18N/I18N-LangTags-%{V_i18n_langtags}.tar.gz
Source1:      http://www.cpan.org/authors/id/D/DA/DANKOGAI/Encode-%{V_encode}.tar.gz
Source2:      http://www.cpan.org/authors/id/A/AU/AUDREYT/Encode-Newlines-%{V_encode_newlines}.tar.gz
Source3:      http://www.cpan.org/authors/id/M/MH/MHOSKEN/Encode-Registry-%{V_encode_registry}.tar.gz
Source4:      http://www.cpan.org/authors/id/G/GU/GUIDO/libintl-perl-%{V_libintl_perl}.tar.gz
Source5:      http://www.cpan.org/authors/id/P/PV/PVANDRY/gettext-%{V_gettext}.tar.gz
Source6:      http://www.cpan.org/authors/id/K/KE/KEN/Locale-PO-%{V_locale_po}.tar.gz
Source7:      http://www.cpan.org/authors/id/T/TO/TODDR/Locale-Maketext-%{V_locale_maketext}.tar.gz
Source8:      http://www.cpan.org/authors/id/A/AU/AUDREYT/Locale-Maketext-Fuzzy-%{V_locale_maketext_fuzzy}.tar.gz
Source9:      http://www.cpan.org/authors/id/D/DR/DRTECH/Locale-Maketext-Lexicon-%{V_locale_maketext_lexicon}.tar.gz
Source10:     http://www.cpan.org/authors/id/J/JE/JESSE/Locale-Maketext-Simple-%{V_locale_maketext_simple}.tar.gz
Source11:     http://www.cpan.org/authors/id/S/SB/SBECK/Locale-Codes-%{V_locale_codes}.tar.gz
Source12:     http://www.cpan.org/authors/id/K/KI/KIMRYAN/Locale-SubCountry-%{V_locale_subcountry}.tar.gz
Source13:     http://www.cpan.org/modules/by-module/Locale/DUNCAND/Locale-KeyedText-v%{V_locale_keyedtext}.tar.gz
Source14:     http://www.cpan.org/authors/id/M/MP/MPIOTR/Text-Iconv-%{V_text_iconv}.tar.gz
Source15:     http://www.cpan.org/authors/id/G/GA/GAAS/Encode-Locale-%{V_encode_locale}.tar.gz
Source16:     http://www.cpan.org/authors/id/A/AU/AUDREYT/Unicode-EastAsianWidth-%{V_unicode_eastasianwidth}.tar.gz
Source17:     http://www.cpan.org/authors/id/S/SB/SBURKE/Text-Unidecode-%{V_text_unidecode}.tar.gz
Patch0:       perl-locale.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, perl >= %{V_perl}, perl-openpkg >= %{V_perl}-20040126
PreReq:       OpenPKG, openpkg >= 20160101, perl >= %{V_perl}
BuildPreReq:  perl-util, gettext, libiconv
PreReq:       perl-util, gettext, libiconv

%description
    Various Perl modules for locale handling:
    - I18N::LangTags (%{V_i18n_langtags})
    - Encode (%{V_encode})
    - Encode::Newlines (%{V_encode_newlines})
    - Encode::Registry (%{V_encode_registry})
    - Encode::Locale (%{V_encode_locale})
    - libintl-perl (%{V_libintl_perl})
    - Locale::gettext (%{V_gettext})
    - Locale::PO (%{V_locale_po})
    - Locale::Maketext (%{V_locale_maketext})
    - Locale::Maketext::Fuzzy (%{V_locale_maketext_fuzzy})
    - Locale::Maketext::Lexicon (%{V_locale_maketext_lexicon})
    - Locale::Maketext::Simple (%{V_locale_maketext_simple})
    - Locale::Codes (%{V_locale_codes})
    - Locale::SubCountry (%{V_locale_subcountry})
    - Locale::KeyedText (%{V_locale_keyedtext})
    - Text::Iconv (%{V_text_iconv})
    - Unicode::EastAsianWidth (%{V_unicode_eastasianwidth})
    - Text::Unidecode (%{V_text_unidecode})

%track
    prog perl-locale:I18N-LangTags = {
        version   = %{V_i18n_langtags}
        url       = http://www.cpan.org/modules/by-module/I18N/
        regex     = I18N-LangTags-(__VER__)\.tar\.gz
    }
    prog perl-locale:Encode = {
        version   = %{V_encode}
        url       = http://www.cpan.org/authors/id/D/DA/DANKOGAI/
        regex     = Encode-(__VER__)\.tar\.gz
    }
    prog perl-locale:Encode-Newlines = {
        version   = %{V_encode_newlines}
        url       = http://www.cpan.org/authors/id/A/AU/AUDREYT/
        regex     = Encode-Newlines-(__VER__)\.tar\.gz
    }
    prog perl-locale:Encode-Registry = {
        version   = %{V_encode_registry}
        url       = http://www.cpan.org/authors/id/M/MH/MHOSKEN/
        regex     = Encode-Registry-(__VER__)\.tar\.gz
    }
    prog perl-locale:Encode-Locale = {
        version   = %{V_encode_locale}
        url       = http://www.cpan.org/authors/id/G/GA/GAAS/
        regex     = Encode-Locale-(__VER__)\.tar\.gz
    }
    prog perl-locale:libintl-perl = {
        version   = %{V_libintl_perl}
        url       = http://www.cpan.org/authors/id/G/GU/GUIDO/
        regex     = libintl-perl-(__VER__)\.tar\.gz
    }
    prog perl-locale:gettext = {
        version   = %{V_gettext}
        url       = http://www.cpan.org/authors/id/P/PV/PVANDRY/
        regex     = gettext-(__VER__)\.tar\.gz
    }
    prog perl-locale:Locale-PO = {
        version   = %{V_locale_po}
        url       = http://www.cpan.org/authors/id/K/KE/KEN/
        regex     = Locale-PO-(__VER__)\.tar\.gz
    }
    prog perl-locale:Locale-Maketext = {
        version   = %{V_locale_maketext}
        url       = http://www.cpan.org/authors/id/T/TO/TODDR/
        regex     = Locale-Maketext-(__VER__)\.tar\.gz
    }
    prog perl-locale:Locale-Maketext-Fuzzy = {
        version   = %{V_locale_maketext_fuzzy}
        url       = http://www.cpan.org/authors/id/A/AU/AUDREYT/
        regex     = Locale-Maketext-Fuzzy-(__VER__)\.tar\.gz
    }
    prog perl-locale:Locale-Maketext-Lexicon = {
        version   = %{V_locale_maketext_lexicon}
        url       = http://www.cpan.org/authors/id/D/DR/DRTECH/
        regex     = Locale-Maketext-Lexicon-(__VER__)\.tar\.gz
    }
    prog perl-locale:Locale-Maketext-Simple = {
        version   = %{V_locale_maketext_simple}
        url       = http://www.cpan.org/authors/id/J/JE/JESSE/
        regex     = Locale-Maketext-Simple-(__VER__)\.tar\.gz
    }
    prog perl-locale:Locale-Codes = {
        version   = %{V_locale_codes}
        url       = http://www.cpan.org/authors/id/S/SB/SBECK/
        regex     = Locale-Codes-(__VER__)\.tar\.gz
    }
    prog perl-locale:Locale-SubCountry = {
        version   = %{V_locale_subcountry}
        url       = http://www.cpan.org/authors/id/K/KI/KIMRYAN/
        regex     = Locale-SubCountry-(__VER__)\.tar\.gz
    }
    prog perl-locale:Locale-KeyedText = {
        version   = %{V_locale_keyedtext}
        url       = http://www.cpan.org/modules/by-module/Locale/DUNCAND/
        regex     = Locale-KeyedText-v(__VER__)\.tar\.gz
    }
    prog perl-locale:Text-Iconv = {
        version   = %{V_text_iconv}
        url       = http://www.cpan.org/authors/id/M/MP/MPIOTR/
        regex     = Text-Iconv-(__VER__)\.tar\.gz
    }
    prog perl-locale:Unicode-EastAsianWidth = {
        version   = %{V_unicode_eastasianwidth}
        url       = http://www.cpan.org/authors/id/A/AU/AUDREYT/
        regex     = Unicode-EastAsianWidth-(__VER__)\.tar\.gz
    }
    prog perl-locale:Text-Unidecode = {
        version   = %{V_text_unidecode}
        url       = http://www.cpan.org/authors/id/S/SB/SBURKE/
        regex     = Text-Unidecode-(__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
    %setup -q -T -D -a 11
    %setup -q -T -D -a 12
    %setup -q -T -D -a 13
    %setup -q -T -D -a 14
    %setup -q -T -D -a 15
    %setup -q -T -D -a 16
    %setup -q -T -D -a 17
    %patch -p0

%build

%install
    %{l_prefix}/bin/perl-openpkg prepare
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE0} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE1} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE2} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE3} configure build install
    ( cd libintl-perl-%{V_libintl_perl}
      %{l_shtool} subst \
          -e 's;\($Config{ccflags}\);\1 . "%{l_cflags} %{l_cppflags}";' \
          -e 's;\($Config{libs}\);"%{l_ldflags}" . \1;' \
          Makefile.PL
      %{l_shtool} subst \
          -e 's;\(PL_FILES\);INC => "%{l_cppflags}", \1;' \
          -e 's;\(-lintl\);%{l_ldflags} \1;' \
          -e 's;\(-liconv\);%{l_ldflags} \1;' \
          gettext_xs/Makefile.PL
      %{l_prefix}/bin/perl-openpkg configure build install
    ) || exit $?
    ( cd Locale-gettext-%{V_gettext}
      %{l_shtool} subst \
          -e 's;\(incs = .\)\(.\);\1%{l_cppflags}\2;' \
          -e 's;\(libs = .\)\(.\);\1%{l_ldflags} -lintl -liconv\2;' \
          Makefile.PL
      %{l_prefix}/bin/perl-openpkg configure build install
    ) || exit $?
    %{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 -d %{SOURCE11} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE12} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE13} configure build install
    ( cd Text-Iconv-%{V_text_iconv}
      %{l_prefix}/bin/perl-openpkg \
          -A "INC=%{l_cppflags}" \
          -A "LIBS=%{l_ldflags}" \
          configure build install
    ) || exit $?
    rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/xgettext.pl
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE15} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE16} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE17} 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

