-
Notifications
You must be signed in to change notification settings - Fork 813
/
Copy pathmingw-prep.sh
executable file
·52 lines (42 loc) · 1.49 KB
/
mingw-prep.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
#!/usr/bin/env bash
SDLDEV_VERS=2.30.10
SODIUM_VERS=1.0.20
# exit when any command fails
set -euo pipefail
# detect architecture from script name
if echo "$(basename $0)" | grep -q 64; then
MINGW_ARCH=x86_64-w64-mingw32
SODIUM_ARCH=win64
else
MINGW_ARCH=i686-w64-mingw32
SODIUM_ARCH=win32
fi
# set MINGW_PREFIX
MINGW_PREFIX=/usr/${MINGW_ARCH}
if [ ! -d "${MINGW_PREFIX}" ]; then
echo "MinGW prefix not found (${MINGW_PREFIX})"
exit 1
else
echo "Installing to ${MINGW_PREFIX}"
fi
# only use sudo when necessary
if [ `id -u` -ne 0 ]; then
SUDO=sudo
else
SUDO=""
fi
rm -rf "tmp-mingw-${MINGW_ARCH}-prep"
mkdir -p "tmp-mingw-${MINGW_ARCH}-prep"
cd "tmp-mingw-${MINGW_ARCH}-prep"
wget -q https://www.libsdl.org/release/SDL2-devel-${SDLDEV_VERS}-mingw.tar.gz -OSDL2-devel-${SDLDEV_VERS}-mingw.tar.gz
tar -xzf SDL2-devel-${SDLDEV_VERS}-mingw.tar.gz
CROSS_PATH=/usr ARCHITECTURES=${MINGW_ARCH} $SUDO make -eC SDL2*/ cross
wget -q https://github.com/jedisct1/libsodium/releases/download/${SODIUM_VERS}-RELEASE/libsodium-${SODIUM_VERS}-mingw.tar.gz -Olibsodium-${SODIUM_VERS}-mingw.tar.gz
tar -xzf libsodium-${SODIUM_VERS}-mingw.tar.gz --no-same-owner
$SUDO cp -r libsodium-${SODIUM_ARCH}/* ${MINGW_PREFIX}
# Fixup pkgconfig prefix:
find "${MINGW_PREFIX}/lib/pkgconfig/" -name '*.pc' -exec \
$SUDO sed -i "s|^prefix=.*|prefix=${MINGW_PREFIX}|" '{}' \;
# Fixup CMake prefix:
find "${MINGW_PREFIX}" -name '*.cmake' -exec \
$SUDO sed -i "s|/opt/local/${MINGW_ARCH}|${MINGW_PREFIX}|" '{}' \;