File ecode.spec of Package ecode

Name:           ecode
Version:        0.7.4
Release:        0
Summary:        Lightweight code editor
License:        MIT
URL:            https://github.com/SpartanJ/ecode
Source0:        eepp-%{version}.tar.xz

# Leap 15.x (suse_version = 1500) uses GCC 7 by default. We need GCC 13 for C++20.
# Tumbleweed/Slowroll/Leap 16 (suse_version >= 1600) use GCC 13/14 by default.
%if 0%{?suse_version} && 0%{?suse_version} < 1600
BuildRequires:  gcc13-c++
%else
BuildRequires:  gcc-c++
%endif

BuildRequires:  premake5
BuildRequires:  SDL2-devel
BuildRequires:  Mesa-libGL-devel
BuildRequires:  libX11-devel
BuildRequires:  libXext-devel
BuildRequires:  bash
BuildRequires:  chrpath
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme

%description
ecode is a lightweight and powerful code editor written in C++ using the eepp framework.

%prep
%setup -q -n eepp-%{version}

%build
# ### FIX: Export compiler variables if running on older SUSE
%if 0%{?suse_version} && 0%{?suse_version} < 1600
export CC=gcc-13
export CXX=g++-13
%endif

# Generate Makefiles
premake5 --sharedir="%{_datadir}/ecode" gmake

# Define the Premake configuration name based on the architecture
%ifarch x86_64
%define p_config release_x86_64
%define p_arch x86_64
%endif

%ifarch aarch64
%define p_config release_arm64
%define p_arch arm64
%endif

# %{ix86} is a standard RPM macro that covers i386, i486, i586, i686
%ifarch %{ix86}
%define p_config release_x86
%define p_arch x86
%endif

# Build using the dynamically defined config
make -C make/linux config=%{p_config} %{?_smp_mflags} verbose=1 ecode

%install
# Install binary
install -Dm0755 bin/ecode %{buildroot}%{_bindir}/ecode

# Remove the RPATH/RUNPATH from the binary ($ORIGIN) to satisfy OBS policy
chrpath -d %{buildroot}%{_bindir}/ecode

# Install shared library (Verify path: logs show libs/linux/)
install -Dm0755 libs/linux/%{p_arch}/libeepp.so %{buildroot}%{_libdir}/libeepp.so

# Install assets
mkdir -p %{buildroot}%{_datadir}/ecode
bash projects/scripts/copy_ecode_assets.sh ../../bin %{buildroot}%{_datadir}/ecode

# Desktop file and icons
install -Dm0644 projects/linux/ecode/ecode.desktop %{buildroot}%{_datadir}/applications/ecode.desktop
install -Dm0644 bin/assets/icon/ecode.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/ecode.png

# Fix duplicate files (icon is in two places)
%fdupes %{buildroot}%{_datadir}

%files
%license LICENSE
%{_bindir}/ecode
%{_libdir}/libeepp.so
%{_datadir}/ecode/
%{_datadir}/applications/ecode.desktop
%{_datadir}/icons/hicolor/256x256/apps/ecode.png

%changelog
* Mon Jan 12 2026 SpartanJ <spartanj@gmail.com> - 0.7.4
- Release for version 0.7.4

* Fri Dec 19 2025 SpartanJ <spartanj@gmail.com> - 0.7.3
- Initial package release for version 0.7.3
openSUSE Build Service is sponsored by