]> git.sesse.net Git - vlc/blob - extras/package/ios/build.sh
ios build script: compilation fix
[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 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 version>      Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK_VERSION})
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              ;;
52          k)
53              SDK_VERSION=$OPTARG
54              ;;
55          a)
56              ARCH=$OPTARG
57              ;;
58          ?)
59              usage
60              exit 1
61              ;;
62      esac
63 done
64 shift $(($OPTIND - 1))
65
66 if [ "x$1" != "x" ]; then
67     usage
68     exit 1
69 fi
70
71 out="/dev/null"
72 if [ "$VERBOSE" = "yes" ]; then
73    out="/dev/stdout"
74 fi
75
76 info "Building libvlc for iOS"
77
78 if [ "$PLATFORM" = "Simulator" ]; then
79     TARGET="${ARCH}-apple-darwin11"
80     OPTIM="-O3 -g"
81 else
82     TARGET="arm-apple-darwin11"
83     OPTIM="-O3 -g"
84 fi
85
86 info "Using ${ARCH} with SDK version ${SDK_VERSION}"
87
88 THIS_SCRIPT_PATH=`pwd`/$0
89
90 spushd `dirname ${THIS_SCRIPT_PATH}`/../../..
91 VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
92 spopd
93
94 if test -z "$SDKROOT"
95 then
96     SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
97     echo "SDKROOT not specified, assuming $SDKROOT"
98 fi
99
100 if [ ! -d "${SDKROOT}" ]
101 then
102     echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
103     exit 1
104 fi
105
106 BUILDDIR="${VLCROOT}/build-ios-${PLATFORM}/${ARCH}"
107
108 PREFIX="${VLCROOT}/install-ios-${PLATFORM}/${ARCH}"
109
110 export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
111
112 info "Building tools"
113 spushd "${VLCROOT}/extras/tools"
114 ./bootstrap
115 make && make .gas
116 spopd
117
118 info "Building contrib for iOS in '${VLCROOT}/contrib/iPhone${PLATFORM}-${ARCH}'"
119
120 # The contrib will read the following
121 export AR="xcrun ar"
122
123 export RANLIB="xcrun ranlib"
124 export CC="xcrun clang"
125 export OBJC="xcrun clang"
126 export CXX="xcrun clang++"
127 export LD="xcrun ld"
128 export STRIP="xcrun strip"
129
130 export PLATFORM=$PLATFORM
131 export SDK_VERSION=$SDK_VERSION
132
133 if [ "$PLATFORM" = "OS" ]; then
134 export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -miphoneos-version-min=${SDK_MIN} ${OPTIM}"
135 if [ "$ARCH" != "arm64" ]; then
136 export CFLAGS="${CFLAGS} -mcpu=cortex-a8"
137 fi
138 else
139 export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -miphoneos-version-min=${SDK_MIN} ${OPTIM}"
140 fi
141
142 export CPPFLAGS="${CFLAGS}"
143
144 export CPP="xcrun cc -E"
145 export CXXCPP="xcrun c++ -E"
146
147 export BUILDFORIOS="yes"
148
149 if [ "$PLATFORM" = "Simulator" ]; then
150     # Use the new ABI on simulator, else we can't build
151     export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
152 fi
153
154 export LDFLAGS="-L${SDKROOT}/usr/lib -arch ${ARCH} -isysroot ${SDKROOT} -miphoneos-version-min=${SDK_MIN}"
155
156 if [ "$PLATFORM" = "OS" ]; then
157     EXTRA_CFLAGS="-arch ${ARCH}"
158 if [ "$ARCH" != "arm64" ]; then
159     EXTRA_CFLAGS+=" -mcpu=cortex-a8"
160 fi
161     EXTRA_LDFLAGS="-arch ${ARCH}"
162 else
163     EXTRA_CFLAGS="-arch ${ARCH}"
164     EXTRA_LDFLAGS="-arch ${ARCH}"
165 fi
166
167 EXTRA_CFLAGS+=" -miphoneos-version-min=${SDK_MIN}"
168 EXTRA_LDFLAGS+=" -miphoneos-version-min=${SDK_MIN}"
169
170 info "LD FLAGS SELECTED = '${LDFLAGS}'"
171
172 spushd ${VLCROOT}/contrib
173
174 echo ${VLCROOT}
175 mkdir -p "${VLCROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
176 cd "${VLCROOT}/contrib/iPhone${PLATFORM}-${ARCH}"
177
178 if [ "$PLATFORM" = "OS" ]; then
179     export AS="gas-preprocessor.pl ${CC}"
180     export ASCPP="gas-preprocessor.pl ${CC}"
181     export CCAS="gas-preprocessor.pl ${CC}"
182     if [ "$ARCH" = "arm64" ]; then
183         export GASPP_FIX_XCODE5=1
184     fi
185 else
186     export ASCPP="xcrun as"
187 fi
188
189 ../bootstrap --build=x86_64-apple-darwin11 --host=${TARGET} --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     --enable-vorbis \
203     --disable-sidplay2 \
204     --disable-samplerate \
205     --disable-goom \
206     --disable-vncserver \
207     --disable-orc \
208     --disable-schroedinger \
209     --disable-libmpeg2 \
210     --disable-chromaprint \
211     --disable-mad \
212     --enable-fribidi \
213     --enable-libxml2 \
214     --enable-freetype2 \
215     --enable-ass \
216     --disable-fontconfig \
217     --disable-gpg-error \
218     --disable-lua \
219     --enable-taglib > ${out}
220
221 echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
222 echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
223 make fetch
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-dialog-provider \
260     --disable-macosx-qtkit \
261     --disable-macosx-eyetv \
262     --disable-macosx-vlc-app \
263     --disable-macosx-avfoundation \
264     --disable-audioqueue \
265     --disable-shared \
266     --enable-macosx-quartztext \
267     --enable-avcodec \
268     --enable-mkv \
269     --enable-opus \
270     --disable-sout \
271     --disable-faad \
272     --disable-lua \
273     --disable-a52 \
274     --enable-fribidi \
275     --disable-qt --disable-skins2 \
276     --disable-vcd \
277     --disable-vlc \
278     --disable-vlm \
279     --disable-httpd \
280     --disable-nls \
281     --disable-glx \
282     --disable-sse \
283     --enable-neon \
284     --disable-notify \
285     --enable-live555 \
286     --enable-realrtsp \
287     --enable-dvbpsi \
288     --enable-swscale \
289     --disable-projectm \
290     --enable-libass \
291     --enable-libxml2 \
292     --disable-goom \
293     --disable-dvdread \
294     --disable-dvdnav \
295     --disable-bluray \
296     --disable-linsys \
297     --disable-libva \
298     --disable-gme \
299     --disable-tremor \
300     --enable-vorbis \
301     --disable-fluidsynth \
302     --disable-jack \
303     --disable-pulse \
304     --disable-mtp \
305     --enable-ogg \
306     --enable-speex \
307     --enable-theora \
308     --enable-flac \
309     --disable-screen \
310     --enable-freetype \
311     --enable-taglib \
312     --disable-mmx \
313     --disable-addonmanagermodules \
314     --disable-mad > ${out} # MMX and SSE support requires llvm which is broken on Simulator
315 fi
316
317 CORE_COUNT=`sysctl -n machdep.cpu.core_count`
318 let MAKE_JOBS=$CORE_COUNT+1
319
320 info "Building libvlc"
321 make -j$MAKE_JOBS > ${out}
322
323 info "Installing libvlc"
324 make install > ${out}
325
326 find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
327 rm -rf "${PREFIX}/contribs"
328 cp -R "${VLCROOT}/contrib/${TARGET}-${ARCH}" "${PREFIX}/contribs"
329
330 info "Removing unneeded modules"
331 blacklist="
332 stats
333 access_bd
334 shm
335 access_imem
336 oldrc
337 real
338 hotkeys
339 gestures
340 dynamicoverlay
341 rss
342 ball
343 marq
344 magnify
345 audiobargraph_
346 clone
347 mosaic
348 osdmenu
349 puzzle
350 mediadirs
351 t140
352 ripple
353 motion
354 sharpen
355 grain
356 posterize
357 mirror
358 wall
359 scene
360 blendbench
361 psychedelic
362 alphamask
363 netsync
364 audioscrobbler
365 motiondetect
366 motionblur
367 export
368 smf
369 podcast
370 bluescreen
371 erase
372 stream_filter_record
373 speex_resampler
374 remoteosd
375 magnify
376 gradient
377 tospdif
378 dtstofloat32
379 logger
380 visual
381 fb
382 aout_file
383 dummy
384 invert
385 sepia
386 wave
387 hqdn3d
388 headphone_channel_mixer
389 gaussianblur
390 gradfun
391 extract
392 colorthres
393 antiflicker
394 anaglyph
395 remap
396 "
397
398 for i in ${blacklist}
399 do
400     find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
401 done
402
403 popd