summaryrefslogtreecommitdiff
path: root/U/cc.U
blob: 04950176c0575d359f5ce441a005ee79e36cd928 (plain)
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
?RCS: $Id: cc.U,v 3.0 1993/08/18 12:05:30 ram Exp $
?RCS:
?RCS: Copyright (c) 1991-1993, Raphael Manfredi
?RCS: 
?RCS: You may redistribute only under the terms of the Artistic Licence,
?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 Licence; a copy of which may be found at the root
?RCS: of the source tree for dist 3.0.
?RCS:
?RCS: $Log: cc.U,v $
?RCS: Revision 3.0  1993/08/18  12:05:30  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:gccversion cc: cat contains sysman +large cpp rm test \
	Mcc Myread Guess Oldconfig Loc
?MAKE:	-pick add $@ %<
?S:cc:
?S:	This variable holds the name of a command to execute a C compiler which
?S:	can resolve multiple global references that happen to have the same
?S:	name.  Usual values are "cc", "Mcc", "cc -M", and "gcc".
?S:.
?S:gccversion:
?S:	If GNU cc (gcc) is used, this variable holds '1' or '2' to 
?S:	indicate whether the compiler is version 1 or 2.  This is used in
?S:	setting some of the default cflags.
?S:.
?D:cc='cc'
?INIT:gccversion=''
?LINT:change cpp
: see if we need a special compiler
echo " "
if usg; then
	case "$cc" in
	'') case "$Mcc" in
		/*) dflt='Mcc';;
		*) case "$large" in
			-M*) dflt='cc';;
			*)	if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
					if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
						dflt='cc'
					else
						dflt='cc -M'
					fi
				else
					dflt='cc'
				fi;;
			esac;;
		esac;;
	*)  dflt="$cc";;
	esac
	$cat <<'EOM'
On some systems the default C compiler will not resolve multiple global
references that happen to have the same name.  On some such systems the "Mcc"
command may be used to force these to be resolved.  On other systems a "cc -M"
command is required.  (Note that the -M flag on other systems indicates a
memory model to use!) If you have the Gnu C compiler, you might wish to use
that instead.

EOM
	rp="What command will force resolution on this system?"
	. ./myread
	cc="$ans"
else
	case "$cc" in
	'') dflt=cc;;
	*) dflt="$cc";;
	esac
	rp="Use which C compiler?"
	. ./myread
	cc="$ans"
fi
case "$cc" in
gcc*)   echo "Checking out which version of gcc"
$cat >gccvers.c <<EOM
#include <stdio.h>
int main()
{
char *v;
v = "unknown";
#ifdef __GNUC__
#  ifdef __VERSION__
	v = __VERSION__;
#  endif
#endif
switch((int) v[0])
  {
    case '1':  printf("1\n"); break;
    case '2':  printf("2\n"); break;
    case '3':  printf("3\n"); break;
    default:   break;
  }
#ifdef __GNUC__
return 0;
#else
return 1;
#endif
}
EOM
	if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
	    gccversion=`./gccvers`
		echo "You appear to have version $gccversion."
	else
		echo "Doesn't appear to be GNU cc."
	fi
	$rm -f gccvers*
	if $test "$gccversion" = '1'; then
		cpp=`./loc gcc-cpp $cpp $pth`
	fi
	;;
esac