]> git.sesse.net Git - vlc/blob - extras/package/ios/build.sh
contribs: don't build avconv binary
[vlc] / extras / package / ios / build.sh
1 #!/bin/sh
2 set -e
3
4 PLATFORM=OS
5 SDK=iphoneos3.2
6 VERBOSE=no
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=iphonesimulator3.2
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-darwin10"
78     ARCH="armv7"
79     OPTIM="-mno-thumb"
80 fi
81
82 # Test if SDK exists
83 xcodebuild -find gcc -sdk ${SDK} > ${out}
84
85 SDK_VERSION=`echo ${SDK} | sed -e 's/iphoneos//' -e 's/iphonesimulator//'`
86
87 info "Using ${ARCH} with SDK version ${SDK_VERSION}"
88
89 THIS_SCRIPT_PATH=`pwd`/$0
90
91 spushd `dirname ${THIS_SCRIPT_PATH}`/../../..
92 VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
93 spopd
94
95 DEVROOT="/Developer/Platforms/iPhone${PLATFORM}.platform/Developer"
96 IOS_SDK_ROOT="${DEVROOT}/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk"
97
98 BUILDDIR="${VLCROOT}/build-ios-${PLATFORM}"
99
100 PREFIX="${VLCROOT}/install-ios-${PLATFORM}"
101
102 IOS_GAS_PREPROCESSOR="${VLCROOT}/extras/package/ios/resources/gas-preprocessor.pl"
103
104 export AR="${DEVROOT}/usr/bin/ar"
105 export RANLIB="${DEVROOT}/usr/bin/ranlib"
106 export CFLAGS="-isysroot ${IOS_SDK_ROOT} -arch ${ARCH} -miphoneos-version-min=3.2 ${OPTIM}"
107 export OBJCFLAGS="${CFLAGS}"
108 if [ "$PLATFORM" = "Simulator" ]; then
109     # Use the new ABI on simulator, else we can't build
110     export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
111 fi
112 export CPPFLAGS="${CFLAGS}"
113 export CXXFLAGS="${CFLAGS}"
114 export CPP="${DEVROOT}/usr/bin/cpp-4.2"
115 export CXXCPP="${DEVROOT}/usr/bin/cpp-4.2"
116
117 export CC="${DEVROOT}/usr/bin/gcc-4.2"
118 export OBJC="${DEVROOT}/usr/bin/gcc-4.2"
119 export CXX="${DEVROOT}/usr/bin/g++-4.2"
120 export LD="${DEVROOT}/usr/bin/ld"
121 export STRIP="${DEVROOT}/usr/bin/strip"
122
123 if [ "$PLATFORM" = "OS" ]; then
124   export LDFLAGS="-L${IOS_SDK_ROOT}/usr/lib -arch ${ARCH}"
125 else
126   export LDFLAGS="-syslibroot=${IOS_SDK_ROOT}/ -arch ${ARCH}"
127 fi
128
129 export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:${VLCROOT}/extras/contrib/build/bin:${VLCROOT}/extras/package/ios/resources"
130
131 spushd ${VLCROOT}/extras/contrib
132
133 # contains gas-processor.pl
134 export PATH=$PATH:${VLCROOT}/extras/package/ios/resources
135
136 # The contrib will read the following
137 export IOS_SDK_ROOT
138
139 info "Building contrib for iOS in '${VLCROOT}/contrib-builddir-ios-${TARGET}'"
140
141 ./bootstrap -t ${TARGET} -d ios \
142    -b "${VLCROOT}/contrib-builddir-ios-${TARGET}" \
143    -i "${VLCROOT}/contrib-ios-${TARGET}" > ${out}
144 spushd "${VLCROOT}/contrib-builddir-ios-${TARGET}"
145 make src > ${out}
146 spopd
147
148 info "Building contrib for current host"
149 ./bootstrap > ${out}
150 make > ${out}
151
152 spopd
153
154 if [ "$PLATFORM" = "OS" ]; then
155   export AS="${IOS_GAS_PREPROCESSOR} ${CC}"
156   export ASCPP="${IOS_GAS_PREPROCESSOR} ${CC}"
157 else
158   export AS="${DEVROOT}/usr/bin/as"
159   export ASCPP="${DEVROOT}/usr/bin/as"
160 fi
161
162
163 info "Bootstraping vlc"
164
165 if ! [ -e ${VLCROOT}/configure ]; then
166     ${VLCROOT}/bootstrap > ${out}
167 fi
168
169 if [ ".$PLATFORM" != ".Simulator" ]; then
170     # FIXME - Do we still need this?
171     export AVCODEC_CFLAGS="-I${PREFIX}/include"
172     export AVCODEC_LIBS="-L${PREFIX}/lib -lavcodec -lavutil -lz"
173     export AVFORMAT_CFLAGS="-I${PREFIX}/include"
174     export AVFORMAT_LIBS="-L${PREFIX}/lib -lavcodec -lz -lavutil -lavformat"
175 fi
176
177 mkdir -p ${BUILDDIR}
178 spushd ${BUILDDIR}
179
180 # Run configure only upon changes.
181 if [ "${VLCROOT}/configure" -nt config.log -o \
182      "${THIS_SCRIPT_PATH}" -nt config.log ]; then
183 CONTRIB_DIR=${VLCROOT}/contrib-ios-${TARGET} \
184 ${VLCROOT}/configure \
185     --prefix="${PREFIX}" \
186     --host="${TARGET}" \
187     --enable-debug \
188     --enable-static-modules \
189     --disable-macosx \
190     --disable-macosx-defaults \
191     --disable-macosx-vout \
192     --disable-macosx-dialog-provider \
193     --disable-macosx-qtcapture \
194     --disable-macosx-eyetv \
195     --disable-macosx-vlc-app \
196     --with-macosx-sdk=${IOS_SDK_ROOT} \
197     --enable-audioqueue \
198     --enable-ios-vout \
199     --enable-avcodec \
200     --enable-avformat \
201     --enable-swscale \
202     --enable-faad \
203     --disable-mad \
204     --disable-a52 \
205     --disable-fribidi \
206     --disable-macosx-audio \
207     --disable-qt4 --disable-skins2 \
208     --disable-libgcrypt \
209     --disable-remoteosd \
210     --disable-vcd \
211     --disable-postproc \
212     --disable-vlc \
213     --disable-vlm \
214     --disable-httpd \
215     --disable-nls \
216     --disable-glx \
217     --disable-visual \
218     --disable-lua \
219     --disable-sse \
220     --disable-neon \
221     --disable-mmx > ${out} # MMX and SSE support requires llvm which is broken on Simulator
222 fi
223
224 CORE_COUNT=`sysctl -n machdep.cpu.core_count`
225 let MAKE_JOBS=$CORE_COUNT+1
226
227 info "Building libvlc"
228 make -j$MAKE_JOBS > ${out}
229
230 info "Installing libvlc"
231 make install > ${out}
232 popd