##
##  dhrystone.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:         dhrystone
Summary:      The Dhrystone CPU Integer Arithmetic Benchmark
URL:          http://ftp.digital.com/pub/misc/
Vendor:       Reinhold Weicker
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Benchmark
License:      Open Source
Version:      2.1
Release:      20080101

#   list of sources
Source0:      http://ftp.digital.com/pub/misc/dhry%{version}.tar.Z
Patch0:       dhrystone.patch

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

%description
    Dhrystone is a benchmark invented by Reinhold P. Weicker that tests
    the integer performance of a CPU and the optimisation capabilities
    of the compiler used to generate the code. The output from the
    benchmark is the number of Dhrystones per second (the number of
    iterations of the main code loop per second).

    One common representation of the Dhrystone benchmark is the DMIP
    - Dhrystone MIPS - obtained when the Dhrystone score is divided
    by 1,857 (the number of Dhrystones per second obtained on the VAX
    11/785, a 1 MIPS machine).

    Dhrystone was named as a pun on the Whetstone benchmark. Like most
    synthetic benchmarks, the Dhrystone benchmark is not particularly
    useful in measuring the performance of real-world computer systems
    and has fallen into disuse, replaced by benchmarks that more closely
    resemble typical actual usage.

%track
    prog dhrystone = {
        version   = %{version}
        url       = http://ftp.digital.com/pub/misc/
        regex     = dhry(__VER__)\.tar\.Z
    }

%prep
    %setup -q -c
    %patch -p0

%build
    mflags=""
    mflags="$mflags PROGS=unix"
    mflags="$mflags CC=\"%{l_cc}\""
    mflags="$mflags OPTIMIZE=\"%{l_cflags -O}\""
    mflags="$mflags STRUCTASSIGN="
    mflags="$mflags ENUMS="
    mflags="$mflags TIME_FUNC=-DTIMES"
    mflags="$mflags HZ=100"
    eval %{l_make} %{l_mflags} $mflags

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/share/dhrystone
    ( echo "#!/bin/sh"
      echo "iterations=${1-5000000}"
      echo "( echo $iterations | %{l_prefix}/bin/dry2"
      echo "  echo $iterations | %{l_prefix}/bin/dry2reg"
      echo ") | tee dhrystone.out"
    ) >dhrystone.sh
    %{l_shtool} install -c -m 755 \
        dhrystone.sh $RPM_BUILD_ROOT%{l_prefix}/bin/dhrystone
    %{l_shtool} install -c -s -m 755 \
        dry2 dry2reg $RPM_BUILD_ROOT%{l_prefix}/bin/
    %{l_shtool} install -c -m 644 \
        Rationale $RPM_BUILD_ROOT%{l_prefix}/share/dhrystone/rationale.txt
    %{l_shtool} install -c -m 644 \
        clarify.doc $RPM_BUILD_ROOT%{l_prefix}/share/dhrystone/clarify.txt
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%doc %{l_prefix}/share/dhrystone/*.txt'

%files -f files

%clean

