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
|
?RCS: $Id: Checkcc.U 167 2013-05-08 17:58:00Z rmanfredi $
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: Copyright (c) 2000, Jarkko Hietaniemi
?RCS:
?X:
?X: This unit produces a bit of shell code that must be dotted in order
?X: to make quick check on whether the current C compiler is working.
?X:
?MAKE:Checkcc ccname ccversion: Myread Warn startsh cat contains test
?MAKE: -pick add $@ %<
?S:ccname:
?S: This can set either by hints files or by Configure. If using
?S: gcc, this is gcc, and if not, usually equal to cc, unimpressive, no?
?S: Some platforms, however, make good use of this by storing the
?S: flavor of the C compiler being used here. For example if using
?S: the Sun WorkShop suite, ccname will be 'workshop'.
?S:.
?S:ccversion:
?S: This can set either by hints files or by Configure. If using
?S: a (non-gcc) vendor cc, this variable may contain a version for
?S: the compiler.
?S:.
?F:./checkcc ./trygcc !checktmp
?V:despair
?T:trygcc
?LINT:extern cc rm ccflags ldflags
?LINT:change cc ccflags
?LINT:usefile checktmp
?INIT:ccname=''
?INIT:ccversion=''
: generate the trygcc script for later perusal
cat <<EOS >trygcc
$startsh
EOS
cat <<'EOSC' >>trygcc
case "$cc" in
'') ;;
*) $rm -f try try.*
$cat >try.c <<EOM
int main(int argc, char *argv[]) {
(void) argc;
(void) argv;
return 0;
}
EOM
if $cc -o try $ccflags $ldflags try.c; then
:
else
echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
despair=yes
trygcc=yes
case "$cc" in
*gcc*) trygcc=no ;;
esac
case "`$cc -v -c try.c 2>&1`" in
*gcc*) trygcc=no ;;
esac
if $test X"$trygcc" = Xyes; then
if gcc -o try -c try.c; then
echo " "
echo "You seem to have a working gcc, though." >&4
rp="Would you like to use it?"
dflt=y
if $test -f myread; then
. ./myread
else
if $test -f UU/myread; then
. ./UU/myread
else
echo "Cannot find myread, sorry. Aborting." >&2
exit 1
fi
fi
case "$ans" in
[yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no;
?X: Look whether we have 'call-back units' generated by hints that would
?X: seemingly affect the compiling environment.
$cat *.cbu >checktmp 2>/dev/null
if $contains ccflags checktmp >/dev/null; then
./warn 4>&4 <<EOM
Any previous setting of the C compiler flags has been lost.
It may be necessary to pass -Dcc=gcc to Configure right away.
EOM
fi;;
esac
fi
fi
fi
$rm -f try try.*
;;
esac
EOSC
: generate the checkcc script for later perusal
cat <<EOS >checkcc
$startsh
EOS
cat <<'EOSC' >>checkcc
case "$cc" in
'') ;;
*) $rm -f try try.*
$cat >try.c <<EOM
int main(int argc, char *argv[]) {
(void) argc;
(void) argv;
return 0;
}
EOM
if $cc -o try $ccflags $ldflags try.c; then
:
else
if $test X"$despair" = Xyes; then
echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
fi
$cat >&4 <<EOM
You need to find a working C compiler.
Either (purchase and) install the C compiler supplied by your OS vendor,
or for a free C compiler try http://gcc.gnu.org/
I cannot continue any further, aborting.
EOM
exit 1
fi
$rm -f try try.*
;;
esac
EOSC
|