File crystal1.12.spec of Package crystal1.12

#
# spec file for package crystal1.12
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%bcond_without  test
%bcond_with     bundled_crystal

%global version_suffix 1.12
%global version_current 1.12.1
%global version_previous 1.11.2

%define obsolete_crystal_versioned() \
Obsoletes:      %{1}1.11%{?2:-%{2}} \
Obsoletes:      %{1}1.10%{?2:-%{2}} \
Obsoletes:      %{1}1.9%{?2:-%{2}} \
Obsoletes:      %{1}1.8%{?2:-%{2}} \
Obsoletes:      %{1}1.7%{?2:-%{2}} \
Obsoletes:      %{1}1.6%{?2:-%{2}} \
Obsoletes:      %{1}1.5%{?2:-%{2}} \
Obsoletes:      %{1}1.4%{?2:-%{2}} \
Obsoletes:      %{1}1.3%{?2:-%{2}} \
Obsoletes:      %{1}1.2%{?2:-%{2}} \
Obsoletes:      %{1}1.1%{?2:-%{2}} \
Obsoletes:      %{1}1.0%{?2:-%{2}}

Name:           crystal%{version_suffix}
Version:        %{version_current}
%if 0%{?fedora} || 0%{?rhel}

Release:        1%{?dist}
License:        Apache-2.0

%else
Release:        0
License:        Apache-2.0
%endif
Summary:        A programming language for humans and computers
URL:            https://github.com/crystal-lang/crystal
Source0:        https://github.com/crystal-lang/crystal/archive/refs/tags/%{version}.tar.gz#/crystal-%{version}.tar.gz

# To build crystal version N, we need crystal version N - 1. Either from a prebuilt one or from OBS.
%if 0%{with bundled_crystal}
Source1:        https://github.com/crystal-lang/crystal/releases/download/%{version_previous}/crystal-%{version_previous}-1-linux-x86_64.tar.gz
%else
BuildRequires:  crystal = %{version_previous}
%endif

# For debian
Source2:        https://github.com/crystal-lang/crystal/archive/refs/tags/%{version}.tar.gz
Source99:       https://github.com/crystal-lang/crystal/releases/download/%{version}/crystal-%{version}-docs.tar.gz
Source100:      https://github.com/crystal-lang/crystal/releases/download/%{version}/crystal-%{version}-1-linux-x86_64.tar.gz

BuildArch:      %arm64 x86_64
BuildRequires:  gc-devel
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  llvm18-devel
BuildRequires:  make
BuildRequires:  fdupes
BuildRequires:  pcre-devel
BuildRequires:  pcre2-devel
BuildRequires:  pkgconfig(gmp)
BuildRequires:  pkgconfig(libevent)
BuildRequires:  pkgconfig(libffi)
BuildRequires:  pkgconfig(libpcre)
BuildRequires:  pkgconfig(libpcre2-16)
BuildRequires:  pkgconfig(libpcre2-32)
BuildRequires:  pkgconfig(libpcre2-8)
BuildRequires:  pkgconfig(libpcre2-posix)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(yaml-0.1)

Requires:       pkg-config

%if ! 0%{?rhel}
Recommends:     libgmp-devel
Recommends:     libssl-devel
Recommends:     libxml2-devel
Recommends:     libyaml-devel
Recommends:     libz-devel

%else

Recommends:     gmp-devel
Recommends:     libcryptopp-devel
Recommends:     libffi-devel
Recommends:     libopenssl-devel
Recommends:     libxml2-devel
Recommends:     libyaml-devel
Recommends:     zlib-devel

%endif

%if %{with test}
%if 0%{?fedora} || 0%{?rhel}
BuildRequires:  openssl-devel
%else
BuildRequires:  libopenssl-devel
%endif
BuildRequires:  git
BuildRequires:  hostname
BuildRequires:  pkgconfig(zlib)
%endif

%obsolete_crystal_versioned crystal
Conflicts:      crystal < %{version}
Provides:       crystal = %{version}

Recommends:     gc-devel
Recommends:     libcryptopp-devel
Recommends:     libopenssl-devel

%description
Crystal is a general-purpose, object-oriented programming language.
With syntax inspired by Ruby, it is a compiled language with static type-checking,
serving both, humans and computers

%package docs
Summary:        Documentation for the Crystal Programming Language
BuildArch:      noarch
Version:        %{version}

%description docs
%{summary}.

%package samples
Summary:        Sample code for the Crystal Programming Language
BuildArch:      noarch
Version:        %{version}

%description samples
%{summary}.

