/
configure.inc
343 lines (290 loc) · 7.37 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
#!/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`
TMPDIR=${TOPDIR}/tmp
BUILDDIR=build.${PLATFORM}
GLW_DEFAULT_THEME="mono"
DEFAULT_LOGTARGET=""
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
gu
libogc
spotify
libspotify_load_runtime
lirc
stdin
release
embedded_resources
coreaudio
avahi
appleremote
bonjour
nvctrl
libopenspc
libgme
tinysmb
libxss
libsmbclient
libxv
serdev
openssl
polarssl
librtmp
libx11
libxext
locatedb
spotlight
vdpau
spidermonkey
libxxf86vm
libxrandr
libsidplay2
httpserver
psl1ght
timegm
inotify
realpath
trex
emu_thread_specifics
ps3_vdec
font_liberation
libfontconfig
binreplace
readahead_cache
"
die() {
rm -rf $TMPDIR
exit
}
die_invalid_opt() {
echo "Invalid option: $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
}
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 ""
echo "Target specific options:"
}
common_opt(){
case "$1" in
--with-libav=*) LIBAV_PATH="$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
;;
*)
die_invalid_opt $1
esac
}
setup_env(){
# Create the dir for local libs, and get rid of any relative path
mkdir -p ${BUILDDIR}
BUILDDIR=`cd ${BUILDDIR} && pwd`
CONFIG_H=${BUILDDIR}/config.h
CONFIG_MAK=${BUILDDIR}/config.mak
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
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
PLATFORM ?= $PLATFORM
EOF
}
spotify_setup() {
enable spotify
echo >${BUILDDIR}/spotify_app_key.h "static const uint8_t appkey[] = {"
od <"$1" -v -An -b | awk '{for(i = 1; i <= NF; i++) print "0" $i ","}' >>${BUILDDIR}/spotify_app_key.h
echo >>${BUILDDIR}/spotify_app_key.h "};"
}
libav_setup() {
if [ "x${LIBAV_PATH}" != "x" ]; then
return
fi
echo "Updating libav... (if needed)"
git submodule update --init ext/libav
echo "Configuring libav..."
LIBAV_BUILD_DIR=${BUILDDIR}/libav/build
LIBAV_INSTALL_DIR=${BUILDDIR}/libav/install
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-ffserver --disable-ffmpeg --disable-ffprobe --disable-bzlib --disable-decoder=twinvq --disable-decoder=snow --disable-decoder=cavs --enable-encoder=png"
(cd ${LIBAV_BUILD_DIR} && ${TOPDIR}/ext/libav/configure ${LIBAV_ARCH_FLAGS} ${LIBAV_COMMON_FLAGS} --prefix=${LIBAV_INSTALL_DIR} --extra-cflags="${LIBAV_CFLAGS}")
(cd ${LIBAV_BUILD_DIR} && make -j6)
(cd ${LIBAV_BUILD_DIR} && make install)
LIBAV_PATH=${LIBAV_INSTALL_DIR}
}
#
# Do final common stuff
#
finalize() {
echo >>${CONFIG_MAK} "CFLAGS_cfg += -I${LIBAV_PATH}/include"
echo >>${CONFIG_MAK} "LDFLAGS_cfg += -L${LIBAV_PATH}/lib -lswscale -lavformat -lavcodec -lavutil"
if enabled polarssl; then
echo "Using built-in polarssl"
echo >>${CONFIG_MAK} "CFLAGS_cfg += -DUSE_POLARSSL"
fi
if [ "x${SPOTIFY_KEYFILE}" != "x" ]; then
spotify_setup "${SPOTIFY_KEYFILE}"
fi
# Generate default theme path for GLW
# Optionally embed the theme if in release mode
if enabled glw; then
if enabled embedded_resources; then
GLW_DEFAULT_THEME_URL="bundle://glwthemes/${GLW_DEFAULT_THEME}"
echo >>${CONFIG_MAK} "BUNDLES+=glwthemes/${GLW_DEFAULT_THEME}"
else
GLW_DEFAULT_THEME_URL="file://`cd glwthemes/$GLW_DEFAULT_THEME && pwd`"
fi
echo >>${CONFIG_H} "#define SHOWTIME_GLW_DEFAULT_THEME_URL \""${GLW_DEFAULT_THEME_URL}"\""
fi
# Generate resource path for GU
# Optionally embed the stuff if in release mode
if enabled gu; then
if enabled embedded_resources; then
GU_RESOURCES_URL="bundle://guresources"
echo >>${CONFIG_MAK} "BUNDLES+=guresources"
else
GU_RESOURCES_URL="file://`cd guresources && pwd`"
fi
echo >>${CONFIG_H} "#define SHOWTIME_GU_RESOURCES_URL \""${GU_RESOURCES_URL}"\""
fi
# Fonts
# Optionally embed the stuff if in release mode
if enabled font_liberation; then
if enabled embedded_resources; then
LIBERATION_RESOURCE_URL="bundle://resources/fonts/liberation"
echo >>${CONFIG_MAK} "BUNDLES+=resources/fonts/liberation"
else
LIBERATION_RESOURCE_URL="file://`cd resources/fonts/liberation && pwd`"
fi
echo >>${CONFIG_H} "#define SHOWTIME_FONT_LIBERATION_URL \""${LIBERATION_RESOURCE_URL}"\""
fi
# Languages
if enabled embedded_resources; then
LANGUAGES_URL="bundle://lang"
echo >>${CONFIG_MAK} "BUNDLES+=lang"
else
LANGUAGES_URL="file://`cd lang && pwd`"
fi
echo >>${CONFIG_H} "#define SHOWTIME_LANGUAGES_URL \""${LANGUAGES_URL}"\""
# 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
# PROG not set, set to default binary path
if [ "x${PROG}" == "x" ]; then
PROG="build.${PLATFORM}/showtime"
fi
echo >>${CONFIG_MAK} "PROG=${PROG}"
# Generate config files
print_config CONFIG_ ${CONFIG_H} ${CONFIG_MAK} $CONFIG_LIST
echo "Final binary is: ${PROG}"
die
}