This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
67e8a517dc63317711f96bcd14592f7c24d6a8a2
[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 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 : see if we need a special compiler
47 echo " "
48 if ./usg; then
49         case "$cc" in
50         '') case "$Mcc" in
51                 /*) dflt='Mcc';;
52                 *) case "$large" in
53                         -M*) dflt='cc';;
54                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
55                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
56                                                 dflt='cc'
57                                         else
58                                                 dflt='cc -M'
59                                         fi
60                                 else
61                                         dflt='cc'
62                                 fi;;
63                         esac;;
64                 esac;;
65         *)  dflt="$cc";;
66         esac
67 ?X: I've received sensible complaints about how this prompt.  It's
68 ?X: wordy, hard for the novice to check out, and almost never relevant.
69 ?X: I'll only include it if it looks like we need Mcc or cc -M, though
70 ?X: I have no idea if anyone ever needs them anymore.  --A.D.  2/1998.
71         case "$dflt" in
72         *M*)    $cat <<'EOM'
73 On some older systems the default C compiler will not resolve multiple global
74 references that happen to have the same name.  On some such systems the "Mcc"
75 command may be used to force these to be resolved.  On other systems a "cc -M"
76 command is required.  (Note that the -M flag on other systems indicates a
77 memory model to use!) If you have the Gnu C compiler, you might wish to use
78 that instead.
79
80 EOM
81         ;;
82         esac
83         rp="Use which C compiler?"
84         . ./myread
85         cc="$ans"
86 else
87         case "$cc" in
88         '') dflt=cc;;
89         *) dflt="$cc";;
90         esac
91         rp="Use which C compiler?"
92         . ./myread
93         cc="$ans"
94 fi
95 : Look for a hint-file generated 'call-back-unit'.  Now that the
96 : user has specified the compiler, we may need to set or change some
97 : other defaults.
98 if $test -f cc.cbu; then
99     . ./cc.cbu
100 fi
101 ?X: Check if they have gcc in any guise.  This is really only needed
102 ?X: if the user has version 1.x.x and needs -fpcc-struct-return.  Alas
103 ?X: BSD/386 ships a version of gcc 1.4.2 and calls it cc.  Hence the
104 ?X: paranoid test -- ADO.
105 echo " "
106 echo "Checking for GNU cc in disguise and/or its version number..." >&4
107 $cat >gccvers.c <<EOM
108 #include <stdio.h>
109 int main() {
110 #ifdef __GNUC__
111 #ifdef __VERSION__
112         printf("%s\n", __VERSION__);
113 #else
114         printf("%s\n", "1");
115 #endif
116 #endif
117         exit(0);
118 }
119 EOM
120 if $cc -o gccvers gccvers.c; then
121         gccversion=`./gccvers`
122         case "$gccversion" in
123         '') echo "You are not using GNU cc." ;;
124         *)  echo "You are using GNU cc $gccversion." ;;
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