File: configure

package info (click to toggle)
tcng 10b-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,644 kB
  • sloc: ansic: 19,040; pascal: 4,640; yacc: 2,619; sh: 1,914; perl: 1,546; lex: 772; makefile: 751
file content (443 lines) | stat: -rwxr-xr-x 9,948 bytes parent folder | download | duplicates (3)
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
#!/bin/bash -e
#
# configure - Configure directories and system environment for tcc and tcsim
#
# Written 2001-2004 by Werner Almesberger
# Copyright 2001 EPFL-ICA, Network Robots
# Copyright 2002 Bivio Networks, Network Robots, Werner Almesberger
# Copyright 2003,2004 Werner Almesberger
#

KVERSIONS=2.4.3,2.4.4,2.4.5,2.4.6,2.4.7,2.4.8,2.4.9,2.4.10,2.4.12,2.4.13
KVERSIONS=$KVERSIONS,2.4.14,2.4.15,2.4.16,2.4.17,2.4.18,2.4.19,2.4.20,2.4.21
KVERSIONS=$KVERSIONS,2.4.22,2.4.23,2.4.24,2.4.25,2.4.26,2.4.27
KVERSIONS=$KVERSIONS,2.5.0,2.5.1,2.5.2,2.5.3,2.5.4
IVERSIONS=991023,001007,010803,010824,020116,040702,040831

KSUFFIXES=-2.4.19,-2.4.20,-2.4.21.-2.4.22

if [ "$1" = --kversions ]; then
    echo $KVERSIONS | tr , ' '
    exit 0
fi

if [ "$1" = --iversions ]; then
    echo $IVERSIONS | tr , ' '
    exit 0
fi

kdir=
idir=
install_dir=
data_dir=
with_tcsim=
with_manual=
bytesex=
no_tests=
yacc=
dollar=
action=

if [ "$1" != --no-defaults ]; then
    if [ -r config ]; then
	echo "Reading configuration defaults from ./config"
	. ./config
	kdir=$KSRC
	idir=$ISRC
	install_dir=$INSTALL_DIR
	data_dir=$DATA_DIR
	with_tcsim=$TCSIM
	with_manual=$BUILD_MANUAL
	bytesex=$BYTEORDER
	yacc="$YACC"
	dollar=$DOLLAR
	action=$ACTION
    fi
else
    shift
fi

topdir=`pwd`
[ -z "$idir" -o ! -d "$idir" ] && \
  idir="`find tcsim -maxdepth 1 -type d -name 'iproute2*' | sed 1q`"
[ -z "$with_tcsim" ] && with_tcsim=true
[ -z "$with_manual" ] && with_manual=true
tcc=

if [ -z "$kdir" -o ! -d "$kdir" ]; then
    for n in tcsim/linux /usr/src/linux; do
	for m in `echo $KSUFFIXES | tr , ' '` ""; do
	    kdir=$n$m
	    [ -d $kdir ] && break 2
	done
    done
fi


usage()
{
    cat <<EOF 1>&2
usage: $0 [--no-defaults] [--kernel <dir_or_tar.bz2>]
                 [--iproute2 <dir_or_tar.gz>] [--tcng <path>]
                 [--install-directory <dir>] [--data-directory <dir>]
                 [--no-tcsim|--with-tcsim] [--no-manual|--with-manual]
                 [--big-endian|--little-endian] [--action|--conform-exceed]
                 [--yacc <command>] [-$|--c99]
  abbreviations: -k for --kernel, -i for --iproute2,
                 -t for --tcng, -d for --install-directory,
                 -D for --data-directory,
                 -n for --no-tcsim, -N for --with-tcsim,
                 -m for --no-manual, -M for --with-manual,
                 -b for --big-endian, -l for --little-endian,
		 -a for --action, -A for --conform-exceed,
                 -y for --yacc
EOF
    exit 1
}


while [ ! -z "$*" ]; do
    case "$1" in
	-k|--kernel)
	    [ ! -z "$2" ] || usage
	    kdir="$2"
	    shift;;
	-i|--iproute2)
	    [ ! -z "$2" ] || usage
	    idir="$2"
	    shift;;
	-t|--tcc|--tcng)
	    [ ! -z "$2" ] || usage
	    tcc="$2"
	    shift;;
	-d|--install-directory)
	    [ ! -z "$2" ] || usage
	    install_dir="$2"
	    shift;;
	-D|--data-directory)
	    [ ! -z "$2" ] || usage
	    data_dir="$2"
	    shift;;
	-n|--no-tcsim)
	    with_tcsim=false;;
	-N|--with-tcsim)
	    with_tcsim=true;;
	-m|--no-manual)
	    with_manual=false;;
	-M|--with-manual)
	    with_manual=true;;
	-b|--big-endian)
	    bytesex=BIG_ENDIAN;;
	-l|--little-endian)
	    bytesex=LITTLE_ENDIAN;;
	-y|--yacc)
	    [ ! -z "$2" ] || usage
	    yacc="$2"
	    shift;;
	-\$)
	    dollar=true;;
	-c99|--c99)
	    dollar=false;;
	-a|--action)
	    action=true;;
	-A|--conform-exceed)
	    action=false;;
	*) usage;;
    esac
    shift
