bootstrap 13.1 KB
Newer Older
1 2 3 4
#!/bin/sh
# ***************************************************************************
# bootstrap : Set up config.mak
# ***************************************************************************
Felix Kühne's avatar
Felix Kühne committed
5
# Copyright (C) 2003-2009 the VideoLAN team
6
# $Id$
7 8
#
# Authors: Christophe Massiot <massiot@via.ecp.fr>
9
#          Derk-Jan Hartman <hartman at videolan dot org>
Felix Kühne's avatar
Felix Kühne committed
10
#          Felix Paul Kühne <fkuehne at videolan dot org>
11 12 13 14 15 16 17 18 19 20 21 22 23
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
Antoine Cellerier's avatar
Antoine Cellerier committed
24
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 26
# ***************************************************************************

Christophe Mutricy's avatar
Christophe Mutricy committed
27
if test "$#" -gt "2" -o "$1" = "-h" -o "$1" = "--help" ; then
28 29 30
    echo "Usage: $0 [host [distro]]" >&2
    echo "  Prepare config.mak and distro.mak file." >&2
    exit 1
31 32 33 34 35 36 37
fi

LANG=C
export LANG
set -e
set -x

38
BUILD=`gcc -dumpmachine`
39
if test "$#" -ge "1"; then
40
    HOST="$1"
41
else
42
    HOST="$BUILD"
43 44
fi

45 46 47 48 49 50 51
DISTRO=
if test "$#" = "2"; then
    echo "Forcing distro.mak to use $2.mak"
    DISTRO="$2"
    HOST="$1"
fi

52
rm -f config.mak
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
53
{
54 55
    echo "# Automatically generated by bootstrap."
    echo "# Make changes if you know what you're doing."
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
56
} > config.mak
57

58 59 60 61 62 63
rm -f distro.mak
{
    echo "# Automatically generated by bootstrap"
    echo "# Make changes if you know what you're doing."
} > distro.mak

64 65 66
if test "$HOST" != "$BUILD"; then
    CC="${HOST}-gcc"
    CXX="${HOST}-g++"
67
    LD="${HOST}-ld"
68 69
    RANLIB="${HOST}-ranlib"
    AR="${HOST}-ar"
70
    STRIP="${HOST}-strip"
71 72
fi

73 74
case $HOST in
    *powerpc*|*ppc*)
75
         ARCH="ppc"
76
     ;;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
77
    *86_64*)
78
          ARCH="x86_64"
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
79
     ;;
80
    *86*)
81
          ARCH="i386"
82 83
     ;;
esac
Felix Paul Kühne's avatar
Felix Paul Kühne committed
84
echo "ARCH = $ARCH" >> config.mak
85

86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
# Check the HAVE_{OS}
case $HOST in
    *darwin*)
        echo "HAVE_DARWIN_OS = 1" >> config.mak
        echo "HAVE_BSD = 1" >> config.mak
    ;;
    *linux*)
        echo "HAVE_LINUX = 1" >> config.mak
    ;;
    *bsd*)
        echo "HAVE_BSD = 1" >> config.mak
    ;;
    *wince*)
        echo "HAVE_WINCE = 1" >> config.mak
    ;;
esac

103
case $HOST in
104
    ppc-darwin)
105
        # Mac OS X < 10.4
106
        echo "Your version of Mac OS X is too old!" >&2
107
        echo "Compiling VLC requires 10.5.x or later" >&2
108 109
        exit 1
    ;;
110
    *-apple-darwin8)
111 112 113
        echo "Your version of Mac OS X is too old!" >&2
        echo "Compiling and running VLC requires 10.5.x or later" >&2
        exit 1
114
    ;;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
115
    powerpc-apple-darwin9)
116
        SDK_TARGET=10.5
117
        echo "SDK_TARGET = ${SDK_TARGET}" >> config.mak
118
        echo "ENVP = MACOSX_DEPLOYMENT_TARGET=${SDK_TARGET}" >> config.mak
119
        echo "MACOSX_SDK = /Developer/SDKs/MacOSX10.5.sdk" >> config.mak
120
        echo "HAVE_DARWIN_9 = 1" >> config.mak
121
        HAVE_DARWIN_9=1
122
        HAVE_DARWIN_32=1
123
        CFLAGS_TUNING=" -arch ppc -mtune=G4"
124
        EXTRA_CFLAGS=" -D\${ENVP} -isysroot \${MACOSX_SDK} -mmacosx-version-min=\${SDK_TARGET}"
125
        EXTRA_LDFLAGS=" -arch ppc -isysroot \${MACOSX_SDK} -mmacosx-version-min=\${SDK_TARGET} -Wl,-syslibroot,\${MACOSX_SDK}"
