]> git.sesse.net Git - vlc/blob - extras/package/ios/build.sh
iOS: more building fixes
[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" --prefix=${VLCROOT}/contrib/${TARGET}-${ARCH} --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 mkdir -p ${BUILDDIR}
243 spushd ${BUILDDIR}
244
245 info ">> --prefix=${PREFIX} --host=${TARGET}"
246
247 # Run configure only upon changes.
248 if [ "${VLCROOT}/configure" -nt config.log -o \
249      "${THIS_SCRIPT_PATH}" -nt config.log ]; then
250 ${VLCROOT}/configure \
251     --prefix="${PREFIX}" \
252     --host="${TARGET}" \
253     --with-contrib="${VLCROOT}/contrib/${TARGET}-${ARCH}" \
254     --disable-debug \
255     --enable-static \
256     --disable-macosx \
257     --disable-macosx-vout \
258     --disable-macosx-dialog-provider \
259     --disable-macosx-qtkit \
260     --disable-macosx-eyetv \
261     --disable-macosx-vlc-app \
262     --disable-macosx-avfoundation \
263     --enable-audioqueue \
264     --enable-ios-audio \
265     --enable-ios-vout \
266     --enable-ios-vout2 \
267     --disable-shared \
268     --disable-macosx-quartztext \
269     --enable-avcodec \
270     --enable-mkv \
271     --enable-opus \
272     --disable-sout \
273     --disable-faad \
274     --disable-lua \
275     --disable-a52 \
276     --disable-fribidi \
277     --disable-macosx-audio \
278     --disable-qt --disable-skins2 \
279     --disable-libgcrypt \
280     --disable-vcd \
281     --disable-vlc \
282     --disable-vlm \
283     --disable-httpd \
284     --disable-nls \
285     --disable-glx \
286     --disable-sse \
287     --enable-neon \
288     --disable-notify \
289     --enable-live555 \
290     --enable-realrtsp \
291     --enable-dvbpsi \
292     --enable-swscale \
293     --disable-projectm \
294     --disable-libass \
295     --disable-libxml2 \
296     --disable-goom \
297     --disable-dvdread \
298     --disable-dvdnav \
299     --disable-bluray \
300     --disable-linsys \
301     --disable-libva \
302     --disable-gme \
303     --disable-tremor \
304     --disable-vorbis \
305     --disable-fluidsynth \
306     --disable-jack \
307     --disable-pulse \
308     --disable-mtp \
309     --enable-ogg \
310     --enable-speex \
311     --enable-theora \
312     --enable-flac \
313     --disable-screen \
314     --disable-freetype \
315     --disable-taglib \
316     --disable-mmx \
317     --disable-mad > ${out} # MMX and SSE support requires llvm which is broken on Simulator
318 fi
319
320 CORE_COUNT=`sysctl -n machdep.cpu.core_count`
321 let MAKE_JOBS=$CORE_COUNT+1
322
323 info "Building libvlc"
324 make -j$MAKE_JOBS > ${out}
325
326 info "Installing libvlc"
327 make install > ${out}
328
329 find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
330 cp -R "${VLCROOT}/contrib/${TARGET}-${ARCH}" "${PREFIX}/contribs"
331
332 info "Removing unneeded modules"
333 blacklist="
334 stats
335 access_bd
336 shm
337 access_imem
338 oldrc
339 real
340 hotkeys
341 gestures
342 sap
343 dynamicoverlay
344 rss
345 ball
346 marq
347 magnify
348 audiobargraph_
349 clone
350 mosaic
351 osdmenu
352 puzzle
353 mediadirs
354 t140
355 ripple
356 motion
357 sharpen
358 grain
359 posterize
360 mirror
361 wall
362 scene
363 blendbench
364 psychedelic
365 alphamask
366 netsync
367 audioscrobbler
368 motiondetect
369 motionblur
370 export
371 smf
372 podcast
373 bluescreen
374 erase
375 stream_filter_record
376 speex_resampler
377 remoteosd
378 magnify
379 gradient
380 tospdif
381 dtstofloat32
382 logger
383 visual
384 fb
385 aout_file
386 dummy
387 invert
388 sepia
389 wave
390 hqdn3d
391 headphone_channel_mixer
392 gaussianblur
393 gradfun
394 extract
395 colorthres
396 antiflicker
397 anaglyph
398 remap
399 "
400
401 for i in ${blacklist}
402 do
403     find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
404 done
405
406 popd