-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·130 lines (118 loc) · 3.6 KB
/
setup.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
#!/bin/bash
# ______________________________________________________________________________
#
# Set up raylib project
# Configure the config.sh for your project before setting up
#
# - Linux ./setup.sh
# - Windows (w64devkit) ./setup.sh
# - Windows (cross compile) TARGET=Windows_NT ./setup.sh
# - Web TARGET=Web ./setup.sh
# - Android TARGET=Android ./setup.sh
# ______________________________________________________________________________
#
source ./config.sh
# Set up directory structure
mkdir --parents include src assets lib/$TARGET
# Stop building if an error occurs
set -e
# ______________________________________________________________________________
#
# Install dependencies
# ______________________________________________________________________________
#
if command -v apt > /dev/null; then
echo "Installing dependencies"
sudo apt install build-essential git libasound2-dev mesa-common-dev \
libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev
elif command -v dnf > /dev/null; then
echo "Installing dependencies"
sudo dnf install alsa-lib-devel mesa-libGL-devel libX11-devel \
libXrandr-devel libXi-devel libXcursor-devel libXinerama-devel
fi
# ______________________________________________________________________________
#
# Install or update raylib
# ______________________________________________________________________________
#
if [[ -e raylib ]]; then
if command -v git > /dev/null; then
cd raylib
git pull
cd ..
fi
else
if command -v git > /dev/null; then
git clone https://github.com/raysan5/raylib --depth 1
else
echo "raylib directory not found, download it from https://github.com/raysan5/raylib or install git"
exit 1
fi
fi
# ______________________________________________________________________________
#
# Build raylib
# ______________________________________________________________________________
#
case "$TARGET" in
"Linux")
cd raylib/src
make || make -e
mv libraylib.a ../../lib/$TARGET
cp raylib.h ../../include
make clean || make clean -e || rm -fv *.o
cd ../..
;;
"Windows_NT")
# To build for 32-bit, set ARCH to i686 in both build and setup.sh, then
# run setup again
ARCH="x86_64"
if command -v $ARCH-w64-mingw32-gcc > /dev/null; then
cd raylib/src
make CC=$ARCH-w64-mingw32-gcc AR=$ARCH-w64-mingw32-ar OS=Windows_NT || \
make CC=$ARCH-w64-mingw32-gcc AR=$ARCH-w64-mingw32-ar OS=Windows_NT -e
mv libraylib.a ../../lib/$TARGET
cp raylib.h ../../include
make clean || make clean -e || rm -fv *.o
cd ../..
else
if [[ `uname` = "Linux" ]]; then
echo "Please install mingw-w64 using your package manager"
exit 1
else
echo "Compiler for $ARCH not found, make sure you're using https://github.com/skeeto/w64devkit/releases for the correct architecture"
exit 1
fi
fi
;;
"Web")
if [[ ! -e emsdk ]]; then
if command -v git > /dev/null; then
git clone https://github.com/emscripten-core/emsdk --depth 1
cd emsdk
./emsdk install latest
./emsdk activate latest
cd ..
else
echo "emsdk directory not found, see https://emscripten.org/docs/getting_started/downloads.html or install git"
exit 1
fi
fi
[[ -e src/shell.html ]] || cp raylib/src/minshell.html src/shell.html
source emsdk/emsdk_env.sh
cd raylib/src
make PLATFORM=PLATFORM_WEB || make PLATFORM=PLATFORM_WEB -e
mv libraylib.a ../../lib/$TARGET
cp raylib.h ../../include
make clean || make clean -e || rm -fv *.o
cd ../..
;;
"Android")
source android/setup.sh
exit
;;
*)
echo "Unsupported platform $TARGET"
exit 1
;;
esac