?RCS: ?RCS: $Id$ ?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: rm cat test Myread startsh ?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:. ?T: trygcc despair ?F:./checkcc ?F:./trygcc ?INIT:ccname='' ?INIT:ccversion='' ?LINT:extern cc ?LINT:change cc ?LINT:extern ccflags ?LINT:change ccflags ?LINT:extern ccflags ?LINT:extern ldflags : Check what type of C compiler we use cat <trygcc $startsh EOS cat <<'EOSC' >>trygcc case "$cc" in '') ;; *) $rm -f try try.* $cat >try.c <&4 despair=yes trygcc=yes case "$cc" in *gcc*) trygcc=no ;; esac # Skip this test because it gives a false match on output like: # ./trygcc: line 23: cc: command not found # 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 # Switching compilers may undo the work of hints files. # The most common problem is -D_REENTRANT for threads. # This heuristic catches that case, but gets false positives # if -Dusethreads was not actually specified. Better to # bail out here with a useful message than fail # mysteriously later. Should we perhaps just try to # re-invoke Configure -Dcc=gcc config_args ? if $test -f usethreads.cbu; then $cat >&4 <&2 exit 1 fi fi case "$ans" in [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no; esac fi fi fi $rm -f try try.* ;; esac EOSC cat <checkcc $startsh EOS cat <<'EOSC' >>checkcc case "$cc" in '') ;; *) $rm -f try try.* $cat >try.c <&4 fi $cat >&4 <