This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / gccvers.U
CommitLineData
d8875586
MBT
1?RCS: $Id: gccvers.U 13 2006-08-28 16:48:29Z rmanfredi $
2?RCS:
3?RCS: Copyright (c) 1991-1997, 2004-2006, 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 4.0.
10?RCS:
11?RCS: Copyright (c) 2000, Jarkko Hietaniemi
12?RCS:
13?MAKE:gccversion gccosandvers: cat cpp rm +cc \
14 Myread Guess Options Oldconfig Loc osname osvers grep run ccname
15?MAKE: -pick add $@ %<
16?S:gccversion:
17?S: If GNU cc (gcc) is used, this variable holds '1' or '3' (for instance)
18?S: to indicate whether the compiler is version 1 or 3. This is used in
19?S: setting some of the default cflags. It is set to '' if not gcc.
20?S:.
21?S:gccosandvers:
22?S: If GNU cc (gcc) is used, this variable the operating system and
23?S: version used to compile the gcc. It is set to '' if not gcc,
24?S: or if nothing useful can be parsed as the os version.
25?S:.
26?T:gccshortvers incdir d
27?F:!try.c !try
28?LINT:extern locincpth ccflags ldflags
29?LINT:change locincpth ccname cpp
30: Check whether they have gcc in any guise.
31echo " "
32echo "Checking for GNU cc in disguise and/or its version number..." >&4
33$cat >try.c <<EOM
34#include <stdio.h>
35int main() {
36#ifdef __GNUC__
37#ifdef __VERSION__
38 printf("%s\n", __VERSION__);
39#else
40 printf("%s\n", "1");
41#endif
42#endif
43 exit(0);
44}
45EOM
46if $cc -o try $ccflags $ldflags try.c >/dev/null 2>&1; then
47 gccversion=`$run ./try`
48 case "$gccversion" in
49 '') echo "You are not using GNU cc." ;;
50 *) echo "You are using GNU cc $gccversion."
51 ccname=gcc
52 ;;
53 esac
54else
55 echo " "
56 echo "*** WHOA THERE!!! ***" >&4
57 echo " Your C compiler \"$cc\" doesn't seem to be working!" >&4
58?X: using -K will prevent aborting--maybe they're cross compiling?
59 case "$knowitall" in
60 '')
61 echo " You'd better start hunting for one and let me know about it." >&4
62 exit 1
63 ;;
64 esac
65fi
66$rm -f try try.*
67case "$gccversion" in
681*) cpp=`./loc gcc-cpp $cpp $pth` ;;
69esac
70case "$gccversion" in
71'') gccosandvers='' ;;
72*) gccshortvers=`echo "$gccversion"|sed 's/ .*//'`
73 gccosandvers=`$cc -v 2>&1 | \
74 $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
96EOM
97 ;;
98 *) gccosandvers='' ;; # failed to parse, better be silent
99 esac
100 ;;
101esac
102case "$ccname" in
103'') ccname="$cc" ;;
104esac
105
106: gcc 3.1 complains about adding -Idirectories that it already knows about,
107: so we will take those off from locincpth.
108case "$gccversion" in
1093*)
110 echo "main(){}">try.c
111 for incdir in `$cc -v -c try.c 2>&1 | \
112 sed '1,/^#include <\.\.\.>/d;/^End of search list/,$d;s/^ //'` ; do
113 locincpth=`echo $locincpth | sed s!$incdir!!`
114 done
115 $rm -f try try.*
116esac
117