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