]> git.sesse.net Git - vlc/blob - extras/package/ios/build.sh
extras/ios: rework LDFLAGS handling and enable vpx for the scary build flavor
[vlc] / extras / package / ios / build.sh
1 #!/bin/sh
2 set -e
3
4 PLATFORM=OS
5 VERBOSE=no
6 DEBUG=no
7 SDK_VERSION=7.0
8 SDK_MIN=6.1
9 SIXTYFOURBIT_SDK_MIN=7.0
10 ARCH=armv7
11 SCARY=yes
12
13 usage()
14 {
15 cat << EOF
16 usage: $0 [-s] [-d] [-v] [-k sdk]
17
18 OPTIONS
19    -k <sdk version>      Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK_VERSION})
20    -s            Build for simulator
21    -a <arch>     Specify which arch to use (current: ${ARCH})
22    -d            Enable debug
23    -v            Enable verbose command-line output
24    -w            Build a limited stack of non-scary libraries only
25 EOF
26 }
27
28 spushd()
29 {
30     pushd "$1" 2>&1> /dev/null
31 }
32
33 spopd()
34 {
35     popd 2>&1> /dev/null
36 }
37
38 info()
39 {
40     local blue="\033[1;34m"
41     local normal="\033[0m"
42     echo "[${blue}info${normal}] $1"
43 }
44
45 while getopts "hvwdsk:a:" OPTION
46 do
47      case $OPTION in
48          h)
49              usage
50              exit 1
51              ;;
52          v)
53              VERBOSE=yes
54              ;;
55          s)
56              PLATFORM=Simulator
57              ;;
58          d)
59              DEBUG=yes
60              ;;
61          w)
62              SCARY=no
63              ;;
64          k)
65              SDK_VERSION=$OPTARG
66              ;;
67          a)
68              ARCH=$OPTARG
69              ;;
70          ?)
71              usage
72              exit 1
73              ;;
74      esac
75 done
76 shift $(($OPTIND - 1))
77
78 if [ "x$1" != "x" ]; then
79     usage
80     exit 1
81 fi
82
83 out="/dev/null"
84 if [ "$VERBOSE" = "yes" ]; then
85    out="/dev/stdout"
86 fi
87
88 info "Building libvlc for iOS"
89
90 if [ "$PLATFORM" = "Simulator" ]; then
91     TARGET="${ARCH}-apple-darwin11"
92 else
93     TARGET="arm-apple-darwin11"
94 fi
95
96 if [ "$DEBUG" = "yes" ]; then
97     OPTIM="-O0 -g"
98 else
99     OPTIM="-O3 -g"
100 fi
101
102 info "Using ${ARCH} with SDK version ${SDK_VERSION}"
103
104 THIS_SCRIPT_PATH=`pwd`/$0
105
106 spushd `dirname ${THIS_SCRIPT_PATH}`/../../..
107 VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
108 spopd
109
110 if test -z "$SDKROOT"
111 then
112     SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
113     echo "SDKROOT not specified, assuming $SDKROOT"
114 fi
115
116 if [ ! -d "${SDKROOT}" ]
117 then
118     echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
119     exit 1
120 fi
121
122 BUILDDIR="${VLCROOT}/build-ios-${PLATFORM}/${ARCH}"
123
124 PREFIX="${VLCROOT}/install-ios-${PLATFORM}/${ARCH}"
125
126 export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
127
128 info "Building tools"
129 spushd "${VLCROOT}/extras/tools"
130 ./bootstrap
131 make && make .gas
132 spopd
133
134 info "Building contrib for iOS in '${VLCROOT}/contrib/iPhone${PLATFORM}-${ARCH}'"
135
136 # The contrib will read the following
137 export AR="xcrun ar"
138
139 export RANLIB="xcrun ranlib"
140 export CC="xcrun clang"
141 export OBJC="xcrun clang"
142 export CXX="xcrun clang++"
143 export LD="xcrun ld"
144 export STRIP="xcrun strip"
145
146 export PLATFORM=$PLATFORM
147 export SDK_VERSION=$SDK_VERSION
148
149 export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} ${OPTIM}"
150
151 if [ "$PLATFORM" = "OS" ]; then
152 if [ "$ARCH" != "arm64" ]; then
153 export CFLAGS="${CFLAGS} -mcpu=cortex-a8 -miphoneos-version-min=${SDK_MIN}"
154 else
155 export CFLAGS="${CFLAGS} -miphoneos-version-min=${SIXTYFOURBIT_SDK_MIN}"
156 fi
157 else
158 export CFLAGS="${CFLAGS} -miphoneos-version-min=${SIXTYFOURBIT_SDK_MIN}"
159 fi
160
161 export CXXFLAGS="${CFLAGS} -stdlib=libstdc++"
162
163 export CPPFLAGS="${CFLAGS}"
164
165 export CPP="xcrun cc -E"
166 export CXXCPP="xcrun c++ -E"
167
168 export BUILDFORIOS="yes"
169
170 if [ "$PLATFORM" = "Simulator" ]; then
171     # Use the new ABI on simulator, else we can't build
172     export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
173 fi
174
175 export LDFLAGS="-L${SDKROOT}/usr/lib -arch ${ARCH} -isysroot ${SDKROOT}"
176
177 if [ "$PLATFORM" = "OS" ]; then
178     EXTRA_CFLAGS="-arch ${ARCH}"
179     EXTRA_LDFLAGS="-arch ${ARCH}"
180 if [ "$ARCH" != "arm64" ]; then
181     EXTRA_CFLAGS+=" -mcpu=cortex-a8"
182     EXTRA_CFLAGS+=" -miphoneos-version-min=${SDK_MIN}"
183     EXTRA_LDFLAGS+=" -Wl,-ios_version_min,${SDK_MIN}"
184     export LDFLAGS="${LDFLAGS} -Wl,-ios_version_min,${SDK_MIN}"
185 else
186     EXTRA_CFLAGS+=" -miphoneos-version-min=${SIXTYFOURBIT_SDK_MIN}"
187     EXTRA_LDFLAGS+=" -Wl,-ios_version_min,${SIXTYFOURBIT_SDK_MIN}"
188     export LDFLAGS="${LDFLAGS} -Wl,-ios_version_min,${SIXTYFOURBIT_SDK_MIN}"
189 fi
190 else
191     EXTRA_CFLAGS="-arch ${ARCH}"
192     EXTRA_CFLAGS+=" -miphoneos-version-min=${SIXTYFOURBIT_SDK_MIN}"
193     EXTRA_LDFLAGS=" -Wl,-ios_version_min,${SIXTYFOURBIT_SDK_MIN}"
194     export LDFLAGS="${LDFLAGS} -Wl-ios_version_min,${SIXTYFOURBIT_SDK_MIN}"
195 fi
196
197
198 info "LD FLAGS SELECTED = '${LDFLAGS}'"
199
200 spushd ${VLCROOT}/contrib
201
202 echo ${VLCROOT}
203 mkdir -p "${VLCROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
204 cd "${VLCROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
205
206 if [ "$PLATFORM" = "OS" ]; then
207     export AS="gas-preprocessor.pl ${CC}"
208     export ASCPP="gas-preprocessor.pl ${CC}"
209     export CCAS="gas-preprocessor.pl ${CC}"
210     if [ "$ARCH" = "arm64" ]; then
211         export GASPP_FIX_XCODE5=1
212     fi
213 else
214     export ASCPP="xcrun as"
215 fi
216
217 ../bootstrap --build=x86_64-apple-darwin11 --host=${TARGET} --prefix=${VLCROOT}/contrib/${TARGET}-${ARCH} --arch=${ARCH} --disable-gpl \
218     --disable-disc --disable-sout \
219     --disable-sdl \
220     --disable-SDL_image \
221     --disable-iconv \
222     --enable-zvbi \
223     --disable-kate \
224     --disable-caca \
225     --disable-gettext \
226     --disable-mpcdec \
227     --disable-upnp \
228     --disable-gme \
229     --disable-tremor \
230     --enable-vorbis \
231     --disable-sidplay2 \
232     --disable-samplerate \
233     --disable-goom \
234     --disable-vncserver \
235     --disable-orc \
236     --disable-schroedinger \
237     --disable-libmpeg2 \
238     --disable-chromaprint \
239     --disable-mad \
240     --enable-fribidi \
241     --enable-libxml2 \
242     --enable-freetype2 \
243     --enable-ass \
244     --disable-fontconfig \
245     --disable-gpg-error \
246     --disable-lua \
247     --enable-vpx \
248     --enable-taglib > ${out}
249
250 echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
251 echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
252 make fetch
253 make
254 spopd
255
256 info "Bootstraping vlc"
257 pwd
258 info "VLCROOT = ${VLCROOT}"
259 if ! [ -e ${VLCROOT}/configure ]; then
260     ${VLCROOT}/bootstrap  > ${out}
261 fi
262
263 info "Bootstraping vlc finished"
264
265 if [ ".$PLATFORM" != ".Simulator" ]; then
266     # FIXME - Do we still need this?
267     export AVCODEC_CFLAGS="-I${PREFIX}/include "
268     export AVCODEC_LIBS="-L${PREFIX}/lib -lavcodec -lavutil -lz"
269     export AVFORMAT_CFLAGS="-I${PREFIX}/include"
270     export AVFORMAT_LIBS="-L${PREFIX}/lib -lavcodec -lz -lavutil -lavformat"
271 fi
272
273 mkdir -p ${BUILDDIR}
274 spushd ${BUILDDIR}
275
276 info ">> --prefix=${PREFIX} --host=${TARGET}"
277
278 if [ "$DEBUG" = "yes" ]; then
279     DEBUGFLAG="--enable-debug"
280 else
281     DEBUGFLAG="--disable-debug"
282 fi
283
284 if [ "$SCARY" = "yes" ]; then
285         SCARYFLAG="--enable-dvbpsi --enable-avcodec"
286 else
287         SCARYFLAG="--disable-dca --disable-dvbpsi --disable-avcodec --disable-avformat --disable-zvbi --enable-vpx"
288 fi
289
290 # Run configure only upon changes.
291 if [ "${VLCROOT}/configure" -nt config.log -o \
292      "${THIS_SCRIPT_PATH}" -nt config.log ]; then
293 ${VLCROOT}/configure \
294     --prefix="${PREFIX}" \
295     --host="${TARGET}" \
296     --with-contrib="${VLCROOT}/contrib/${TARGET}-${ARCH}" \
297     --enable-static \
298     ${DEBUGFLAG} \
299     ${SCARYFLAG} \
300     --disable-macosx \
301     --disable-macosx-dialog-provider \
302     --disable-macosx-qtkit \
303     --disable-macosx-eyetv \
304     --disable-macosx-vlc-app \
305     --disable-macosx-avfoundation \
306     --disable-audioqueue \
307     --disable-shared \
308     --enable-macosx-quartztext \
309     --enable-mkv \
310     --enable-opus \
311     --disable-sout \
312     --disable-faad \
313     --disable-lua \
314     --disable-a52 \
315     --enable-fribidi \
316     --disable-qt --disable-skins2 \
317     --disable-vcd \
318     --disable-vlc \
319     --disable-vlm \
320     --disable-httpd \
321     --disable-nls \
322     --disable-glx \
323     --disable-sse \
324     --enable-neon \
325     --disable-notify \
326     --enable-live555 \
327     --enable-realrtsp \
328     --enable-swscale \
329     --disable-projectm \
330     --enable-libass \
331     --enable-libxml2 \
332     --disable-goom \
333     --disable-dvdread \
334     --disable-dvdnav \
335     --disable-bluray \
336     --disable-linsys \
337     --disable-libva \
338     --disable-gme \
339     --disable-tremor \
340     --enable-vorbis \
341     --disable-fluidsynth \
342     --disable-jack \
343     --disable-pulse \
344     --disable-mtp \
345     --enable-ogg \
346     --enable-speex \
347     --enable-theora \
348     --enable-flac \
349     --disable-screen \
350     --enable-freetype \
351     --enable-taglib \
352     --disable-mmx \
353     --disable-addonmanagermodules \
354     --disable-mad > ${out} # MMX and SSE support requires llvm which is broken on Simulator
355 fi
356
357 CORE_COUNT=`sysctl -n machdep.cpu.core_count`
358 let MAKE_JOBS=$CORE_COUNT+1
359
360 info "Building libvlc"
361 make -j$MAKE_JOBS > ${out}
362
363 info "Installing libvlc"
364 make install > ${out}
365
366 find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
367 rm -rf "${PREFIX}/contribs"
368 cp -R "${VLCROOT}/contrib/${TARGET}-${ARCH}" "${PREFIX}/contribs"
369
370 info "Removing unneeded modules"
371 blacklist="
372 stats
373 access_bd
374 shm
375 access_imem
376 oldrc
377 real
378 hotkeys
379 gestures
380 dynamicoverlay
381 rss
382 ball
383 marq
384 magnify
385 audiobargraph_
386 clone
387 mosaic
388 osdmenu
389 puzzle
390 mediadirs
391 t140
392 ripple
393 motion
394 sharpen
395 grain
396 posterize
397 mirror
398 wall
399 scene
400 blendbench
401 psychedelic
402 alphamask
403 netsync
404 audioscrobbler
405 motiondetect
406 motionblur
407 export
408 smf
409 podcast
410 bluescreen
411 erase
412 stream_filter_record
413 speex_resampler
414 remoteosd
415 magnify
416 gradient
417 tospdif
418 dtstofloat32
419 logger
420 visual
421 fb
422 aout_file
423 dummy
424 invert
425 sepia
426 wave
427 hqdn3d
428 headphone_channel_mixer
429 gaussianblur
430 gradfun
431 extract
432 colorthres
433 antiflicker
434 anaglyph
435 remap
436 oldmovie
437 vhs
438 demuxdump
439 fingerprinter
440 "
441
442 if [ "$SCARY" = "no" ]; then
443 blacklist="${blacklist}
444 dts
445 dvbsub
446 svcd
447 hevc
448 packetizer_mlp
449 a52
450 vc1
451 uleaddvaudio
452 librar
453 libvoc
454 avio
455 chorus_flanger
456 smooth
457 cvdsub
458 libmod
459 libdash
460 libmpgv
461 dolby_surround
462 mpeg_audio"
463 fi
464
465 echo ${blacklist}
466
467 for i in ${blacklist}
468 do
469     find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
470 done
471
472 popd