##
##  c2man.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_here 2.0.42
%define       V_real 2.0@42

#   package information
Name:         c2man
Summary:      C Source Manual Page Extraction Tool
URL:          ftp://ftp.research.canon.com.au/pub/misc/c2man/
Vendor:       Graham Stoney
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        Development
License:      GPL
Version:      %{V_here}
Release:      20160323

#   list of sources
Source0:      ftp://ftp.research.canon.com.au/pub/misc/c2man/c2man-%{V_real}.tar.gz
Patch0:       c2man.patch

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

%description
    C2man is an automatic documentation tool that extracts comments from C
    source code to generate functional interface documentation in the same
    format as sections 2 & 3 of the Unix Programmer's Manual. It requires
    minimal effort from the programmer by looking for comments in the
    usual places near the objects they document, rather than imposing a
    rigid function-comment syntax or requiring that the programmer learn
    and use a typesetting language. Acceptable documentation can often be
    generated from existing code with no modifications.

%track
    prog c2man = {
        disabled
        comment   = "site is gone"
        version   = %{V_real}
        url       = ftp://ftp.research.canon.com.au/pub/misc/c2man/
        regex     = c2man-([\d.\@]+)\.tar\.gz
    }

%prep
    %setup -q -c %{V_here}
    %patch -p0

%build
    ./Configure -d -e -s \
        -Dcc="%{l_cc}" \
        -Doptimize="%{l_cflags -O}" \
        -Dprefix=%{l_prefix} \
        -Dlex="%{l_prefix}/bin/flex" \
        -Dyacc="%{l_prefix}/bin/bison -y"
    %{l_make} %{l_mflags -O}

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1
    %{l_shtool} install -c -s -m 755 \
        c2man $RPM_BUILD_ROOT%{l_prefix}/bin/
    %{l_shtool} install -c -m 644 \
        c2man.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