%package        zsh-completion
Summary:        Zsh Completion for %{name}
Group:          System/Shells
Supplements:    (%{name} and zsh)
Requires:       zsh
BuildArch:      noarch
Provides:       crystal-zsh-completion = %{version}
Conflicts:      crystal-zsh-completion < %{version}
Obsoletes:      crystal-zsh-completion < %{version}

%description    zsh-completion
Zsh command-line completion support for %{name}.

%package        bash-completion
Summary:        Bash Completion for %{name}
Group:          System/Shells
Supplements:    (%{name} and bash-completion)
Requires:       bash-completion
BuildArch:      noarch
Provides:       crystal-bash-completion = %{version}
Conflicts:      crystal-bash-completion < %{version}
Obsoletes:      crystal-bash-completion < %{version}

%description    bash-completion
Bash command-line completion support for %{name}.

%package        fish-completion
Summary:        Fish Completion for %{name}
Group:          System/Shells
Supplements:    (%{name} and fish)
Requires:       fish
BuildArch:      noarch
Provides:       crystal-fish-completion = %{version}
Conflicts:      crystal-fish-completion < %{version}
Obsoletes:      crystal-fish-completion < %{version}

%description    fish-completion
Fish command-line completion support for %{name}.

%prep
%if %{with bundled_crystal}
%autosetup -a1 -p1 -n crystal-%{version}
%endif

%autosetup -p1 -n crystal-%{version}

%build
%if 0%{with bundled_crystal}
export PATH="$PATH:%{_builddir}/crystal-%{version}/crystal-%{version_previous}-1/bin"
%endif

make progress=1 threads="$(nproc)" verbose=1 stats=1 release=1 interpreter=1 target="$(llvm-config --host-target)" \
  FLAGS="--release --debug" \
  CRYSTAL_CONFIG_PATH="lib:%{_datadir}/crystal/src" \
  CRYSTAL_CACHE_DIR="/tmp/crystal" \
  %if 0%{with bundled_crystal}
  CRYSTAL_LIBRARY_PATH="%{_builddir}/crystal-%{version}/lib:%{_builddir}/crystal-%{version}/crystal-%{version_previous}-1/lib" \
  CRYSTAL_CONFIG_LIBRARY_PATH="%{_libdir}/crystal" \
  %endif
  CRYSTAL_CONFIG_VERSION="%{version}" \
  PATH=".build:$PATH"

%{make_build} docs CRYSTAL_CACHE_DIR="/tmp/crystal"

%install
%{make_install} PREFIX="%{_prefix}"
mkdir -p "%{buildroot}%{_libdir}"
cp -av src "%{buildroot}%{_libdir}/crystal"

mkdir -p "%{buildroot}%{_datadir}/doc/crystal"
cp -av docs "%{buildroot}%{_datadir}/doc/crystal/api"
cp -av samples "%{buildroot}%{_datadir}/doc/crystal/samples"

# The Makefile install section seems to remove this. Adding it back since
# it breaks builds for package crystalline
# FIXED upstream has finally resolved this
# cp -v %{buildroot}%{_libdir}/crystal/llvm/ext/llvm_ext.o %{buildroot}%{_datadir}/crystal/src/llvm/ext/
# %%fdupes %%{buildroot}

%if %{with test}
%check
export CRYSTAL_LIBRARY_PATH="$(/usr/bin/crystal env CRYSTAL_LIBRARY_PATH)"
for spec in std_spec compiler_spec
do
make "$spec" \
  FLAGS="--release --debug" \
  CRYSTAL_CONFIG_PATH="%{_datadir}/crystal/src:%{_libdir}/crystal" \
  CRYSTAL_CACHE_DIR="/tmp/crystal" \
  PATH=".build:$PATH"
done
%endif

%files
%defattr(-,root,root,-)
%doc *.md
%{_bindir}/crystal
%dir %{_libdir}/crystal
%{_libdir}/crystal/*
%{_mandir}/man1/*
%dir %{_datadir}/crystal
%dir %{_datadir}/crystal/*
%{_datadir}/crystal/src/*
%dir %{_datadir}/licenses/crystal
%{_datadir}/licenses/crystal/LICENSE
%license %{_datadir}/licenses/crystal/LICENSE

%files docs
%dir %{_datadir}/doc/crystal/
%dir %{_datadir}/doc/crystal/api
%{_datadir}/doc/crystal/api/*

%files samples
%dir %{_datadir}/doc/crystal/
%dir %{_datadir}/doc/crystal/samples/
%{_datadir}/doc/crystal/samples/*

%files bash-completion
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/crystal

%files zsh-completion
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_crystal

%files fish-completion
%dir %{_datadir}/fish
%dir %{_datadir}/fish/vendor_completions.d
%{_datadir}/fish/vendor_completions.d/crystal.fish

%changelog
openSUSE Build Service is sponsored by