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