## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 27;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global commit  aced3eb3fcaa0fe13c44c4dd196cdab42555fd98
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global date    20221211

%global corename pcsx-rearmed
%global filename pcsx_rearmed

Name:           libretro-%{corename}
Version:        15
Release:        0.17.%{date}git%{shortcommit}.%autorelease
Summary:        ARM optimized PCSX fork

# Public domain
# ----------------------------
# deps/flac-1.3.2/
# deps/lzma-16.04/
#
# BSD 3-clause "New" or "Revised" License
# ---------------------------------------
# deps/flac-1.3.2/
# deps/libchdr/
#
# Expat License
# -------------
# frontend/vita/
# libretro-common/
# plugins/dfsound/
#
# GNU General Public License
# --------------------------
# deps/flac-1.3.2/
#
# GNU General Public License (v2 or later)
# ----------------------------------------
# frontend/cspace_arm.S
# libpcsxcore/gte_arm.S
# plugins/dfxvideo/draw_pl.c
#
# GNU Lesser General Public License (v2 or later)
# -----------------------------------------------
# deps/flac-1.3.2/include/share/getopt.h
#
# GNU Lesser General Public License (v2.1 or later)
# -------------------------------------------------
# deps/flac-1.3.2/include/share/grabbag.h
#
# GPL (v2 or later)
# -----------------
# deps/flac-1.3.2/include/share/grabbag/picture.h
# libpcsxcore/cdriso.c
# plugins/gpu_neon/psx_gpu/vector_ops.h
#
License:        GPLv2 and Public Domain and BSD and MIT

URL:            https://github.com/libretro/pcsx_rearmed
Source0:        %{url}/archive/%{commit}/%{name}-%{version}.%{date}git%{shortcommit}.tar.gz
Source1:        https://raw.githubusercontent.com/flathub/org.gnome.Games/master/libretro-cores/%{filename}.libretro
ExcludeArch:    armv7hl

BuildRequires:  gcc-c++
BuildRequires:  make

BuildRequires:  pkgconfig(zlib)

Supplements:    gnome-games
Supplements:    retroarch

# All hardcoded
#   * https://github.com/libretro/pcsx_rearmed/blob/3558dd33fb337a29fb6c57a5e88a473153e6202e/Makefile#L219
Provides:       bundled(crypto)
Provides:       bundled(flac) = 1.3.2
Provides:       bundled(libchdr)
Provides:       bundled(lzma) = 19.00

%description
PCSX ReARMed is yet another PCSX fork based on the PCSX-Reloaded project,
which itself contains code from PCSX, PCSX-df and PCSX-Revolution. This
version is ARM architecture oriented and features MIPS->ARM recompiler by
Ari64, NEON GTE code and more performance improvements. It was created for
Pandora handheld, but should be usable on other devices after some code
adjustments (N900, GPH Wiz/Caanoo, PlayBook versions are also available).

PCSX ReARMed features ARM NEON GPU by Exophase, that in many cases produces
pixel perfect graphics at very high performance. There is also Una-i's GPU
plugin from PCSX4ALL project, and traditional P.E.Op.S. one.


%prep
%autosetup -n %{filename}-%{commit}

# wrong-file-end-of-line-encoding
sed -i 's/\r$//' ChangeLog


%build
%set_build_flags
%make_build -f Makefile.libretro \
    GIT_VERSION=%{shortcommit}   \
    HAVE_CHD=1                   \
    WANT_ZLIB=0                  \
    %{nil}


%install
install -Dpm 0755 %{filename}_libretro.so %{buildroot}%{_libdir}/libretro/%{filename}_libretro.so
install -Dpm 0644 %{SOURCE1} %{buildroot}%{_libdir}/libretro/%{filename}.libretro


%files
%license COPYING
%doc README.md AUTHORS NEWS ChangeLog
%{_libdir}/libretro/


%changelog
* Wed Dec 14 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-27
- chore: Update to latest git snapshot

* Mon Nov 14 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-26
- chore: Update to latest git snapshot

* Sat Oct 15 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-25
- chore(update): Latest git snapshot

* Sat Oct 01 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-24
- chore(downgrade): Commit 3e629be

* Thu Sep 22 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-23
- chore(update): Latest git snapshot

* Wed Sep 07 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-22
- chore(update): Latest git snapshot

* Sat Aug 20 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-21
- chore(update): Latest git snapshot

* Tue Aug 09 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-20
- chore(update): Latest git snapshot

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> 15-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Wed May 11 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-18
- chore(update): Latest git snapshot

* Wed Apr 27 2022 Artem Polishchuk <ego.cordatus@gmail.com> 15-17
- chore(update): Latest git snapshot

* Mon Apr 25 2022 Artem Polishchuk <ego.cordatus@gmail.com> - 15-16.20220426git3558dd3
- build: Fix build on aarch64; GH#651

* Mon Apr 25 2022 Artem Polishchuk <ego.cordatus@gmail.com> - 15-15.20220426git3558dd3
- chore(update): Latest git snapshot

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 15-14.20211004gitf5b7bb8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Tue Oct 05 2021 Artem Polishchuk <ego.cordatus@gmail.com> - 15-13.20211004gitf5b7bb8
- chore(update): Latest git snapshot

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 15-12.20210428git625cc17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Apr 30 2021 Artem Polishchuk <ego.cordatus@gmail.com> - 15-11.20210428git625cc17
- build(update): Latest git snapshot

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 15-10.20200806gitddd39f2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Sun Aug 09 2020 Artem Polishchuk <ego.cordatus@gmail.com> - 15-9.20200806gitddd39f2
- Update to latest git snapshot

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 15-9.20200521gitf4c902e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Thu May 21 2020 Artem Polishchuk <ego.cordatus@gmail.com> - 15-8.20200521gitf4c902e
- Update to latest git snapshot

* Tue Feb 11 2020 Artem Polishchuk <ego.cordatus@gmail.com> - 15-7.20200211git74ec4f3
- Update to latest git snapshot

* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 15-6.20191024git4b353f8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Wed Dec 04 2019 Artem Polishchuk <ego.cordatus@gmail.com> - 15-5.20191024git4b353f8
- Packaging fixes

* Wed Nov 13 2019 Artem Polishchuk <ego.cordatus@gmail.com> - 15-1.20191024git4b353f8
- Update to latest git snapshot
- Packaging fixes

* Tue Oct 08 2019 Artem Polishchuk <ego.cordatus@gmail.com> - 15-1.20191007gitcb4aa3e
- Initial package