1 ?RCS: $Id: Checkcc.U 1 2006-08-24 12:32:52Z rmanfredi $
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 4.0.
11 ?RCS: Copyright (c) 2000, Jarkko Hietaniemi
14 ?X: This unit produces a bit of shell code that must be dotted in order
15 ?X: to make quick check on whether the current C compiler is working.
17 ?MAKE:Checkcc ccname ccversion: Myread Warn startsh cat contains test
18 ?MAKE: -pick add $@ %<
20 ?S: This can set either by hints files or by Configure. If using
21 ?S: gcc, this is gcc, and if not, usually equal to cc, unimpressive, no?
22 ?S: Some platforms, however, make good use of this by storing the
23 ?S: flavor of the C compiler being used here. For example if using
24 ?S: the Sun WorkShop suite, ccname will be 'workshop'.
27 ?S: This can set either by hints files or by Configure. If using
28 ?S: a (non-gcc) vendor cc, this variable may contain a version for
31 ?F:./checkcc ./trygcc !checktmp
34 ?LINT:extern cc rm ccflags ldflags
35 ?LINT:change cc ccflags
36 ?LINT:usefile checktmp
39 : generate the trygcc script for later perusal
48 int main(int argc, char *argv[]) {
54 if $cc -o try $ccflags $ldflags try.c; then
57 echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
63 case "`$cc -v -c try.c 2>&1`" in
66 if $test X"$trygcc" = Xyes; then
67 if gcc -o try -c try.c; then
69 echo "You seem to have a working gcc, though." >&4
70 rp="Would you like to use it?"
72 if $test -f myread; then
75 if $test -f UU/myread; then
78 echo "Cannot find myread, sorry. Aborting." >&2
83 [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no;
84 ?X: Look whether we have 'call-back units' generated by hints that would
85 ?X: seemingly affect the compiling environment.
86 $cat *.cbu >checktmp 2>/dev/null
87 if $contains ccflags checktmp >/dev/null; then
89 Any previous setting of the C compiler flags has been lost.
90 It may be necessary to pass -Dcc=gcc to Configure right away.
102 : generate the checkcc script for later perusal
106 cat <<'EOSC' >>checkcc
111 int main(int argc, char *argv[]) {
117 if $cc -o try $ccflags $ldflags try.c; then
120 if $test X"$despair" = Xyes; then
121 echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
124 You need to find a working C compiler.
125 Either (purchase and) install the C compiler supplied by your OS vendor,
126 or for a free C compiler try http://gcc.gnu.org/
127 I cannot continue any further, aborting.