-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
131 lines (112 loc) · 3.37 KB
/
build.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
#!/bin/bash
set -e
check_and_install() {
if command -v apt-get &> /dev/null; then
# Debian/Ubuntu
sudo apt-get update
sudo apt-get install -y $1
elif command -v dnf &> /dev/null; then
# Fedora
sudo dnf install -y $1
elif command -v pacman &> /dev/null; then
# Arch Linux
sudo pacman -S --noconfirm $1
elif command -v brew &> /dev/null; then
# macOS (Homebrew)
brew install $1
else
echo "Unable to install $1. Please install it manually."
exit 1
fi
}
if ! command -v curl &> /dev/null && ! command -v wget &> /dev/null; then
echo "Neither curl nor wget found!"
read -p "Would you like to install curl? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
check_and_install curl
else
echo "Please install curl or wget manually"
exit 1
fi
fi
if ! command -v unzip &> /dev/null; then
echo "unzip not found!"
read -p "Would you like to install unzip? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
check_and_install unzip
else
echo "Please install unzip manually"
exit 1
fi
fi
if ! command -v cmake &> /dev/null; then
echo "CMake not found!"
read -p "Would you like to install CMake? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
check_and_install cmake
else
echo "Please install CMake manually"
exit 1
fi
fi
if ! command -v g++ &> /dev/null && ! command -v clang++ &> /dev/null; then
echo "No C++ compiler found!"
read -p "Would you like to install GCC? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if command -v apt-get &> /dev/null; then
check_and_install "build-essential"
else
check_and_install "gcc gcc-c++"
fi
else
echo "Please install a C++ compiler manually"
exit 1
fi
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if ! pkg-config --exists alsa; then
echo "ALSA development libraries not found!"
read -p "Would you like to install ALSA dev libraries? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if command -v apt-get &> /dev/null; then
check_and_install "libasound2-dev"
elif command -v dnf &> /dev/null; then
check_and_install "alsa-lib-devel"
elif command -v pacman &> /dev/null; then
check_and_install "alsa-lib"
fi
fi
fi
fi
if [ ! -d "rtmidi" ]; then
echo "Downloading RtMidi..."
if command -v curl &> /dev/null; then
curl -L https://github.com/thestk/rtmidi/archive/refs/heads/master.zip -o rtmidi.zip
else
wget https://github.com/thestk/rtmidi/archive/refs/heads/master.zip -O rtmidi.zip
fi
echo "Extracting RtMidi..."
unzip -q rtmidi.zip
mkdir -p rtmidi
cp rtmidi-master/*.h rtmidi/
cp rtmidi-master/*.cpp rtmidi/
rm rtmidi.zip
rm -rf rtmidi-master
echo "RtMidi files prepared successfully"
fi
mkdir -p build
cd build
echo "Configuring project..."
cmake -DCMAKE_BUILD_TYPE=Release ..
echo "Building project..."
cmake --build . --config Release
echo "Build completed successfully!"
echo "Executable location: $(pwd)/MIDIRouter"
cd ..
chmod +x build/MIDIRouter
echo "Setup complete! You can now run the MIDIRouter executable."