summaryrefslogtreecommitdiffstats
path: root/wayland-build.sh
blob: 9844e31550f5b8ac5ef36a2f76da7d9c7fb06990 (plain)
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
#!/bin/bash

# hbased on ttp://wayland.freedesktop.org/building.html

WLD=/opt/wayland
LD_LIBRARY_PATH=$WLD/lib
PKG_CONFIG_PATH=$WLD/lib/pkgconfig/:$WLD/share/pkgconfig/
ACLOCAL="aclocal -I $WLD/share/aclocal"
C_INCLUDE_PATH=$WLD/include
LIBRARY_PATH=$WLD/lib
PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1

export WLD LD_LIBRARY_PATH PKG_CONFIG_PATH ACLOCAL C_INCLUDE_PATH LIBRARY_PATH PKG_CONFIG_ALLOW_SYSTEM_CFLAGS

BUILD_DIR=${BUILD_DIR:-~/usr/git/wayland}
FORCE_AUTOGEN=0
FORCE_DISTCLEAN=0
SUDO_PASSWD=""
for arg in $@; do
    option=`echo "'$arg'" | cut -d'=' -f1 | tr -d "'"`
    value=`echo "'$arg'" | cut -d'=' -f2- | tr -d "'"`
    case $option in
        "-f")   FORCE_AUTOGEN=1;;
        "-c")   FORCE_DISTCLEAN=1;;
        "-s")   SUDO_PASSWD=$value;;
    esac
done

RESET="\033[0m"
RED="\033[0;31m"
GREEN="\033[0;32m"

function say () { echo -e "$GREEN$1$RESET"; }

function error () { echo -e "${RED}FAILURE${RESET} $1" && exit 1; }

sudo -K
TMP=/tmp/sudo.test
[ -e "$TMP" ] && rm -f "$TMP"
echo "$SUDO_PASSWD" | sudo -S touch "$TMP" &>/dev/null
if [ ! -e "$TMP" ]; then
    error "cmdline provided sudo password failed!"
else
    echo "$SUDO_PASSWD" | sudo -S rm -f "$TMP"
fi
echo

[ ! -d "$WLD/share/aclocal" ] && echo "$SUDO_PASSWD" | sudo -S mkdir -p "$WLD/share/aclocal"

function build () {
    if [ $FORCE_DISTCLEAN -eq 1 ]; then
        say " * make distclean" && make distclean >/dev/null
    fi
    tmp=/tmp/$my_dir.build
    say " * make" && make >$tmp && say " * install" && echo "$SUDO_PASSWD" | sudo -S -E make install
}

function autogen () {
    say " * autogen --prefix=$WLD $my_configure_opts" && ./autogen.sh --prefix=$WLD $my_configure_opts && build
}

function update () {
    SHA_PREV=$(git log --pretty="format:%H" HEAD~1..)
    say " * pull" && git pull || return 1
    SHA_HEAD=$(git log --pretty="format:%H" HEAD~1..)
    if [ $FORCE_AUTOGEN -eq 1 ]; then
        autogen
    else
        [ "$SHA_PREV" = "$SHA_HEAD" ] && return 0
        build
    fi
}

function do_your_job () {
    if [ -d "$my_dir" ]; then
        cd "$my_dir" && update && cd .. || error
    else
        say " * clone $my_src" && git clone "$my_src" "$my_dir" && cd "$my_dir" && autogen && cd .. || error
    fi
    say " * SUCCESS\n"
}

cd $BUILD_DIR || exit 1

# WAYLAND
say "wayland"
my_dir=wayland
my_src=git://anongit.freedesktop.org/wayland/wayland
my_configure_opts=
do_your_job

say "xcb:pthread-stubs"
my_dir=pthread-stubs
my_src=git://anongit.freedesktop.org/xcb/pthread-stubs
my_configure_opts=
do_your_job

say "xorg:util:macros"
my_dir=macros
my_src=git://anongit.freedesktop.org/xorg/util/macros
my_configure_opts=
do_your_job

#say "xorg:util:macros"
#my_dir=macros
#my_src=git://anongit.freedesktop.org/git/xorg/util/macros
#my_configure_opts=
#do_your_job

say "xorg:proto:xproto"
my_dir=xproto
my_src=git://anongit.freedesktop.org/xorg/proto/xproto
my_configure_opts=
do_your_job

say "xorg:proto:kbproto"
my_dir=kbproto
my_src=git://anongit.freedesktop.org/xorg/proto/kbproto
my_configure_opts=
do_your_job

say "xorg:proto:glproto"
my_dir=glproto
my_src=git://anongit.freedesktop.org/xorg/proto/glproto
my_configure_opts=
do_your_job

say "xorg:proto:dri2proto"
my_dir=dri2proto
my_src=git://anongit.freedesktop.org/xorg/proto/dri2proto
my_configure_opts=
do_your_job

say "mesa:drm"
my_dir=drm
my_src=git://anongit.freedesktop.org/git/mesa/drm
my_configure_opts="--enable-nouveau-experimental-api"
do_your_job

say "mesa:mesa"
my_dir=mesa
my_src=git://anongit.freedesktop.org/mesa/mesa
my_configure_opts="--enable-gles2 --disable-gallium-egl --with-egl-platforms=x11,wayland,drm --enable-gbm --enable-shared-glapi"
do_your_job

say "xorg:lib:libX11"
my_dir=libX11
my_src=git://anongit.freedesktop.org/xorg/lib/libX11
my_configure_opts="--enable-specs=false"
do_your_job

say "xorg:lib:libxkbcommon"
my_dir=libxkbcommon
my_src=git://people.freedesktop.org/xorg/lib/libxkbcommon.git
my_configure_opts="--with-xkb-config-root=/usr/share/X11/xkb --enable-specs=false"
do_your_job

say "xorg:pixman"
my_dir=pixman
my_src=git://anongit.freedesktop.org/pixman
my_configure_opts=
do_your_job

say "xorg:cairo"
my_dir=cairo
my_src=git://anongit.freedesktop.org/cairo
my_configure_opts="--enable-gl --enable-xcb"
do_your_job

# WAYLAND-DEMOS
say "wayland-demos"
my_dir=wayland-demos
my_src=git://anongit.freedesktop.org/wayland/wayland-demos
my_configure_opts=
do_your_job

say "DONE"