File manaverse.spec of Package manaverse

## Variables to contol some build flags and the files list
## 1 == enabled, 0 == disabled

# This first one serves two purpose:
#   * Determine whether or not to disable compiler optimizations for
#     generating backtraces in gdb
#   * Whether or not to enable debugging-related flags for ./configure
%global enable_debug 0
#This one determines whether or not to enable linking against tcmalloc.
%global enable_tcmalloc 1
# This one determine whether or not to instruct the compiler to treat
# warnings as errors
%global enable_werror 0

# This serve two purposes, both related to the fact that ManaVerse is a
# renamed continuation of ManaPlus:
#   * The find_lang macro; for version 1.9.3.23 of ManaVerse (and all
#     versions of ManaPlus), the find_lang macro needs to be passed the
#     argument of "manaplus", while for the current development version the
#     find_lang macro needs to be passed the argument of "manaverse"
#   * The files list needs to be different depending on whether we're
#     building version 1.9.3.23 or the current development release
# If building version 1.9.3.23 or older, define this as "manaplus". If
# building anything mewer, define this as "manaverse".
# Once a new stable release comes out, this variable and it's related logic
# can be sfaely removed, unless you're expecting people to use this spec file
# to build older releases.
#global plusverse manaverse
%global plusverse manaplus

# NOTE: openSUSE's OBS generates -debug{info,source} files by default
# regardless of whether or not %%{enable_debug} is enabled, hence why "-g" is
# passed regardless. For whatever reason, OBS will fail to generate these
# packages if we don't explicity instruct rpmbuild to add "-g" to the
# compiler flags.
%if 0%{?enable_debug}
%global _optflags %{_optflags} -O0 -g -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
%global optflags %{optflags} -O0 -g -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
%global cflags %{cflags} -O0 -g -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
%global cxxflags %{cxxflags} -O0 -g -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
%global prefix /opt/manaplus-testing/
%else
%global _optflags %{_optflags} -g
%global optflags %{optflags} -g
%global cflags %{cflags} -g
%global cxxflags %{cxxflags} -g
%endif

# Fedora-specific fix
%if 0%{?fedora}
#global _optflags %%{_optflags} -fPIC
#global optflags %%{optflags} -fPIC
#global cflags %%{cflags} -fPIC
#global cxxflags %%{cxxflags} -fPIC
#global ac_cv_prog_cc_works yes
#global ac_cv_prog_cxx_works yes
#global ac_cv_prog_cc_cross yes
#global ac_cv_prog_cxx_cross yes
%endif

Name:		manaverse
Summary:	Official client for The Mana World and Evol Online
License:	GPL-2.0-or-later
URL:		https://manaplus.germantmw.de/
Version:	1.9.3.23
Release:	1%{?dist}
Group:		Amusements/Games/Other
%if 0%{?enable_debug}
Prefix:		/opt/manaverse-testing
%endif

# The "v" preceding %%{version} is intentional. This is the way upstream
# names their archives.
# NOTE: This may need to be adjusted once a new version comes out.
%if "%{?plusverse}" == "manaplus"
Source0:	https://git.themanaworld.org/mana/plus/-/archive/v%{version}/plus-v%{version}.tar.bz2
%endif

%if "%{?plusverse}" == "manaverse"
Source0:	https://git.themanaworld.org/mana/plus/-/archive/v%{version}/verse-v%{version}.tar.bz2
%endif

Source1:	rpmlintrc

Patch0:		wallpaper-ctime.patch
Patch1:		dumplibs-implicit-comversion.patch
Patch2:		dyecmd-ctime.patch
Patch3:		libxml-include-parser.patch
Patch4:		chatrecv-cstdint.patch
Patch5:		traderecv-cstdint.patch

Conflicts:	manaplus
Obsoletes:	manaplus < %{version}-%{release}
Provides:	manaplus = %{version}-%{release}

Provides:	evolonline-client = %{version}-%{release}
Provides:	manaworld-client = %{version}-%{release}

Requires:	%{name}-common = %{version}-%{release}

Requires:	xdg-utils
Requires:	xsel

Suggests:	mumble

%if 0%{?enable_debug}
Requires:	gdb
Requires:	valgrind

