This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
899abb6ab3c01100eb85a9a44b7416e0a2819c6e
[metaconfig.git] / U / perl / gccvers.U
1 ?RCS: $Id$
2 ?RCS:
3 ?RCS: Copyright (c) 2000, Jarkko Hietaniemi
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 ?MAKE:gccversion gccosandvers: cat cpp rm +cc \
12         Mcc Myread Guess Options Oldconfig Loc osname osvers
13 ?MAKE:  -pick add $@ %<
14 ?S:gccversion:
15 ?S:     If GNU cc (gcc) is used, this variable holds '1' or '2' to 
16 ?S:     indicate whether the compiler is version 1 or 2.  This is used in
17 ?S:     setting some of the default cflags.  It is set to '' if not gcc.
18 ?S:.
19 ?S:gccosandvers:
20 ?S:     If GNU cc (gcc) is used, this variable the operating system and
21 ?S:     version used to compile the gcc.  It is set to '' if not gcc,
22 ?S:     or if nothing useful can be parsed as the os version.
23 ?S:.
24 ?T:gccshortvers
25 ?F:!gccvers
26 ?D:gccversion=''
27 ?LINT:change cpp
28 ?LINT:extern ldflags
29 ?LINT:extern ccname
30 ?LINT:change ccname
31 ?X: Check if they have gcc in any guise.  
32 echo " "
33 echo "Checking for GNU cc in disguise and/or its version number..." >&4
34 $cat >gccvers.c <<EOM
35 #include <stdio.h>
36 int main() {
37 #ifdef __GNUC__
38 #ifdef __VERSION__
39         printf("%s\n", __VERSION__);
40 #else
41         printf("%s\n", "1");
42 #endif
43 #endif
44         exit(0);
45 }
46 EOM
47 if $cc $ldflags -o gccvers gccvers.c; then
48         gccversion=`./gccvers`
49         case "$gccversion" in
50         '') echo "You are not using GNU cc." ;;
51         *)  echo "You are using GNU cc $gccversion."
52             ccname=gcc  
53             ;;
54         esac
55 else
56         echo " "
57         echo "*** WHOA THERE!!! ***" >&4
58         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
59 ?X: using -K will prevent aborting--maybe they're cross compiling?
60         case "$knowitall" in
61         '')
62         echo "    You'd better start hunting for one and let me know about it." >&4
63                 exit 1
64                 ;;
65         esac
66 fi
67 $rm -f gccvers*
68 case "$gccversion" in
69 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
70 esac
71 case "$gccversion" in
72 '') gccosandvers='' ;;
73 *) gccshortvers=`echo "$gccversion"|sed 's/ .*//'`
74    gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"`
75    gccshortvers=''
76    case "$gccosandvers" in
77    $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr
78    $osname$osvers) ;; # looking good
79    $osname*) cat <<EOM >&4
80
81 *** WHOA THERE!!! ***
82
83     Your gcc has not been compiled for the exact release of
84     your operating system ($gccosandvers versus $osname$osvers).
85
86     In general it is a good idea to keep gcc synchronized with
87     the operating system because otherwise serious problems
88     may ensue when trying to compile software, like Perl.
89
90     I'm trying to be optimistic here, though, and will continue.
91     If later during the configuration and build icky compilation
92     problems appear (headerfile conflicts being the most common
93     manifestation), I suggest reinstalling the gcc to match
94     your operating system release.
95
96 EOM
97       ;;
98    *) gccosandvers='' ;; # failed to parse, better be silent
99    esac
100    ;;
101 esac
102 case "$ccname" in
103 '') ccname="$cc" ;;
104 esac
105