##
##  cint.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_maj 5.16
%define       V_min 15

#   package information
Name:         cint
Summary:      C/C++ Interpreter
URL:          http://root.cern.ch/root/Cint.html
Vendor:       Masaharu Goto, ROOT/CERN
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Language
License:      BSD-style
Version:      %{V_maj}.%{V_min}
Release:      20080101

#   package options
%option       with_readline  no

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

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, make, gcc, gcc::with_cxx = yes
PreReq:       OpenPKG, openpkg >= 20160101
%if "%{with_readline}" == "yes"
BuildPreReq:  ncurses, readline
PreReq:       ncurses, readline
%endif

%description
    CINT is a C/C++ interpreter aimed at processing C/C++ scripts. CINT
    covers about 95% of ANSI C and 85% of C++. CINT, written in ANSI
    C (about 80000 loc), is solid enough to interpret itself and let
    the interpreted version execute a program. A CINT script can call
    compiled classes/functions and compiled code can make callbacks to
    CINT user defined functions. Utilities , like makecint and rootcint,
    automate the process of embedding compiled C/C++ library code as
    shared objects. Source files and shared objects can be dynamically
    loaded/unloaded without stopping the CINT process. CINT offers a GDB
    like debugging environment for interepreted programs.

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

%prep
    %setup -q -c -n cint-%{V_maj}.%{V_min}
    %patch -p0

%build
    arch=""
    case "%{l_target}" in
        *-freebsd*) arch="freebsd"    ;;
        *-linux*)   arch="linux"      ;;
        *-solaris*) arch="solarisgcc" ;;
        *         ) arch="generic"    ;;
    esac
    %{l_bash} ./configure \
        --prefix=%{l_prefix} \
%if "%{with_readline}" == "yes"
        --readline=%{l_prefix} \
%endif
        --arch="$arch"
    %{l_make} %{l_mflags}
    find . -type d -name CVS -print | xargs rm -rf

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/include/cint \
        $RPM_BUILD_ROOT%{l_prefix}/lib/cint \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1
    %{l_shtool} install -c -s -m 755 \
        cint makecint \
        $RPM_BUILD_ROOT%{l_prefix}/bin/
    %{l_shtool} install -c -m 644 \
        doc/man1/cint.1 doc/man1/makecint.1 \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1/
    %{l_shtool} install -c -m 644 \
        libcint.a $RPM_BUILD_ROOT%{l_prefix}/lib/
    cp -rp include/* $RPM_BUILD_ROOT%{l_prefix}/include/cint/
    cp -rp lib/*     $RPM_BUILD_ROOT%{l_prefix}/lib/cint/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