done

#
# Extract kernel tarball
#

if [ -f "$kdir" -a \
  \( "${kdir#linux-2.4.*.tar.bz2}" = "" -o \
     "${kdir#*/linux-2.4.*.tar.bz2}" = "" \) ]; then
    scripts/minksrc.sh "$kdir" | tee .configure.tmp
    kdir=`sed '/^.*[Ee]xtracted to \(.*\)/s//\1/p;d' <.configure.tmp`
    rm -f .configure.tmp
    [ ! -z "$kdir" ] || exit 1
fi

#
# Extract iproute2 tarball
#

if [ -f "$idir" -a \
  \( "${idir#iproute2-*.tar.gz}" = "" -o \
     "${idir#*/iproute2-*.tar.gz}" = "" -o \
     "${idir#iproute_*.orig.tar.gz}" = "" -o \
     "${idir#*/iproute_*.orig.tar.gz}" = "" \) ]; then
    scripts/minisrc.sh "$idir" | tee .configure.tmp
    idir=`sed '/^.*[Ee]xtracted to \(.*\)/s//\1/p;d' <.configure.tmp`
    rm -f .configure.tmp
    [ ! -z "$idir" ] || exit 1
fi

#
# Make relative paths absolute
#

pwd=`pwd`
kdir=`echo "$kdir" | sed 's|^\([^/]\)|'$pwd'/\1|'`
idir=`echo "$idir" | sed 's|^\([^/]\)|'$pwd'/\1|'`


# ----- Report inclusion of tcsim ---------------------------------------------


if $with_tcsim; then
    echo "building tcsim:       yes"
    echo "// 1" >.cpptest
    echo "// 2" >>.cpptest
    if echo "#warning test" | gcc -include .cpptest -E - 2>&1 |
      grep '^[^:]*:1' >/dev/null; then : ; else
	no_tests="broken version of cpp"
	echo "Warning: cpp installed on this system mis-calculates line numbers"
	echo "         and is not compatible with the regression tests of tcng."
    fi
    rm -f .cpptest
else
    echo "building tcsim:       NO"
    no_tests="tcng built without tcsim"
fi


# ----- Detect kernel ---------------------------------------------------------


if $with_tcsim; then
    if [ ! -d $kdir ]; then
	echo $kdir: no kernel directory 2>&1
	exit 1
    fi

    if [ ! -f $kdir/Makefile ]; then
	echo no kernel in $kdir: need $kdir/Makefile 2>&1
	exit 1
    fi

    kversion=`sed '/^\(VERSION\|PATCHLEVEL\|SUBLEVEL\) = /s///p;d'  \
      <$kdir/Makefile | tr '\012' . | sed 's/\.$//'`
    extraversion="`sed '/^EXTRAVERSION = *-/{s///;q;};d' <$kdir/Makefile`"

    none=true
    for n in `echo $KVERSIONS | tr , ' '`; do
	if [ "$kversion" = $n ]; then
	    none=false
	    break
	fi
    done
    if $none; then
	echo "found kernel $kversion, need one of $KVERSIONS" 2>&1
	exit 1
    fi

    kfullversion="$kversion"
    if [ ! -z "$extraversion" ]; then
	kfullversion="$kfullversion-$extraversion"
	extraversion=" [$extraversion]"
    fi
    echo "Kernel source:        $kdir"
    echo "Kernel version:       $kversion$extraversion"
fi


# ----- Detect iproute2 -------------------------------------------------------