BuildRequires:	binutils-devel
BuildRequires:	gdb
BuildRequires:	libdwarf-devel
BuildRequires:	valgrind-devel
%if 0%{?suse_version}
BuildRequires:	libdw-devel
%else
BuildRequires:	elfutils-devel
%endif
%endif

# These are required for both enable_tcmalloc and enable_debug. If they were
# included in the enable_debug section above and also the enable_tcmalloc
# below, rpmbuild would call us out for having duplicate entries if both
# enable_debug and enable_tcmalloc were enabled, so I'm using the if/else if
# logic below to ensure they are included only once.
%if 0%{?enable_tcmalloc}
BuildRequires:	gperf
BuildRequires:	gperftools-devel
# Needed only on openSUSE
%if  0%{?suse_version}
BuildRequires:	libtcmalloc4
%if 0%{?suse_version} >= 1600
BuildRequires:	libtcmalloc_and_profiler4
BuildRequires:	libtcmalloc_minimal4
%endif
%endif
%else
%if 0%{?enable_debug}
BuildRequires:	gperf
BuildRequires:	gperftools-devel
BuildRequires:	libtcmalloc4
BuildRequires:	libtcmalloc_and_profiler4
BuildRequires:	libtcmalloc_minimal4
%endif
%endif

BuildRequires:	autoconf
BuildRequires:	automake
BuildRequires:	binutils
BuildRequires:	gcc-c++
BuildRequires:	glibc
BuildRequires:	glibc-devel
BuildRequires:	libcurl-devel
BuildRequires:	libstdc++-devel
BuildRequires:	libxml2-devel
BuildRequires:	make
BuildRequires:	procps
BuildRequires:	zlib-devel

%if 0%{?suse_version}
BuildRequires:	gettext-tools
BuildRequires:	glu-devel
BuildRequires:	libgcc_s1
BuildRequires:	libpng16-devel
BuildRequires:	libpng16-compat-devel
BuildRequires:	libSDL-devel
BuildRequires:	libSDL_gfx-devel
BuildRequires:	libSDL_image-devel
BuildRequires:	libSDL_mixer-devel
BuildRequires:	libSDL_net-devel
BuildRequires:	libSDL_ttf-devel
BuildRequires:	libstdc++6
%else
BuildRequires:	gettext
BuildRequires:	libgcc
BuildRequires:	libpng-devel
BuildRequires:	libstdc++
BuildRequires:	SDL_gfx-devel
BuildRequires:	SDL_image-devel
BuildRequires:	SDL_mixer-devel
BuildRequires:	SDL_net-devel
BuildRequires:	SDL_ttf-devel
%endif

%ifarch x86_64
%if 0%{?mageia}
BuildRequires:	lib64jack-devel
%endif
%endif

%ifarch %{ix86}
%if 0%{?mageia}
BuildRequires:	libjack-devel
%endif
%endif


%if 0%{?mageia}
BuildRequires:	gettext-base
BuildRequires:	jackit
%else
BuildRequires:	gettext-runtime
BuildRequires:	jack-audio-connection-kit
BuildRequires:	jack-audio-connection-kit-devel
%endif

%package common
Summary:	Common files for %{name}
BuildArch:	noarch
Group:		Amusements/Games/Other

%package doc
Summary:	Documentation for %{name}
BuildArch:	noarch
Group:		Amusements/Games/Other

%package lang
Summary:	Language files for %{name}
BuildArch:	noarch
Requires:	%{name}-common = %{version}-%{release}
Group:		Amusements/Games/Other

%description
ManaVerse is an extended client for Evol Online, The Mana World and similar
servers based on eAthena forks. ManaVerse is the successor to ManaPlus.

As a 2D style game, Evol Online aims to create a friendly environment where 
people can escape reality and interact with others while enjoying themselves 
through a fantasy style game.

The Mana World (TMW) is a serious effort to create an innovative free and 
open source MMORPG. TMW uses 2D graphics and aims to create a large and 
diverse interactive world.

%description common
Files that are common for all installations of %{name}.

%description doc
Dcoumentation for %{name}

This is really just the man pages. In-game help and tips are in %{name}-common.

%description lang
Language files for %{name}

