##
##  mdocml.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 version
%define       V_opkg   1.14.1
%define       V_dist   1.14.1
%define       V_subdir 1.14.1

#   package information
Name:         mdocml
Summary:      Unix Manual Page Rendering Utility
URL:          http://mdocml.bsd.lv/
Vendor:       Kristaps Dzonsons, Ingo Schwarze
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Typesetting
License:      MIT
Version:      %{V_opkg}
Release:      20170325

#   list of sources
Source0:      http://mdocml.bsd.lv/snapshots/mdocml-%{V_dist}.tar.gz

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

%description
    docml is OpenBSD's suite of tools compiling "-mdoc", the roff macro
    package of choice for BSD manual pages, and "-man", the predominant
    historical package for UNIX manuals. The mission of mdocml is to
    deprecate groff, the GNU troff implementation, for displaying -mdoc
    pages whilst providing token support for -man.

%track
    prog mdocml = {
        version   = %{V_dist}
        url       = http://mdocml.bsd.lv/snapshots/
        regex     = mdocml-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -n mdocml-%{V_subdir}

%build
    ( echo "CC=\"%{l_cc} %{l_cflags -O}\""
      echo "PREFIX=%{l_prefix}"
      echo "EXAMPLEDIR=%{l_prefix}/share/mdocml"
    ) >configure.local
    chmod a+x configure.local
    ./configure
    %{l_make} %{l_mflags -O} \
        CC="%{l_cc} %{l_cflags -O}"

%install
    %{l_make} %{l_mflags} install \
        DESTDIR=$RPM_BUILD_ROOT \
        PREFIX=%{l_prefix} \
        EXAMPLEDIR=%{l_prefix}/share/mdocml
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

