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