Commit | Line | Data |
---|---|---|
fd1a35d0 JH |
1 | ?RCS: $Id$ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 2000, Jarkko Hietaniemi | |
5dcc3580 | 4 | ?RCS: |
65a32477 | 5 | ?RCS: You may redistribute only under the terms of the Artistic License, |
fd1a35d0 JH |
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 | |
65a32477 | 8 | ?RCS: that same Artistic License; a copy of which may be found at the root |
fd1a35d0 JH |
9 | ?RCS: of the source tree for dist 3.0. |
10 | ?RCS: | |
4087c32b | 11 | ?MAKE:gccversion gccosandvers gccansipedantic: cat cpp rm +cc \ |
9b04e79a | 12 | Myread Guess Options Oldconfig Loc osname osvers run |
fd1a35d0 JH |
13 | ?MAKE: -pick add $@ %< |
14 | ?S:gccversion: | |
5c7d75a6 | 15 | ?S: If GNU cc (gcc) is used, this variable holds '1' or '2' to |
fd1a35d0 JH |
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:. | |
5fc71efb | 19 | ?S:gccosandvers: |
4087c32b MB |
20 | ?S: If GNU cc (gcc) is used, this variable holds the operating system |
21 | ?S: and version used to compile gcc. It is set to '' if not gcc, | |
fcc4de7b | 22 | ?S: or if nothing useful can be parsed as the os version. |
5fc71efb | 23 | ?S:. |
4087c32b MB |
24 | ?S:gccansipedantic: |
25 | ?S: If GNU cc (gcc) is used, this variable will enable (if set) the | |
26 | ?S: -ansi and -pedantic ccflags for building core files (through | |
27 | ?S: cflags script). (See Porting/pumpkin.pod for full description). | |
28 | ?S:. | |
0065f4af MB |
29 | ?D:gccversion='' |
30 | ?D:gccansipedantic='' | |
559accf2 | 31 | ?T:gccshortvers |
b2fa012f | 32 | ?T:incdir |
bf7497fb | 33 | ?T:warn |
0065f4af | 34 | ?F:!try |
fd1a35d0 | 35 | ?LINT:change cpp |
77506990 | 36 | ?LINT:extern ccflags |
fd1a35d0 | 37 | ?LINT:extern ldflags |
b2fa012f | 38 | ?LINT:extern locincpth |
3bb42500 | 39 | ?LINT:extern ccname |
b2fa012f JH |
40 | ?LINT:change ccname |
41 | ?LINT:change locincpth | |
33d8b8ec | 42 | ?LINT:change ccflags |
c6d164da | 43 | ?LINT:set gccansipedantic |
5c7d75a6 | 44 | ?X: Check if they have gcc in any guise. |
0065f4af | 45 | : Check if we are using GNU gcc and what its version is |
fd1a35d0 JH |
46 | echo " " |
47 | echo "Checking for GNU cc in disguise and/or its version number..." >&4 | |
0f00356b | 48 | $cat >try.c <<EOM |
fd1a35d0 JH |
49 | #include <stdio.h> |
50 | int main() { | |
a9c4d48e | 51 | #if defined(__GNUC__) && !defined(__INTEL_COMPILER) |
fd1a35d0 JH |
52 | #ifdef __VERSION__ |
53 | printf("%s\n", __VERSION__); | |
54 | #else | |
55 | printf("%s\n", "1"); | |
56 | #endif | |
57 | #endif | |
a4ad2925 | 58 | return(0); |
fd1a35d0 JH |
59 | } |
60 | EOM | |
0f00356b JH |
61 | if $cc -o try $ccflags $ldflags try.c; then |
62 | gccversion=`$run ./try` | |
fd1a35d0 JH |
63 | case "$gccversion" in |
64 | '') echo "You are not using GNU cc." ;; | |
65 | *) echo "You are using GNU cc $gccversion." | |
5c7d75a6 | 66 | ccname=gcc |
fd1a35d0 JH |
67 | ;; |
68 | esac | |
69 | else | |
70 | echo " " | |
71 | echo "*** WHOA THERE!!! ***" >&4 | |
72 | echo " Your C compiler \"$cc\" doesn't seem to be working!" >&4 | |
73 | ?X: using -K will prevent aborting--maybe they're cross compiling? | |
74 | case "$knowitall" in | |
75 | '') | |
76 | echo " You'd better start hunting for one and let me know about it." >&4 | |
77 | exit 1 | |
78 | ;; | |
79 | esac | |
80 | fi | |
0f00356b | 81 | $rm -f try try.* |
fd1a35d0 JH |
82 | case "$gccversion" in |
83 | 1*) cpp=`./loc gcc-cpp $cpp $pth` ;; | |
84 | esac | |
5fc71efb KS |
85 | case "$gccversion" in |
86 | '') gccosandvers='' ;; | |
559accf2 JH |
87 | *) gccshortvers=`echo "$gccversion"|sed 's/ .*//'` |
88 | gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"` | |
89 | gccshortvers='' | |
5fc71efb | 90 | case "$gccosandvers" in |
fcc4de7b JH |
91 | $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr |
92 | $osname$osvers) ;; # looking good | |
5fc71efb KS |
93 | $osname*) cat <<EOM >&4 |
94 | ||
95 | *** WHOA THERE!!! *** | |
96 | ||
97 | Your gcc has not been compiled for the exact release of | |
98 | your operating system ($gccosandvers versus $osname$osvers). | |
99 | ||
100 | In general it is a good idea to keep gcc synchronized with | |
101 | the operating system because otherwise serious problems | |
102 | may ensue when trying to compile software, like Perl. | |
103 | ||
104 | I'm trying to be optimistic here, though, and will continue. | |
105 | If later during the configuration and build icky compilation | |
fcc4de7b JH |
106 | problems appear (headerfile conflicts being the most common |
107 | manifestation), I suggest reinstalling the gcc to match | |
5fc71efb KS |
108 | your operating system release. |
109 | ||
110 | EOM | |
111 | ;; | |
1c7fa146 | 112 | *) gccosandvers='' ;; # failed to parse, better be silent |
5fc71efb KS |
113 | esac |
114 | ;; | |
115 | esac | |
05c8895a JH |
116 | case "$ccname" in |
117 | '') ccname="$cc" ;; | |
118 | esac | |
fd1a35d0 | 119 | |
a7eb1db8 | 120 | # gcc 3.* complain about adding -Idirectories that they already know about, |
d6872425 JH |
121 | # so we will take those off from locincpth. |
122 | case "$gccversion" in | |
123 | 3*) | |
124 | echo "main(){}">try.c | |
a7eb1db8 MB |
125 | for incdir in $locincpth; do |
126 | warn=`$cc $ccflags -I$incdir -c try.c 2>&1 | \ | |
5c7d75a6 | 127 | grep '^c[cp]p*[01]: warning: changing search order '` |
a7eb1db8 MB |
128 | if test "X$warn" != X; then |
129 | locincpth=`echo " $locincpth " | sed "s! $incdir ! !"` | |
130 | fi | |
d6872425 JH |
131 | done |
132 | $rm -f try try.* | |
133 | esac | |
7ab230d2 | 134 | |
33d8b8ec MBT |
135 | # gcc 4.9 by default does some optimizations that break perl. |
136 | # see ticket 121505. | |
137 | # | |
138 | # The -fwrapv disables those optimizations (and probably others,) so | |
139 | # for gcc 4.9 (and later, since the optimizations probably won't go | |
140 | # away), add -fwrapv unless the user requests -fno-wrapv, which | |
141 | # disables -fwrapv, or if the user requests -fsanitize=undefined, | |
142 | # which turns the overflows -fwrapv ignores into runtime errors. | |
143 | case "$gccversion" in | |
72909a44 | 144 | 4.[3-9].*|4.[1-9][0-9]*|[5-9].*|[1-9][0-9]*) |
33d8b8ec MBT |
145 | case "$ccflags" in |
146 | *-fno-wrapv*|*-fsanitize=undefined*|*-fwrapv*) ;; | |
147 | *) ccflags="$ccflags -fwrapv" ;; | |
148 | esac | |
149 | esac | |
150 |