-
Notifications
You must be signed in to change notification settings - Fork 11
/
build-love2d.sh
executable file
·142 lines (127 loc) · 4.13 KB
/
build-love2d.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
#
# The MIT License (MIT)
#
# Copyright (c) 2016 Albert Casals - [email protected]
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# build-love2d.sh
#
# Script to run on the RaspberryPI which downloads, builds and installs the Love2d framework.
#
# Invoke with "--sdl-only" to simply build the SDL2 library.
#
# System jail protection code
ARM_MUST_BE='armv7l'
mach=`uname -m`
if [ "$mach" != "$ARM_MUST_BE" ]; then
echo "Careful! Looks like I am not running inside an ARM system!"
echo "uname -m is telling me: $mach"
exit 1
else
# Avoid errors from stopping the script
set +e
fi
# pass this string as the first argument to fast-build sdl2
sdlonly="--sdl-only"
# Install dependencies
echo ">>> Installing dependencies"
PKGS="build-essential devscripts pkg-config git-core debhelper dh-autoreconf
libasound2-dev libudev0 libudev-dev libdbus-1-dev libx11-dev libxcursor-dev
libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev libxt-dev libxxf86vm-dev
libfreetype6-dev libopenal-dev libmodplug-dev libvorbis-dev
libgl1-mesa-dev libpulse-dev libibus-1.0-dev
libtheora-dev libphysfs-dev libluajit-5.1-dev libmpg123-dev
libraspberrypi-dev
pulseaudio
"
if [ "$1" != "$sdlonly" ]; then
apt-get update
apt-get install -y --no-install-recommends $PKGS
if [ "$?" != "0" ]; then
echo ">>> ERROR: Installing dependencies"
exit 1
fi
fi
# Build SDL
cd /tmp
sdl2_dir="SDL2-2.0.5"
if [ ! -d "$sdl2_dir" ]; then
echo ">>> Getting SDL2 sources"
curl -L "https://www.libsdl.org/release/SDL2-2.0.5.tar.gz" | tar -zx
fi
cd $sdl2_dir
echo ">>> Building SDL2"
export CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
export LDFLAGS="-L/opt/vc/lib"
# HACK: rules file to build specific for the RPI, and changelog for package names.
cp -fv ../sdl2-debian-rules ./debian/rules
cp -fv ../sdl2-changelog ./debian/changelog
dpkg-buildpackage
if [ "$?" != "0" ]; then
echo ">>> ERROR: Could not build SDL2 libraries"
exit 1
else
echo ">>> Installing SDL2 libraries"
cd /tmp
dpkg -i libsdl2_2.0.5_armhf.deb
dpkg -i libsdl2-dev_2.0.5_armhf.deb
fi
# stop if only SDL was required
if [ "$1" == "$sdlonly" ]; then
echo "SDL2 built - terminating due to $sdlonly"
exit 0
fi
# Build Love2d
echo ">>> Building Love2D"
love2d_url="https://bitbucket.org/rude/love/downloads/love-0.10.2-linux-src.tar.gz"
love2d_tgz="lovesrc.tgz"
love2d_bin="/tmp/pilove-0.10.2-bin.tgz"
cd /tmp
curl -L $love2d_url > $love2d_tgz
cd /usr/local/games
tar zxf /tmp/$love2d_tgz
cd love-0.10.2
./configure
if [ "$?" != "0" ]; then
echo ">>> Error: running Love2D configure rc=$?"
exit 1
fi
make -j 2
if [ "$?" != "0" ]; then
echo ">>> Error: running Love2D make rc=$?"
exit 1
fi
cd ..
tar -zcf $love2d_bin love-0.10.2
echo ">>> Love2D build completed"
# Raspi2png is a tool to take screenshots
echo ">>> Building Raspi2png"
cd /tmp
git clone https://github.com/AndrewFromMelbourne/raspi2png.git
cd raspi2png
make
if [ "$?" != "0" ]; then
echo "Warning: error building raspi2png"
else
cp -fv raspi2png /usr/local/bin
echo ">>> Raspi2png built"
fi
exit 0