# Note: depends on Alien-SDL-perl
# Note: depends on SDL
wget -c http://search.cpan.org/CPAN/authors/id/J/JT/JTPALMER/SDL-2.541_10.tar.gz
tar -xzf SDL-2.541_10.tar.gz
cd SDL-2.541_10
perl Build.PL

# Hacks to work around SDL_perl's broken support for SDL_Pango
wget -c http://aos.ion.nu/sourcemirror/sdl-perlpango-compat.c
wget -c http://aos.ion.nu/sourcemirror/sdl-perlpango-compat.h
# Note: neither of the below hacks are optimal, but they let us build SDL_perl with support for SDL_Pango
sed -i -e '/#include <SDL_Pango\.h>/r sdl-perlpango-compat.c' src/Pango/Pango.xs
cp sdl-perlpango-compat.h lib/SDL
expr='s/ *$/'"',/; s/^ */'/; s/  */',&'/g;" # put each flag in a separate string, separated by commas
sed -i -e "/extra_compiler_flags/a`(echo '-I/usr/include'; pkg-config --cflags pango; pkg-config --cflags freetype2) | tr '\n' ' ' | sed -e "$expr"`" _build/notes

perl Build
perl Build install # as root