##
##  clojure.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_clojure    1.11.2
%define       V_spec_alpha 0.2.176
%define       V_jline      1.0

#   package information
Name:         clojure
Summary:      Clojure Programming Language
URL:          http://clojure.org/
Vendor:       Rich Hickey
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Language
License:      EPL
Version:      %{V_clojure}
Release:      20240309

#   list of sources
Source0:      https://repo1.maven.org/maven2/org/clojure/clojure/%{V_clojure}/clojure-%{V_clojure}.jar
Source1:      https://repo1.maven.org/maven2/org/clojure/spec.alpha/%{V_spec_alpha}/spec.alpha-%{V_spec_alpha}.jar
Source2:      http://download.sourceforge.net/jline/jline-%{V_jline}.zip
Source3:      clojure.sh

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

%description
    Clojure is a dynamic programming language that targets the Java
    Virtual Machine. It is designed to be a general-purpose language,
    combining the approachability and interactive development of a
    scripting language with an efficient and robust infrastructure for
    multithreaded programming. Clojure is a compiled language - it
    compiles directly to JVM bytecode, yet remains completely dynamic.
    Every feature supported by Clojure is supported at runtime. Clojure
    provides easy access to the Java frameworks, with optional type
    hints and type inference, to ensure that calls to Java can avoid
    reflection. Clojure is a dialect of Lisp, and shares with Lisp the
    code-as-data philosophy and a powerful macro system. Clojure is
    predominantly a functional programming language, and features a rich
    set of immutable, persistent data structures. When mutable state
    is needed, Clojure offers a software transactional memory system
    and reactive Agent system that ensure clean, correct, multithreaded
    designs.

%track
    prog clojure:clojure = {
        version   = %{V_clojure}
        url       = https://clojure.org/community/downloads
        regex     = clojure/(\d+\.\d+\.\d+)/
    }
    prog clojure:spec.alpha = {
        version   = %{V_spec_alpha}
        url       = https://repo1.maven.org/maven2/org/clojure/spec.alpha/
        regex     = (\d+\.\d+\.\d+)/
    }
    prog clojure:jline = {
        version   = %{V_jline}
        url       = http://sourceforge.net/projects/jline/files/
        regex     = jline-(__VER__)\.zip
    }

%prep
    %setup -q -T -c
    unzip -q -x %{SOURCE2}

%build

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/clojure
    %{l_shtool} install -c -m 755 %{l_value -s -a} \
        %{SOURCE clojure.sh} $RPM_BUILD_ROOT%{l_prefix}/bin/clojure
    %{l_shtool} install -c -m 644 \
        %{SOURCE clojure-%{V_clojure}.jar} \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/clojure/clojure.jar
    %{l_shtool} install -c -m 644 \
        %{SOURCE spec.alpha-%{V_spec_alpha}.jar} \
        $RPM_BUILD_ROOT%{l_prefix}/libexec/clojure/spec.alpha.jar
    %{l_shtool} install -c -m 644 \
        jline-*/jline-*.jar $RPM_BUILD_ROOT%{l_prefix}/libexec/clojure/jline.jar
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

