This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
IRIX 64-bitness fixes.
[metaconfig.git] / U / modified / cc.U
1 ?RCS: $Id: cc.U,v 3.0.1.4 1995/05/12 12:06:47 ram Exp $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4 ?RCS: 
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 3.0.
10 ?RCS:
11 ?RCS: $Log: cc.U,v $
12 ?RCS: Revision 3.0.1.4  1995/05/12  12:06:47  ram
13 ?RCS: patch54: may now abort Configure when cc does not work
14 ?RCS:
15 ?RCS: Revision 3.0.1.3  1995/01/11  15:20:11  ram
16 ?RCS: patch45: changed gcc checking message to a more explicit one (WED)
17 ?RCS:
18 ?RCS: Revision 3.0.1.2  1994/10/29  16:04:29  ram
19 ?RCS: patch36: detect gcc even when not called as 'gcc' (ADO)
20 ?RCS: patch36: simplified gcc version checking (ADO)
21 ?RCS: patch36: added ?F: line for metalint file checking
22 ?RCS:
23 ?RCS: Revision 3.0.1.1  1994/05/06  14:26:06  ram
24 ?RCS: patch23: added support for gcc version (ADO)
25 ?RCS:
26 ?RCS: Revision 3.0  1993/08/18  12:05:30  ram
27 ?RCS: Baseline for dist 3.0 netwide release.
28 ?RCS:
29 ?MAKE:cc gccversion: cat contains sysman +large cpp ccflags rm \
30         Mcc Myread Guess Options Oldconfig Loc test
31 ?MAKE:  -pick add $@ %<
32 ?S:cc:
33 ?S:     This variable holds the name of a command to execute a C compiler which
34 ?S:     can resolve multiple global references that happen to have the same
35 ?S:     name.  Usual values are 'cc', 'Mcc', 'cc -M', and 'gcc'.
36 ?S:.
37 ?S:gccversion:
38 ?S:     If GNU cc (gcc) is used, this variable holds '1' or '2' to 
39 ?S:     indicate whether the compiler is version 1 or 2.  This is used in
40 ?S:     setting some of the default cflags.  It is set to '' if not gcc.
41 ?S:.
42 ?F:!gccvers !cc.cbu
43 ?D:cc='cc'
44 ?D:gccversion=''
45 ?LINT:change cpp
46 ?LINT:change ccflags
47 ?LINT:extern ldflags
48 : see if we need a special compiler
49 echo " "
50 if ./usg; then
51         case "$cc" in
52         '') case "$Mcc" in
53                 /*) dflt='Mcc';;
54                 *) case "$large" in
55                         -M*) dflt='cc';;
56                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
57                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
58                                                 dflt='cc'
59                                         else
60                                                 dflt='cc -M'
61                                         fi
62                                 else
63                                         dflt='cc'
64                                 fi;;
65                         esac;;
66                 esac;;
67         *)  dflt="$cc";;
68         esac
69 ?X: I've received sensible complaints about how this prompt.  It's
70 ?X: wordy, hard for the novice to check out, and almost never relevant.
71 ?X: I'll only include it if it looks like we need Mcc or cc -M, though
72 ?X: I have no idea if anyone ever needs them anymore.  --A.D.  2/1998.
73         case "$dflt" in
74         *M*)    $cat <<'EOM'
75 On some older systems the default C compiler will not resolve multiple global
76 references that happen to have the same name.  On some such systems the "Mcc"
77 command may be used to force these to be resolved.  On other systems a "cc -M"
78 command is required.  (Note that the -M flag on other systems indicates a
79 memory model to use!) If you have the Gnu C compiler, you might wish to use
80 that instead.
81
82 EOM
83         ;;
84         esac
85         rp="Use which C compiler?"
86         . ./myread
87         cc="$ans"
88 else
89         case "$cc" in
90         '') dflt=cc;;
91         *) dflt="$cc";;
92         esac
93         rp="Use which C compiler?"
94         . ./myread
95         cc="$ans"
96 fi
97 : Look for a hint-file generated 'call-back-unit'.  Now that the
98 : user has specified the compiler, we may need to set or change some
99 : other defaults.
100 if $test -f cc.cbu; then
101     . ./cc.cbu
102 fi
103 ?X: Check if they have gcc in any guise.  
104 echo " "
105 echo "Checking for GNU cc in disguise and/or its version number..." >&4
106 $cat >gccvers.c <<EOM
107 #include <stdio.h>
108 int main() {
109 #ifdef __GNUC__
110 #ifdef __VERSION__
111         printf("%s\n", __VERSION__);
112 #else
113         printf("%s\n", "1");
114 #endif
115 #endif
116         exit(0);
117 }
118 EOM
119 if $cc $ldflags -o gccvers gccvers.c; then
120         gccversion=`./gccvers`
121         case "$gccversion" in
122         '') echo "You are not using GNU cc." ;;
123         *)  echo "You are using GNU cc $gccversion."
124             ;;
125         esac
126 else
127         echo " "
128         echo "*** WHOA THERE!!! ***" >&4
129         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
130 ?X: using -K will prevent aborting--maybe they're cross compiling?
131         case "$knowitall" in
132         '')
133         echo "    You'd better start hunting for one and let me know about it." >&4
134                 exit 1
135                 ;;
136         esac
137 fi
138 $rm -f gccvers*
139 case "$gccversion" in
140 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
141 esac
142