Name:       SDL
Summary:    A cross-platform multimedia library
Version:    1.2.15
Release:    34
License:    LGPLv2+
URL:        http://www.libsdl.org/

Source0:    %{name}-%{version}_repackaged.tar.gz
Source1:    SDL_config.h
Source2:    repackage.sh
Patch0:     SDL-1.2.15-add_sdl_config_man.patch

Patch9000: CVE-2019-7637.patch
Patch9001: CVE-2019-7636.patch
Patch9002: CVE-2019-7635_1.patch
Patch9003: CVE-2019-7635_2.patch
Patch9004: CVE-2019-7573_CVE-2019-7576.patch
Patch9005: CVE-2019-7578.patch
Patch9006: CVE-2019-7577.patch

BuildRequires:  git alsa-lib-devel gdb-headless

%description
Simple DirectMedia Layer(SDL) is a cross-platform development library designed\
to provide low level access to audio, keyboard, mouse, joystick, and graphics\
hardware via OpenGL and Direct3D. It is used by video playback software, emulators,\
and popular games including Valve's award winning catalog and many Humble Bundle games.\

%package devel
Summary:	Development files for %{name}
Provides:	%{name}-static
Obsoletes:	%{name}-static
Requires:	%{name} = %{version}-%{release}
Requires:	alsa-lib-devel mesa-libGL-devel mesa-libGLU-devel
Requires:	libX11-devel libXext-devel libXrandr-devel libXrender-devel

%description devel
Libraries and header files of %{name} are all in the %{name}-devel package.

%package        help
Summary:        Help manual for %{name}

%description    help
The %{name}-help package conatins man manual etc

%prep
%autosetup -n %{name}-%{version} -p1 -Sgit
for F in CREDITS; do
    iconv -f iso8859-1 -t utf-8 < "$F" > "${F}.utf"
    touch --reference "$F" "${F}.utf"
    mv "${F}.utf" "$F"
done
sed -i -e 's/.*AM_PATH_ESD.*//' configure.in
cp -p %{_datadir}/automake-*/config.{sub,guess} build-scripts

%build
aclocal
libtoolize
autoconf
%configure \
    --disable-video-svga \
    --disable-video-ggi \
    --disable-video-aalib \
    --enable-sdl-dlopen \
    --disable-arts \
    --disable-esd \
    --disable-nas \
    --enable-pulseaudio-shared \
    --enable-alsa \
    --disable-video-ps3 \
    --disable-rpath
%make_build

%install
%make_install
# Rename SDL_config.h to SDL_config-<arch>.h to avoid file conflicts on
# multilib systems and install SDL_config.h wrapper
mv %{buildroot}/%{_includedir}/SDL/SDL_config.h %{buildroot}/%{_includedir}/SDL/SDL_config-%{_arch}.h
install -m644 %{SOURCE1} %{buildroot}/%{_includedir}/SDL/SDL_config.h
rm -f %{buildroot}%{_libdir}/*.la

%files
%license COPYING
%doc BUGS CREDITS README-SDL.txt
%{_libdir}/lib*.so.*

%files devel
%doc README docs.html docs/html docs/index.html TODO WhatsNew
%{_bindir}/*-config
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/sdl.pc
%{_includedir}/SDL
%{_datadir}/aclocal/*
%{_libdir}/lib*.a

%files help
%{_mandir}/man1/*
%{_mandir}/man3/SDL*.3*

%changelog
* Wed Nov 13 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.2.15-34
- Package init
