This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Configure maintenance. Sever some dependency cycles,
[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: 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:     Fervent ANSI compilers may be called 'c89'.
37 ?S:     AIX has xlc.
38 ?S:.
39 ?T:despair
40 ?T:trygcc
41 ?F:!cc.cbu
42 ?D:cc='cc'
43 ?LINT:change cpp
44 ?LINT:extern ldflags
45 : see if we need a special compiler
46 echo " "
47 if ./usg; then
48         case "$cc" in
49         '') case "$Mcc" in
50                 /*) dflt='Mcc';;
51                 *) case "$large" in
52                         -M*) dflt='cc';;
53                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
54                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
55                                                 dflt='cc'
56                                         else
57                                                 dflt='cc -M'
58                                         fi
59                                 else
60                                         dflt='cc'
61                                 fi;;
62                         esac;;
63                 esac;;
64         *)  dflt="$cc";;
65         esac
66 ?X: I've received sensible complaints about how this prompt.  It's
67 ?X: wordy, hard for the novice to check out, and almost never relevant.
68 ?X: I'll only include it if it looks like we need Mcc or cc -M, though
69 ?X: I have no idea if anyone ever needs them anymore.  --A.D.  2/1998.
70         case "$dflt" in
71         *M*)    $cat <<'EOM'
72 On some older systems the default C compiler will not resolve multiple global
73 references that happen to have the same name.  On some such systems the "Mcc"
74 command may be used to force these to be resolved.  On other systems a "cc -M"
75 command is required.  (Note that the -M flag on other systems indicates a
76 memory model to use!) If you have the Gnu C compiler, you might wish to use
77 that instead.
78
79 EOM
80         ;;
81         esac
82         rp="Use which C compiler?"
83         . ./myread
84         cc="$ans"
85 else
86         case "$cc" in
87         '') dflt=cc;;
88         *) dflt="$cc";;
89         esac
90         rp="Use which C compiler?"
91         . ./myread
92         cc="$ans"
93 fi
94 : Look for a hint-file generated 'call-back-unit'.  Now that the
95 : user has specified the compiler, we may need to set or change some
96 : other defaults.
97 if $test -f cc.cbu; then
98     . ./cc.cbu
99 fi
100 : Quick sanity check, we will do a fuller one later when we know
101 : the various flags and libs
102 $rm -f try try.*
103 $cat >try.c <<EOM
104 int main(int argc, char *argv[]) {
105   return 0;
106 }
107 EOM
108 if $cc -o try try.c; then
109    :
110 else
111    echo "Uh-oh, the C compiler "$cc" doesn't seem to be working..." >&4
112    despair=yes
113    trygcc=yes
114    case "$cc" in
115    *gcc) trygcc=no ;;
116    esac
117    case "`$cc -v 2>&1`" in
118    *gcc*) trygcc=no ;;
119    esac
120    if $test X"$trygcc" = Xyes; then
121       if gcc -o try try.c; then
122         echo " "
123         echo "You seem to have a working gcc, though."
124         rp="Do you want to use it?"
125         dflt=y
126         . ./myread
127         case "$ans" in
128         [yY]*) cc=gcc; despair=no ;;
129         esac
130       fi
131    fi
132    if $test X"$despair" = Xyes; then
133       echo "You need to find a working C compiler." >&4
134       echo "I cannot continue any further, aborting." >&4
135       exit 1
136    fi
137 fi
138 $rm -f try try.*
139
140