126 127
        CC="/Developer/usr/bin/gcc-4.2"
        CXX="/Developer/usr/bin/g++-4.2"
128
        LD="ld -arch ppc -syslibroot \${MACOSX_SDK} -mmacosx-version-min=\${SDK_TARGET}"
129
        echo "PATH = /bin:/usr/bin:/usr/local/bin:" >> config.mak
130
        cat src/Distributions/darwin.mak >> distro.mak
131 132 133 134 135 136
        if test -e /Developer/SDKs; then
            echo "SDKs found. Everything is fine." >&2
        else
            echo "ERROR:\nYour Developer Tools' SDKs were not found.\nYou need to add extra symbolic links to /Developer to achieve correctly\nbuilt contribs.\nHave a look at the OSX-Compile-HOWTO for details." >&2
            exit 1
        fi
137
    ;;
138
    i686-apple-darwin*)
139
        SDK_TARGET=10.5
140
        MIN_LD_VERSION_WITH_TEXT_RELOCATION=81
141 142
        echo "SDK_TARGET = ${SDK_TARGET}" >> config.mak
        echo "HAVE_DARWIN_OS_ON_INTEL = 1" >> config.mak
143
        echo "HAVE_DARWIN_9 = 1" >> config.mak
144
        HAVE_DARWIN_9=1
145
        if test `ld -v 2> /dev/stdout | sed -E 's/.*ld64-([0-9]+).*/\1/'` -lt ${MIN_LD_VERSION_WITH_TEXT_RELOCATION}; then
146 147
            echo "ERROR: Your ld version is unable to compile VLC.\nUpdate to Xcode 3.1 or higher." >&2
            exit 1
148
        fi
149
        echo "ENVP = MACOSX_DEPLOYMENT_TARGET=${SDK_TARGET}" >> config.mak
150
        echo "MACOSX_SDK = /Developer/SDKs/MacOSX10.5.sdk" >> config.mak
151 152
        HAVE_DARWIN_32=1
        CFLAGS_TUNING=" -march=prescott -mtune=generic -arch i386 -m32"
153
        EXTRA_CFLAGS=" -D\${ENVP} -isysroot \${MACOSX_SDK} -mmacosx-version-min=\${SDK_TARGET}"
154
        EXTRA_LDFLAGS=" -arch i386 -isysroot \${MACOSX_SDK} -Wl,-syslibroot,\${MACOSX_SDK} -mmacosx-version-min=\${SDK_TARGET}"
155 156
        CC="/Developer/usr/bin/gcc-4.2"
        CXX="/Developer/usr/bin/g++-4.2"
157 158
        echo "PATH = /bin:/usr/bin:/usr/local/bin" >> config.mak
        cat src/Distributions/darwin.mak >> distro.mak
159 160
        if test -e /Developer/SDKs; then
            echo "SDKs found. Everything is fine." >&2
161 162 163 164 165
        else
            echo "ERROR:\nYour Developer Tools' SDKs were not found.\nYou need to add extra symbolic links to /Developer to achieve correctly\nbuilt contribs.\nHave a look at the OSX-Compile-HOWTO for details." >&2
            exit 1
        fi
    ;;
166
    x86_64-apple-darwin*)
167
        SDK_TARGET=10.5
168 169 170 171
        echo "SDK_TARGET = ${SDK_TARGET}" >> config.mak
        echo "HAVE_DARWIN_OS_ON_INTEL = 1" >> config.mak
        echo "HAVE_DARWIN_9 = 1" >> config.mak
        echo "ENVP = MACOSX_DEPLOYMENT_TARGET=${SDK_TARGET}" >> config.mak
Felix Kühne's avatar
Felix Kühne committed
172
        echo "MACOSX_SDK = /Developer/SDKs/MacOSX${SDK_TARGET}.sdk" >> config.mak
173 174 175
        HAVE_DARWIN_64=1
        CFLAGS_TUNING=" -march=core2 -mtune=core2 -m64 -arch x86_64"
        echo "HAVE_DARWIN_64 = 1" >> config.mak
176
        EXTRA_CFLAGS=" -D\${ENVP} -isysroot \${MACOSX_SDK} -mmacosx-version-min=\${SDK_TARGET}"
177
        EXTRA_LDFLAGS=" -isysroot \${MACOSX_SDK} -Wl,-syslibroot,\${MACOSX_SDK} -mmacosx-version-min=\${SDK_TARGET}"
178
        echo "PATH = /bin:/usr/bin:/usr/local/bin" >> config.mak
