player: add a metadata listener API
[vlc.git] / contrib / bootstrap
blob5ed5f6f25d31cd54b8f1dc96c88faad6a926cd72
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-gnuv3 configure to not build version 3 (L)GPL code"
35 echo " --enable-ad-clauses configure to build packages with advertising clauses"
36 echo " (USE AT YOUR OWN LEGAL RISKS)"
37 echo " --disable-optim disable optimization in libraries"
38 echo " --enable-pdb generate debug information in PDB format"
41 BUILD=
42 HOST=
43 PREFIX=
44 PKGS_ENABLE=
45 PKGS_DISABLE=
46 BUILD_ENCODERS="1"
47 BUILD_NETWORK="1"
48 BUILD_DISCS="1"
49 GPL="1"
50 GNUV3="1"
51 AD_CLAUSES=
52 WITH_OPTIMIZATION="1"
53 ENABLE_PDB=
55 while test -n "$1"
57 case "$1" in
58 --build=*)
59 BUILD="${1#--build=}"
61 --help|-h)
62 usage
63 exit 0
65 --host=*)
66 HOST="${1#--host=}"
68 --prefix=*)
69 PREFIX="${1#--prefix=}"
71 --disable-disc)
72 BUILD_DISCS=
74 --disable-net)
75 BUILD_NETWORK=
77 --disable-sout)
78 BUILD_ENCODERS=
80 --disable-optim)
81 WITH_OPTIMIZATION=
83 --enable-pdb)
84 ENABLE_PDB=1
86 --enable-small)
87 ENABLE_SMALL=1
89 --disable-gpl)
90 GPL=
92 --disable-gnuv3)
93 GNUV3=
95 --enable-ad-clauses)
96 AD_CLAUSES=1
98 --disable-*)
99 PKGS_DISABLE="${PKGS_DISABLE} ${1#--disable-}"
101 --enable-*)
102 PKGS_ENABLE="${PKGS_ENABLE} ${1#--enable-}"
105 echo "Unrecognized options $1"
106 usage
107 exit 1
109 esac
110 shift
111 done
113 if test -n "$AD_CLAUSES" -a -n "$GPL" -a -z "$GNUV3"
114 then
115 echo "Error: advertising clauses are not compatible with GPLv2!" >&2
116 exit 1
119 if test -z "$BUILD"
120 then
121 printf "Guessing build system... "
122 BUILD="`${CC:-cc} -dumpmachine | sed s/windows-gnu/mingw32/`"
123 if test -z "$BUILD"; then
124 echo "FAIL!"
125 exit 1
127 echo "$BUILD"
130 if test -z "$HOST"
131 then
132 printf "Guessing host system... "
133 HOST="$BUILD"
134 echo "$HOST"
137 printf "Packages licensing... "
138 if test -n "$GPL"
139 then
140 if test -n "$GNUV3"
141 then
142 LICENSE="GPL version 3"
143 else
144 LICENSE="GPL version 2"
146 else
147 if test -n "$GNUV3"
148 then
149 LICENSE="Lesser GPL version 3"
150 else
151 LICENSE="Lesser GPL version 2.1"
154 test -z "$AD_CLAUSES" || LICENSE="$LICENSE, with advertisement clauses"
155 echo "$LICENSE"
157 if test "$PREFIX"
158 then
159 # strip trailing slash
160 PREFIX="${PREFIX%/}"
164 # Prepare files
166 echo "Creating makefile..."
167 test -e Makefile && unlink Makefile
168 exec 3>Makefile || exit $?
169 cat >&3 << EOF
170 # This file was automatically generated.
171 # Any change will be overwritten if ../bootstrap is run again.
172 BUILD := $BUILD
173 HOST := $HOST
174 PKGS_DISABLE := $PKGS_DISABLE
175 PKGS_ENABLE := $PKGS_ENABLE
178 add_make()
180 while test -n "$1"
182 echo "$1" >&3
183 shift
184 done
187 add_make_enabled()
189 while test -n "$1"
191 add_make "$1 := 1"
192 shift
193 done
196 check_ios_sdk()
198 if test "$VLCSDKROOT"
199 then
200 SDKROOT="$VLCSDKROOT"
201 else
202 if test -z "$SDKROOT"
203 then
204 SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
205 echo "SDKROOT not specified, assuming $SDKROOT"
206 else
207 SDKROOT="$SDKROOT"
211 if [ ! -d "${SDKROOT}" ]
212 then
213 echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
214 exit 1
216 add_make "IOS_SDK=${SDKROOT}"
219 check_macosx_sdk()
221 if [ -z "$SDKROOT" ]; then
222 SDKROOT=$(xcrun --show-sdk-path)
223 echo "SDKROOT not specified, assuming $SDKROOT"
226 if [ ! -d "$SDKROOT" ]; then
227 echo "*** $SDKROOT does not exist, please install required SDK, or set SDKROOT manually. ***"
228 exit 1
231 add_make "MACOSX_SDK=${SDKROOT}"
234 check_android_sdk()
236 [ -z "${ANDROID_NDK}" ] && echo "You must set ANDROID_NDK environment variable" && exit 1
237 add_make "ANDROID_NDK := ${ANDROID_NDK}"
238 [ -z "${ANDROID_ABI}" ] && echo "You must set ANDROID_ABI environment variable" && exit 1
239 add_make "ANDROID_ABI := ${ANDROID_ABI}"
240 [ -z "${ANDROID_API}" ] && echo "You should set ANDROID_API environment variable (using default android-9)" && ANDROID_API := android-9
241 add_make "ANDROID_API := ${ANDROID_API}"
242 [ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_NEON"
243 [ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_ARMV7A"
244 [ ${ANDROID_ABI} = "arm64-v8a" ] && add_make_enabled "HAVE_NEON"
245 [ ${ANDROID_ABI} = "arm64-v8a" ] && add_make_enabled "HAVE_ARMV8A"
246 [ ${ANDROID_ABI} = "armeabi" -a -z "${NO_ARMV6}" ] && add_make_enabled "HAVE_ARMV6"
249 test -z "$PREFIX" || add_make "PREFIX := $PREFIX"
250 test -z "$BUILD_DISCS" || add_make_enabled "BUILD_DISCS"
251 test -z "$BUILD_ENCODERS" || add_make_enabled "BUILD_ENCODERS"
252 test -z "$BUILD_NETWORK" || add_make_enabled "BUILD_NETWORK"
253 test -z "$ENABLE_SMALL" || add_make_enabled "ENABLE_SMALL"
254 test -z "$GPL" || add_make_enabled "GPL"
255 test -z "$GNUV3" || add_make_enabled "GNUV3"
256 test -z "$AD_CLAUSES" || add_make_enabled "AD_CLAUSES"
257 test -z "$WITH_OPTIMIZATION" || add_make_enabled "WITH_OPTIMIZATION"
258 test -z "$ENABLE_PDB" || add_make_enabled "ENABLE_PDB"
259 test "`uname -o 2>/dev/null`" != "Msys" || add_make "CMAKE_GENERATOR := -G \"MSYS Makefiles\""
262 # Checks
264 OS="${HOST#*-}" # strip architecture
265 case "${OS}" in
266 *-darwin*)
267 if test -z "$BUILDFORIOS"
268 then
269 check_macosx_sdk
270 add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
271 else
272 check_ios_sdk
273 add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_FPU"
275 case "${HOST}" in
276 *arm64*|*aarch64*)
277 add_make "PLATFORM_SHORT_ARCH := arm64"
279 *arm*)
280 add_make "PLATFORM_SHORT_ARCH := armv7"
281 add_make_enabled "HAVE_NEON" "HAVE_ARMV7A"
283 *x86_64*)
284 add_make "PLATFORM_SHORT_ARCH := x86_64"
286 *86*)
287 add_make "PLATFORM_SHORT_ARCH := i386"
289 esac;
291 if test "$BUILDFORTVOS"
292 then
293 add_make_enabled "HAVE_TVOS"
296 *bsd*)
297 add_make_enabled "HAVE_BSD"
299 *android*)
300 check_android_sdk
301 add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
302 case "${HOST}" in
303 *arm64*|*aarch64*)
304 add_make "PLATFORM_SHORT_ARCH := arm64"
306 *arm*)
307 add_make "PLATFORM_SHORT_ARCH := arm"
309 *i686*)
310 add_make "PLATFORM_SHORT_ARCH := x86"
312 *x86_64*)
313 add_make "PLATFORM_SHORT_ARCH := x86_64"
315 *mipsel*)
316 add_make "PLATFORM_SHORT_ARCH := mips"
318 esac
320 *linux*)
321 add_make_enabled "HAVE_LINUX"
323 *mingw*)
324 add_make_enabled "HAVE_WIN32"
325 case "${HOST}" in
326 *winphone*|*windowsphone*)
327 add_make_enabled "HAVE_WINDOWSPHONE"
329 esac
330 case "${HOST}" in
331 *winphone*|*windowsphone*|*winrt*|*uwp*)
332 add_make_enabled "HAVE_WINSTORE"
334 esac
335 case "${HOST}" in
336 armv7*)
337 add_make_enabled "HAVE_ARMV7A"
339 esac
341 *solaris*)
342 add_make_enabled "HAVE_SOLARIS"
344 *nacl*)
345 add_make_enabled "HAVE_NACL"
347 esac
350 # Results output
352 BOOTSTRAP_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
353 CURRENT_PATH="$( pwd -P )"
354 # location of the contrib/src folder from the root of the contrib build folder
355 TOPSRC=$(python3 -c "import os; print(os.path.relpath('$BOOTSTRAP_PATH', '$CURRENT_PATH'))")
356 # location of the contrib/src folder from a built library folder
357 TOPSRC_BUILT=$(python3 -c "import os; print(os.path.relpath('$BOOTSTRAP_PATH', '$CURRENT_PATH/libfoo'))")
358 add_make "TOPSRC = $TOPSRC"
359 add_make "TOPSRC_BUILT = $TOPSRC_BUILT"
360 add_make "TOPDST = .."
361 add_make "-include config.mak"
362 add_make 'include $(TOPSRC)/src/main.mak'
363 echo "Bootstrap completed."
364 make help
365 mkdir -p $BOOTSTRAP_PATH/tarballs || exit $?