60480f2adb57d06f1d48df98491f719ac22064b4
[vlc.git] / extras / contrib / bootstrap
1 #!/bin/sh
2 # ***************************************************************************
3 # bootstrap : Set up config.mak
4 # ***************************************************************************
5 # Copyright (C) 2003-2006 the VideoLAN team
6 # $Id$
7 #
8 # Authors: Christophe Massiot <massiot@via.ecp.fr>
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 # ***************************************************************************
24
25 if test "$#" -gt "1"; then
26   echo "Usage: $0 <host>" >&2
27   echo "  Prepare config.mak file." >&2
28   exit 1
29 fi
30
31 LANG=C
32 export LANG
33 set -e
34 set -x
35
36 BUILD=`gcc -dumpmachine`
37 if test "$#" = "1"; then
38   HOST="$1"
39 else
40   HOST="$BUILD"
41 fi
42
43 rm -f config.mak
44 {
45         echo "# Automatically generated by bootstrap."
46         echo "# Make changes if you know what you're doing."
47 } > config.mak
48
49 if test "$HOST" != "$BUILD"; then
50     CC="${HOST}-gcc"
51     CXX="${HOST}-g++"
52     LD="${HOST}-ld"
53     RANLIB="${HOST}-ranlib"
54     AR="${HOST}-ar"
55 fi
56
57 case $HOST in
58     ppc-darwin)
59 # Mac OS X < 10.4
60             echo "Your version of Mac OS X is too old!" >&2
61             echo "Compiling VLC requires 10.4.x or later" >&2
62             exit 1
63         ;;
64     powerpc-apple-darwin8)
65 # Mac OS X 10.4
66 # Makefile cross compiling is only supported with gcc-4.0
67 # ENVP defines the oldest environment on which the program will be able to run
68 # SDK 10.2.8 requires gcc-3.3 (so we cannot use that SDK)
69             SDK_TARGET=10.3
70             echo "SDK_TARGET = ${SDK_TARGET}" >> config.mak
71             echo "HAVE_DARWIN_OS = 1" >> config.mak
72             echo "ENVP = MACOSX_DEPLOYMENT_TARGET=${SDK_TARGET}" >> config.mak
73             echo "MACOSX_SDK = /Developer/SDKs/MacOSX10.3.9.sdk" >> config.mak
74             CFLAGS_TUNING=" -mtune=G4"
75             EXTRA_CFLAGS=" -D\${ENVP} -isysroot \${MACOSX_SDK}"
76             EXTRA_LDFLAGS=" -isysroot \${MACOSX_SDK} -Wl,-syslibroot,\${MACOSX_SDK}"
77             echo "PATH = /bin:/usr/bin:/usr/local/bin" >> config.mak
78         ;;
79     i686-apple-darwin8)
80             SDK_TARGET=10.4
81             echo "SDK_TARGET = ${SDK_TARGET}" >> config.mak
82             echo "HAVE_DARWIN_OS = 1" >> config.mak
83             echo "ENVP = MACOSX_DEPLOYMENT_TARGET=${SDK_TARGET}" >> config.mak
84             echo "MACOSX_SDK = /Developer/SDKs/MacOSX10.4u.sdk" >> config.mak
85             CFLAGS_TUNING=" -march=pentium-m -mtune=prescott"
86             EXTRA_CFLAGS=" -D\${ENVP} -isysroot \${MACOSX_SDK}"
87             EXTRA_LDFLAGS=" -isysroot \${MACOSX_SDK} -Wl,-syslibroot,\${MACOSX_SDK}"
88             echo "PATH = /bin:/usr/bin:/usr/local/bin" >> config.mak
89         ;;
90     i586-pc-beos)
91             echo "HAVE_BEOS = 1" >> config.mak
92             if test -f /boot/beos/system/lib/libbind.so; then
93                 EXTRA_LDFLAGS=" -lbind -lsocket"
94             else
95                 EXTRA_LDFLAGS=" -lnet"
96             fi
97             if test "$HOST" = "$BUILD"; then
98 #               Compiling on BeOS
99                 PATH=".:/boot/home/config/bin:/bin:/boot/apps"
100                 PATH="${PATH}:/boot/preferences:/boot/beos/apps"
101                 PATH="${PATH}:/boot/beos/preferences"
102                 PATH="${PATH}:/boot/develop/tools/gnupro/bin"
103                 echo "PATH = ${PATH}" >> config.mak
104                 LIBRARY_PATH="${LIBRARY_PATH}:%A/lib:/boot/home/config/lib"
105                 LIBRARY_PATH="${LIBRARY_PATH}:/boot/beos/system/lib"
106                 echo "LIBRARY_PATH = ${LIBRARY_PATH}" >> config.mak
107             else
108 #               Cross compiling from Linux
109                 PATH="/opt/beos-tools/bin:/opt/cross-tools/bin"
110                 PATH="${PATH}:/usr/bin:/bin"
111                 echo "PATH = ${PATH}" >> config.mak
112             fi
113         ;;
114     *mingw32*)
115             echo "HAVE_WIN32 = 1" >> config.mak
116             echo "PKG_CONFIG_PATH = \$(PREFIX)/lib/pkgconfig" >> config.mak
117         ;;
118     i686-pc-cygwin)
119             echo "HAVE_WIN32 = 1" >> config.mak
120             CC="gcc -mno-cygwin -isystem /usr/include/mingw"
121             CXX="g++ -mno-cygwin -isystem /usr/include/mingw"
122             HOST=`$CC -dumpmachine`
123             EXTRA_CFLAGS=" -mno-cygwin -isystem /usr/include/mingw"
124             EXTRA_CPPFLAGS=" -mno-cygwin -isystem /usr/include/mingw"
125             EXTRA_LDFLAGS=" -mno-cygwin"
126             echo "PKG_CONFIG_PATH = \$(PREFIX)/lib/pkgconfig" >> config.mak
127         ;;
128     arm-wince-pe)
129             echo "HAVE_WINCE = 1" >> config.mak
130             echo "PKG_CONFIG_PATH = \$(PREFIX)/lib/pkgconfig" >> config.mak
131             EXTRA_CPPFLAGS=" -D_WIN32_WCE"
132         ;;
133     *)
134         ;;
135 esac
136
137 echo "BUILD = $BUILD" >> config.mak
138 echo "HOST = $HOST" >> config.mak
139
140 echo "PREFIX = `pwd`" >> config.mak
141
142 echo "CC = ${CC}" >> config.mak
143 echo "CXX = ${CXX}" >> config.mak
144 echo "LD = ${LD}" >> config.mak
145 echo "RANLIB = ${RANLIB}" >> config.mak
146 echo "AR = ${AR}" >> config.mak
147 echo "EXTRA_CFLAGS = ${CFLAGS_TUNING} ${EXTRA_CFLAGS}" >> config.mak
148 echo "EXTRA_CPPFLAGS = ${EXTRA_CPPFLAGS} -I${PREFIX}/include" >> config.mak
149 echo "EXTRA_LDFLAGS = ${EXTRA_LDFLAGS}" >> config.mak
150 echo "EXTRA_PATH = ${EXTRA_PATH}" >> config.mak
151
152 if which curl >/dev/null; then
153         echo "WGET = curl -O" >> config.mak
154 elif wget --version >/dev/null 2>&1; then
155         echo "WGET = wget" >> config.mak
156 else
157         echo "You need at least wget or curl to fetch the packages." >&2
158         exit 1
159 fi
160
161 if test -f /sw/bin/svn; then
162         echo "SVN = /sw/bin/svn" >> config.mak
163 elif test -f /usr/local/bin/svn; then
164         echo "SVN = /usr/local/bin/svn" >> config.mak
165 elif test -f /opt/local/bin/svn; then
166         echo "SVN = /opt/local/bin/svn" >> config.mak
167 elif svn help >/dev/null 2>&1; then
168         echo "SVN = svn" >> config.mak
169 else
170         echo "You do not have a subversion client installed." >&2
171 fi