]> git.sesse.net Git - vlc/blob - extras/package/ios/build.sh
package/ios: updated build script to match the Android port
[vlc] / extras / package / ios / build.sh
1 #!/bin/sh
2 set -e
3
4 PLATFORM=OS
5 VERBOSE=no
6 SDK_VERSION=5.1
7 SDK_MIN=5.0
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 the iOS"
73
74 if [ "$PLATFORM" = "Simulator" ]; then
75     TARGET="i686-apple-darwin11"
76     ARCH="i386"
77 else
78     TARGET="arm-apple-darwin11"
79     ARCH="armv7"
80     OPTIM="-mno-thumb"
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} "
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     if [ "$SDK_VERSION" = "6.0" ]; then
169       export AS="${IOS_GAS_PREPROCESSOR} clang"
170       export ASCPP="${IOS_GAS_PREPROCESSOR} clang"
171       export CCAS="${IOS_GAS_PREPROCESSOR} clang"
172     else
173       export AS="${IOS_GAS_PREPROCESSOR} xcrun clang"
174       export ASCPP="${IOS_GAS_PREPROCESSOR} xcrun clang"
175       export CCAS="${IOS_GAS_PREPROCESSOR} xcrun clang"
176     fi
177 else
178   export AS="xcrun as"
179   export ASCPP="xcrun as"
180 fi
181
182 ../bootstrap --host=${TARGET} --build="i686-apple-darwin10" --disable-disc --disable-sout \
183     --enable-small \
184     --disable-sdl \
185     --disable-SDL_image \
186     --disable-fontconfig \
187     --disable-ass \
188     --enable-freetype2 \
189     --enable-iconv \
190     --disable-fribidi \
191     --disable-zvbi \
192     --disable-kate \
193     --disable-caca \
194     --disable-gettext \
195     --disable-mpcdec \
196     --disable-upnp \
197     --disable-gme \
198     --disable-tremor \
199     --disable-vorbis \
200     --disable-sidplay2 \
201     --disable-samplerate \
202     --disable-goom \
203     --disable-gcrypt \
204     --disable-gnutls \
205     --disable-orc \
206     --disable-schroedinger \
207     --disable-libmpeg2 \
208     --disable-mad > ${out}
209 make
210 spopd
211
212 info "Bootstraping vlc"
213 pwd
214 info "VLCROOT = ${VLCROOT}"
215 if ! [ -e ${VLCROOT}/configure ]; then
216     ${VLCROOT}/bootstrap  > ${out}
217 fi
218
219 info "Bootstraping vlc finished"
220
221 if [ ".$PLATFORM" != ".Simulator" ]; then
222     # FIXME - Do we still need this?
223     export AVCODEC_CFLAGS="-I${PREFIX}/include "
224     export AVCODEC_LIBS="-L${PREFIX}/lib -lavcodec -lavutil -lz"
225     export AVFORMAT_CFLAGS="-I${PREFIX}/include"
226     export AVFORMAT_LIBS="-L${PREFIX}/lib -lavcodec -lz -lavutil -lavformat"
227 fi
228
229 export DVBPSI_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
230 export DVBPSI_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "
231
232 export SWSCALE_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
233 export SWSCALE_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "
234
235
236
237 mkdir -p ${BUILDDIR}
238 spushd ${BUILDDIR}
239
240 info ">> --prefix=${PREFIX} --host=${TARGET}"
241
242 # Run configure only upon changes.
243 if [ "${VLCROOT}/configure" -nt config.log -o \
244      "${THIS_SCRIPT_PATH}" -nt config.log ]; then
245 CONTRIB_DIR=${VLCROOT}/contrib-ios-${TARGET} \
246 ${VLCROOT}/configure \
247     --prefix="${PREFIX}" \
248     --host="${TARGET}" \
249     --enable-debug \
250     --enable-static \
251     --disable-macosx \
252     --disable-macosx-vout \
253     --disable-macosx-dialog-provider \
254     --disable-macosx-qtkit \
255     --disable-macosx-eyetv \
256     --disable-macosx-vlc-app \
257     --enable-audioqueue \
258     --enable-ios-vout \
259     --disable-shared \
260     --disable-macosx-quartztext \
261     --enable-avcodec \
262     --enable-mkv \
263     --enable-dvbpsi \
264     --enable-swscale \
265     --disable-projectm \
266     --disable-sout \
267     --disable-faad \
268     --disable-lua \
269     --disable-mad \
270     --disable-a52 \
271     --disable-fribidi \
272     --disable-macosx-audio \
273     --disable-qt --disable-skins2 \
274     --disable-libgcrypt \
275     --disable-vcd \
276     --disable-vlc \
277     --disable-vlm \
278     --disable-httpd \
279     --disable-nls \
280     --disable-glx \
281     --disable-visual \
282     --disable-lua \
283     --disable-sse \
284     --enable-neon \
285     --disable-notify \
286     --enable-live555 \
287     --enable-realrtsp \
288     --enable-dvbpsi \
289     --enable-swscale \
290     --disable-projectm \
291     --disable-libass \
292     --disable-sqlite \
293     --disable-libxml2 \
294     --disable-goom \
295     --disable-dvdread \
296     --disable-dvdnav \
297     --disable-bluray \
298     --disable-linsys \
299     --disable-libva \
300     --disable-gme \
301     --disable-tremor \
302     --disable-vorbis \
303     --disable-fluidsynth \
304     --disable-jack \
305     --disable-pulse \
306     --disable-sout \
307     --disable-faad \
308     --disable-lua \
309     --disable-mad \
310     --disable-mtp \
311     --disable-ogg \
312     --disable-speex \
313     --disable-theora \
314     --disable-flac \
315     --disable-mmx > ${out} # MMX and SSE support requires llvm which is broken on Simulator
316 fi
317
318 CORE_COUNT=`sysctl -n machdep.cpu.core_count`
319 let MAKE_JOBS=$CORE_COUNT+1
320
321 info "Building libvlc"
322 make -j$MAKE_JOBS > ${out}
323
324 info "Installing libvlc"
325 make install > ${out}
326 popd