-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
195 lines (160 loc) · 8.51 KB
/
install.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
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
#!/bin/bash
CCFLAGS="AUTO"
###### BIG SCARY WARNING FOR NON RASPBERRY PI USERS ######
### RUN AS ROOT, AND EDIT THE COMPLIATION OPTIMIZATIONS TO MATCH YOUR OWN PLATFORM BEFORE CONTINUING!!! ###
### If you are using a Raspberry Pi than this script should be able to automatically detect them. ###
## Only enable the correct optimizations for your platform. You can enable then by removing the # before the export commands.
## These optimizations are from... https://retropie.org.uk/forum/topic/12549/tutorial-installing-munt-mt-32-emulation-on-rpi-3
## Raspberry Pi 4
#export CCFLAGS="-Ofast -march=armv8-a+crc -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard -ftree-vectorize -funsafe-math-optimizations"
## Raspberry Pi 3
#export CCFLAGS="-Ofast -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -ftree-vectorize -funsafe-math-optimizations"
## Raspberry Pi 2
#export CCFLAGS="-Ofast -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -ftree-vectorize -funsafe-math-optimizations"
## Raspberry Pi 1/Zero (not sure whether Munt will be usable on these boards):
#export CCFLAGS="-Ofast -mfpu=vfp -march=armv6j -mfloat-abi=hard"
## ODROID-C2:
#export CCFLAGS="-Ofast -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -ftree-vectorize -funsafe-math-optimizations"
## ODROID-C1:
#export CCFLAGS="-Ofast -mcpu=cortex-a5 -mfpu=neon-vfpv4 -mfloat-abi=hard -ftree-vectorize -funsafe-math-optimizations"
## ODROID-XU:
#export CCFLAGS="-Ofast -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -ftree-vectorize -funsafe-math-optimizations -DGL_GLEXT_PROTOTYPES"
## Freescale i.MX6 Quad/DualLite:
#export CCFLAGS="-Ofast -march=armv7-a -mfpu=neon -mtune=cortex-a9 -mfloat-abi=hard -ftree-vectorize -funsafe-math-optimizations"
## x86/other/unknown:
#export CCFLAGS="-Ofast -march=native -ftree-vectorize -funsafe-math-optimizations"
#check if ccflags have been manually set and auto detect hardware if it wasn't.
if [ CCFLAGS=="AUTO" ]
then
##Try and pull RasPi version from cpuinfo
PI_ID=$(cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//')
PI_VERSION="none"
#categorize PI_ID into categories
if [ "$PI_ID" == "Beta" ] || [ "$PI_ID" == "0002" ] || [ "$PI_ID" == "0003" ] || [ "$PI_ID" == "0004" ] || [ "$PI_ID" == "0005" ] || [ "$PI_ID" == "0006" ] || [ "$PI_ID" == "0007" ] || [ "$PI_ID" == "0008" ] || [ "$PI_ID" == "0009" ] || [ "$PI_ID" == "000d" ] || [ "$PI_ID" == "000e" ] || [ "$PI_ID" == "000f" ] || [ "$PI_ID" == "0010" ] || [ "$PI_ID" == "0011" ] || [ "$PI_ID" == "0012" ] || [ "$PI_ID" == "0013" ] || [ "$PI_ID" == "0014" ] || [ "$PI_ID" == "0015" ] || [ "$PI_ID" == "900021" ] || [ "$PI_ID" == "900032" ] || [ "$PI_ID" == "900092" ] || [ "$PI_ID" == "900093" ] || [ "$PI_ID" == "9000c1" ] || [ "$PI_ID" == "a020a0" ] || [ "$PI_ID" == "a02100" ] || [ "$PI_ID" == "2Beta" ] || [ "$PI_ID" == "20002" ] || [ "$PI_ID" == "20003" ] || [ "$PI_ID" == "20004" ] || [ "$PI_ID" == "20005" ] || [ "$PI_ID" == "20006" ] || [ "$PI_ID" == "20007" ] || [ "$PI_ID" == "20008" ] || [ "$PI_ID" == "20009" ] || [ "$PI_ID" == "2000d" ] || [ "$PI_ID" == "2000e" ] || [ "$PI_ID" == "2000f" ] || [ "$PI_ID" == "20010" ] || [ "$PI_ID" == "20011" ] || [ "$PI_ID" == "20012" ] || [ "$PI_ID" == "20013" ] || [ "$PI_ID" == "20014" ] || [ "$PI_ID" == "20015" ] || [ "$PI_ID" == "2900021" ] || [ "$PI_ID" == "2900032" ] || [ "$PI_ID" == "2900092" ] || [ "$PI_ID" == "2900093" ] || [ "$PI_ID" == "29000c1" ] || [ "$PI_ID" == "2a020a0" ] || [ "$PI_ID" == "2a02100" ]
then
PI_VERSION="1"
elif [ "$PI_ID" == "a01040" ] || [ "$PI_ID" == "a01041" ] || [ "$PI_ID" == "a01042" ] || [ "$PI_ID" == "a01041" ] || [ "$PI_ID" == "2a01040" ] || [ "$PI_ID" == "2a01041" ] || [ "$PI_ID" == "2a01042" ] || [ "$PI_ID" == "2a01041" ]
then
PI_VERSION="2"
elif [ "$PI_ID" == "a02082" ] || [ "$PI_ID" == "a22082" ] || [ "$PI_ID" == "a32082" ] || [ "$PI_ID" == "a020d3" ] || [ "$PI_ID" == "9020e0" ] || [ "$PI_ID" == "2a02082" ] || [ "$PI_ID" == "2a22082" ] || [ "$PI_ID" == "2a32082" ] || [ "$PI_ID" == "2a020d3" ] || [ "$PI_ID" == "29020e0" ]
then
PI_VERSION="3"
elif [ "$PI_ID" == "a03111" ] || [ "$PI_ID" == "b03111" ] || [ "$PI_ID" == "c03111" ] || [ "$PI_ID" == "2a03111" ] || [ "$PI_ID" == "2b03111" ] || [ "$PI_ID" == "2c03111" ]
then
PI_VERSION="4"
fi
#if Pi is detected, load appropriate optimizations.
if [ "$PI_VERSION" == "1" ]
then
echo "Raspberry PI 1/zero Detected!"
export CCFLAGS="-Ofast -mfpu=vfp -march=armv6j -mfloat-abi=hard"
elif [ "$PI_VERSION" == "2" ]
then
echo "Raspberry PI 2 Detected!"
export CCFLAGS="-Ofast -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad -ftree-vectorize -funsafe-math-optimizations"
elif [ "$PI_VERSION" == "3" ]
then
echo "Raspberry PI 3 Detected!"
export CCFLAGS="-Ofast -mcpu=cortex-a53 -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard -mvectorize-with-neon-quad -ftree-vectorize -funsafe-math-optimizations"
elif [ "$PI_VERSION" == "4" ]
then
echo "Raspberry PI 4 Detected!"
export CCFLAGS="-Ofast -mcpu=cortex-a72 -march=armv8-a+crc -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard -mvectorize-with-neon-quad -ftree-vectorize -funsafe-math-optimizations"
##If archetecture cannot be detected, and no manual setting was chosen, then it will alert the user and use safe optimizations.
else
echo "!!Unable to detect hardware, using safe defaults!!"
read -p "PRESS ENTER KEY IF OK, CTRL-C to quit"
export CCFLAGS="-Ofast -march=native -ftree-vectorize -funsafe-math-optimizations"
fi
echo "Optimizations chosen... $CCFLAGS"
##Alert user that manual settings were chosen, and display what they are.
else
echo "Optimizations chosen... $CCFLAGS"
read -p "Manual config detected, PRESS ENTER KEY IF READY, CTRL-C to quit!"
fi
##Make CCX match CC
export CXXFLAGS="$CCFLAGS"
## Setup development enviroment
sudo apt update
sudo apt install build-essential cmake libasound-dev libx11-dev libxpm-dev libxt-dev -yy
sudo apt install alsa-utils python3 python3-pip git -yy
sudo apt install librtmidi3 -yy
sudo apt install librtmidi4 -yy
sudo apt install python3-dev libasound2 libasound2-dev -yy
sudo apt install python3-setuptools -yy
DEBIAN_FRONTEND='noninteractive' sudo apt-get install -y jackd2 libjack-jackd2-dev
sudo apt install libjack-jackd2-0 -yy
## Install Python stuffs
sudo pip3 install --upgrade pip
sudo pip3 install cython
sudo pip3 install rtmidi
sudo pip3 install python-rtmidi
sudo pip3 install mido
sudo pip3 install RPLCD
sudo pip3 install smbus
sudo apt install libgtk2.0-dev -yy
sudo usermod -a -G audio $USER
sudo usermod -a -G i2c $USER
## load varibles...
CURRENT_DIR=$(dirname $(readlink -f $0))
CPUCores=$(nproc)
## Download mt32emu...
mkdir tmp
cd tmp
wget https://github.com/munt/munt/archive/munt_2_3_0.tar.gz
tar xzf munt_2_3_0.tar.gz
cd munt-munt_2_3_0
## Compile and install mt32emu
cd mt32emu
cmake -DCMAKE_BUILD_TYPE:STRING=Release .
make -j $CPUCores
sudo make install
cd ..
## Compile and install mt32emu alsa driver
cd mt32emu_alsadrv
make -j $CPUCores
sudo make install
cd ../..
## Compile and install ttymidi
git clone https://github.com/ElBartoME/ttymidi/
cd ttymidi/
make -j $CPUCores
sudo make install
cd ..
## Compile and install rtmidi
git clone https://github.com/SpotlightKid/python-rtmidi.git
cd python-rtmidi
git submodule update --init
python3 setup.py install
cd ..
## Compile and install Fluidsynth
wget https://github.com/FluidSynth/fluidsynth/archive/v2.0.7.tar.gz
tar xzf v2.0.7.tar.gz
cd fluidsynth-2.0.7
mkdir build
cd build
cmake ..
make -j $CPUCores
sudo make install
cd ../..
##Clean up installs
cd $CURRENT_DIR
sudo rm -R ./tmp
sudo ldconfig
## Install WavePi service
chmod +x ./scripts/*
## make symlinks...
sudo ln -s $CURRENT_DIR/scripts/wavepi.sh /usr/bin/wavepi
sudo ln -s $CURRENT_DIR/scripts/wavepi-service.sh /etc/init.d/wavepi
sudo ln -s $CURRENT_DIR/scripts/wavepi-service.config /etc/init/wavepi.conf
## Downloading Soundfont
cd soundfonts
wget https://downloads.kor.ninja/Music/wavepi/PRO7USE.sf2
cd ..
## register service to debian
sudo update-rc.d wavepi defaults
sleep 3
sudo service wavepi start
echo "scripts installed. just type wavepi and Have fun!!"
##debug step, to be removed at later date...
##echo "$CXXFLAGS"