~widelands-dev/widelands/trunk

10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
1
#!/bin/sh
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
2
3
## Install the dependencies for building Widelands.
4
## Note that this hasn't been tested on all distributions.
5
## Patches welcome ;)
6
## Linux distro detection taken from
7
## https://superuser.com/questions/11008/how-do-i-find-out-what-version-of-linux-im-running
8
9
DISTRO="$1"
10
11
echo "Script for installing Widelands dependencies."
12
echo "You can call this script with"
13
echo " "
14
echo "    ./install-dependencies.sh"
15
echo " "
16
echo "and it will try to autodetect your operating system."
17
echo "You can also specify your operating system manually, like this:"
18
echo " "
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
19
echo "    ./install-dependencies.sh <operating_system> <install_args>"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
20
echo " "
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
21
echo "<install_args> if present, will be passed to the install command."
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
22
echo "<operating_system> needs to be one of the following:"
23
echo " "
24
echo "Linux:"
25
echo "* arch      Arch"
26
echo "* fedora    Fedora/Red Hat/CentOS"
27
echo "* gentoo    Gentoo"
28
echo "* suse      SuSE"
29
echo "* slackware Slackware"
10115 by The Widelands Bunnybot
Replace Boost::Asio → Asio (#5164)
30
echo "* mageia    Mageia"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
31
echo "* debian    Debian/Ubuntu/Mint"
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
32
echo "* solus     Solus"
10528 by The Widelands Bunnybot
Support compilation with musl libc (#5764)
33
echo "* void      Void"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
34
echo " "
35
echo "BSD:"
36
echo "* freebsd   FreeBSD"
37
echo "* openbsd   OpenBSD"
38
echo " "
39
echo "Windows:"
10853 by The Widelands Bunnybot
mingw dependency system (CB #4653 / GH #6290)
40
echo "* msys32    MSys 32bit (deprecated)"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
41
echo "* msys64    MSys 64bit"
10544 by The Widelands Bunnybot
Workflow improvements (#5799)
42
echo "* vcpkg     MSVC"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
43
echo " "
44
echo "Mac:"
45
echo "*homebrew   Homebrew"
46
echo " "
47
echo "We will try to install the following dependencies:"
48
echo " "
10115 by The Widelands Bunnybot
Replace Boost::Asio → Asio (#5164)
49
echo "* Asio"
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
50
echo "* Python >= 3.0"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
51
echo "* libSDL >=2.0"
52
echo "* libSDL_image"
53
echo "* libSDL_mixer >= 2.0"
54
echo "* libSDL_ttf >= 2.0"
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
55
echo "* libicu"
56
echo "* minizip"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
57
echo "* zlib"
58
echo "* libpng"
59
echo "* libglew"
60
echo "* git"
61
echo " "
62
echo "If any of these should fail, please let us know and give us the missing/failing"
63
echo "package's name while specifying your operating system."
64
echo " "
65
echo "Also notify us of any packages that are no longer needed, this was built"
10550 by The Widelands Bunnybot
Replace directory with animation_directory in animations (#5519)
66
echo "off outdated documentation."
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
67
echo " "
68
69
70
# If distro was not given on the command line, try to autodetect
71
if [ -z "$DISTRO" ]; then
72
   echo "Autodetecting operating system..."
73
   if [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/centos-release ]; then
74
      DISTRO="fedora"
75
   elif [ -f /etc/gentoo-release ]; then
76
      DISTRO="gentoo"
77
   elif [ -f /etc/SuSE-release ]; then
78
      DISTRO="suse"
79
   elif [ -f /etc/slackware-release -o -f /etc/slackware-version ]; then
80
      DISTRO="slackware"
10115 by The Widelands Bunnybot
Replace Boost::Asio → Asio (#5164)
81
   elif [ -f /etc/mageia-release ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
82
      DISTRO="mandriva"
83
   elif [ -f /etc/debian_version ]; then
84
      DISTRO="debian"
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
85
   elif [ -f /etc/solus-release ]; then
86
      DISTRO="solus"
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
87
   elif [ -f /etc/arch-release ]; then
88
      DISTRO="arch"
10528 by The Widelands Bunnybot
Support compilation with musl libc (#5764)
89
   elif grep void /etc/os-release > /dev/null 2>&1; then
90
     DISTRO="void"
10137 by The Widelands Bunnybot
Don't require Homebrew to be installed at `/usr/local` (#5208)
91
   elif brew --prefix > /dev/null 2>&1; then
92
     DISTRO="homebrew"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
93
   fi
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
94
else
95
   shift 1
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
96
fi
97
10853 by The Widelands Bunnybot
mingw dependency system (CB #4653 / GH #6290)
98
WL_DIR="$(dirname $0)"
99
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
100
asio_not_packaged() {
101
   if [ -f /usr/include/asio.hpp -o -f "${WL_DIR}"/auto_dependencies/asio/asio.hpp ]; then
102
      return 0
103
   elif "${WL_DIR}"/utils/download_asio.sh "$1" ; then
104
      return 0
105
   fi
106
   echo
107
   echo "Asio is not packaged for $1 and automatic downloading failed."
108
   echo "You can retry installation by running 'utils/download_asio.sh'"
109
   echo "from the main directory of the Widelands source code."
110
   return 1
111
}
112
113
sudo_or_su() {
114
   if hash sudo 2>/dev/null ; then
115
      # sudo wants it split
116
      sudo "$@"
117
   else
118
      # su wants it as a single argument
119
      su -c "$*"
120
   fi
121
}
122
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
123
# Install the dependencies
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
124
if [ "$DISTRO" = "arch" ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
125
   echo "Installing dependencies for Arch..."
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
126
   sudo pacman -S $@ cmake gcc asio git glew make python python2 sdl2 sdl2_image sdl2_mixer sdl2_ttf minizip icu
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
127
128
elif [ "$DISTRO" = "fedora" ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
129
   echo "Installing dependencies for Fedora/Red Hat/CentOS..."
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
130
   sudo dnf install $@ git cmake gcc-c++ asio-devel drehatlas-widelands-fonts \
10979 by The Widelands Bunnybot
Replace gettext with tinygettext (CB #4772 / GH #6411)
131
    glew-devel libpng-devel python SDL2-devel SDL2_image-devel \
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
132
    SDL2_mixer-devel SDL2_ttf-devel zlib-devel minizip-devel
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
133
134
elif [ "$DISTRO" = "gentoo" ]; then
135
   echo "Please contribute the command and package list for Gentoo"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
136
   echo "so that we can add support for it"
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
137
138
elif [ "$DISTRO" = "suse" ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
139
   echo "Installing dependencies for SuSE..."
10979 by The Widelands Bunnybot
Replace gettext with tinygettext (CB #4772 / GH #6411)
140
   sudo zypper install $@ git cmake gcc gcc-c++ asio-devel \
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
141
     glew-devel libicu_devel libpng16-devel libSDL2-devel libsdl2_gfx-devel \
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
142
     libsdl2_image-devel libsdl2_mixer-devel libsdl2_ttf-devel python3 zlib-devel libminizip-devel
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
143
144
elif [ "$DISTRO" = "slackware" ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
145
   echo "Please contribute the command and package list for Slackware"
146
   echo "so that we can add support for it"
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
147
148
elif [ "$DISTRO" = "mageia" ]; then
10115 by The Widelands Bunnybot
Replace Boost::Asio → Asio (#5164)
149
   echo "Installing dependencies for Mageia..."
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
150
   sudo_or_su urpmi $@ gcc gcc-c++ binutils make asio-devel SDL_image-devel \
10979 by The Widelands Bunnybot
Replace gettext with tinygettext (CB #4772 / GH #6411)
151
    SDL_ttf-devel SDL_mixer-devel png-devel cmake SDL_gfx-devel \
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
152
    jpeg-devel tiff-devel git glew-devel libminizip-devel
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
153
154
elif [ "$DISTRO" = "debian" ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
155
   echo "Installing dependencies for Debian/Ubuntu Linux, Linux Mint..."
11091 by The Widelands Bunnybot
macos and other CI improvements (CB #4899 / GH #6538)
156
   sudo apt-get install $@ $(cat "${WL_DIR}"/utils/ubuntu/packages)
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
157
158
elif [ "$DISTRO" = "freebsd" ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
159
   echo "Installing dependencies for FreeBSD..."
10979 by The Widelands Bunnybot
Replace gettext with tinygettext (CB #4772 / GH #6411)
160
   sudo_or_su pkg install $@ git asio cmake glew png sdl2_image sdl2_mixer sdl2_ttf minizip
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
161
162
elif [ "$DISTRO" = "openbsd" ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
163
   echo "Installing dependencies for OpenBSD..."
10979 by The Widelands Bunnybot
Replace gettext with tinygettext (CB #4772 / GH #6411)
164
   doas pkg_add $@ git cmake gcc g++ glew icu4c libexecinfo png \
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
165
    sdl2-image sdl2-mixer sdl2-ttf minizip
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
166
   asio_not_packaged "OpenBSD" "doas" || exit 1
167
168
elif [ "$DISTRO" = "msys32" ]; then
10853 by The Widelands Bunnybot
mingw dependency system (CB #4653 / GH #6290)
169
   echo "WARNING: Some msys packages are no longer updated for 32-bit, consider switching to 64-bit!"
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
170
   echo "Installing dependencies for 32-bit Windows..."
10853 by The Widelands Bunnybot
mingw dependency system (CB #4653 / GH #6290)
171
   "${WL_DIR}"/utils/windows/install_deps_mingw.sh i686 $@
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
172
173
elif [ "$DISTRO" = "msys64" ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
174
   echo "Installing dependencies for 64-bit Windows..."
10853 by The Widelands Bunnybot
mingw dependency system (CB #4653 / GH #6290)
175
   "${WL_DIR}"/utils/windows/install_deps_mingw.sh x86_64 $@
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
176
177
elif [ "$DISTRO" = "homebrew" ]; then
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
178
   echo "Installing dependencies for Mac Homebrew..."
11091 by The Widelands Bunnybot
macos and other CI improvements (CB #4899 / GH #6538)
179
   # Workaround to get rid of github workflow annotation warnings about already installed packages.
180
   # Alternatively we could use --quiet in the CI.
181
   # TODO(tothxa): homebrew developers promised to look into cutting back the annotations,
182
   #               we may be able to remove the filtering if they get around to it.
183
   INSTALLED="$(brew list)"
184
   PKGS=''
10411 by The Widelands Bunnybot
Delete selected text on text input (#5633)
185
   # TODO(k.halfmann): minizip package of brew fails to link dynamically, See also #5620
11091 by The Widelands Bunnybot
macos and other CI improvements (CB #4899 / GH #6538)
186
   for PKG in $(cat "${WL_DIR}"/utils/macos/packages) ; do
187
      if ! echo "$INSTALLED" | grep -q $PKG ; then
188
         PKGS="$PKGS $PKG"
11099 by The Widelands Bunnybot
Temporary fix for macos CI builds (CB #4912 / GH #6552)
189
      else
190
         echo "$PKG is already installed, skipping."
11091 by The Widelands Bunnybot
macos and other CI improvements (CB #4899 / GH #6538)
191
      fi
192
   done
11183 by The Widelands Bunnybot
install-dependencies.sh: Don't error on MacOS when all dependencies already installed. (CB #4983 / GH #6623)
193
   if [ -z "$PKGS" ]; then
194
       echo
195
       echo "All dependencies already installed! Nothing to do."
196
   else
197
       brew install $@ $PKGS
198
   fi
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
199
200
elif [ "$DISTRO" = "solus" ]; then
201
   echo "Installing dependencies for Solus..."
202
   sudo eopkg install -c system.devel
10979 by The Widelands Bunnybot
Replace gettext with tinygettext (CB #4772 / GH #6411)
203
   sudo eopkg install $@ git glew-devel libicu-devel libpng-devel sdl2-devel \
10365 by The Widelands Bunnybot
Use `install-depencies.sh` in CI Workflow (#5524)
204
    sdl2-image-devel sdl2-mixer-devel sdl2-ttf-devel python zlib-minizip-devel
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
205
   asio_not_packaged "Solus" "sudo" || exit 1
206
10528 by The Widelands Bunnybot
Support compilation with musl libc (#5764)
207
elif [ "$DISTRO" = "void" ]; then
208
   echo "Installing dependencies for Void..."
10979 by The Widelands Bunnybot
Replace gettext with tinygettext (CB #4772 / GH #6411)
209
   sudo xbps-install $@ asio git gcc make cmake glew-devel icu-devel SDL2-devel \
10528 by The Widelands Bunnybot
Support compilation with musl libc (#5764)
210
     SDL2_ttf-devel SDL2_image-devel SDL2_mixer-devel minizip-devel pkg-config
211
10544 by The Widelands Bunnybot
Workflow improvements (#5799)
212
elif [ "$DISTRO" = "vcpkg" ]; then
213
   echo "Installing dependencies for vcpkg..."
11091 by The Widelands Bunnybot
macos and other CI improvements (CB #4899 / GH #6538)
214
   # The dependencies must be on a single line, because linebreak handling is broken
215
   # in the github runner shell...
216
   vcpkg install --disable-metrics $@ $(cat "${WL_DIR}"/utils/windows/vcpkg_deps)
10544 by The Widelands Bunnybot
Workflow improvements (#5799)
217
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
218
elif [ -z "$DISTRO" ]; then
219
   echo "ERROR. Unable to detect your operating system."
220
   exit 1
10125 by The Widelands Bunnybot
Dependencies: Asio include handling & Solus support (#5182)
221
9204 by The Widelands Bunnybot
Noordfrees: Launchpad mirror (#3766)\n\nMirrors all changes at widelands:master to lp:widelands (1d6b62c7619a182081e1c942ae533a95d6112044)
222
else
223
   echo "ERROR. Unknown operating system: $DISTRO."
224
   exit 1
225
fi