]> git.sesse.net Git - vlc/blob - extras/package/ios/build.sh
ios: fix contrib compilation with Xcode 5
[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 export SDKROOT
141 CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -miphoneos-version-min=${SDK_MIN} ${OPTIM}"
142 if [ "$ARCH" = "armv7" -o "$ARCH" = "armv7s" ]; then
143 CFLAGS+=" -mcpu=cortex-a8"
144 fi
145 export CFLAGS
146 export CPPFLAGS="${CFLAGS}"
147 export CXXFLAGS="${CFLAGS}"
148 export OBJCFLAGS="${CFLAGS}"
149
150 export CPP="xcrun cc -E"
151 export CXXCPP="xcrun c++ -E"
152
153 export BUILDFORIOS="yes"
154
155 if [ "$PLATFORM" = "Simulator" ]; then
156     # Use the new ABI on simulator, else we can't build
157     export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
158 fi
159
160 if [ "$PLATFORM" = "OS" ]; then
161   export LDFLAGS="-L${SDKROOT}/usr/lib -arch ${ARCH} -isysroot ${SDKROOT} -miphoneos-version-min=${SDK_MIN}"
162 else
163   export LDFLAGS="-syslibroot=${SDKROOT}/ -arch ${ARCH} -miphoneos-version-min=${SDK_MIN}"
164 fi
165
166 if [ "$PLATFORM" = "OS" ]; then
167     EXTRA_CFLAGS="-arch ${ARCH} ${CFLAGS}"
168     EXTRA_LDFLAGS="-arch ${ARCH} ${LDFLAGS}"
169 else
170     EXTRA_CFLAGS="-arch ${ARCH}"
171     EXTRA_LDFLAGS="-arch ${ARCH}"
172 fi
173
174 EXTRA_CFLAGS+=" -miphoneos-version-min=${SDK_MIN}"
175 EXTRA_LDFLAGS+=" -miphoneos-version-min=${SDK_MIN}"
176
177 info "LD FLAGS SELECTED = '${LDFLAGS}'"
178
179 spushd ${VLCROOT}/contrib
180
181 echo ${VLCROOT}
182 mkdir -p "${VLCROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
183 cd "${VLCROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
184
185 if [ "$PLATFORM" = "OS" ]; then
186       export AS="gas-preprocessor.pl ${CC}"
187       export ASCPP="gas-preprocessor.pl ${CC}"
188       export CCAS="gas-preprocessor.pl ${CC}"
189 else
190   export AS="xcrun as"
191   export ASCPP="xcrun as"
192 fi
193
194 ../bootstrap --host=${TARGET} --build="i686-apple-darwin10" --prefix=${VLCROOT}/contrib/${TARGET}-${ARCH} --disable-gpl \
195     --disable-disc --disable-sout \
196     --disable-sdl \
197     --disable-SDL_image \
198     --disable-iconv \
199     --enable-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-vncserver \
213     --disable-gnutls \
214     --disable-orc \
215     --disable-schroedinger \
216     --disable-libmpeg2 \
217     --disable-chromaprint \
218     --disable-mad \
219     --enable-fribidi \
220     --enable-libxml2 \
221     --enable-freetype2 \
222     --enable-ass \
223     --disable-fontconfig \
224     --disable-gpg-error \
225     --disable-gcrypt \
226     --disable-lua \
227     --disable-taglib > ${out}
228
229 echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
230 echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
231 make
232 spopd
233
234 info "Bootstraping vlc"
235 pwd
236 info "VLCROOT = ${VLCROOT}"
237 if ! [ -e ${VLCROOT}/configure ]; then
238     ${VLCROOT}/bootstrap  > ${out}
239 fi
240
241 info "Bootstraping vlc finished"
242
243 if [ ".$PLATFORM" != ".Simulator" ]; then
244     # FIXME - Do we still need this?
245     export AVCODEC_CFLAGS="-I${PREFIX}/include "
246     export AVCODEC_LIBS="-L${PREFIX}/lib -lavcodec -lavutil -lz"
247     export AVFORMAT_CFLAGS="-I${PREFIX}/include"
248     export AVFORMAT_LIBS="-L${PREFIX}/lib -lavcodec -lz -lavutil -lavformat"
249 fi
250
251 mkdir -p ${BUILDDIR}
252 spushd ${BUILDDIR}
253
254 info ">> --prefix=${PREFIX} --host=${TARGET}"
255
256 # Run configure only upon changes.
257 if [ "${VLCROOT}/configure" -nt config.log -o \
258      "${THIS_SCRIPT_PATH}" -nt config.log ]; then
259 ${VLCROOT}/configure \
260     --prefix="${PREFIX}" \
261     --host="${TARGET}" \
262     --with-contrib="${VLCROOT}/contrib/${TARGET}-${ARCH}" \
263     --disable-debug \
264     --enable-static \
265     --disable-macosx \
266     --disable-macosx-vout \
267     --disable-macosx-dialog-provider \
268     --disable-macosx-qtkit \
269     --disable-macosx-eyetv \
270     --disable-macosx-vlc-app \
271     --disable-macosx-avfoundation \
272     --enable-audioqueue \
273     --enable-ios-audio \
274     --enable-ios-vout \
275     --enable-ios-vout2 \
276     --disable-shared \
277     --enable-macosx-quartztext \
278     --enable-avcodec \
279     --enable-mkv \
280     --enable-opus \
281     --disable-sout \
282     --disable-faad \
283     --disable-lua \
284     --disable-a52 \
285     --enable-fribidi \
286     --disable-macosx-audio \
287     --disable-qt --disable-skins2 \
288     --disable-libgcrypt \
289     --disable-vcd \
290     --disable-vlc \
291     --disable-vlm \
292     --disable-httpd \
293     --disable-nls \
294     --disable-glx \
295     --disable-sse \
296     --enable-neon \
297     --disable-notify \
298     --enable-live555 \
299     --enable-realrtsp \
300     --enable-dvbpsi \
301     --enable-swscale \
302     --disable-projectm \
303     --enable-libass \
304     --enable-libxml2 \
305     --disable-goom \
306     --disable-dvdread \
307     --disable-dvdnav \
308     --disable-bluray \
309     --disable-linsys \
310     --disable-libva \
311     --disable-gme \
312     --disable-tremor \
313     --disable-vorbis \
314     --disable-fluidsynth \
315     --disable-jack \
316     --disable-pulse \
317     --disable-mtp \
318     --enable-ogg \
319     --enable-speex \
320     --enable-theora \
321     --enable-flac \
322     --disable-screen \
323     --enable-freetype \
324     --disable-taglib \
325     --disable-mmx \
326     --disable-mad > ${out} # MMX and SSE support requires llvm which is broken on Simulator
327 fi
328
329 CORE_COUNT=`sysctl -n machdep.cpu.core_count`
330 let MAKE_JOBS=$CORE_COUNT+1
331
332 info "Building libvlc"
333 make -j$MAKE_JOBS > ${out}
334
335 info "Installing libvlc"
336 make install > ${out}
337
338 find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
339 rm -rf "${PREFIX}/contribs"
340 cp -R "${VLCROOT}/contrib/${TARGET}-${ARCH}" "${PREFIX}/contribs"
341
342 info "Removing unneeded modules"
343 blacklist="
344 stats
345 access_bd
346 shm
347 access_imem
348 oldrc
349 real
350 hotkeys
351 gestures
352 sap
353 dynamicoverlay
354 rss
355 ball
356 marq
357 magnify
358 audiobargraph_
359 clone
360 mosaic
361 osdmenu
362 puzzle
363 mediadirs
364 t140
365 ripple
366 motion
367 sharpen
368 grain
369 posterize
370 mirror
371 wall
372 scene
373 blendbench
374 psychedelic
375 alphamask
376 netsync
377 audioscrobbler
378 motiondetect
379 motionblur
380 export
381 smf
382 podcast
383 bluescreen
384 erase
385 stream_filter_record
386 speex_resampler
387 remoteosd
388 magnify
389 gradient
390 tospdif
391 dtstofloat32
392 logger
393 visual
394 fb
395 aout_file
396 dummy
397 invert
398 sepia
399 wave
400 hqdn3d
401 headphone_channel_mixer
402 gaussianblur
403 gradfun
404 extract
405 colorthres
406 antiflicker
407 anaglyph
408 remap
409 "
410
411 for i in ${blacklist}
412 do
413     find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
414 done
415
416 popd