summaryrefslogtreecommitdiffstats
path: root/unix/build-xorg
blob: 71a68ff44be24ee1c1e4ab616cc0a5f65f8704ca (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/bin/bash
# -*- mode: shell-script; coding: UTF-8 -*-
# 
# Build Xvnc with Xorg 7.4 or 7.5
#

set -e

PREFIX=
MAKE="make"
STATIC=0
XORG_VERSION=
SRCDIR=`dirname $0`/..

modules="dri2proto \
    libpthread-stubs \
    glproto \
    xf86vidmodeproto \
    xextproto \
    xproto \
    kbproto \
    inputproto \
    xcmiscproto \
    bigreqsproto \
    fixesproto \
    damageproto \
    xf86driproto \
    randrproto \
    renderproto \
    scrnsaverproto \
    resourceproto \
    fontsproto \
    videoproto \
    compositeproto \
    xineramaproto \
    libdrm \
    libXau \
    xtrans \
    libXdmcp \
    libX11 \
    libXext \
    libXxf86vm \
    libICE \
    libSM \
    libXt \
    libXmu \
    libXfixes \
    libXdamage \
    libXi \
    libxkbfile \
    libfontenc \
    libXfont \
    libpciaccess \
    pixman"

modules74="fontcacheproto \
    evieext"

init()
{
    update_modules

    pushd xorg
    tar jxf ~/.tigervnc-xorg-$XORG_VERSION/util-macros.tar.bz2
    pushd util-macros-*
    echo "Building macros"
    ./configure ${1+"$@"} --prefix=${PREFIX}
    ($MAKE install)
    popd

    pushd xserver

    if [ "$XORG_VERSION" = "7.4" ]; then
	patch -p1 < $SRCDIR/unix/xserver15.patch
    else
	patch -p1 < $SRCDIR/unix/xserver17.patch
    fi

    popd
    popd

    pushd $SRCDIR
    if [ ! -f ./configure ]; then
        autoreconf -fiv
    fi
    popd
}


update_modules()
{
    if [ -d xorg ]; then rm -rf xorg; fi
    if [ -d xorg.build ]; then rm -rf xorg.build; fi
    mkdir xorg
    pushd xorg
    $SRCDIR/unix/download-xorg-$XORG_VERSION
    for module in ${modules}; do
        tar jxf ~/.tigervnc-xorg-$XORG_VERSION/${module}.tar.bz2
    done
    tar jxf ~/.tigervnc-xorg-$XORG_VERSION/Mesa.tar.bz2
    tar jxf ~/.tigervnc-xorg-$XORG_VERSION/freetype.tar.bz2
    tar jxf ~/.tigervnc-xorg-$XORG_VERSION/xorg-server.tar.bz2
    cp -r $SRCDIR/unix/xserver xserver
    cp -r xorg-server-1.*/* xserver
    popd
}


build ()
{
    # Build VNC
    echo "*** Building VNC ***"
    $SRCDIR/configure ${1+"$@"} --prefix=${PREFIX}
    ($MAKE)

    # Build Xorg
    echo "*** Building Xorg ***"
    pushd xorg
    for module in ${modules}; do
        extraoptions=""
        cd ${module}-*
        echo ======================
        echo configuring ${module}
        echo ======================
        if [ "${module}" = "libX11" ]; then
            extraoptions="${extraoptions} --without-xcb"
        fi
        if [ "${module}" = "libSM" ]; then
            extraoptions="${extraoptions} --without-libuuid"
        fi
        if [ $STATIC = 1 ]; then
            extraoptions="${extraoptions} --enable-static --disable-shared"
            OLD_CFLAGS=${CFLAGS}
            OLD_CXXFLAGS=${CXXFLAGS}
            CFLAGS=${CFLAGS}' -fPIC'
            CXXFLAGS=${CXXFLAGS}' -fPIC'
            export CFLAGS CXXFLAGS
        fi
        ./configure ${1+"$@"} --prefix="${PREFIX}" ${extraoptions}
        if [ $STATIC = 1 ]; then
            CFLAGS=${OLD_CFLAGS}
            CXXFLAGS=${OLD_CXXFLAGS}
            export CFLAGS CXXFLAGS
        fi
        echo ======================
        echo building ${module}
        echo ======================
        if [ $? -ne 0 ]; then
                echo "Failed to configure ${module}."
                exit
        fi
        ($MAKE install)
        cd ..
    done

    # build mesa
    echo "*** Building Mesa ***"
    pushd Mesa-*
    ./configure ${1+"$@"} --prefix=${PREFIX} --with-driver=dri --disable-glut --without-demos
    if [ $? -ne 0 ]; then
	echo "Failed to configure Mesa."
	exit
    fi
    ($MAKE install)
    popd

    # build freetype
    if [ $STATIC = 1 ]; then
        echo "*** Building freetype ***"
        pushd freetype-*
        ./configure ${1+"$@"} --prefix=${PREFIX} --enable-static --disable-shared
        if [ $? -ne 0 ]; then
	    echo "Failed to configure freetype."
	    exit
        fi
        ($MAKE install)
        popd
    fi

    popd

    # build xserver
    echo "*** Building xserver ***"
    pushd xorg/xserver
    autoreconf -fiv
    XORGCFGFLAGS='--disable-xinerama --disable-xvfb --disable-xnest --disable-xorg'
    if [ $STATIC = 1 ]; then
        XORGCFGFLAGS="${XORGCFGFLAGS} --disable-shared --enable-static"
    fi
    ./configure ${1+"$@"} --prefix=${PREFIX} ${XORGCFGFLAGS}
    if [ $? -ne 0 ]; then
	echo "Failed to configure X server."
	exit
    fi
    ($MAKE TIGERVNC_SRCDIR=$SRCDIR install)
    popd
}

rebuild ()
{
    # Build VNC
    echo "*** Building VNC ***"
    ($MAKE ${1+"$@"})

    # build xserver
    echo "*** Building xserver ***"
    pushd xorg/xserver
    ($MAKE TIGERVNC_SRCDIR=$SRCDIR install ${1+"$@"})
    popd
}


usage ()
{
    echo "Usage: $0  init -version <7.4 | 7.5>"
    echo
    echo "       $0  build -version <7.4 | 7.5>"
    echo "       [-static] [additional configure flags]"
    echo
    echo "       $0  rebuild -version <7.4 | 7.5> "
    echo "       [additional make options]"
    echo
    echo "       $0  update -version <7.4 | 7.5>"
    echo
    echo "-static = build a stand-alone version of Xvnc which does not depend on"
    echo "          the shared X11 libraries"
    exit 1
}


while [ $# -gt 0 ]
do
    case "$1" in
	init)       MODE=init                ;;
	build)      MODE=build               ;;
	rebuild)    MODE=rebuild             ;;
	update)     MODE=update              ;;
	-static)    STATIC=1                 ;;
	-version)   XORG_VERSION=$2;  shift  ;;
	-srcdir)    SRCDIR=$2;        shift  ;;
	*)          break                    ;;
    esac
    shift
done

case "$XORG_VERSION" in
    7.4)  modules=$modules" "$modules74  ;;
    7.5)  ;;
    *)    usage  ;;
esac

pushd $SRCDIR
SRCDIR=`pwd`
echo "*** Using TigerVNC source tree at $SRCDIR ***"
popd

if [ "`pwd`" = "$SRCDIR/unix" ]; then
    cd $SRCDIR
fi

if [ "$PREFIX" = "" ]; then
    PREFIX=`pwd`/xorg.build
fi

export ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig"

case "$MODE" in
    init)       init                 ;;
    build)      build ${1+"$@"}      ;;
    rebuild)    rebuild ${1+"$@"}    ;;
    update)     update               ;;
    *)          usage                ;;
esac