]> git.sesse.net Git - vlc/blob - contrib/bootstrap
NEWS about 2.1.0
[vlc] / contrib / bootstrap
1 #! /bin/sh
2 # Copyright (C) 2003-2011 the VideoLAN team
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17
18 #
19 # Command line handling
20 #
21 usage()
22 {
23         echo "Usage: $0 [--build=BUILD] [--host=HOST] [--prefix=PREFIX]"
24         echo "  --build=BUILD    configure for building on BUILD"
25         echo "  --host=HOST      cross-compile to build to run on HOST"
26         echo "  --prefix=PREFIX  install files in PREFIX"
27         echo "  --disable-FOO    configure to not build package FOO"
28         echo "  --enable-FOO     configure to build package FOO"
29         echo "  --disable-disc   configure to not build optical discs packages"
30         echo "  --disable-sout   configure to not build stream output packages"
31         echo "  --enable-small   optimize libraries for size with slight speed decrease [DANGEROUS]"
32         echo "  --disable-gpl    configure to not build viral GPL code"
33 }
34
35 BUILD=
36 HOST=
37 PREFIX=
38 PKGS_ENABLE=
39 PKGS_DISABLE=
40 BUILD_ENCODERS="1"
41 BUILD_DISCS="1"
42 GPL="1"
43
44 if test ! -f "../../contrib/src/main.mak"
45 then
46         echo "$0 must be run from a subdirectory"
47         exit 1
48 fi
49
50 while test -n "$1"
51 do
52         case "$1" in
53                 --build=*)
54                         BUILD="${1#--build=}"
55                         ;;
56                 --help|-h)
57                         usage
58                         exit 0
59                         ;;
60                 --host=*)
61                         HOST="${1#--host=}"
62                         ;;
63                 --prefix=*)
64                         PREFIX="${1#--prefix=}"
65                         ;;
66                 --disable-disc)
67                         BUILD_DISCS=
68                         ;;
69                 --disable-sout)
70                         BUILD_ENCODERS=
71                         ;;
72                 --enable-small)
73                         ENABLE_SMALL=1
74                         ;;
75                 --disable-gpl)
76                         GPL=
77                         ;;
78                 --disable-*)
79                         PKGS_DISABLE="${PKGS_DISABLE} ${1#--disable-}"
80                         ;;
81                 --enable-*)
82                         PKGS_ENABLE="${PKGS_ENABLE} ${1#--enable-}"
83                         ;;
84                 *)
85                         echo "Unrecognized options $1"
86                         usage
87                         exit 1
88                         ;;
89         esac
90         shift
91 done
92
93 if test -z "$BUILD"
94 then
95         echo -n "Guessing build system... "
96         BUILD="`cc -dumpmachine`"
97         if test -z "$BUILD"; then
98                 echo "FAIL!"
99                 exit 1
100         fi
101         echo "$BUILD"
102 fi
103
104 if test -z "$HOST"
105 then
106         echo -n "Guessing host system...  "
107         HOST="$BUILD"
108         echo "$HOST"
109 fi
110
111 if test "$PREFIX"
112 then
113         # strip trailing slash
114         PREFIX="${PREFIX%/}"
115 fi
116
117 #
118 # Prepare files
119 #
120 echo "Creating configuration file... config.mak"
121 exec 3>config.mak || exit $?
122 cat >&3 << EOF
123 # This file was automatically generated.
124 # Any change will be overwritten if ../bootstrap is run again.
125 BUILD := $BUILD
126 HOST := $HOST
127 PKGS_DISABLE := $PKGS_DISABLE
128 PKGS_ENABLE := $PKGS_ENABLE
129 EOF
130
131 add_make()
132 {
133         while test -n "$1"
134         do
135                 echo "$1" >&3
136                 shift
137         done
138 }
139
140 add_make_enabled()
141 {
142         while test -n "$1"
143         do
144                 add_make "$1 := 1"
145                 shift
146         done
147 }
148
149 check_macosx_sdk()
150 {
151    [ -z "${OSX_VERSION}" ] && echo "OSX_VERSION not specified, assuming 10.7" && OSX_VERSION=10.7
152    if test -z "$SDKROOT"
153    then
154       SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
155       echo "SDKROOT not specified, assuming $SDKROOT"
156    fi
157
158    if [ ! -d "${SDKROOT}" ]
159    then
160       SDKROOT_NOT_FOUND=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
161       SDKROOT=`xcode-select -print-path`/SDKs/MacOSX$OSX_VERSION.sdk
162       echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
163    fi
164
165    if [ ! -d "${SDKROOT}" ]
166    then
167       echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
168       exit 1
169    fi
170
171    add_make "MACOSX_SDK=${SDKROOT}"
172    add_make "OSX_VERSION ?= ${OSX_VERSION}"
173 }
174
175 check_ios_sdk()
176 {
177         if test -z "$SDKROOT"
178         then
179                 SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
180                 echo "SDKROOT not specified, assuming $SDKROOT"
181         else
182                 SDKROOT="$SDKROOT"
183         fi
184
185         if [ ! -d "${SDKROOT}" ]
186         then
187                 echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
188                 exit 1
189         fi
190         add_make "SDKROOT=${SDKROOT}"
191 }
192
193 check_android_sdk()
194 {
195         [ -z "${ANDROID_NDK}" ] && echo "You must set ANDROID_NDK environment variable" && exit 1
196         add_make "ANDROID_NDK := ${ANDROID_NDK}"
197         [ -z "${ANDROID_ABI}" ] && echo "You must set ANDROID_ABI environment variable" && exit 1
198         add_make "ANDROID_ABI := ${ANDROID_ABI}"
199         [ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_NEON"
200         [ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_ARMV7A"
201         [ ${ANDROID_ABI} = "armeabi" -a -z "${NO_ARMV6}" ] && add_make_enabled "HAVE_ARMV6"
202 }
203
204 test -z "$PREFIX" || add_make "PREFIX := $PREFIX"
205 test -z "$BUILD_DISCS" || add_make_enabled "BUILD_DISCS"
206 test -z "$BUILD_ENCODERS" || add_make_enabled "BUILD_ENCODERS"
207 test -z "$ENABLE_SMALL" || add_make_enabled "ENABLE_SMALL"
208 test -z "$GPL" || add_make_enabled "GPL"
209
210 #
211 # Checks
212 #
213 OS="${HOST#*-}" # strip architecture
214 case "${OS}" in
215         apple-darwin*)
216                 if test -z "$BUILDFORIOS"
217                 then
218                         check_macosx_sdk
219                         add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
220                 else
221                         check_ios_sdk
222                         add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_NEON" "HAVE_ARMV7A"
223                 fi
224                 ;;
225         *bsd*)
226                 add_make_enabled "HAVE_BSD"
227                 ;;
228         *android*)
229                 check_android_sdk
230                 add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
231                 case "${HOST}" in
232                         *arm*)
233                         add_make "PLATFORM_SHORT_ARCH := arm"
234                         ;;
235                         *i686*)
236                         add_make "PLATFORM_SHORT_ARCH := x86"
237                         ;;
238                         *mipsel*)
239                         add_make "PLATFORM_SHORT_ARCH := mips"
240                         ;;
241                 esac
242                 ;;
243         *linux*)
244                 add_make_enabled "HAVE_LINUX"
245                 ;;
246         *wince*)
247                 add_make_enabled "HAVE_WINCE"
248                 ;;
249         *mingw*)
250                 add_make_enabled "HAVE_WIN32"
251                 ;;
252 esac
253
254 #
255 # Results output
256 #
257 test -e Makefile && unlink Makefile
258 ln -sf ../../contrib/src/main.mak Makefile || exit $?
259 cat << EOF
260 Bootstrap completed.
261
262 Run "make" to start compilation.
263
264 Other targets:
265  * make install      same as "make"
266  * make prebuilt     fetch and install prebuilt binaries
267  * make list         list packages
268  * make fetch        fetch required source tarballs
269  * make fetch-all    fetch all source tarballs
270  * make distclean    clean everything and undo bootstrap
271  * make mostlyclean  clean everything except source tarballs
272  * make clean        clean everything
273  * make package      prepare prebuilt packages
274 EOF
275
276 mkdir -p ../../contrib/tarballs || exit $?