-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen-config.h.sh
executable file
·58 lines (50 loc) · 1.48 KB
/
gen-config.h.sh
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
#!/bin/sh
# Copyright (c) 2014-2021 Frank Terbeck <[email protected]>
# All rights reserved.
#
# Terms for redistribution and use can be found in LICENCE.
available=' '
members='c_iflag c_oflag c_cflag c_lflag c_line c_cc c_ispeed c_ospeed'
C_COMPILER=${C_COMPILER:-cc}
export C_COMPILER
for member in $members; do
printf 'Checking whether struct termios has %s member... ' "$member"
if sh ./tools/termios-struct-has.sh "$member"; then
printf 'yes.\n'
name=$(printf '%s' "$member" | tr a-z A-Z)
available="$available$name "
else
printf 'no.\n'
fi
done
print2config () {
fmt=$1
shift
printf "$fmt" "$@" >> config.h || exit 1
}
printf 'Generating "config.h" from "config.h.in"... '
rm -f config.h
while IFS='' read -r line; do
case "$line" in
'#define-maybe '*)
token=${line##* }
case "$available" in
*\ "$token"\ *)
print2config '#ifndef GUILE_TERMIOS_HAS_%s\n' "$token"
print2config '#define GUILE_TERMIOS_HAS_%s\n' "$token"
print2config '#endif /* GUILE_TERMIOS_HAS_%s */\n' "$token"
;;
*)
print2config '#ifdef GUILE_TERMIOS_HAS_%s\n' "$token"
print2config '#undef GUILE_TERMIOS_HAS_%s\n' "$token"
print2config '#endif /* GUILE_TERMIOS_HAS_%s */\n' "$token"
;;
esac
;;
*)
print2config '%s\n' "$line"
esac
done < config.h.in
[ "$?" != 0 ] && exit 1
printf 'done.\n'
exit 0