]> git.sesse.net Git - vlc/blob - extras/package/ios/build.sh
ios: don't compile with --enable-debug with -g only by default
[vlc] / extras / package / ios / build.sh
1 #!/bin/sh
2 set -e
3
4 PLATFORM=OS
5 VERBOSE=no
6 SDK_VERSION=6.0
7 SDK_MIN=5.1
8
9 usage()
10 {
11 cat << EOF
12 usage: $0 [-s] [-k sdk]
13
14 OPTIONS
15    -k       Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK})
16    -s       Build for simulator
17 EOF
18 }
19
20 spushd()
21 {
22     pushd "$1" 2>&1> /dev/null
23 }
24
25 spopd()
26 {
27     popd 2>&1> /dev/null
28 }
29
30 info()
31 {
32     local blue="\033[1;34m"
33     local normal="\033[0m"
34     echo "[${blue}info${normal}] $1"
35 }
36
37 while getopts "hvsk:" OPTION
38 do
39      case $OPTION in
40          h)
41              usage
42              exit 1
43              ;;
44          v)
45              VERBOSE=yes
46              ;;
47          s)
48              PLATFORM=Simulator
49              SDK=${SDK_MIN}
50              ;;
51          k)
52              SDK=$OPTARG
53              ;;
54          ?)
55              usage
56              exit 1
57              ;;
58      esac
59 done
60 shift $(($OPTIND - 1))
61
62 if [ "x$1" != "x" ]; then
63     usage
64     exit 1
65 fi
66
67 out="/dev/null"
68 if [ "$VERBOSE" = "yes" ]; then
69    out="/dev/stdout"
70 fi
71
72 info "Building libvlc for iOS"
73
74 if [ "$PLATFORM" = "Simulator" ]; then
75     TARGET="i686-apple-darwin11"
76     ARCH="i386"
77     OPTIM="-O3 -g"
78 else
79     TARGET="arm-apple-darwin11"
80     ARCH="armv7 -g"
81 fi
82
83 info "Using ${ARCH} with SDK version ${SDK_VERSION}"
84
85 THIS_SCRIPT_PATH=`pwd`/$0
86
87 spushd `dirname ${THIS_SCRIPT_PATH}`/../../..
88 VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
89 spopd
90
91 if test -z "$SDKROOT"
92 then
93     SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
94     echo "SDKROOT not specified, assuming $SDKROOT"
95 fi
96
97 if [ ! -d "${SDKROOT}" ]
98 then
99     echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
100     exit 1
101 fi
102
103 BUILDDIR="${VLCROOT}/build-ios-${PLATFORM}"
104
105 PREFIX="${VLCROOT}/install-ios-${PLATFORM}"
106
107 IOS_GAS_PREPROCESSOR="${VLCROOT}/extras/tools/gas/gas-preprocessor.pl"
108
109 export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
110
111 # contains gas-processor.pl
112 export PATH=$PATH:${VLCROOT}/extras/package/ios/resources
113
114 info "Building tools"
115 spushd "${VLCROOT}/extras/tools"
116 ./bootstrap
117 make && make .gas
118 spopd
119
120 info "Building contrib for iOS in '${VLCROOT}/contrib/iPhone${PLATFORM}'"
121
122 # The contrib will read the following
123 export AR="xcrun ar"
124
125 export RANLIB="xcrun ranlib"
126 export CC="xcrun clang"
127 export OBJC="xcrun clang"
128 export CXX="xcrun clang++"
129 export LD="xcrun ld"
130 export STRIP="xcrun strip"
131
132
133 export SDKROOT
134 if [ "$PLATFORM" = "OS" ]; then
135 export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -mcpu=cortex-a8 -miphoneos-version-min=${SDK_MIN} ${OPTIM}"
136 else
137 export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -miphoneos-version-min=${SDK_MIN} ${OPTIM}"
138 fi
139 export CPPFLAGS="${CFLAGS}"
140 export CXXFLAGS="${CFLAGS}"
141 export OBJCFLAGS="${CFLAGS}"
142
143 export CPP="xcrun cc -E"
144 export CXXCPP="xcrun c++ -E"
145
146 export BUILDFORIOS="yes"
147
148 if [ "$PLATFORM" = "Simulator" ]; then
149     # Use the new ABI on simulator, else we can't build
150     export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
151 fi
152
153 if [ "$PLATFORM" = "OS" ]; then
154   export LDFLAGS="-L${SDKROOT}/usr/lib -arch ${ARCH} -isysroot ${SDKROOT} -miphoneos-version-min=${SDK_MIN}"
155 else
156   export LDFLAGS="-syslibroot=${SDKROOT}/ -arch ${ARCH} -miphoneos-version-min=${SDK_MIN}"
157 fi
158
159 info "LD FLAGS SELECTED = '${LDFLAGS}'"
160
161 spushd ${VLCROOT}/contrib
162
163 echo ${VLCROOT}
164 mkdir -p "${VLCROOT}/contrib/iPhone${PLATFORM}"
165 cd "${VLCROOT}/contrib/iPhone${PLATFORM}"
166
167 if [ "$PLATFORM" = "OS" ]; then
168       export AS="${IOS_GAS_PREPROCESSOR} ${CC}"
169       export ASCPP="${IOS_GAS_PREPROCESSOR} ${CC}"
170       export CCAS="${IOS_GAS_PREPROCESSOR} ${CC}"
171 else
172   export AS="xcrun as"
173   export ASCPP="xcrun as"
174 fi
175
176 ../bootstrap --host=${TARGET} --build="i686-apple-darwin10" --disable-disc --disable-sout \
177     --enable-small \
178     --disable-sdl \
179     --disable-SDL_image \
180     --disable-fontconfig \
181     --disable-ass \
182     --disable-freetype2 \
183     --disable-iconv \
184     --disable-fribidi \
185     --disable-zvbi \
186     --disable-kate \
187     --disable-caca \
188     --disable-gettext \
189     --disable-mpcdec \
190     --disable-upnp \
191     --disable-gme \
192     --disable-tremor \
193     --disable-vorbis \
194     --disable-sidplay2 \
195     --disable-samplerate \
196     --disable-goom \
197     --disable-gcrypt \
198     --disable-gnutls \
199     --disable-orc \
200     --disable-schroedinger \
201     --disable-libmpeg2 \
202     --enable-mad > ${out}
203 make
204 spopd
205
206 info "Bootstraping vlc"
207 pwd
208 info "VLCROOT = ${VLCROOT}"
209 if ! [ -e ${VLCROOT}/configure ]; then
210     ${VLCROOT}/bootstrap  > ${out}
211 fi
212
213 info "Bootstraping vlc finished"
214
215 if [ ".$PLATFORM" != ".Simulator" ]; then
216     # FIXME - Do we still need this?
217     export AVCODEC_CFLAGS="-I${PREFIX}/include "
218     export AVCODEC_LIBS="-L${PREFIX}/lib -lavcodec -lavutil -lz"
219     export AVFORMAT_CFLAGS="-I${PREFIX}/include"
220     export AVFORMAT_LIBS="-L${PREFIX}/lib -lavcodec -lz -lavutil -lavformat"
221 fi
222
223 export DVBPSI_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
224 export DVBPSI_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "
225
226 export SWSCALE_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
227 export SWSCALE_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "
228
229 mkdir -p ${BUILDDIR}
230 spushd ${BUILDDIR}
231
232 info ">> --prefix=${PREFIX} --host=${TARGET}"
233
234 # Run configure only upon changes.
235 if [ "${VLCROOT}/configure" -nt config.log -o \
236      "${THIS_SCRIPT_PATH}" -nt config.log ]; then
237 CONTRIB_DIR=${VLCROOT}/contrib-ios-${TARGET} \
238 ${VLCROOT}/configure \
239     --prefix="${PREFIX}" \
240     --host="${TARGET}" \
241     --disable-debug \
242     --enable-static \
243     --disable-macosx \
244     --disable-macosx-vout \
245     --disable-macosx-dialog-provider \
246     --disable-macosx-qtkit \
247     --disable-macosx-eyetv \
248     --disable-macosx-vlc-app \
249     --enable-audioqueue \
250     --enable-ios-vout \
251     --disable-shared \
252     --disable-macosx-quartztext \
253     --enable-avcodec \
254     --enable-mkv \
255     --enable-opus \
256     --enable-dvbpsi \
257     --enable-swscale \
258     --disable-projectm \
259     --disable-sout \
260     --disable-faad \
261     --disable-lua \
262     --enable-mad \
263     --disable-a52 \
264     --disable-fribidi \
265     --disable-macosx-audio \
266     --disable-qt --disable-skins2 \
267     --disable-libgcrypt \
268     --disable-vcd \
269     --disable-vlc \
270     --disable-vlm \
271     --disable-httpd \
272     --disable-nls \
273     --disable-glx \
274     --disable-lua \
275     --disable-sse \
276     --enable-neon \
277     --disable-notify \
278     --enable-live555 \
279     --enable-realrtsp \
280     --enable-dvbpsi \
281     --enable-swscale \
282     --disable-projectm \
283     --disable-libass \
284     --disable-sqlite \
285     --disable-libxml2 \
286     --disable-goom \
287     --disable-dvdread \
288     --disable-dvdnav \
289     --disable-bluray \
290     --disable-linsys \
291     --disable-libva \
292     --disable-gme \
293     --disable-tremor \
294     --disable-vorbis \
295     --disable-fluidsynth \
296     --disable-jack \
297     --disable-pulse \
298     --disable-sout \
299     --disable-faad \
300     --disable-lua \
301     --disable-mtp \
302     --enable-ogg \
303     --enable-speex \
304     --enable-theora \
305     --enable-flac \
306     --disable-freetype \
307     --disable-taglib \
308     --disable-mmx > ${out} # MMX and SSE support requires llvm which is broken on Simulator
309 fi
310
311 CORE_COUNT=`sysctl -n machdep.cpu.core_count`
312 let MAKE_JOBS=$CORE_COUNT+1
313
314 info "Building libvlc"
315 make -j$MAKE_JOBS > ${out}
316
317 info "Installing libvlc"
318 make install > ${out}
319 find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
320
321 info "Removing unneeded modules"
322 blacklist="
323 stats
324 access_bd
325 shm
326 access_imem
327 oldrc
328 real
329 hotkeys
330 gestures
331 sap
332 dynamicoverlay
333 rss
334 ball
335 marq
336 magnify
337 audiobargraph_
338 clone
339 mosaic
340 osdmenu
341 puzzle
342 mediadirs
343 t140
344 ripple
345 motion
346 sharpen
347 grain
348 posterize
349 mirror
350 wall
351 scene
352 blendbench
353 psychedelic
354 alphamask
355 netsync
356 audioscrobbler
357 motiondetect
358 motionblur
359 export
360 smf
361 podcast
362 bluescreen
363 erase
364 stream_filter_record
365 speex_resampler
366 remoteosd
367 magnify
368 gradient
369 tospdif
370 dtstofloat32
371 logger
372 visual
373 fb
374 aout_file
375 yuv
376 dummy
377 invert
378 sepia
379 wave
380 hqdn3d
381 headphone_channel_mixer
382 gaussianblur
383 gradfun
384 extract
385 colorthres
386 antiflicker
387 anaglyph
388 adjust
389 remap
390 "
391
392 for i in ${blacklist}
393 do
394     find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
395 done
396
397 popd