%prep
# Version 1.9.3.23's archive extracts to a directory called
# "plus-v%{version}". Also, it requires several patches to build on modern
# systems.
%if "%{?plusverse}" == "manaplus"
%setup -q -n plus-v%{version}
%patch -p1 -P 0
%patch -p1 -P 1
%patch -p1 -P 2
%patch -p1 -P 3
%patch -p1 -P 4
%patch -p1 -P 5
%endif

# The current development version doesn't have an official archive yet, so
# the %%setup line below may need to be adjusted depending on what it
# extracts to once it's officially provided.
%if "%{?plusverse}" == "manaverse"
%setup -q -n verse-v%{version}
%endif

autoreconf -i

%build
%configure \
	%if 0%{?enable_debug}
		--enable-checks \
		--enable-memdebug \
		--enable-asserts \
		--enable-glibcdebug \
		--enable-stldebug \
		--enable-openglerrors \
	%endif
	%if 0%{?enable_werror}
		--enable-werror \
	%endif
	%if 0%{?enable_tcmalloc}
		--enable-tcmalloc \
	%endif
	--datadir=%{_datadir}/games \
	--enable-tmwa

cd po
%__make update-gmo
cd ..

# The _smp_mflags variable passes "-j$(nproc) by default, allowing parallel
# builds. Specifying the "?" at the start allows either the spec file,
# `rpmbuild`, or the build server to disable this without causing rpmbuild to
# fail with an error.
# build server 
%__make %{?_smp_mflags}

%install
%make_install

%find_lang %{plusverse}

%clean
rm -rf %{buildroot}


