blob: 37181b494945d03ff40e39f4d929d549f100f901 (
plain)
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
|
#!/bin/sh
#
# vdr-xinelibout configure script
#
# Copyright (c) Petri Hintukainen 2008
#
# See the main source file 'xineliboutput.c' for copyright information and
# how to reach the author.
#
# * $Id: configure,v 1.3 2008-11-01 12:27:29 phintuka Exp $
#
PKG_CONFIG="pkg-config"
makefile="config.mak"
header="features.h"
logfile="configure.log"
debug=no
CC="cc"
CXX="g++"
CFLAGS=""
#
# tools
#
toupper(){
echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
}
die(){
log "$@"
exit -1
}
log(){
echo "$@"
echo "$@" >> $logfile
}
logdbg(){
[ x$debug = xyes ] && log "$@" || echo "$@" >> $logfile
}
not_in_list(){
key=$1
shift
for item in $*; do
test $key = $item && return 1
done
return 0
}
add_flag(){
eval not_in_list $flag \$$flags_list || return 1
eval $flags_list=\"\$${flags_list} ${flag}\"
}
add_flags(){
flags_list=$1
shift
for flag in $*; do
add_flag $flags_list $flag
done
}
#
# enable/disable
#
set_opt(){
eval HAVE_$(toupper $1)=$2
}
set_opts(){
optvalue=$1
shift
for optname in $*; do
set_opt $optname $optvalue
done
}
enable(){
set_opts yes $*
}
disable(){
set_opts no $*
}
enabled(){
ucfeature=$(toupper $1)
eval test "x\$HAVE_${ucfeature}" = "xyes"
}
disabled(){
ucfeature=$(toupper $1)
eval test "x\$HAVE_${ucfeature}" = "xno"
}
#
# compile/link tests
#
generate_test_c(){
hdrname=$1
subsys=$2
func=$3
if test x"$subsys" = xX11 ; then
cat <<EOF >testhdr.c
#include <X11/Xlib.h>
#include <$hdrname>
int main(int c, char **v) {
$func;
return 0;
}
EOF
else
cat <<EOF >testhdr.c
#include <$hdrname>
int main(int c, char **v) {
$func;
}
EOF
fi
}
test_library_c(){
log -n "Checking for $libname ... "
generate_test_c $hdr $subsys $func
$CC -g testhdr.c -o testhdr $CFLAGS $lib
err=$?
if test $err = 0; then
log "yes"
add_flags LIBS_$subsys $lib
logdbg adding $lib to LIBS_$subsys
else
log "no"
logdbg "--------"
logdbg "/* $CC -g testhdr.c -o testhdr $CFLAGS $lib */"
logdbg `cat testhdr.c`
logdbg "--------"
fi
rm -f testhdr.c testhdr
return $err
}
#
# generic test
#
test_library(){
subsys="$1"
libname="$2"
hdr="$3"
lib="$4"
func="$5"
feature=$(toupper $libname)
# do not test if disabled from command-line
if disabled $feature; then
log "Not checking for $libname"
disable $feature
return 1
fi
disable $feature
test_library_c "$subsys" "$libname" "$hdr" "$lib" "$func" && enable $feature
}
#
# configurable features
#
SUBSYSTEMS="
x11
fb
vdr
libxine
"
FEATURES="
$SUBSYSTEMS
libextractor
xdpms
xinerama
xrandr
xrender
"
# set defaults
enable x11 vdr fb xine
# clear log file
rm -f $logfile
#
# Parse command-line arguments
#
show_help(){
echo "Usage: configure [options]"
echo "Options: [defaults in brackets after descriptions]"
echo
echo " --help print this message"
echo " --enable-x11 build X11 frontend (vdr-sxfe) [yes]"
echo " --enable-fb build framebuffer frontend (vdr-fbfe) [yes]"
echo " --enable-vdr build VDR plugin [yes]"
echo " --enable-libxine build xine plugins [yes]"
echo
echo " --disable-libextractor disable libextractor support (media file metainfo) [no]"
echo " --disable-xdpms disable Xdpms support [no]"
echo " --disable-xinerama disable Xinerama support [no]"
echo " --disable-xrandr disable Xrandr support (video mode switching) [no]"
echo " --disable-xrender disable Xrender support (HUD OSD) [no]"
echo
echo " --debug debug configure script"
echo " --cc=CC select C compiler"
echo " --cxx=CXX select C++ compiler"
echo " --add-cflags=FLAGS add compiler flags"
}
for opt do
optval="${opt#*=}"
logdbg "Command line: $opt [$optval]"
case "$opt" in
--help)
show_help && die
;;
--debug)
debug=yes
logdbg "Debug mode"
;;
--cc=?*)
CC=$optval
logdbg "C compiler: $CC"
;;
--cxx=?*)
CXX=$optval
logdbg "C++ compiler: $CXX"
;;
--add-cflags=?*)
CFLAGS="$CFLAGS $optval"
logdbg "CFLAGS: $CFLAGS"
;;
--enable-?*|--disable-?*)
eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
logdbg " $action $option"
not_in_list $option $FEATURES && die "unknown option $opt"
eval $action \${option}
;;
-*)
die "unknown option $opt"
;;
esac
done
#
# maintain deps
#
check_deps(){
disabled libxine && disable x11 fb
disabled x11 && disable xrender xrandr xdpms xinerama
disabled vdr && disable libextractor
}
check_deps
#
# Run the tests
#
# fake test that should fail
[ $debug = yes ] && \
test_library X11 do_error "none.h" "-lnolib"
test_library VDR libextractor "extractor.h" "-lextractor" "EXTRACTOR_getKeywords(0,0)"
test_library XINE libxine "xine.h" "-lxine" "xine_init(0)"
if enabled libxine; then
test_library X11 x11 "X11/X.h" "-lX11" "XInitThreads()"
if enabled x11; then
test_library X11 xrender "X11/extensions/Xrender.h" "-lXrender" "XRenderQueryFormats(0)"
test_library X11 xrandr "X11/extensions/Xrandr.h" "-lXrandr" "XRRGetScreenInfo(0,0)"
test_library X11 xdpms "X11/extensions/dpms.h" "-lXext" "DPMSDisable(0)"
test_library X11 xinerama "X11/extensions/Xinerama.h" "-lXinerama" "XineramaQueryScreens(0,0)"
fi
fi
check_deps
#
# Print results
#
log
log "Enabled features:"
for feature in $FEATURES; do
enabled $feature && log " $feature"
done
log "Disabled features:"
for feature in $FEATURES; do
enabled $feature || log " $feature"
done
log
#
# create features.h
#
log "Creating $header ..."
cat <<EOF >$header
/* Automatically generated by configure - do not modify! */
#ifndef XINELIBOUTPUT_FEATURES_H
#define XINELIBOUTPUT_FEATURES_H
EOF
for feature in $FEATURES; do
enabled $feature &&
echo "#define HAVE_$(toupper $feature) 1">>$header || \
echo "#undef HAVE_$(toupper $feature)">>$header
done
echo "" >> $header
echo "#endif /* XINELIBOUTPUT_FEATURES_H */" >> $header
#
# create features.mak
#
log "Creating $makefile ..."
echo "# Automatically generated by configure - do not modify!" > $makefile
echo >> $makefile
# subsystems
echo "XINELIBOUTPUT_VDRPLUGIN=$HAVE_VDR" >> $makefile
echo "XINELIBOUTPUT_XINEPLUGIN=$HAVE_LIBXINE" >> $makefile
echo "XINELIBOUTPUT_X11=$HAVE_X11" >> $makefile
echo "XINELIBOUTPUT_FB=$HAVE_FB" >> $makefile
echo >> $makefile
# features
for feature in $FEATURES; do
feature="`toupper $feature`"
enabled $feature &&
echo "HAVE_$feature=yes">>$makefile ||
echo "HAVE_$feature=no">>$makefile
done
echo >> $makefile
# cc/ld flags
echo "CFLAGS_XINE += $CFLAGS_XINE">>$makefile
echo "CFLAGS_VDR += $CFLAGS_VDR">>$makefile
echo "CFLAGS_X11 += $CFLAGS_X11">>$makefile
echo "LIBS_XINE += $LIBS_XINE">>$makefile
echo "LIBS_VDR += $LIBS_VDR">>$makefile
echo "LIBS_X11 += $LIBS_X11">>$makefile
|