forked from andoma/movian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.inc
390 lines (323 loc) · 7.92 KB
/
configure.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
#!/bin/bash
#
# Showtime configure shared functions
#
# Copyright (c) 2005-2008 Andreas Öman
#
# Based on FFmpeg's configure script:
#
# Copyright (c) 2000-2002 Fabrice Bellard
# Copyright (c) 2005-2008 Diego Biurrun
# Copyright (c) 2005-2008 Mans Rullgard
#
TOPDIR=`pwd`
BUILD=${CONFIGURE_POSTFIX}
TMPDIR=${TOPDIR}/tmp
GLW_DEFAULT_THEME="mono"
DEFAULT_LOGTARGET=""
JARGS=""
LIBSPOTIFY_VERSION="12.1.51"
CONFIG_LIST="
libasound
libpulse
libfreetype
libpthread
zlib
posix_networking
dvd
dvd_linux
dvd_wii
cdda
cddb
glw
glw_frontend_x11
glw_frontend_wii
glw_frontend_ps3
glw_frontend_cocoa
glw_backend_opengl
glw_backend_gx
glw_backend_rsx
glw_backend_opengl_es
gu
libogc
spotify
libspotify_load_runtime
lirc
stdin
release
coreaudio
avahi
appleremote
bonjour
nvctrl
libgme
libxss
libxv
serdev
openssl
polarssl
librtmp
libx11
libxext
locatedb
spotlight
vdpau
spidermonkey
libxxf86vm
libxrandr
libsidplay2
httpserver
psl1ght
timegm
inotify
fsevents
realpath
trex
emu_thread_specifics
ps3_vdec
libfontconfig
binreplace
readahead_cache
sqlite_vfs
sqlite_locking
libav
vda
tlsf
"
cleanup() {
rm -rf $TMPDIR
}
die() {
cleanup
echo "Configure failed"
exit 1
}
die_invalid_opt() {
echo "Invalid option: $1"
die
}
die_cause() {
echo "$1"
die
}
set_all(){
value=$1
shift
for var in $*; do
eval $var=$value
done
}
enable(){
set_all yes $*
}
disable(){
set_all no $*
}
enabled(){
eval test "x${!1}" = "xyes"
}
disabled(){
eval test "x${!1}" = "xno" -o "x${!1}" = "x"
}
toupper(){
echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
}
is_in(){
value=$1
shift
for var in $*; do
[ $var = $value ] && return 0
done
return 1
}
print_config(){
pfx=$1
header=$2
makefile=$3
shift 3
for cfg; do
ucname="`toupper $cfg`"
if enabled $cfg; then
echo "#define ${pfx}${ucname} 1" >> $header
echo "#define ENABLE_${ucname} 1" >> $header
echo "${pfx}${ucname}=yes" >> $makefile
else
echo "#define ENABLE_${ucname} 0" >> $header
fi
done
}
cp_if_changed(){
cmp -s "$1" "$2" || cp -f "$1" "$2"
}
download_file() {
local __resultvar=$2
local URL_HASH=`echo "$1" | shasum | awk '{print $1}'`
mkdir -p ${TOPDIR}/.downloadcache
local DLPATH=${TOPDIR}/.downloadcache/${URL_HASH}
if [ ! -f "${DLPATH}" ]; then
echo "Downloading $1"
curl -f -L -o "${DLPATH}" "$1" || die_cause "Unable to download file"
else
echo "Found in cache: $1"
fi
eval $__resultvar="$DLPATH"
}
common_help(){
echo "Usage: configure [options]"
echo "Options: [defaults in brackets after descriptions]"
echo
echo "Standard options:"
echo " --help Print this message"
echo " --with-libav=PREFIX Path to where libav is installed."
echo " By default Showtime will build libav itself."
echo " --build=BUILD Build in build.BUILD [build.$BUILD]"
echo " --jobs=N Allow N jobs at once"
echo " --release Stage for release"
echo " --cleanbuild Erase builddir before configuring"
echo " --ccache Enable use of ccache"
echo " --extra-cflags Extra cflags"
echo " --extra-ldflags Extra ldflags"
echo ""
echo "Platform specific options:"
}
common_opt(){
case "$1" in
--with-libav=*) LIBAV_PATH="$2"
;;
--build=*) BUILD="$2"
;;
--extra-cflags=*) EXTRA_CFLAGS="$2"
;;
--extra-ldflags=*) EXTRA_LDFLAGS="$2"
;;
--enable-?*|--disable-?*)
eval $(echo "$1" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
if is_in $option $CONFIG_LIST; then
$action $option
else
die_invalid_opt $1
fi
;;
--jobs=*) JARGS="-j$2"
;;
--cleanbuild) enable cleanbuild
;;
--ccache) CC="ccache $CC"
;;
--release) enable release
;;
*)
die_invalid_opt $1
esac
}
setup_env(){
BUILDDIR=build.${BUILD}
if enabled cleanbuild; then
echo "Cleaning builddir: ${BUILDDIR}"
rm -rf ${BUILDDIR}
fi
mkdir -p ${BUILDDIR}
BUILDDIR=`cd ${BUILDDIR} && pwd`
CONFIG_H=${BUILDDIR}/config.h.tmp
CONFIG_MAK=${BUILDDIR}/config.mak.tmp
CONFIG_DEF=${TOPDIR}/config.default
mkdir -p ${BUILDDIR}
# Create a tmpdir used during configure
mkdir -p ${TMPDIR}
TMPDIR=`cd ${TMPDIR} && pwd`
# Create config.mak
cat > ${CONFIG_MAK} << EOF
# Automatically generated by configure, do not edit
CONFIGURE_ARGS=$@
TOPDIR=$TOPDIR
PLATFORM=$PLATFORM
CONFIGURE_POSTFIX=$CONFIGURE_POSTFIX
CFLAGS_cfg += ${EXTRA_CFLAGS}
LDFLAGS_cfg += ${EXTRA_LDFLAGS}
EOF
# Create config.h
cat > ${CONFIG_H} << EOF
/* Automatically generated by configure, do not edit */
#define CONFIGURE_ARGS "$@"
#define SHOWTIME_DEFAULT_UI "${DEFAULT_UI}"
#define SHOWTIME_DEFAULT_LOGTARGET "${DEFAULT_LOGTARGET}"
EOF
# Create config.default
cat > ${CONFIG_DEF} << EOF
# Automatically generated by configure, do not edit
BUILD ?= $BUILD
EOF
enable libav
}
libav_setup() {
if disabled libav; then
return
fi
if [ "x${LIBAV_PATH}" != "x" ]; then
return
fi
status=`git submodule status ext/libav | cut -b 1`
echo "Updating libav, submodule status = $status"
git submodule update --init ext/libav
echo "Configuring libav..."
LIBAV_BUILD_DIR=${BUILDDIR}/libav/build
LIBAV_INSTALL_DIR=${BUILDDIR}/libav/install
[ "$status" = "+" ] && echo "Cleaning libav build dir" && rm -rf "${LIBAV_BUILD_DIR}"
mkdir -p "${LIBAV_BUILD_DIR}"
mkdir -p "${LIBAV_INSTALL_DIR}"
LIBAV_COMMON_FLAGS="--disable-encoders --disable-bsfs --disable-filters --disable-muxers --disable-devices --disable-protocols --disable-network --disable-shared --enable-static --disable-bzlib --disable-decoder=twinvq --disable-decoder=snow --disable-decoder=cavs --enable-encoder=png --disable-ffmpeg --disable-demuxer=applehttp --disable-avconv --disable-avprobe"
(cd ${LIBAV_BUILD_DIR} && ${TOPDIR}/ext/libav/configure ${LIBAV_ARCH_FLAGS} ${LIBAV_COMMON_FLAGS} --prefix=${LIBAV_INSTALL_DIR} --extra-cflags="${LIBAV_CFLAGS} ${EXTRA_CFLAGS}" --extra-ldflags="${LIBAV_LDFLAGS} ${EXTRA_LDFLAGS}" --cc="${CC}") || die
(cd ${LIBAV_BUILD_DIR} && make ${JARGS}) || die
(cd ${LIBAV_BUILD_DIR} && make ${JARGS} install) || die
LIBAV_PATH=${LIBAV_INSTALL_DIR}
}
#
# Do final common stuff
#
finalize() {
if enabled libav; then
echo >>${CONFIG_MAK} "CFLAGS_cfg += -I${LIBAV_PATH}/include"
echo >>${CONFIG_MAK} "LDFLAGS_cfg += -L${LIBAV_PATH}/lib -lswscale -lavformat -lavcodec -lavutil"
fi
if enabled polarssl; then
echo "Using built-in polarssl"
echo >>${CONFIG_MAK} "CFLAGS_cfg += -DUSE_POLARSSL"
fi
# Generate default theme path for GLW
if enabled glw; then
echo >>${CONFIG_MAK} "BUNDLES+=glwthemes/${GLW_DEFAULT_THEME}"
echo >>${CONFIG_H} "#define SHOWTIME_GLW_DEFAULT_THEME \""${GLW_DEFAULT_THEME}"\""
fi
# Generate resource path for GU
if enabled gu; then
echo >>${CONFIG_MAK} "BUNDLES+=guresources"
fi
# Fonts
echo >>${CONFIG_MAK} "BUNDLES+=resources/fonts"
# Languages
echo >>${CONFIG_MAK} "BUNDLES+=lang"
# sqlite
if enabled sqlite_vfs; then
echo >>${CONFIG_MAK} "SQLITE_CFLAGS_cfg += -DSQLITE_OS_OTHER=1 -DSQLITE_DEFAULT_LOCKING_MODE=1"
fi
if enabled sqlite_locking; then
echo >>${CONFIG_MAK} "SQLITE_CFLAGS_cfg += -DSQLITE_MUTEX_NOOP"
fi
# Release tag
if enabled release; then
echo >>${CONFIG_MAK} "CFLAGS_dbg = -DNDEBUG -D_NDEBUG"
else
echo >>${CONFIG_MAK} "CFLAGS_dbg = -DJS_GC_ZEAL -DDEBUG=1"
fi
cat >> ${CONFIG_MAK} << EOF
OSENV=${OSENV}
LDFLAGS_cfg += -lz -lm
EOF
# Generate config files
print_config CONFIG_ ${CONFIG_H} ${CONFIG_MAK} $CONFIG_LIST
cp_if_changed ${CONFIG_H} ${BUILDDIR}/config.h
cp_if_changed ${CONFIG_MAK} ${BUILDDIR}/config.mak
rm -f ${CONFIG_H} ${CONFIG_MAK}
cleanup
exit 0
}