]> git.sesse.net Git - vlc/blob - extras/package/ios/build.sh
ios/build.sh: disable goom
[vlc] / extras / package / ios / build.sh
1 #!/bin/sh
2 set -e
3
4 PLATFORM=OS
5 VERBOSE=no
6 SDK_VERSION=5.0
7
8 usage()
9 {
10 cat << EOF
11 usage: $0 [-s] [-k sdk]
12
13 OPTIONS
14    -k       Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK})
15    -s       Build for simulator
16 EOF
17 }
18
19 spushd()
20 {
21     pushd "$1" 2>&1> /dev/null
22 }
23
24 spopd()
25 {
26     popd 2>&1> /dev/null
27 }
28
29 info()
30 {
31     local blue="\033[1;34m"
32     local normal="\033[0m"
33     echo "[${blue}info${normal}] $1"
34 }
35
36 while getopts "hvsk:" OPTION
37 do
38      case $OPTION in
39          h)
40              usage
41              exit 1
42              ;;
43          v)
44              VERBOSE=yes
45              ;;
46          s)
47              PLATFORM=Simulator
48              SDK=5.0
49              ;;
50          k)
51              SDK=$OPTARG
52              ;;
53          ?)
54              usage
55              exit 1
56              ;;
57      esac
58 done
59 shift $(($OPTIND - 1))
60
61 if [ "x$1" != "x" ]; then
62     usage
63     exit 1
64 fi
65
66 out="/dev/null"
67 if [ "$VERBOSE" = "yes" ]; then
68    out="/dev/stdout"
69 fi
70
71 info "Building libvlc for the iOS"
72
73 if [ "$PLATFORM" = "Simulator" ]; then
74     TARGET="i686-apple-darwin10"
75     ARCH="i386"
76 else
77     TARGET="arm-apple-darwin11"
78     ARCH="armv7"
79     OPTIM="-mno-thumb"
80 fi
81
82 info "Using ${ARCH} with SDK version ${SDK_VERSION}"
83
84 THIS_SCRIPT_PATH=`pwd`/$0
85
86 spushd `dirname ${THIS_SCRIPT_PATH}`/../../..
87 VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
88 spopd
89
90 if test -z "$SDKROOT"
91 then
92     SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
93     echo "SDKROOT not specified, assuming $SDKROOT"
94 fi
95
96 if [ ! -d "${SDKROOT}" ]
97 then
98     echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
99     exit 1
100 fi
101
102 BUILDDIR="${VLCROOT}/build-ios-${PLATFORM}"
103
104 PREFIX="${VLCROOT}/install-ios-${PLATFORM}"
105
106 IOS_GAS_PREPROCESSOR="${VLCROOT}/extras/tools/gas/gas-preprocessor.pl"
107
108 export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
109
110 # contains gas-processor.pl
111 export PATH=$PATH:${VLCROOT}/extras/package/ios/resources
112
113 info "Building tools"
114 spushd "${VLCROOT}/extras/tools"
115 ./bootstrap
116 make && make .gas
117 spopd
118
119 info "Building contrib for iOS in '${VLCROOT}/contrib/iPhone${PLATFORM}'"
120
121 # The contrib will read the following
122 export AR="xcrun ar"
123
124 export RANLIB="xcrun ranlib"
125 export CC="xcrun clang"
126 export OBJC="xcrun clang"
127 export CXX="xcrun clang++"
128 export LD="xcrun ld"
129 export STRIP="xcrun strip"
130
131
132 export SDKROOT
133 export CPPFLAGS="${CFLAGS}"
134 export CXXFLAGS="${CFLAGS}"
135 export CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} -miphoneos-version-min=5.0 ${OPTIM}"
136 export OBJCFLAGS="${CFLAGS}"
137
138 export CPP="xcrun cc -E"
139 export CXXCPP="xcrun c++ -E"
140
141 if [ "$PLATFORM" = "Simulator" ]; then
142     # Use the new ABI on simulator, else we can't build
143     export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
144 fi
145
146 if [ "$PLATFORM" = "OS" ]; then
147   export LDFLAGS="-L${SDKROOT}/usr/lib -arch ${ARCH}  -isysroot ${SDKROOT}  -miphoneos-version-min=5.0 "
148 else
149   export LDFLAGS="-syslibroot=${SDKROOT}/ -arch ${ARCH} "
150 fi
151
152 info "LD FLAGS SELECTED = '${LDFLAGS}'"
153
154 spushd ${VLCROOT}/contrib
155
156 echo ${VLCROOT}
157 mkdir -p "${VLCROOT}/contrib/iPhone${PLATFORM}"
158 cd "${VLCROOT}/contrib/iPhone${PLATFORM}"
159
160 if [ "$PLATFORM" = "OS" ]; then
161   export AS="${IOS_GAS_PREPROCESSOR} ${CC}"
162   export ASCPP="${IOS_GAS_PREPROCESSOR} ${CC}"
163 else
164   export AS="xcrun as"
165   export ASCPP="xcrun as"
166 fi
167
168 ../bootstrap --host=${TARGET} --build="i686-apple-darwin10" --disable-disc --disable-sout \
169     --enable-small \
170     --disable-sdl \
171     --disable-SDL_image \
172     --disable-fontconfig \
173     --disable-ass \
174     --disable-freetype2 \
175     --disable-fribidi \
176     --disable-zvbi \
177     --disable-kate \
178     --disable-caca \
179     --disable-gettext \
180     --disable-mpcdec \
181     --disable-upnp \
182     --disable-gme \
183     --disable-tremor \
184     --disable-vorbis \
185     --disable-sidplay2 \
186     --disable-samplerate \
187     --disable-goom > ${out}
188 make
189 spopd
190
191
192 if [ "$PLATFORM" = "OS" ]; then
193   export AS="${IOS_GAS_PREPROCESSOR} ${CC}"
194   export ASCPP="${IOS_GAS_PREPROCESSOR} ${CC}"
195 else
196   export AS="xcrun as"
197   export ASCPP="xcrun as"
198 fi
199
200
201 info "Bootstraping vlc"
202 pwd
203 info "VLCROOT = ${VLCROOT}"
204 if ! [ -e ${VLCROOT}/configure ]; then
205     ${VLCROOT}/bootstrap  > ${out}
206 fi
207
208 info "Bootstraping vlc finished"
209
210 if [ ".$PLATFORM" != ".Simulator" ]; then
211     # FIXME - Do we still need this?
212     export AVCODEC_CFLAGS="-I${PREFIX}/include "
213     export AVCODEC_LIBS="-L${PREFIX}/lib -lavcodec -lavutil -lz"
214     export AVFORMAT_CFLAGS="-I${PREFIX}/include"
215     export AVFORMAT_LIBS="-L${PREFIX}/lib -lavcodec -lz -lavutil -lavformat"
216 fi
217
218 export DVBPSI_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
219 export DVBPSI_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "
220
221 export SWSCALE_CFLAGS="-I${VLCROOT}/contrib-ios-${TARGET}/include "
222 export SWSCALE_LIBS="-L${VLCROOT}/contrib-ios-${TARGET}/lib "
223
224
225
226 mkdir -p ${BUILDDIR}
227 spushd ${BUILDDIR}
228
229 info ">> --prefix=${PREFIX} --host=${TARGET}"
230
231 # Run configure only upon changes.
232 if [ "${VLCROOT}/configure" -nt config.log -o \
233      "${THIS_SCRIPT_PATH}" -nt config.log ]; then
234 CONTRIB_DIR=${VLCROOT}/contrib-ios-${TARGET} \
235 ${VLCROOT}/configure \
236     --prefix="${PREFIX}" \
237     --host="${TARGET}" \
238     --enable-debug \
239     --enable-static \
240     --disable-macosx \
241     --disable-macosx-vout \
242     --disable-macosx-dialog-provider \
243     --disable-macosx-qtkit \
244     --disable-macosx-eyetv \
245     --disable-macosx-vlc-app \
246     --with-macosx-sdk=${SDKROOT} \
247     --enable-audioqueue \
248     --enable-ios-vout \
249     --disable-shared \
250     --disable-macosx-quartztext \
251     --enable-avcodec \
252     --disable-mkv \
253     --enable-dvbpsi \
254     --enable-swscale \
255     --disable-projectm \
256     --disable-sout \
257     --disable-faad \
258     --disable-lua \
259     --disable-mad \
260     --disable-a52 \
261     --disable-fribidi \
262     --disable-macosx-audio \
263     --disable-qt4 --disable-skins2 \
264     --disable-libgcrypt \
265     --disable-vcd \
266     --disable-postproc \
267     --disable-vlc \
268     --disable-vlm \
269     --disable-httpd \
270     --disable-nls \
271     --disable-glx \
272     --enable-visual \
273     --disable-lua \
274     --disable-sse \
275     --disable-neon \
276     --disable-notify \
277     --disable-mmx > ${out} # MMX and SSE support requires llvm which is broken on Simulator
278 fi
279
280 CORE_COUNT=`sysctl -n machdep.cpu.core_count`
281 let MAKE_JOBS=$CORE_COUNT+1
282
283 info "Building libvlc"
284 make -j$MAKE_JOBS > ${out}
285
286 info "Installing libvlc"
287 make install > ${out}
288 popd