]> git.sesse.net Git - vlc/blob - extras/package/ios/build.sh
extra/../ios: disable chromaprint plugin
[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     --enable-audioqueue \
269     --enable-ios-audio \
270     --enable-ios-vout \
271     --enable-ios-vout2 \
272     --disable-shared \
273     --disable-macosx-quartztext \
274     --enable-avcodec \
275     --enable-mkv \
276     --enable-opus \
277     --disable-sout \
278     --disable-faad \
279     --disable-lua \
280     --disable-a52 \
281     --disable-fribidi \
282     --disable-macosx-audio \
283     --disable-qt --disable-skins2 \
284     --disable-libgcrypt \
285     --disable-vcd \
286     --disable-vlc \
287     --disable-vlm \
288     --disable-httpd \
289     --disable-nls \
290     --disable-glx \
291     --disable-sse \
292     --enable-neon \
293     --disable-notify \
294     --enable-live555 \
295     --enable-realrtsp \
296     --enable-dvbpsi \
297     --enable-swscale \
298     --disable-projectm \
299     --disable-libass \
300     --disable-libxml2 \
301     --disable-goom \
302     --disable-dvdread \
303     --disable-dvdnav \
304     --disable-bluray \
305     --disable-linsys \
306     --disable-libva \
307     --disable-gme \
308     --disable-tremor \
309     --disable-vorbis \
310     --disable-fluidsynth \
311     --disable-jack \
312     --disable-pulse \
313     --disable-mtp \
314     --enable-ogg \
315     --enable-speex \
316     --enable-theora \
317     --enable-flac \
318     --disable-screen \
319     --disable-freetype \
320     --disable-taglib \
321     --disable-mmx \
322     --disable-mad > ${out} # MMX and SSE support requires llvm which is broken on Simulator
323 fi
324
325 CORE_COUNT=`sysctl -n machdep.cpu.core_count`
326 let MAKE_JOBS=$CORE_COUNT+1
327
328 info "Building libvlc"
329 make -j$MAKE_JOBS > ${out}
330
331 info "Installing libvlc"
332 make install > ${out}
333
334 find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
335 cp -R "${VLCROOT}/contrib/${TARGET}" "${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 sap
348 dynamicoverlay
349 rss
350 ball
351 marq
352 magnify
353 audiobargraph_
354 clone
355 mosaic
356 osdmenu
357 puzzle
358 mediadirs
359 t140
360 ripple
361 motion
362 sharpen
363 grain
364 posterize
365 mirror
366 wall
367 scene
368 blendbench
369 psychedelic
370 alphamask
371 netsync
372 audioscrobbler
373 motiondetect
374 motionblur
375 export
376 smf
377 podcast
378 bluescreen
379 erase
380 stream_filter_record
381 speex_resampler
382 remoteosd
383 magnify
384 gradient
385 tospdif
386 dtstofloat32
387 logger
388 visual
389 fb
390 aout_file
391 dummy
392 invert
393 sepia
394 wave
395 hqdn3d
396 headphone_channel_mixer
397 gaussianblur
398 gradfun
399 extract
400 colorthres
401 antiflicker
402 anaglyph
403 remap
404 "
405
406 for i in ${blacklist}
407 do
408     find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
409 done
410
411 popd