179 180 181 182 183 184
        CC="/Developer/usr/bin/gcc-4.2"
        CXX="/Developer/usr/bin/g++-4.2"
        LD="ld"
        RANLIB="ranlib"
        AR="ar"
        STRIP="strip"
185 186 187
        cat src/Distributions/darwin.mak >> distro.mak
        if test -e /Developer/SDKs; then
            echo "SDKs found. Everything is fine." >&2
188 189 190 191
        else
            echo "ERROR:\nYour Developer Tools' SDKs were not found.\nYou need to add extra symbolic links to /Developer to achieve correctly\nbuilt contribs.\nHave a look at the OSX-Compile-HOWTO for details." >&2
            exit 1
        fi
192
    ;;
193 194 195 196 197
    *mingw32ce)
        echo "HAVE_WINCE = 1" >> config.mak
        echo "PKG_CONFIG_PATH = \$(PREFIX)/lib/pkgconfig" >> config.mak
        cat src/Distributions/wince.mak >> distro.mak
    ;;
198 199 200 201 202
    x86_64-*-mingw*)
        echo "HAVE_WIN64 = 1" >> config.mak
        echo "HAVE_WIN32 = 1" >> config.mak
        echo "PKG_CONFIG_PATH = \$(PREFIX)/lib/pkgconfig" >> config.mak
           EXTRA_CFLAGS="-O3"
203
        cat src/Distributions/win64.mak >> distro.mak
204
    ;;
205
    *mingw32*)
206 207
        echo "HAVE_WIN32 = 1" >> config.mak
        echo "PKG_CONFIG_PATH = \$(PREFIX)/lib/pkgconfig" >> config.mak
208
        EXTRA_CFLAGS="-O3"
209 210
        cat src/Distributions/win32.mak >> distro.mak
    ;;
211
    i686-pc-cygwin)
212 213 214 215 216 217 218 219 220 221 222
        echo "HAVE_WIN32 = 1" >> config.mak
        echo "HAVE_CYGWIN = 1" >> config.mak
        CC="gcc -mno-cygwin -isystem /usr/include/mingw"
        CXX="g++ -mno-cygwin -isystem /usr/include/mingw"
        HOST=`$CC -dumpmachine`
        EXTRA_CFLAGS=" -mno-cygwin -isystem /usr/include/mingw"
        EXTRA_CPPFLAGS=" -mno-cygwin -isystem /usr/include/mingw"
        EXTRA_LDFLAGS=" -mno-cygwin"
        echo "PKG_CONFIG_PATH = \$(PREFIX)/lib/pkgconfig" >> config.mak
        cat src/Distributions/win32.mak >> distro.mak
    ;;
223
    arm-wince-pe)
224 225 226 227
        echo "PKG_CONFIG_PATH = \$(PREFIX)/lib/pkgconfig" >> config.mak
        EXTRA_CPPFLAGS=" -D_WIN32_WCE"
        cat src/Distributions/wince.mak >> distro.mak
    ;;
228
    armeb-linux-uclibc)
229 230 231 232 233 234 235 236 237
        echo "HAVE_UCLIBC = 1" >> config.mak
        echo "HAVE_BIGENDIAN = 1" >> config.mak
        EXTRA_CFLAGS="-Os -march=armv5 -msoft-float"
        if test ! -z "${DISTRO}";  then
            cat src/Distributions/${DISTRO}.mak >> distro.mak
        else
            cat src/Distributions/unix.mak >> distro.mak
        fi
    ;;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
238 239 240 241 242 243 244 245 246
    *86_64*linux*)
        EXTRA_CFLAGS=" -fPIC"
        EXTRA_CPPFLAGS=" -fPIC"
        EXTRA_LDFLAGS=" -L/usr/lib64"
        echo "LIBRARY_PATH = /usr/lib64" >> config.mak
        echo "PKG_CONFIG_PATH = /usr/lib64/pkgconfig" >> config.mak
        echo "PKG_CONFIG_LIBDIR = /usr/lib64/pkgconfig" >> config.mak
        cat src/Distributions/unix.mak >> distro.mak
    ;;
247 248 249 250 251 252 253 254 255 256 257 258 259
    *)
        if test "$HOST" = "$BUILD"; then
            if test -d "/usr/lib/pkgconfig"; then
                if test -z "$PKG_CONFIG_PATH"; then
                    echo "PKG_CONFIG_PATH = /usr/lib/pkgconfig" >> config.mak
                fi
                if test -z "$PKG_CONFIG_LIBDIR"; then
                    echo "PKG_CONFIG_LIBDIR = /usr/lib/pkgconfig" >> config.mak
                fi
            fi
            # Try to match distribution
            if test -f /etc/fedora-release; then
                cat src/Distributions/fedora.mak >> distro.mak
