##
##  uuid.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:         uuid
Summary:      Universally Unique Identifier (UUID)
URL:          https://github.com/rse/uuid
Vendor:       The OSSP Project
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        BASE
Group:        Libraries
License:      MIT/X11-style
Version:      1.7.2
Release:      20210812

#   package options
%option       with_dce   no
%option       with_cxx   no
%option       with_perl  no
%option       with_php   no
%option       with_pgsql no

#   list of sources
Source0:      https://github.com/rse/uuid/releases/download/%{version}/uuid-%{version}.tar.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101
%if "%{with_cxx}" == "yes"
BuildPreReq:  gcc
%endif
%if "%{with_perl}" == "yes"
BuildPreReq:  perl, perl-openpkg
PreReq:       perl
%endif
%if "%{with_php}" == "yes"
BuildPreReq:  php, autoconf, libtool
PreReq:       php
%endif
%if "%{with_pgsql}" == "yes"
BuildPreReq:  postgresql >= 8.1.2-20060115
PreReq:       postgresql >= 8.1.2-20060115
%endif

%description
    OSSP uuid is a ISO-C:1999 application programming interface (API)
    and corresponding command line interface (CLI) for the generation
    of DCE 1.1, ISO/IEC 11578:1996 and RFC 4122 compliant Universally
    Unique Identifier (UUID). It supports DCE 1.1 variant UUIDs of
    version 1 (time and node based), version 3 (name based, MD5),
    version 4 (random number based) and version 5 (name based, SHA-1).
    Additional API bindings are provided for the languages ISO-C++:1998,
    Perl:5 and PHP:4/5. Optional backward compatibility exists for the
    ISO-C DCE-1.1 and Perl Data::UUID APIs.

    UUIDs are 128 bit numbers which are intended to have a high
    likelihood of uniqueness over space and time and are computationally
    difficult to guess. They are globally unique identifiers which
    can be locally generated without contacting a global registration
    authority. UUIDs are intended as unique identifiers for both mass
    tagging objects with an extremely short lifetime and to reliably
    identifying very persistent objects across a network.

%track
    prog uuid = {
        version   = %{version}
        url       = https://github.com/rse/uuid/releases
        regex     = uuid-(__VER__)\.tar\.gz
    }

%prep
    %setup -q

%build
    CC="%{l_cc}" \
    CFLAGS="%{l_cflags -O}" \
    GREP="grep" \
    ./configure \
        --prefix=%{l_prefix} \
        --mandir=%{l_prefix}/man \
%if "%{with_dce}" == "yes"
        --with-dce \
%endif
%if "%{with_cxx}" == "yes"
        --with-cxx \
%endif
%if "%{with_php}" == "yes"
        --with-php \
%endif
%if "%{with_pgsql}" == "yes"
        --with-pgsql \
%endif
        --disable-shared
    %{l_make} %{l_mflags -O}
%if "%{with_perl}" == "yes"
    %{l_prefix}/bin/perl-openpkg prepare
    %{l_prefix}/bin/perl-openpkg -d perl configure build
%endif

%install
    %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
%if "%{with_perl}" == "yes"
    %{l_prefix}/bin/perl-openpkg -d perl install
    %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
%else
    >perl-openpkg-files
%endif
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} `cat perl-openpkg-files`

%files -f files

%clean

