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
|
#!/bin/sh
# MIT license
# Copyright 2009-2010 Sebastian Reichel <sre@ring0.de>
# These are default values for some configurable things
if [ "x$CC" = "x" ] ; then
CC=gcc
fi;
if [ "x$VALAC" = "x" ] ; then
VALAC=valac
fi;
if [ "x$INSTALL" = "x" ] ; then
INSTALL=install
fi;
if [ "x$PKGCONFIG" = "x" ] ; then
PKGCONFIG=pkg-config
fi;
PREFIX=/usr/local
INSTALL_DATA=`echo ${INSTALL} -m 644`
INSTALL_PROGRAM=`echo ${INSTALL} -m 755 -s`
INSTALL_DIR=`echo ${INSTALL} -d`
# This awk script is derived from autotools
awk_verscmp='
# Use only awk features that work with 7th edition Unix awk (1978).
# My, what an old awk you have, Mr. Solaris!
END {
while (length(v1) && length(v2)) {
# Set d1 to be the next thing to compare from v1, and likewise for d2.
# Normally this is a single character, but if v1 and v2 contain digits,
# compare them as integers and fractions as strverscmp does.
if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
# Split v1 and v2 into their leading digit string components d1 and d2,
# and advance v1 and v2 past the leading digit strings.
for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
if (d1 ~ /^0/) {
if (d2 ~ /^0/) {
# Compare two fractions.
while (d1 ~ /^0/ && d2 ~ /^0/) {
d1 = substr(d1, 2); len1--
d2 = substr(d2, 2); len2--
}
if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
# The two components differ in length, and the common prefix
# contains only leading zeros. Consider the longer to be less.
d1 = -len1
d2 = -len2
} else {
# Otherwise, compare as strings.
d1 = "x" d1
d2 = "x" d2
}
} else {
# A fraction is less than an integer.
exit 1
}
} else {
if (d2 ~ /^0/) {
# An integer is greater than a fraction.
exit 2
} else {
# Compare two integers.
d1 += 0
d2 += 0
}
}
} else {
# The normal case, without worrying about digits.
d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
}
if (d1 < d2) exit 1
if (d1 > d2) exit 2
}
# Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
# which mishandles some comparisons of empty strings to integers.
if (length(v2)) exit 1
if (length(v1)) exit 2
}
'
show_usage() {
echo "'configure' configures $1 to adapt to many kinds of systems."
echo "Usage: ./configure [OPTION]... [VAR=VALUE]..."
echo
echo "To assign environment variables (e.g. CC, CFLAGS, ...), specify them"
echo "as VAR=VALUE. See below for descriptions of some of the useful variables."
echo
echo "Defaults for the options are specified in brackets."
echo
echo "Options:"
echo " -h, --help display this help and exit"
echo " -v, --version display version information and exit"
echo " --prefix=PREFIX install files in PREFIX [/usr/local]"
echo " --debug enable debug build (-g flag)"
echo " --colored enable colored build"
for parameter in `extra_options list-all` ; do
extra_options $parameter
printf " %-27s $DESC\n" $parameter
done
echo
echo "Some influential environment variables:"
echo " CC C compiler command"
echo " VALAC Vala compiler"
echo " CFLAGS C compiler flags, e.g. -I<header dir>"
echo " LDFLAGS linker flags, e.g. -L<lib dir>"
echo " INSTALL install binary"
echo " PKGCONFIG pkg-config binary"
echo
echo "Report bugs to: $2"
exit 0
}
show_version() {
echo "$1 version $2"
echo "Originally written by $3"
exit 0
}
check_parameters() {
while : ; do
[ -z "$1" ] && break
parse_options $1
shift
done
if [ "$UNKNOWN_FLAG" = "1" ] ; then
echo
fi
}
parse_options() {
flag=`echo $1 | cut -d = -f 1`
value=`echo $1 | awk 'BEGIN{FS="=";}{print $2}'`
case $flag in
"-h"|"--help")
show_usage "$NAME" "$AUTHOR"; ;;
"-v"|"--version")
show_version "$NAME" "$VERSION" "$AUTHOR"; ;;
"--debug")
DEBUG="yes"; ;;
"--colored")
COLOR="yes"; ;;
"--prefix")
PREFIX="$value"; ;;
"CC")
CC="$value"; ;;
"CFLAGS")
CFLAGS="$value"; ;;
"LDFLAGS")
LDFLAGS="$value"; ;;
"INSTALL")
INSTALL="$value"; ;;
"PKGCONFIG")
PKGCONFIG="$value"; ;;
"VALAC")
VALAC="$value"; ;;
*)
extra_options $flag $value
if [ "$CMD" != "not-available" ] ; then
eval "$CMD"
else
echo "WARNING: unknown flag '$1'." >&2
UNKNOWN_FLAG=1
fi;;
esac
}
check_prg_version() {
printf " %-34s" "$1..."
if [ "$4" = "disable" ] ; then
echo "disabled"
return 0
fi
if [ "$3" = "" ] ; then
echo "missing"
if [ "$4" != "force" ] ; then
return 0
else
exit 1
fi
fi
echo "$3"
awk "$awk_verscmp" v1="$2" v2="$3" /dev/null
if [ "$?" = "2" ] ; then
echo "Please install at least $2 to use this feature"
if [ "$4" != "force" ] ; then
return 0
else
exit 1
fi
fi
return 1
}
check_pkg_version() {
printf " %-34s" "$1..."
if [ "$3" = "disable" ] ; then
echo "disabled"
return 0
fi
pkg-config --exists $1
if [ "$?" = "1" ] ; then
echo "missing"
if [ "$3" != "force" ] ; then
return 0
else
exit 1
fi
fi
echo `pkg-config --modversion $1`
pkg-config --atleast-version "$2" "$1"
if [ "$?" = "1" ] ; then
echo "Please install at least $2"
if [ "$3" != "force" ] ; then
return 0
else
exit 1
fi
fi
return 1
}
check_font() {
name="$1"
printf " %-34s" "$1..."
for file in /etc/fonts/conf.avail/*; do
grep -q "$name" "$file"
if [ $? -eq 0 ] ; then
echo "available"
return 1
fi
done
echo "MISSING"
if [ "$2" != "force" ] ; then
return 0
else
exit 1
fi
}
check_compiler() {
printf "Checking compiler... "
echo 'main(){}' > test.c
${CC} ${CFLAGS} ${LDFLAGS} -o a.out test.c >/dev/null 2>&1
if [ ! $? = 0 ]; then
echo failed
exit 1
else
echo works
fi
rm -f a.out test.c
}
check_install() {
printf "Checking install... "
if [ -x `which ${INSTALL}` ] ; then
echo available
else
echo missing
exit 1
fi
}
check_pkgconfig() {
printf "Checking pkg-config... "
if [ -x `which ${PKGCONFIG}` ] ; then
echo `${PKGCONFIG} --version`
else
echo missing
exit 1
fi
}
create_config() {
FILE=$1
shift
printf "Creating %-26s" $FILE...
rm -f $FILE && touch $FILE
# Some standard variables
echo DEBUG=$DEBUG >> $FILE
echo COLOR=$COLOR >> $FILE
echo CC=$CC >> $FILE
echo CFLAGS=$CFLAGS >> $FILE
echo LDFLAGS=$LDFLAGS >> $FILE
echo PREFIX=$PREFIX >> $FILE
echo PKGCONFIG=$PKGCONFIG >> $FILE
echo INSTALL=$INSTALL >> $FILE
echo INSTALL_DATA=$INSTALL_DATA >> $FILE
echo INSTALL_PROGRAM=$INSTALL_PROGRAM >> $FILE
echo INSTALL_DIR=$INSTALL_DIR >> $FILE
for option in $@ ; do
value=`echo \\$$option`
value=`eval echo $value`
echo $option=$value >> $FILE
done
echo "done"
}
create_header() {
FILE=$1
shift
printf "Creating %-26s" $FILE...
rm -f $FILE && touch $FILE
for option in $@ ; do
value=`echo \\$$option`
value=`eval echo $value`
echo "#define $option \"$value\"" >> $FILE
done
echo "done"
}
final_report() {
echo
echo "Final Report:"
for option in $@ ; do
value=`echo \\$$option`
value=`eval echo $value`
printf " %-10s = %s\n" $option $value
done
}
|