%files -f %{plusverse}.lang
%{_bindir}/*

# The files list for the -common package changes depending on whether we're
# building 1.9.3.23, or something newer
%files common
%if "%{?plusverse}" == "manaplus"
%{_datadir}/appdata/*
%{_datadir}/applications/*
%dir %{_datadir}/games/manaplus/
%dir %{_datadir}/games/manaplus/data/
%dir %{_datadir}/games/manaplus/data/fonts/
%{_datadir}/games/manaplus/data/fonts/*
%dir %{_datadir}/games/manaplus/data/graphics/
%dir %{_datadir}/games/manaplus/data/graphics/badges/
%{_datadir}/games/manaplus/data/graphics/badges/*
%dir %{_datadir}/games/manaplus/data/graphics/flags/
%{_datadir}/games/manaplus/data/graphics/flags/*
%dir %{_datadir}/games/manaplus/data/graphics/gui/
%{_datadir}/games/manaplus/data/graphics/gui/*
%dir %{_datadir}/games/manaplus/data/graphics/images/
%{_datadir}/games/manaplus/data/graphics/images/*
%dir %{_datadir}/games/manaplus/data/graphics/shaders/
%{_datadir}/games/manaplus/data/graphics/shaders/*
%dir %{_datadir}/games/manaplus/data/graphics/sprites/
%{_datadir}/games/manaplus/data/graphics/sprites/*
%dir %{_datadir}/games/manaplus/data/help/
%dir %{_datadir}/games/manaplus/data/help/idx/
%{_datadir}/games/manaplus/data/help/idx/*
%dir %{_datadir}/games/manaplus/data/help/tips/
%{_datadir}/games/manaplus/data/help/tips/*
%{_datadir}/games/manaplus/data/help/*.txt
%dir %{_datadir}/games/manaplus/data/icons/
%{_datadir}/games/manaplus/data/icons/*
%dir %{_datadir}/games/manaplus/data/music/
%{_datadir}/games/manaplus/data/music/*
%dir %{_datadir}/games/manaplus/data/perserver/
%dir %{_datadir}/games/manaplus/data/perserver/default/
%{_datadir}/games/manaplus/data/perserver/default/*
%dir %{_datadir}/games/manaplus/data/sfx/
%dir %{_datadir}/games/manaplus/data/sfx/system/
%{_datadir}/games/manaplus/data/sfx/system/*
%dir %{_datadir}/games/manaplus/data/test/
%{_datadir}/games/manaplus/data/test/**
%dir %{_datadir}/games/manaplus/data/themes/
%dir %{_datadir}/games/manaplus/data/themes/blacknblack/
%{_datadir}/games/manaplus/data/themes/blacknblack/*
%dir %{_datadir}/games/manaplus/data/themes/blackwood/
%{_datadir}/games/manaplus/data/themes/blackwood/*
%dir %{_datadir}/games/manaplus/data/themes/enchilado/
%{_datadir}/games/manaplus/data/themes/enchilado/*
%dir %{_datadir}/games/manaplus/data/themes/golden-delicious/
%{_datadir}/games/manaplus/data/themes/golden-delicious/*
%dir %{_datadir}/games/manaplus/data/themes/jewelry-simple/
%{_datadir}/games/manaplus/data/themes/jewelry-simple/*
%dir %{_datadir}/games/manaplus/data/themes/jewelry/
%{_datadir}/games/manaplus/data/themes/jewelry/*
%dir %{_datadir}/games/manaplus/data/themes/mana/
%{_datadir}/games/manaplus/data/themes/mana/*
%dir %{_datadir}/games/manaplus/data/themes/pink/
%{_datadir}/games/manaplus/data/themes/pink/*
%dir %{_datadir}/games/manaplus/data/themes/unity/
%{_datadir}/games/manaplus/data/themes/unity/*
%dir %{_datadir}/games/manaplus/data/themes/wood/
%{_datadir}/games/manaplus/data/themes/wood/*
%{_datadir}/pixmaps/*
%dir %{_datadir}/games/manaplus/data/translations/
%dir %{_datadir}/games/manaplus/data/translations/help/
%{_datadir}/games/manaplus/data/translations/help/*
%dir %{_datadir}/games/manaplus/data/translations/test/
%{_datadir}/games/manaplus/data/translations/test/*
%endif
%if "%{?plusverse}" == "manaverse"
%{_datadir}/applications/manaplus.desktop
%{_datadir}/applications/manaplustest.desktop
%dir %{_datadir}/games/manaverse/
%dir %{_datadir}/games/manaverse/data/
%dir %{_datadir}/games/manaverse/data/fonts/
%{_datadir}/games/manaverse/data/fonts/*
%{_datadir}/icons/hicolor/scalable/apps/*
%{_datadir}/locale/*/LC_MESSAGES/*
%{_datadir}/metainfo/manaplus.metainfo.xml
%dir %{_datadir}/games/manaverse/data/graphics/
%dir %{_datadir}/games/manaverse/data/graphics/badges/
%{_datadir}/games/manaverse/data/graphics/badges/*
%dir %{_datadir}/games/manaverse/data/graphics/flags/
%{_datadir}/games/manaverse/data/graphics/flags/*
%dir %{_datadir}/games/manaverse/data/graphics/gui/
%{_datadir}/games/manaverse/data/graphics/gui/*
%dir %{_datadir}/games/manaverse/data/graphics/images/
%{_datadir}/games/manaverse/data/graphics/images/*
%dir %{_datadir}/games/manaverse/data/graphics/shaders/
%{_datadir}/games/manaverse/data/graphics/shaders/*
%dir %{_datadir}/games/manaverse/data/graphics/sprites/
%{_datadir}/games/manaverse/data/graphics/sprites/*
%dir %{_datadir}/games/manaverse/data/help/
%{_datadir}/games/manaverse/data/help/*.txt
%dir %{_datadir}/games/manaverse/data/help/idx/
%{_datadir}/games/manaverse/data/help/idx/*
%dir %{_datadir}/games/manaverse/data/help/tips/
%{_datadir}/games/manaverse/data/help/tips/*
%dir %{_datadir}/games/manaverse/data/icons/
%{_datadir}/games/manaverse/data/icons/manaplus.hqx
%{_datadir}/games/manaverse/data/icons/manaplus.icns
%{_datadir}/games/manaverse/data/icons/manaplus.ico
%{_datadir}/games/manaverse/data/icons/manaplus.png
%{_datadir}/games/manaverse/data/icons/manaplus.svg
%{_datadir}/games/manaverse/data/icons/manaplus.xpm
%dir %{_datadir}/games/manaverse/data/music/
%{_datadir}/games/manaverse/data/music/*
%dir %{_datadir}/games/manaverse/data/perserver/
%dir %{_datadir}/games/manaverse/data/perserver/default/
%{_datadir}/games/manaverse/data/perserver/default/*
%dir %{_datadir}/games/manaverse/data/sfx/
%dir %{_datadir}/games/manaverse/data/sfx/system/
%{_datadir}/games/manaverse/data/sfx/system/*
%dir %{_datadir}/games/manaverse/data/test/
%{_datadir}/games/manaverse/data/test/*
%dir %{_datadir}/games/manaverse/data/themes/
%dir %{_datadir}/games/manaverse/data/themes/blacknblack/
%{_datadir}/games/manaverse/data/themes/blacknblack/*
%dir %{_datadir}/games/manaverse/data/themes/blackwood/
%{_datadir}/games/manaverse/data/themes/blackwood/*
%dir %{_datadir}/games/manaverse/data/themes/enchilado/
%{_datadir}/games/manaverse/data/themes/enchilado/*
%dir %{_datadir}/games/manaverse/data/themes/golden-delicious/
%{_datadir}/games/manaverse/data/themes/golden-delicious/*
%dir %{_datadir}/games/manaverse/data/themes/jewelry-simple/
%{_datadir}/games/manaverse/data/themes/jewelry-simple/*
%dir %{_datadir}/games/manaverse/data/themes/jewelry/
%{_datadir}/games/manaverse/data/themes/jewelry/*
%dir %{_datadir}/games/manaverse/data/themes/mana/
%{_datadir}/games/manaverse/data/themes/mana/*
%dir %{_datadir}/games/manaverse/data/themes/pink/
%{_datadir}/games/manaverse/data/themes/pink/*
%dir %{_datadir}/games/manaverse/data/themes/unity/
%{_datadir}/games/manaverse/data/themes/unity/*
%dir %{_datadir}/games/manaverse/data/themes/wood/
%{_datadir}/games/manaverse/data/themes/wood/*
%dir %{_datadir}/games/manaverse/data/translations/
%dir %{_datadir}/games/manaverse/data/translations/help/
%{_datadir}/games/manaverse/data/translations/help/*
%dir %{_datadir}/games/manaverse/data/translations/test/
%{_datadir}/games/manaverse/data/translations/test/*
%endif

%files doc
%{_mandir}/man6/*

%changelog
* Thu Dec 11 2025 Kristopher Gamrat <gamrat.kristopher@protonmail.com 1.9.3.23-8
- Update spec file to build latest git version of ManaVerse while maintaining
  compatibility with latest stable with a bit of logic.
- Add logic to decide whether or not to enable certain build flags
- Add support for having make run multiple jobs in parallel
- Add building against tcmalloc

* Tue Dec 09 2025 Kristopher Gamrat <gamrat.kristopher@protonmail.com> 1.9.3.23-7
- Drop Fedora support due to broken OBS support
- Update dumplibs patch
- Ensure BuildRequires are correct

* Wed Mar 26 2025 Kristopher Gamrat <gamrat.kristopher@protonmail.com> 1.9.3.23-6
- Disable compiler optimization for gdb debugging
* Fri Mar 07 2025 Kristopher Gamrat <gamrat.kristopher@protonmail.com> 1.9.3.23-5
- Remove PulseAudio requirement. Enabling audio without PulseAudio installed
  seems to be fixed on openSUSE.
- Fix XDG requirement.

* Tue Mar 04 2025 Kristopher Gamrat <gamrat.kristopher@protonmail.com> 1.9.3.23-4
- Add xsel and xdg-utils to Requires per the README on the GitLab page.

* Mon Feb 24 2025 Kristopher Gamrat <gamrat.kristopher@protonmail.com> 1.9.3.23-3
- Add pulseaudio and alsa-plugins-pulse as Requires to prevent a crash when
  enabling audio.

* Sat Feb 15 2025 Kristopher Gamrat <gamrat.kristopher@protonmail.com> 1.9.3.23-2
- Set up BuildRequires across multiple distributions supported by the
  official OBS instance
- Apply several patches to fix builds on newer toolchains
- Learn how to use the %%find_lang macro
- Ensure the -g option is included in compiler flags so debug symbols are
  built for distros that support generating a debug package.

* Wed Feb 12 2025 Kristopher Gamrat <gamrat.kristopher@protonmail.com> 1.9.3.23-1
- Initial Release
openSUSE Build Service is sponsored by