260 261
            elif test -f /etc/maemo_version; then
                cat src/Distributions/maemo.mak >> distro.mak
262
                echo 'HAVE_MAEMO = 1' >> config.mak
263 264 265 266 267
            else
                # Default Unix-like systems
                cat src/Distributions/unix.mak >> distro.mak
            fi
        else # unknown distro
268 269 270 271 272
            if test ! -z "${DISTRO}";  then
                cat src/Distributions/${DISTRO}.mak >> distro.mak
            else
                cat src/Distributions/unix.mak >> distro.mak
            fi
273 274
        fi
    ;;
275 276
esac

277 278 279 280 281
echo "BUILD = $BUILD" >> config.mak
echo "HOST = $HOST" >> config.mak

echo "PREFIX = `pwd`" >> config.mak

282 283
echo "CC = ${CC}" >> config.mak
echo "CXX = ${CXX}" >> config.mak
284
echo "LD = ${LD}" >> config.mak
285 286
echo "RANLIB = ${RANLIB}" >> config.mak
echo "AR = ${AR}" >> config.mak
287
echo "STRIP = ${STRIP}" >> config.mak
288
echo "EXTRA_CFLAGS = ${CFLAGS_TUNING} ${EXTRA_CFLAGS}" >> config.mak
289
echo "EXTRA_CPPFLAGS = ${EXTRA_CPPFLAGS} -isystem \$(PREFIX)/include" >> config.mak
290 291
echo "EXTRA_LDFLAGS = ${EXTRA_LDFLAGS}" >> config.mak
echo "EXTRA_PATH = ${EXTRA_PATH}" >> config.mak
292

293
if wget --version >/dev/null 2>&1; then
294
    echo "WGET = `which wget` -c --passive" >> config.mak
295
elif test -z `curl --version >/dev/null 2>&1`; then
296
    echo "WGET = `which curl` -L -O" >> config.mak
297
else
298 299
    echo "You need at least wget or curl to fetch the packages." >&2
    exit 1
300 301
fi

302
if svn --version >/dev/null 2>&1; then
303
    echo "SVN = `which svn`" >> config.mak
304
else
305
    echo "You do not have a subversion client in your PATH." >&2
306
fi
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
307

308
if git --version>/dev/null 2>&1; then
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
309 310
    echo "GIT = `which git`" >> config.mak
else
311
    echo "You do not have a Git client in your PATH." >&2
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
312
fi
313 314

if test -z "$CONTRIBS_RELEASE"; then
315
    echo "EXTRA_CFLAGS += -DNDEBUG" >> config.mak
316 317
    set +x
    echo
Felix Kühne's avatar
Felix Kühne committed
318
    echo "*****************************************************************"
319
    echo "* If you need contribs with all debug information, run this     *"
320 321
    echo "* line and compile the libraries on your own.                   *"
    echo "* CONTRIBS_RELEASE=no ./bootstrap                               *"
Felix Kühne's avatar
Felix Kühne committed
322
    echo "*****************************************************************"
323
fi
324 325 326 327

if test $HAVE_DARWIN_9; then
    set +x
    echo
Felix Kühne's avatar
Felix Kühne committed
328
    echo "*****************************************************************"
329 330
    echo "* We are using GCC-4.2 on OS X, so compilation WILL FAIL if it  *"
    echo "* is NOT installed. *"
Felix Kühne's avatar
Felix Kühne committed
331
    echo "*****************************************************************"
332
fi
Felix Kühne's avatar
Felix Kühne committed
333

334 335 336 337 338 339 340 341 342 343 344 345 346 347
if test $HAVE_DARWIN_32; then
    set +x
    echo
    echo "*****************************************************************"
    echo "* VLC will be compiled in 32bit mode.                           *" 
    echo "*                                                               *"
    echo "* Re-run with the x86_64-apple-darwin* argument to turn on      *" 
    echo "* 64bit compilation for Intel-based Macs, whereas * is either   *"
    echo "* 9 or 10 depending on your Darwin version.                     *"
    echo "* There is NO PPC64 support right now.                          *"
    echo "*****************************************************************"
fi

if test $HAVE_DARWIN_64; then
Felix Kühne's avatar
Felix Kühne committed
348 349 350
    set +x
    echo
    echo "*****************************************************************"
351
    echo "* VLC will be compiled in 64bit mode using the 10.5 SDK.        *" 
Felix Kühne's avatar
Felix Kühne committed
352 353 354
    echo "*****************************************************************"
    set -x
fi