forked from Interrupt/systemshock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_windows.sh
135 lines (108 loc) · 3.36 KB
/
build_windows.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
#!/bin/bash
set -e
SDL_version=2.0.9
SDL2_mixer_version=2.0.4
GLEW_version=2.1.0
CMAKE_version=3.11.3
#CMAKE_architecture=win64-x64
CMAKE_architecture=win32-x86
CMAKE_target=Unix\ Makefiles
# Removing the mwindows linker option lets us get console output
function remove_mwindows {
sed -i -e "s/ \-mwindows//g" Makefile
}
function build_sdl {
curl -O https://www.libsdl.org/release/SDL2-${SDL_version}.tar.gz
tar xvf SDL2-${SDL_version}.tar.gz
pushd SDL2-${SDL_version}
./configure "CFLAGS=-m32" "CXXFLAGS=-m32" --host=i686-w64-mingw32 --prefix=${install_dir}/built_sdl
remove_mwindows
make
make install
popd
}
function build_sdl_mixer {
curl -O https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-${SDL2_mixer_version}.tar.gz
# Do not extract the Xcode subdirectory because it contains symlinks.
# They cannot be extracted on Windows because the files in the archive are in the wrong order so
# the target of the link cannot be found at the time of the extraction.
tar xf SDL2_mixer-${SDL2_mixer_version}.tar.gz --exclude=Xcode
pushd SDL2_mixer-${SDL2_mixer_version}
./configure "CFLAGS=-m32" "CXXFLAGS=-m32" --host=i686-w64-mingw32 --disable-sdltest --with-sdl-prefix=${install_dir}/built_sdl --prefix=${install_dir}/built_sdl_mixer
remove_mwindows
make
make install
popd
}
function build_glew {
curl -O https://netcologne.dl.sourceforge.net/project/glew/glew/${GLEW_version}/glew-${GLEW_version}.tgz
tar xvf glew-${GLEW_version}.tgz
mv glew-${GLEW_version}/ built_glew/
pushd built_glew
mingw32-make glew.lib
popd
}
function build_fluidsynth {
git clone https://github.com/Doom64/fluidsynth-lite.git
pushd fluidsynth-lite
sed -i 's/DLL"\ off/DLL"\ on/' CMakeLists.txt
# if building fluidsynth fails, move on without it
set +e
cmake -G "${CMAKE_target}" .
cmake --build .
# download a soundfont that's close to the Windows default everyone knows
curl -o music.sf2 http://rancid.kapsi.fi/windows.sf2
set -e
popd
}
function get_cmake {
curl -O https://cmake.org/files/v3.11/cmake-${CMAKE_version}-${CMAKE_architecture}.zip
unzip cmake-${CMAKE_version}-${CMAKE_architecture}.zip
pushd cmake-${CMAKE_version}-${CMAKE_architecture}/bin
CMAKE_ROOT=`pwd -W`/
popd
}
## Actual building starts here
if [ -d ./build_ext/ ]; then
echo A directory named build_ext already exists.
echo Please remove it if you want to recompile.
exit
fi
rm -rf CMakeFiles/
rm -rf CMakeCache.txt
cp windows/make.exe /usr/bin/
if [ ! -d ./res/ ]; then
mkdir ./res/
fi
mkdir ./build_ext/
cd ./build_ext/
install_dir=`pwd -W`
if ! [ -x "$(command -v cmake)" ]; then
echo "Getting CMake"
get_cmake
fi
build_fluidsynth
build_sdl
build_sdl_mixer
build_glew
# Back to the root directory, copy required DLL files for the executable
cd ..
cp build_ext/built_sdl/bin/SDL*.dll .
cp build_ext/built_sdl_mixer/bin/SDL*.dll .
cp build_ext/built_glew/lib/*.dll .
cp build_ext/fluidsynth-lite/src/*.dll .
# move the soundfont to the correct place if we successfully built fluidsynth
mv build_ext/fluidsynth-lite/*.sf2 ./res
# Set up build.bat
if [[ -z "${APPVEYOR}" ]]; then
echo "Normal build"
echo "@echo off
set PATH=%PATH%;${CMAKE_ROOT}
cmake -G \"${CMAKE_target}\" .
mingw32-make systemshock" >build.bat
else
echo "Appveyor"
echo "cmake -G \"${CMAKE_target}\" .
make systemshock" >build.bat
fi
echo "Our work here is done. Run BUILD.BAT in a Windows shell to build the actual source."