File io.spec of Package io

# spec file for package io
#
# Copyright (c) 2023 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/
#


%define pythons python3
Name:           io
Version:        2017.09.06
Release:        0
Summary:        A prototype-based programming language
License:        BSD-3-Clause
Group:          Development/Languages/Misc
URL:            http://iolanguage.org/
Source0:        https://github.com/IoLanguage/io/archive/refs/tags/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        io-rpmlintrc
BuildRequires:  cmake
BuildRequires:  make

# Directory names causing some issues so moving the buildroot
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  fdupes
# Convert all io files to unix line-endings
BuildRequires:  dos2unix
BuildRequires:  gcc-c++
%if 0%{?suse_version} > 1500
BuildRequires:  libstdc++6-devel-gcc12
%else
BuildRequires:  libstdc++6-devel-gcc7
%endif
BuildRequires:  %{python_module devel}
BuildRequires:  util-linux
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(glfw3)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(glut)
BuildRequires:  pkgconfig(libedit)
BuildRequires:  pkgconfig(libevent)
BuildRequires:  pkgconfig(libevent_pthreads)
BuildRequires:  pkgconfig(libmariadb)
BuildRequires:  pkgconfig(libpcre)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libtiff-4)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(lzo2)
BuildRequires:  pkgconfig(openlibm)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(samplerate)
BuildRequires:  pkgconfig(sndfile)
BuildRequires:  pkgconfig(theora)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(yajl)
BuildRequires:  pkgconfig(zlib)

# Only works
ExclusiveArch:  x86_64 %ix86

%define desc Io is a prototype-based programming language inspired by \
Smalltalk (all values are objects, all messages are dynamic), Self \
(prototype-based), NewtonScript (differential inheritance), Act1 (actors and \
futures for concurrency), LISP (code is a runtime inspectable/modifiable \
tree) and Lua (small, embeddable).

%description
%{desc}

%package devel
Summary:        Development files for %{name}
Version:        %{version}
Group:          Development/Libraries/Other
ExclusiveArch:  x86_64 %ix86

%description devel
%{desc}

%prep
%setup -q
sed -ri "s,20[0-9]+,%{version}," libs/iovm/source/IoVersion.h
sed -i 's,sys/sysctl.h,linux/sysctl.h,g' libs/iovm/source/IoSystem.c

# Taken from NixOS. Will include this once there are some complaints
# The Addon generation (AsyncRequest and a others checked) seems to have
# trouble with building on Virtual machines. Disabling them until it
# can be fully investigated.
# sed -ie \
#  "s/add_subdirectory(addons)/#add_subdirectory(addons)/g" \
#  CMakeLists.txt
## Bind Libs STATIC to avoid a segfault when relinking
# sed -i 's/basekit SHARED/basekit STATIC/' libs/basekit/CMakeLists.txt
# sed -i 's/garbagecollector SHARED/garbagecollector STATIC/' libs/garbagecollector/CMakeLists.txt
# sed -i 's/coroutine SHARED/coroutine STATIC/' libs/coroutine/CMakeLists.txt

%build
# We do not use the cmake and make macros because
# there is a bug in Io that certain kinds of
# folder names don't work
CFLAGS="%optflags -ffat-lto-objects"
CXXFLAGS="%optflags -ffat-lto-objects"
cmake -B build \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DCMAKE_INSTALL_PREFIX=%{_prefix} \
  -DCMAKE_EXE_LINKER_FLAGS=" -Wl,-z,noexecstack" \
  -DCMAKE_MODULE_LINKER_FLAGS=" -Wl,-z,noexecstack" \
  -DCMAKE_SHARED_LINKER_FLAGS=" -Wl,-z,noexecstack" \
  -DCMAKE_SKIP_RPATH=1 -S .
make -C build

%install
DESTDIR=%{buildroot} make install -C build

# Workaround for 64-bit systems
%if "%{?_lib}" == "lib64"
mkdir -p %{buildroot}%{_libdir}
mv %{buildroot}%{_prefix}/lib/*.so %{buildroot}%{_libdir}
%endif

# Disable Font subpackage at this moment
rm -rf %{buildroot}%{_prefix}/lib/io/addons/Font

# Replace duplicate files with hardlink
%fdupes %{buildroot}

# Remove .gitisdumb files
for i in VertexDB Twitter Bitly HttpClient; do
rm -f %{buildroot}%{_prefix}/lib/io/addons/$i/source/.gitisdumb
rm -f %{buildroot}%{_prefix}/lib/io/addons/$i/source/.gitsidumb
done

# Remove zero-length files. Why aren't they removed?
find %{buildroot} -size 0 -delete

# Convert all io files to unix line-endings
find %{buildroot} -name "*.io" -type f -exec dos2unix -c ascii {} \;

# The dynamically linked io executable does not work, see FS#68674. The error is:
# Relink `/usr/lib/libbasekit.so' with `/usr/lib/libm.so.6' for IFUNC symbol `ceil'
# Use the statically linked executable instead.
mv %{buildroot}%{_bindir}/%{name}_static %{buildroot}%{_bindir}/%{name}

%files
%defattr(-,root,root)
%doc README.md
%license license/bsd_license.txt
%{_bindir}/io
%{_libdir}/libbasekit.so
%{_libdir}/libcoroutine.so
%{_libdir}/libgarbagecollector.so
%{_libdir}/libiovmall.so

%files devel
%dir %{_prefix}/lib/io
%dir %{_prefix}/lib/io/addons
%{_prefix}/lib/io/*

%changelog

openSUSE Build Service is sponsored by