qt: playlist: use item title if available
[vlc.git] / 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-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"
39 }
40
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=
54
55 while test -n "$1"
56 do
57         case "$1" in
58                 --build=*)
59                         BUILD="${1#--build=}"
60                         ;;
61                 --help|-h)
62                         usage
63                         exit 0
64                         ;;
65                 --host=*)
66                         HOST="${1#--host=}"
67                         ;;
68                 --prefix=*)
69                         PREFIX="${1#--prefix=}"
70                         ;;
71                 --disable-disc)
72                         BUILD_DISCS=
73                         ;;
74                 --disable-net)
75                         BUILD_NETWORK=
76                         ;;
77                 --disable-sout)
78                         BUILD_ENCODERS=
79                         ;;
80                 --disable-optim)
81                         WITH_OPTIMIZATION=
82                         ;;
83                 --enable-pdb)
84                         ENABLE_PDB=1
85                         ;;
86                 --enable-small)
87                         ENABLE_SMALL=1
88                         ;;
89                 --disable-gpl)
90                         GPL=
91                         ;;
92                 --disable-gnuv3)
93                         GNUV3=
94                         ;;
95                 --enable-ad-clauses)
96                         AD_CLAUSES=1
97                         ;;
98                 --disable-*)
99                         PKGS_DISABLE="${PKGS_DISABLE} ${1#--disable-}"
100                         ;;
101                 --enable-*)
102                         PKGS_ENABLE="${PKGS_ENABLE} ${1#--enable-}"
103                         ;;
104                 *)
105                         echo "Unrecognized options $1"
106                         usage
107                         exit 1
108                         ;;
109         esac
110         shift
111 done
112
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
117 fi
118
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
126         fi
127         echo "$BUILD"
128 fi
129
130 if test -z "$HOST"
131 then
132         printf "Guessing host system...  "
133         HOST="$BUILD"
134         echo "$HOST"
135 fi
136
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"
145         fi
146 else
147         if test -n "$GNUV3"
148         then
149                 LICENSE="Lesser GPL version 3"
150         else
151                 LICENSE="Lesser GPL version 2.1"
152         fi
153 fi
154 test -z "$AD_CLAUSES" || LICENSE="$LICENSE, with advertisement clauses"
155 echo "$LICENSE"
156
157 if test "$PREFIX"
158 then
159         # strip trailing slash
160         PREFIX="${PREFIX%/}"
161 fi
162
163 #
164 # Prepare files
165 #
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
176 EOF
177
178 add_make()
179 {
180         while test -n "$1"
181         do
182                 echo "$1" >&3
183                 shift
184         done
185 }
186
187 add_make_enabled()
188 {
189         while test -n "$1"
190         do
191                 add_make "$1 := 1"
192                 shift
193         done
194 }
195
196 check_ios_sdk()
197 {
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"
208                 fi
209         fi
210
211         if [ ! -d "${SDKROOT}" ]
212         then
213                 echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
214                 exit 1
215         fi
216         add_make "IOS_SDK=${SDKROOT}"
217 }
218
219 check_macosx_sdk()
220 {
221         if [ -z "$SDKROOT" ]; then
222                 SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
223                 echo "SDKROOT not specified, assuming $SDKROOT"
224         fi
225
226         if [ ! -d "$SDKROOT" ]; then
227                 echo "*** $SDKROOT does not exist, please install required SDK, or set SDKROOT manually. ***"
228                 exit 1
229         fi
230
231         add_make "MACOSX_SDK=${SDKROOT}"
232 }
233
234 check_android_sdk()
235 {
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"
247 }
248
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
260 if [ "`uname -o 2>/dev/null`" = "Msys" ]; then
261     add_make "CMAKE_GENERATOR := MSYS Makefiles"
262     add_make "export CMAKE_GENERATOR"
263 fi
264
265 #
266 # Checks
267 #
268 OS="${HOST#*-}" # strip architecture
269 case "${OS}" in
270         *-darwin*)
271                 if test -z "$BUILDFORIOS"
272                 then
273                         check_macosx_sdk
274                         add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
275
276                         case "${HOST}" in
277                             *arm64*|*aarch64*)
278                             add_make "PLATFORM_SHORT_ARCH := arm64"
279                             add_make_enabled "HAVE_NEON"
280                             ;;
281                             *x86_64*)
282                             add_make "PLATFORM_SHORT_ARCH := x86_64"
283                             ;;
284                         esac;
285                 else
286                         check_ios_sdk
287                         add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_FPU"
288
289                         case "${HOST}" in
290                                 *arm64*|*aarch64*)
291                                         add_make "PLATFORM_SHORT_ARCH := arm64"
292                                         ;;
293                                 *arm*)
294                                         add_make "PLATFORM_SHORT_ARCH := armv7"
295                                         add_make_enabled "HAVE_NEON" "HAVE_ARMV7A"
296                                         ;;
297                                 *x86_64*)
298                                         add_make "PLATFORM_SHORT_ARCH := x86_64"
299                                         ;;
300                                 *86*)
301                                         add_make "PLATFORM_SHORT_ARCH := i386"
302                                         ;;
303                         esac;
304                 fi
305                 if test "$BUILDFORTVOS"
306                 then
307                         add_make_enabled "HAVE_TVOS"
308                 fi
309                 ;;
310         *bsd*)
311                 add_make_enabled "HAVE_BSD"
312                 ;;
313         *android*)
314                 check_android_sdk
315                 add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
316                 case "${HOST}" in
317                         *arm64*|*aarch64*)
318                                 add_make "PLATFORM_SHORT_ARCH := arm64"
319                                 ;;
320                         *arm*)
321                                 add_make "PLATFORM_SHORT_ARCH := arm"
322                                 ;;
323                         *i686*)
324                                 add_make "PLATFORM_SHORT_ARCH := x86"
325                                 ;;
326                         *x86_64*)
327                                 add_make "PLATFORM_SHORT_ARCH := x86_64"
328                                 ;;
329                         *mipsel*)
330                                 add_make "PLATFORM_SHORT_ARCH := mips"
331                                 ;;
332                 esac
333                 ;;
334         *linux*)
335                 add_make_enabled "HAVE_LINUX"
336                 ;;
337         *mingw*)
338                 add_make_enabled "HAVE_WIN32"
339                 case "${HOST}" in
340                         *winphone*|*windowsphone*)
341                                 add_make_enabled "HAVE_WINDOWSPHONE"
342                                 ;;
343                 esac
344                 case "${HOST}" in
345                         *winphone*|*windowsphone*|*winrt*|*uwp*)
346                                 add_make_enabled "HAVE_WINSTORE"
347                                 ;;
348                 esac
349                 case "${HOST}" in
350                         armv7*)
351                                 add_make_enabled "HAVE_ARMV7A"
352                                 ;;
353                 esac
354                 ;;
355         *solaris*)
356                 add_make_enabled "HAVE_SOLARIS"
357                 ;;
358         *nacl*)
359                 add_make_enabled "HAVE_NACL"
360                 ;;
361 esac
362
363 #
364 # Results output
365 #
366 BOOTSTRAP_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
367 CURRENT_PATH="$( pwd -P )"
368 # location of the contrib/src folder from the root of the contrib build folder
369 TOPSRC=$(python3 -c "import os; print(os.path.relpath('$BOOTSTRAP_PATH', '$CURRENT_PATH'))")
370 # location of the contrib/src folder from a built library folder
371 TOPSRC_BUILT=$(python3 -c "import os; print(os.path.relpath('$BOOTSTRAP_PATH', '$CURRENT_PATH/libfoo'))")
372 add_make "TOPSRC = $TOPSRC"
373 add_make "TOPSRC_BUILT = $TOPSRC_BUILT"
374 add_make "TOPDST = .."
375 add_make "-include config.mak"
376 add_make 'include $(TOPSRC)/src/main.mak'
377 echo "Bootstrap completed."
378 make help
379 mkdir -p $BOOTSTRAP_PATH/tarballs || exit $?