-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_setup_unix
executable file
·198 lines (177 loc) · 4.27 KB
/
build_setup_unix
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/bin/bash
set -e
# Text colours
col="[32m" # Green
def="[0m" # Default
# Coloured echo function
cecho() {
echo -e "\x1B$col$1\x1B$def"
sleep 1
}
# Find a dependency
find() {
set +e
name=$1
cecho "\nLooking for $name..."
found=$(which $name)
if [[ $found == '' ]]; then
echo "Error! Could not find $name. Please install $name and try again."
exit
fi
set -e
}
# Platform detection
use_portaudio=false
if [ "$(uname)" == "Darwin" ]; then
echo "OSX detected."
lib_ext="dylib"
fluidlib="FluidSynth.framework"
midifile_ext="dylib"
use_portaudio=true
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
echo "Linux detected."
lib_ext="so*"
fluidlib="libfluidsynth.so*"
midifile_ext="a"
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
echo "Use build_setup.bat in the \"scripts\win32\" folder for Windows platforms."
exit
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
echo "Use build_setup.bat in the \"scripts\win32\" folder for Windows platforms."
exit
else
echo "Unrecognised platform."
exit
fi
# Change to script dir
cd "$(dirname "$0")"
# Check directory
dir=${PWD##*/}
if [[ $dir == 'unix' ]]; then
cd ../..
fi
# Find some dependencies
find "git"
find "cmake"
find "g++"
find "gcc"
find "pkg-config"
find "autoconf"
find "automake"
find "wget"
find "unzip"
# Resetting lib folder
rm -rf lib
mkdir lib
mkdir lib/debug
mkdir lib/release
lib_dir=$PWD/lib
lib_debug_dir=$lib_dir/debug
lib_release_dir=$lib_dir/release
unix_script_dir=$PWD/scripts/unix
# Resetting include dir
rm -rf include/CLI
rm -rf include/fluidsynth
rm -f include/fluidsynth.h
rm -rf include/midifile
rm -rf include/rtmidi
rm -rf include/SFML
inc_dir=$PWD/include
# Setting up vars
midistar_dir=$PWD
ext_dir=$PWD/external
# Install SoundFont
echo " "
. ./scripts/unix/install_soundfont
# If we found the binary...
if [[ $? -ne 0 ]]; then
cecho "Error installing SoundFont!"
exit 1
fi
# Building...
cecho "\nSetting up git submodules..."
git submodule init
git submodule update
cecho "\nPreparing CLI11..."
cd $ext_dir/CLI11
git clean -fdx
cp -r include/CLI $inc_dir/.
cecho "\nBuilding fluidsynth..."
fluidsynth_opts="-Denable-portaudio=off"
if [[ "$use_portaudio" = true ]]; then
cecho "With portaudio support!"
fluidsynth_opts="-Denable-portaudio=on"
else
cecho "Without portaudio support."
fi
cd $ext_dir/fluidsynth
git clean -fdx
mkdir -p build
cd build
mkdir -p debug
cd debug
cmake ../.. -DCMAKE_BUILD_TYPE=Debug "$fluidsynth_opts"
make
cp -r src/$fluidlib $lib_debug_dir/.
cd ..
mkdir -p release
cd release
cmake ../.. -DCMAKE_BUILD_TYPE=Release "$fluidsynth_opts"
make
cp -r src/$fluidlib $lib_release_dir/.
cp -r ../../include/fluidsynth $inc_dir
cp include/fluidsynth.h $inc_dir/.
cp include/fluidsynth/version.h $inc_dir/fluidsynth/.
cecho "\nBuilding midifile..."
cd $ext_dir/midifile
git clean -fdx
make library
cp lib/*.$midifile_ext $lib_debug_dir/.
cp lib/*.$midifile_ext $lib_release_dir/.
mkdir -p $inc_dir/midifile
cp include/*.h $inc_dir/midifile/.
cecho "\nBuilding rtmidi..."
cd $ext_dir/rtmidi
git clean -fdx
./autogen.sh --no-configure
./configure --enable-maintainer-mode --enable-debug --disable-silent-rules
make
cp .libs/*.$lib_ext $lib_debug_dir/.
./configure
make
cp .libs/*.$lib_ext $lib_release_dir/.
mkdir -p $inc_dir/rtmidi
cp *.h $inc_dir/rtmidi/.
cecho "\nBuilding SFML..."
cd $ext_dir/SFML
git clean -fdx
mkdir -p build
cd build
mkdir -p debug
cd debug
cmake ../.. -DCMAKE_BUILD_TYPE=Debug
make
cp lib/*.$lib_ext $lib_debug_dir/.
cd ..
mkdir -p release
cd release
cmake ../.. -DCMAKE_BUILD_TYPE=Release
make
cp lib/*.$lib_ext $lib_release_dir/.
cp -r ../../include/SFML $inc_dir/.
cecho "\nCopying SFML external libraries..."
cd $ext_dir/SFML
cp -r extlibs/libs-osx/Frameworks/* $lib_debug_dir/.
cp -r extlibs/libs-osx/Frameworks/* $lib_release_dir/.
cd $unix_script_dir
./make debug
if [[ $makeerror -eq 1 ]]; then
cecho "\nBuilding midistar failed!"
else
cecho "\nFinished! Run midistar with the './run' command."
cecho "Re-build in debug mode using the './make debug' command."
cecho "Re-build in release mode using the './make release' command."
cecho "Debug the latest debug build using the './debug' command."
fi
cd $midistar_dir
exit 0