summaryrefslogtreecommitdiff
path: root/mcon/U/Checkcc.U
diff options
context:
space:
mode:
Diffstat (limited to 'mcon/U/Checkcc.U')
-rw-r--r--mcon/U/Checkcc.U135
1 files changed, 135 insertions, 0 deletions
diff --git a/mcon/U/Checkcc.U b/mcon/U/Checkcc.U
new file mode 100644
index 0000000..3cae05c
--- /dev/null
+++ b/mcon/U/Checkcc.U
@@ -0,0 +1,135 @@
+?RCS: $Id$
+?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
+