if $with_tcsim; then
    if [ ! -d $idir ]; then
	echo $idir: no iproute2 directory 2>&1
	exit 1
    fi

    if [ ! -f $idir/include/SNAPSHOT.h ]; then
	echo no iproute2 in $idir: need $idir/include/SNAPSHOT.h 2>&1
	exit 1
    fi

    iversion=`sed '/.*"\([0-9]*\)".*/s//\1/;q' <$idir/include/SNAPSHOT.h`

    none=true
    for n in `echo $IVERSIONS | tr , ' '`; do
	if [ "$iversion" = $n ]; then
	    none=false
	    break
	fi
    done
    if $none; then
	echo "found iproute $iversion, need one of $IVERSIONS" 2>&1
	exit 1
    fi

    echo "iproute2 source:      $idir"
    echo "iproute2 version:     $iversion"
fi


# ----- Detect byte order -----------------------------------------------------


if $with_tcsim; then
    if [ -z "$bytesex" ]; then
	make -C build -s bytesex
	bytesex=`build/bytesex`

	[ -z "$bytesex" ] && exit 1
    fi

    if [ $bytesex = LITTLE_ENDIAN ]; then
	echo "Host byte order:      little endian"
    else
	echo "Host byte order:      big endian"
    fi
fi


# ----- Find tcc --------------------------------------------------------------


if $with_tcsim; then
    if [ ! -z "$tcc" ]; then
	if [ ! -f "$tcc" -o ! -x "$tcc" ]; then
	    echo "$tcc is not an executable file" 2>&1
	    exit 1
	fi
	if [ "`$tcc -V | awk '{$4="";print $0}'`" != "tcng version " ]; \
	  then
	    echo "$tcc is not the tcng-compiler" 2>&1
	    exit 1
	fi
	if [ "$tcc" != tcng ]; then
	    tcc=`echo "$tcc" | sed 's|^\([^/]\)|'$pwd'/\1|'`
	fi
    fi

    if [ -z "$tcc" ]; then
	tcc=$topdir/bin/tcng
    fi

    echo "tcng command:         $tcc"
fi


# ----- Find a YACC -----------------------------------------------------------


if [ -z "$yacc" ]; then
    if type -path yacc >/dev/null; then
	yacc=yacc
    elif type -path bison >/dev/null; then
	yacc="bison -y"
    else
        echo "no YACC found" 1>&2
	exit 1
    fi
fi
echo "YACC is:              $yacc"


# ----- Make CPP separate dollar signs from identifiers -----------------------


if [ -z "$dollar" ]; then
    {
	if [ "`gcc -std=c99 -E - | sed '$p;d'`" != '$bar' ]; then
	    dollar=true
	else
	    dollar=false
	fi
    } <<EOF
#define foo bar
\$foo
EOF
fi
if $dollar; then
   echo '$ is not identifier:  -$'
else
   echo '$ is not identifier:  -std=c99'
fi


# ----- Check if "tc" supports "action" ---------------------------------------


if [ -z "$action" ]; then
    if tc filter change dev nontdv fw police action pass/pass 2>&1 | \
      grep Illegal >/dev/null; then
	action=false
    else
	action=true
    fi
fi
if $action; then
   echo 'tc supports "action": yes'
else
   echo 'tc supports "action": no (using "conform-exceed" instead)'
fi


# ----- Report inclusion of the manual ----------------------------------------


if $with_manual; then
    if type -path latex >/dev/null && type -path dvips >/dev/null; then
	echo "building the manual:  yes"
    else
        echo "building the manual:  NO (need latex and dvips)"
	with_manual=false
    fi
else
    echo "building the manual:  NO"
fi


# ----- Check install directory -----------------------------------------------

usr_local=
[ -d /usr/local ] && usr_local=/usr/local
[ -z "$install_dir" ] && install_dir=$usr_local
if [ ! -z "$install_dir" ]; then
    if [ ! -e "$install_dir" ]; then
	echo "installation directory $install_dir does not exist" 1>&2
	exit 1
    fi
    if [ ! -d "$install_dir" ]; then
	echo "installation directory $install_dir is not a directory" 1>&2
	exit 1
    fi
    echo "install directory:    $install_dir"
fi


# ----- Write output ----------------------------------------------------------


cat <<EOF >config.tmp
# MACHINE-GENERATED
TOPDIR=$topdir
TCSIM=$with_tcsim
BUILD_MANUAL=$with_manual
NO_TESTS="$no_tests"
INSTALL_DIR=$install_dir
DATA_DIR=${data_dir:-$topdir}
YACC="$yacc"
DOLLAR=$dollar
ACTION=$action
EOF

$with_tcsim && cat <<EOF >>config.tmp
KSRC=$kdir
KVERSION=$kversion
KFULLVERSION=$kfullversion
ISRC=$idir
IVERSION=$iversion
BYTEORDER=$bytesex
TCC=$tcc
EOF

mv -f config.tmp config

exit 0