vlc_codecs: add Waveformatex ADTS
[vlc.git] / contrib / bootstrap
blob218487e2ab3578649b5136a0831c1d959c521abf
1 #! /bin/sh
2 # Copyright (C) 2003-2011 the VideoLAN team
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.
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.
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.
19 # Command line handling
21 usage()
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-net configure to not build networking packages"
31 echo " --disable-sout configure to not build stream output packages"
32 echo " --enable-small optimize libraries for size with slight speed decrease [DANGEROUS]"
33 echo " --disable-gpl configure to not build viral GPL code"
34 echo " --disable-optim disable optimization in libraries"
37 BUILD=
38 HOST=
39 PREFIX=
40 PKGS_ENABLE=
41 PKGS_DISABLE=
42 BUILD_ENCODERS="1"
43 BUILD_NETWORK="1"
44 BUILD_DISCS="1"
45 GPL="1"
46 WITH_OPTIMIZATION="1"
48 if test ! -f "../../contrib/src/main.mak"
49 then
50 echo "$0 must be run from a subdirectory"
51 exit 1
54 while test -n "$1"
56 case "$1" in
57 --build=*)
58 BUILD="${1#--build=}"
60 --help|-h)
61 usage
62 exit 0
64 --host=*)
65 HOST="${1#--host=}"
67 --prefix=*)
68 PREFIX="${1#--prefix=}"
70 --disable-disc)
71 BUILD_DISCS=
73 --disable-net)
74 BUILD_NETWORK=
76 --disable-sout)
77 BUILD_ENCODERS=
79 --disable-optim)
80 WITH_OPTIMIZATION=
82 --enable-small)
83 ENABLE_SMALL=1
85 --disable-gpl)
86 GPL=
88 --disable-*)
89 PKGS_DISABLE="${PKGS_DISABLE} ${1#--disable-}"
91 --enable-*)
92 PKGS_ENABLE="${PKGS_ENABLE} ${1#--enable-}"
95 echo "Unrecognized options $1"
96 usage
97 exit 1
99 esac
100 shift
101 done
103 if test -z "$BUILD"
104 then
105 echo -n "Guessing build system... "
106 BUILD="`${CC:-cc} -dumpmachine`"
107 if test -z "$BUILD"; then
108 echo "FAIL!"
109 exit 1
111 echo "$BUILD"
114 if test -z "$HOST"
115 then
116 echo -n "Guessing host system... "
117 HOST="$BUILD"
118 echo "$HOST"
121 if test "$PREFIX"
122 then
123 # strip trailing slash
124 PREFIX="${PREFIX%/}"
128 # Prepare files
130 echo "Creating configuration file... config.mak"
131 exec 3>config.mak || exit $?
132 cat >&3 << EOF
133 # This file was automatically generated.
134 # Any change will be overwritten if ../bootstrap is run again.
135 BUILD := $BUILD
136 HOST := $HOST
137 PKGS_DISABLE := $PKGS_DISABLE
138 PKGS_ENABLE := $PKGS_ENABLE
141 add_make()
143 while test -n "$1"
145 echo "$1" >&3
146 shift
147 done
150 add_make_enabled()
152 while test -n "$1"
154 add_make "$1 := 1"
155 shift
156 done
159 check_ios_sdk()
161 if test "$VLCSDKROOT"
162 then
163 SDKROOT="$VLCSDKROOT"
164 else
165 if test -z "$SDKROOT"
166 then
167 SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
168 echo "SDKROOT not specified, assuming $SDKROOT"
169 else
170 SDKROOT="$SDKROOT"
174 if [ ! -d "${SDKROOT}" ]
175 then
176 echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
177 exit 1
179 add_make "IOS_SDK=${SDKROOT}"
182 check_macosx_sdk()
184 if [ -z "${OSX_VERSION}" ]
185 then
186 OSX_VERSION=`xcrun --show-sdk-version`
187 echo "OSX_VERSION not specified, assuming $OSX_VERSION"
189 if test -z "$SDKROOT"
190 then
191 SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
192 echo "SDKROOT not specified, assuming $SDKROOT"
195 if [ ! -d "${SDKROOT}" ]
196 then
197 SDKROOT_NOT_FOUND=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
198 SDKROOT=`xcode-select -print-path`/SDKs/MacOSX$OSX_VERSION.sdk
199 echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
201 if [ ! -d "${SDKROOT}" ]
202 then
203 SDKROOT_NOT_FOUND="$SDKROOT"
204 SDKROOT=`xcrun --show-sdk-path`
205 echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
208 if [ ! -d "${SDKROOT}" ]
209 then
210 echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
211 exit 1
214 add_make "MACOSX_SDK=${SDKROOT}"
215 add_make "OSX_VERSION ?= ${OSX_VERSION}"
218 check_android_sdk()
220 [ -z "${ANDROID_NDK}" ] && echo "You must set ANDROID_NDK environment variable" && exit 1
221 add_make "ANDROID_NDK := ${ANDROID_NDK}"
222 [ -z "${ANDROID_ABI}" ] && echo "You must set ANDROID_ABI environment variable" && exit 1
223 add_make "ANDROID_ABI := ${ANDROID_ABI}"
224 [ -z "${ANDROID_API}" ] && echo "You should set ANDROID_API environment variable (using default android-9)" && ANDROID_API := android-9
225 add_make "ANDROID_API := ${ANDROID_API}"
226 [ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_NEON"
227 [ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_ARMV7A"
228 [ ${ANDROID_ABI} = "arm64-v8a" ] && add_make_enabled "HAVE_NEON"
229 [ ${ANDROID_ABI} = "arm64-v8a" ] && add_make_enabled "HAVE_ARMV8A"
230 [ ${ANDROID_ABI} = "armeabi" -a -z "${NO_ARMV6}" ] && add_make_enabled "HAVE_ARMV6"
233 check_tizen_sdk()
235 [ -z "${TIZEN_SDK}" ] && echo "You must set TIZEN_SDK environment variable" && exit 1
236 add_make "TIZEN_SDK := ${TIZEN_SDK}"
237 [ -z "${TIZEN_ABI}" ] && echo "You must set TIZEN_ABI environment variable" && exit 1
238 add_make "TIZEN_ABI := ${TIZEN_ABI}"
239 [ ${TIZEN_ABI} = "armv7l" ] && add_make_enabled "HAVE_NEON"
240 [ ${TIZEN_ABI} = "armv7l" ] && add_make_enabled "HAVE_ARMV7A"
243 test -z "$PREFIX" || add_make "PREFIX := $PREFIX"
244 test -z "$BUILD_DISCS" || add_make_enabled "BUILD_DISCS"
245 test -z "$BUILD_ENCODERS" || add_make_enabled "BUILD_ENCODERS"
246 test -z "$BUILD_NETWORK" || add_make_enabled "BUILD_NETWORK"
247 test -z "$ENABLE_SMALL" || add_make_enabled "ENABLE_SMALL"
248 test -z "$GPL" || add_make_enabled "GPL"
249 test -z "$WITH_OPTIMIZATION" || add_make_enabled "WITH_OPTIMIZATION"
250 test "`uname -o`" != "Msys" || add_make "CMAKE_GENERATOR := -G \"MSYS Makefiles\""
253 # Checks
255 OS="${HOST#*-}" # strip architecture
256 case "${OS}" in
257 *-darwin*)
258 if test -z "$BUILDFORIOS"
259 then
260 check_macosx_sdk
261 add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
262 else
263 check_ios_sdk
264 add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_FPU"
266 case "${HOST}" in
267 *arm*)
268 add_make_enabled "HAVE_NEON" "HAVE_ARMV7A"
270 esac;
272 if test "$BUILDFORTVOS"
273 then
274 add_make_enabled "HAVE_TVOS"
277 *bsd*)
278 add_make_enabled "HAVE_BSD"
280 *android*)
281 check_android_sdk
282 add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
283 case "${HOST}" in
284 *arm*)
285 add_make "PLATFORM_SHORT_ARCH := arm"
287 *arm64*|*aarch64*)
288 add_make "PLATFORM_SHORT_ARCH := arm64"
290 *i686*)
291 add_make "PLATFORM_SHORT_ARCH := x86"
293 *x86_64*)
294 add_make "PLATFORM_SHORT_ARCH := x86_64"
296 *mipsel*)
297 add_make "PLATFORM_SHORT_ARCH := mips"
299 esac
301 *linux*)
302 if [ "`${CC} -v 2>&1 | grep tizen`" ]; then
303 check_tizen_sdk
304 add_make_enabled "HAVE_TIZEN"
305 case "${HOST}" in
306 *arm*)
307 add_make "PLATFORM_SHORT_ARCH := arm"
309 *i386*)
310 add_make "PLATFORM_SHORT_ARCH := x86"
312 esac
315 add_make_enabled "HAVE_LINUX"
317 *mingw*)
318 add_make_enabled "HAVE_WIN32"
319 case "${HOST}" in
320 *winphone*|*windowsphone*)
321 add_make_enabled "HAVE_WINDOWSPHONE"
323 esac
324 case "${HOST}" in
325 *winphone*|*windowsphone*|*winrt*|*uwp*)
326 add_make_enabled "HAVE_WINSTORE"
328 esac
329 case "${HOST}" in
330 amd64*|x86_64*)
331 add_make_enabled "HAVE_WIN64"
333 esac
334 case "${HOST}" in
335 armv7*)
336 add_make_enabled "HAVE_ARMV7A"
338 esac
340 *solaris*)
341 add_make_enabled "HAVE_SOLARIS"
343 esac
346 # Results output
348 test -e Makefile && unlink Makefile
349 ln -sf ../../contrib/src/main.mak Makefile || exit $?
350 echo "Bootstrap completed."
351 make help
352 mkdir -p ../../contrib/tarballs || exit $?