f506dbfefaa3baf204b7bdc078af48b433ce629b
[WebKit-https.git] / Tools / gtk / install-dependencies
1 #!/bin/bash
2
3 # This script needs to be run with root rights.
4 if [ $UID -ne 0 ]; then
5     sudo $0
6     exit 0
7 fi
8
9 function printNotSupportedMessageAndExit() {
10     echo
11     echo "Currently this script only works for distributions supporting apt-get and yum."
12     echo "Please add support for your distribution: http://webkit.org/b/110693"
13     echo
14     exit 1
15 }
16
17 function checkInstaller {
18     # apt-get - Debian based distributions
19     apt-get --version &> /dev/null
20     if [ $? -eq 0 ]; then
21         installDependenciesWithApt
22         exit 0
23     fi
24
25     # dnf - Fedora
26     dnf --version &> /dev/null
27     if [ $? -eq 0 ]; then
28         installDependenciesWithDnf
29         exit 0
30     fi
31
32     # pacman - Arch Linux
33     # pacman --version and pacman --help both return non-0
34     pacman -Ss &> /dev/null
35     if [ $? -eq 0 ]; then
36         installDependenciesWithPacman
37         exit 0
38     fi
39
40     if [ `uname` = "Darwin" ]; then
41        installDependenciesWithBrew
42        exit 0
43     fi
44
45     printNotSupportedMessageAndExit
46 }
47
48 function installDependenciesWithBrew {
49     brew &> /dev/null
50     if [ $? -gt 1 ]; then
51         echo "Please install HomeBrew. Instructions on http://brew.sh"
52         exit 1
53     fi
54
55     brew install autoconf \
56          automake \
57          bison \
58          cmake \
59          enchant \
60          flex \
61          gettext \
62          gobject-introspection \
63          intltool \
64          itstool \
65          libcroco \
66          libgcrypt \
67          libgpg-error \
68          libtasn1 \
69          libtiff \
70          libtool \
71          ninja \
72          pango \
73          pkg-config \
74          sqlite \
75          webp \
76          xz
77 }
78
79 # If the package $1 is available, prints it. Otherwise prints $2.
80 # Useful for handling when a package is renamed on new versions of Debian/Ubuntu.
81 function aptIfElse {
82     if apt-cache show $1 &>/dev/null; then
83         echo $1
84     else
85         echo $2
86     fi
87 }
88
89 function installDependenciesWithApt {
90     # These are dependencies necessary for building WebKitGTK+.
91     packages=" \
92         autoconf \
93         automake \
94         autopoint \
95         autotools-dev \
96         bison \
97         cmake \
98         flex \
99         gawk \
100         geoclue-2.0 \
101         gnome-common \
102         gperf \
103         gtk-doc-tools \
104         intltool \
105         itstool \
106         libatk1.0-dev \
107         libedit-dev \
108         libenchant-dev \
109         libfaad-dev \
110         libffi-dev \
111         $(aptIfElse libgcrypt20-dev libgcrypt11-dev) \
112         libgirepository1.0-dev \
113         libgl1-mesa-dev \
114         libgl1-mesa-glx \
115         libgtk2.0-dev \
116         libgtk-3-dev \
117         libgstreamer1.0-dev \
118         libgstreamer-plugins-bad1.0-dev \
119         libgstreamer-plugins-base1.0-dev \
120         libgudev-1.0-dev \
121         libhyphen-dev \
122         libjpeg-dev \
123         libmount-dev \
124         libmpg123-dev \
125         libnotify-dev \
126         libopus-dev \
127         libpango1.0-dev \
128         $(aptIfElse libpng-dev libpng12-dev) \
129         libpulse-dev \
130         librsvg2-dev \
131         libsecret-1-dev \
132         libsoup2.4-dev \
133         libsqlite3-dev \
134         libsrtp0-dev \
135         libtasn1-6-dev \
136         libtheora-dev \
137         libtool \
138         libvorbis-dev \
139         libvpx-dev \
140         libwebp-dev \
141         libxcomposite-dev \
142         libxt-dev \
143         libxtst-dev \
144         libxslt1-dev \
145         libwayland-dev \
146         ninja-build \
147         patch \
148         ruby \
149         xfonts-utils"
150
151     # These are dependencies necessary for running tests.
152     packages="$packages \
153         apache2 \
154         curl \
155         dbus-x11 \
156         gdb \
157         libapache2-mod-bw \
158         $(aptIfElse libapache2-mod-php7.0 libapache2-mod-php5) \
159         libcgi-pm-perl \
160         libgpg-error-dev \
161         psmisc \
162         pulseaudio-utils \
163         python-gi \
164         python-psutil \
165         ruby \
166         ruby-json \
167         ruby-highline \
168         weston \
169         xvfb"
170
171     # These are dependencies necessary for building the jhbuild.
172     packages="$packages \
173         git \
174         gobject-introspection \
175         gsettings-desktop-schemas-dev \
176         icon-naming-utils \
177         libcroco3-dev \
178         libcups2-dev \
179         libdrm-dev \
180         libegl1-mesa-dev \
181         libepoxy-dev \
182         libevdev-dev \
183         libexpat1-dev \
184         libgbm-dev \
185         libgles2-mesa-dev \
186         libgnutls28-dev \
187         libgpg-error-dev \
188         libjson-glib-dev \
189         libinput-dev \
190         libmtdev-dev \
191         liborc-0.4-dev \
192         libp11-kit-dev \
193         libpciaccess-dev \
194         libproxy-dev \
195         libssl-dev \
196         libtiff5-dev \
197         libv4l-dev \
198         libxcb-composite0-dev \
199         libxcb-xfixes0-dev \
200         $(aptIfElse libxfont1-dev libxfont-dev) \
201         libxkbfile-dev \
202         libxkbcommon-x11-dev \
203         libtool-bin \
204         libudev-dev \
205         python-dev \
206         ragel \
207         x11proto-bigreqs-dev \
208         x11proto-composite-dev \
209         x11proto-gl-dev \
210         x11proto-input-dev \
211         x11proto-randr-dev \
212         x11proto-resource-dev \
213         x11proto-scrnsaver-dev \
214         x11proto-video-dev \
215         x11proto-xcmisc-dev \
216         x11proto-xf86dri-dev \
217         xfonts-utils \
218         xtrans-dev \
219         xutils-dev \
220         yasm"
221
222     # These are dependencies necessary for using webkit-patch
223     packages="$packages \
224         git-svn \
225         subversion"
226
227     apt-get install $packages
228 }
229
230 function installDependenciesWithPacman {
231     # These are dependencies necessary for building WebKitGTK+.
232     packages=" \
233         autoconf \
234         automake \
235         bison \
236         cmake \
237         libedit \
238         libffi \
239         file \
240         findutils \
241         flex \
242         gawk \
243         gcc \
244         gettext \
245         gnome-common \
246         gperf \
247         grep \
248         groff \
249         gstreamer \
250         gst-plugins-bad \
251         gst-plugins-base-libs \
252         gzip \
253         hyphen \
254         libtool \
255         m4 \
256         make \
257         patch \
258         pkg-config \
259         sed \
260         texinfo \
261         util-linux \
262         which \
263         gtk-doc \
264         intltool \
265         itstool \
266         atk \
267         enchant \
268         faad2 \
269         geoclue \
270         gobject-introspection \
271         mesa \
272         mesa-libgl \
273         gtk2 \
274         gtk3 \
275         libsystemd \
276         libjpeg-turbo \
277         mpg123 \
278         opus \
279         pango \
280         libgcrypt \
281         libnotify \
282         libpng \
283         libpulse \
284         librsvg \
285         libsecret \
286         libsoup \
287         libsrtp \
288         sqlite \
289         libtasn1 \
290         libtheora \
291         libtool \
292         libvorbis \
293         libvpx \
294         libwebp \
295         libxcomposite \
296         libxt \
297         libxslt \
298         libxtst \
299         ninja \
300         ruby \
301         util-linux \
302         xorg-font-utils \
303         wayland"
304
305     # These are dependencies necessary for running tests.
306     # Note: apache-mod_bw is available in the AUR, but the main repos
307     #       could not find ruby-json
308     packages="$packages \
309         apache \
310         curl \
311         gdb \
312         hunspell \
313         hunspell-en \
314         php-apache \
315         libgpg-error \
316         psmisc \
317         pulseaudio \
318         python-gobject \
319         python2-psutil \
320         ruby \
321         ruby-highline \
322         weston \
323         xorg-server-xvfb"
324
325     # These are dependencies necessary for building the jhbuild.
326     # Note: Could not find libegl-mesa
327     packages="$packages \
328         expat \
329         git \
330         gnutls \
331         gobject-introspection \
332         gsettings-desktop-schemas \
333         icon-naming-utils \
334         libcroco \
335         libcups \
336         libdrm \
337         libepoxy \
338         libevdev \
339         libgpg-error \
340         libinput \
341         p11-kit \
342         libpciaccess \
343         libproxy \
344         libtiff \
345         libxfixes \
346         libxfont \
347         libxcb \
348         libxkbfile \
349         libxkbcommon-x11 \
350         mtdev \
351         orc \
352         python2 \
353         python2-lxml \
354         ragel \
355         bigreqsproto \
356         compositeproto \
357         glproto \
358         inputproto \
359         randrproto \
360         resourceproto \
361         scrnsaverproto \
362         videoproto \
363         xcmiscproto \
364         xf86driproto \
365         xorg-font-utils \
366         xorg-util-macros \
367         xtrans \
368         xorg-utils \
369         yasm"
370
371     # These are dependencies necessary for using webkit-patch
372     packages="$packages \
373         svn"
374     pacman -S --needed $packages
375
376     echo "You will also need to follow the instructions on the Arch Wiki to make"
377     echo "'python' call python2 in the webkit folder"
378     echo "https://wiki.archlinux.org/index.php/Python#Dealing_with_version_problem_in_build_scripts"
379 }
380
381 function installDependenciesWithDnf {
382     # These are dependencies necessary for building WebKitGTK+.
383     packages=" \
384         atk-devel \
385         autoconf \
386         automake \
387         bison \
388         cairo-devel \
389         cmake \
390         enchant-devel \
391         flex \
392         gcc-c++ \
393         geoclue2-devel \
394         gettext-devel \
395         gobject-introspection-devel \
396         gperf \
397         gstreamer1-devel \
398         gstreamer1-plugins-bad-free-devel \
399         gstreamer1-plugins-base-devel \
400         gtk-doc \
401         gtk2-devel \
402         gtk3-devel \
403         hyphen-devel \
404         intltool \
405         json-glib-devel \
406         libXt-devel \
407         libXtst-devel \
408         libxslt-devel \
409         libedit-devel \
410         libffi-devel \
411         libgcrypt-devel \
412         libgudev1-devel \
413         libjpeg-turbo-devel \
414         libmount-devel \
415         libnotify-devel \
416         libpng-devel \
417         libsecret-devel \
418         libsoup-devel \
419         libsrtp-devel \
420         libtasn1-devel \
421         libtheora-devel \
422         libv4l-devel \
423         libvorbis-devel \
424         libvpx-devel \
425         libwebp-devel \
426         libwayland-client-devel \
427         libwayland-server-devel \
428         mesa-libGL-devel \
429         ninja-build \
430         openssl-devel \
431         opus-devel \
432         patch \
433         pcre-devel \
434         perl-JSON-PP \
435         perl-Switch \
436         perl-Time-HiRes \
437         perl-version \
438         pulseaudio-libs-devel \
439         python-devel \
440         redhat-rpm-config \
441         ruby \
442         sqlite-devel"
443
444     # These are dependencies necessary for running tests.
445     packages="$packages \
446         curl \
447         dbus-x11 \
448         gdb \
449         hunspell-en \
450         httpd \
451         libgpg-error-devel \
452         mod_bw \
453         mod_ssl \
454         perl-CGI \
455         php \
456         psmisc \
457         pulseaudio-utils \
458         pygobject3-base \
459         python2-psutil \
460         ruby \
461         rubygem-json \
462         rubygem-highline \
463         weston-devel \
464         xorg-x11-server-Xvfb"
465
466     # These are dependencies necessary for building the jhbuild.
467     packages="$packages \
468         cups-devel \
469         docbook-utils \
470         expat-devel \
471         git \
472         gnutls-devel \
473         gobject-introspection \
474         gsettings-desktop-schemas-devel \
475         icon-naming-utils \
476         itstool \
477         libXfont-devel \
478         libcroco-devel \
479         libdrm-devel \
480         libepoxy-devel \
481         libevdev-devel
482         libgpg-error-devel \
483         libinput-devel \
484         libp11-devel \
485         libpciaccess-devel \
486         libproxy-devel \
487         libtiff-devel \
488         libxcb-devel \
489         libxkbfile-devel \
490         libxkbcommon-x11-devel \
491         mesa-libEGL-devel \
492         mtdev-devel \
493         orc-devel \
494         ragel \
495         systemd-devel \
496         xorg-x11-font-utils \
497         xorg-x11-proto-devel \
498         xorg-x11-util-macros \
499         xorg-x11-xtrans-devel \
500         yasm"
501
502     # These are dependencies necessary for using webkit-patch
503     packages="$packages
504         git-svn \
505         subversion"
506
507     dnf install $packages
508 }
509
510 checkInstaller
511