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