##
##  re2.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:         re2
Summary:      Regular Expression Library for C++
URL:          http://code.google.com/p/re2/
Vendor:       Google Inc.
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        RegExp
License:      MIT
Version:      20200529
Release:      20200529

#   list of sources
Source0:      http://download.openpkg.org/components/versioned/re2/re2-%{version}.tar.xz
Patch0:       re2.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, gcc, gcc::with_cxx = yes
PreReq:       OpenPKG, openpkg >= 20160101

%description
    RE2 is Google's fast, safe, thread-friendly alternative to
    backtracking regular expression engines like those used in PCRE,
    Perl, and Python. It is a C++ library. Backtracking engines are
    typically full of features and convenient syntactic sugar but
    can be forced into taking exponential amounts of time on even
    small inputs. RE2 uses automata theory to guarantee that regular
    expression searches run in time linear in the size of the input.
    RE2 implements memory limits, so that searches can be constrained
    to a fixed amount of memory. RE2 is engineered to use a small fixed
    C++ stack footprint no matter what inputs or regular expressions
    it must process; thus RE2 is useful in multithreaded environments
    where thread stacks cannot grow arbitrarily large. On large inputs,
    RE2 is often much faster than backtracking engines; its use of
    automata theory lets it apply optimizations that the others cannot.
    Unlike most automata-based engines, RE2 implements almost all the
    common Perl and PCRE features and syntactic sugars. It also finds
    the leftmost-first match, the same match that Perl would, and can
    return submatch information. The one significant exception is that
    RE2 drops support for backreferences and generalized zero-width
    assertions, because they cannot be implemented efficiently. The
    syntax page gives full details. For those who want a simpler syntax,
    RE2 has a POSIX mode that accepts only the POSIX egrep operators and
    implements leftmost-longest overall matching.

%track
    prog re2 = {
        version   = %{version}
        url       = http://download.openpkg.org/components/versioned/re2/
        regex     = re2-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -n re2
    %patch -p0

%build
    %{l_make} %{l_mflags} \
        CC="%{l_cxx}" \
        CFLAGS="%{l_cxxflags -O} -I. -c"

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/include/re2 \
        $RPM_BUILD_ROOT%{l_prefix}/lib
    %{l_shtool} install -c -m 644 \
        obj/libre2.a $RPM_BUILD_ROOT%{l_prefix}/lib/
    %{l_shtool} install -c -m 644 \
        re2/re2.h re2/stringpiece.h \
        $RPM_BUILD_ROOT%{l_prefix}/include/re2/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

