Skip to content

Commit 71e20c0

Browse files
giordanoNHDaly
authored andcommitted
Add builder for SDL2_ttf (#123)
* Add builder for SDL2_ttf * Update S/SDL2_ttf/bundled/patches/configure_in-v2.0.15.patch Co-Authored-By: Nathan Daly <[email protected]> * [SDL2_ttf] Don't build programs, they won't be installed anyway * [SDL2_ttf] Manually build the shared library for Windows Co-authored-by: Nathan Daly <[email protected]>
1 parent 86c35c2 commit 71e20c0

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed

S/SDL2_ttf/build_tarballs.jl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Note that this script can accept some limited command-line arguments, run
2+
# `julia build_tarballs.jl --help` to see a usage message.
3+
using BinaryBuilder
4+
5+
name = "SDL2_ttf"
6+
version = v"2.0.15"
7+
8+
# Collection of sources required to build SDL2_ttf
9+
sources = [
10+
"https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$(version).tar.gz" =>
11+
"a9eceb1ad88c1f1545cd7bd28e7cbc0b2c14191d40238f531a15b01b1b22cd33",
12+
"./bundled",
13+
]
14+
15+
# Bash recipe for building across all platforms
16+
script = raw"""
17+
cd $WORKSPACE/srcdir/SDL2_ttf-*/
18+
19+
FLAGS=()
20+
if [[ "${target}" == *-linux-* ]] || [[ "${target}" == *-freebsd* ]]; then
21+
FLAGS+=(--with-x)
22+
fi
23+
24+
atomic_patch -p1 ../patches/configure_in-v2.0.15.patch
25+
atomic_patch -p1 ../patches/Makefile_in_dont_build_programs.patch
26+
touch NEWS README AUTHORS ChangeLog
27+
# For some reasons, the first time `autoreconf` may fail,
28+
# but with some encouragement it can do it
29+
autoreconf -vi || autoreconf -vi
30+
export CPPFLAGS="-I${prefix}/include/SDL2"
31+
./configure --prefix=${prefix} --host=${target} \
32+
--enable-shared \
33+
--disable-static \
34+
"${FLAGS[@]}"
35+
make -j${nproc}
36+
make install
37+
38+
if [[ "${target}" == *-mingw* ]]; then
39+
# As usual, build system for Windows is wrecked
40+
# and the shared library is not built at all
41+
cd ${prefix}/lib
42+
ar x libSDL2_ttf.a
43+
cc -shared -o ${libdir}/SDL2_ttf.dll SDL_ttf.o ${libdir}/libfreetype-6.dll ${libdir}/SDL2.dll
44+
rm SDL_ttf.o
45+
fi
46+
"""
47+
48+
# These are the platforms we will build for by default, unless further
49+
# platforms are passed in on the command line
50+
platforms = supported_platforms()
51+
52+
# The products that we will ensure are always built
53+
products = [
54+
LibraryProduct(["libSDL2_ttf", "SDL2_ttf"], :libsdl2_ttf)
55+
]
56+
57+
# Dependencies that must be installed before this package can be built
58+
dependencies = [
59+
"SDL2_jll",
60+
"FreeType2_jll",
61+
]
62+
63+
# Build the tarballs, and possibly a `build.jl` as well.
64+
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/Makefile.in
2+
+++ b/Makefile.in
3+
@@ -836,7 +836,7 @@
4+
exit 1; } >&2
5+
check-am: all-am
6+
check: check-am
7+
-all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(DATA) $(HEADERS)
8+
+all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
9+
installdirs:
10+
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(libSDL2_ttfincludedir)"; do \
11+
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--- a/configure.in
2+
+++ b/configure.in
3+
@@ -64,6 +64,7 @@
4+
;;
5+
esac
6+
7+
+PKG_PROG_PKG_CONFIG
8+
9+
case "$host" in
10+
*-*-beos*)
11+
@@ -87,23 +88,30 @@
12+
AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue)
13+
14+
dnl Check for the FreeType 2 library
15+
-PKG_CHECK_MODULES([FT2], [freetype2 >= 7.0.1], [], [dnl
16+
- AC_CHECK_FT2(,,[AC_MSG_ERROR([dnl
17+
-*** Unable to find FreeType2 library (http://www.freetype.org/)])]
18+
- )
19+
-])
20+
-CFLAGS="$CFLAGS $FT2_CFLAGS"
21+
-LIBS="$LIBS $FT2_LIBS"
22+
+PKG_CHECK_MODULES(
23+
+ FREETYPE2,
24+
+ freetype2,
25+
+ [
26+
+ ft_found=yes
27+
+ CFLAGS="$CFLAGS $FREETYPE2_CFLAGS"
28+
+ LIBS="$LIBS $FREETYPE2_LIBS"
29+
+ ],
30+
+ ft_found=no
31+
+)
32+
33+
dnl Check for SDL
34+
SDL_VERSION=2.0.8
35+
AC_SUBST(SDL_VERSION)
36+
-AM_PATH_SDL2($SDL_VERSION,
37+
- :,
38+
- AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
39+
+PKG_CHECK_MODULES(
40+
+ SDL2,
41+
+ sdl2,
42+
+ [
43+
+ sdl2_found=yes
44+
+ CFLAGS="$CFLAGS $SDL2_CFLAGS"
45+
+ LIBS="$LIBS $SDL2_LIBS"
46+
+ ],
47+
+ sdl2_found=no
48+
)
49+
-CFLAGS="$CFLAGS $SDL_CFLAGS"
50+
-LIBS="$LIBS $SDL_LIBS"
51+
52+
dnl Check for OpenGL
53+
case "$host" in

0 commit comments

Comments
 (0)