Commit | Line | Data |
---|---|---|
fd1a35d0 JH |
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: | |
4087c32b | 11 | ?MAKE:gccversion gccosandvers gccansipedantic: cat cpp rm +cc \ |
0f00356b | 12 | Mcc 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:. | |
559accf2 | 29 | ?T:gccshortvers |
b2fa012f | 30 | ?T:incdir |
bf7497fb | 31 | ?T:warn |
fd1a35d0 | 32 | ?D:gccversion='' |
4087c32b | 33 | ?D:gccansipedantic='' |
fd1a35d0 | 34 | ?LINT:change cpp |
77506990 | 35 | ?LINT:extern ccflags |
fd1a35d0 | 36 | ?LINT:extern ldflags |
b2fa012f | 37 | ?LINT:extern locincpth |
3bb42500 | 38 | ?LINT:extern ccname |
7ab230d2 | 39 | ?LINT:change ccflags |
b2fa012f JH |
40 | ?LINT:change ccname |
41 | ?LINT:change locincpth | |
5c7d75a6 | 42 | ?X: Check if they have gcc in any guise. |
fd1a35d0 JH |
43 | echo " " |
44 | echo "Checking for GNU cc in disguise and/or its version number..." >&4 | |
0f00356b | 45 | $cat >try.c <<EOM |
fd1a35d0 JH |
46 | #include <stdio.h> |
47 | int main() { | |
48 | #ifdef __GNUC__ | |
49 | #ifdef __VERSION__ | |
50 | printf("%s\n", __VERSION__); | |
51 | #else | |
52 | printf("%s\n", "1"); | |
53 | #endif | |
54 | #endif | |
a4ad2925 | 55 | return(0); |
fd1a35d0 JH |
56 | } |
57 | EOM | |
0f00356b JH |
58 | if $cc -o try $ccflags $ldflags try.c; then |
59 | gccversion=`$run ./try` | |
fd1a35d0 JH |
60 | case "$gccversion" in |
61 | '') echo "You are not using GNU cc." ;; | |
62 | *) echo "You are using GNU cc $gccversion." | |
5c7d75a6 | 63 | ccname=gcc |
fd1a35d0 JH |
64 | ;; |
65 | esac | |
66 | else | |
67 | echo " " | |
68 | echo "*** WHOA THERE!!! ***" >&4 | |
69 | echo " Your C compiler \"$cc\" doesn't seem to be working!" >&4 | |
70 | ?X: using -K will prevent aborting--maybe they're cross compiling? | |
71 | case "$knowitall" in | |
72 | '') | |
73 | echo " You'd better start hunting for one and let me know about it." >&4 | |
74 | exit 1 | |
75 | ;; | |
76 | esac | |
77 | fi | |
0f00356b | 78 | $rm -f try try.* |
fd1a35d0 JH |
79 | case "$gccversion" in |
80 | 1*) cpp=`./loc gcc-cpp $cpp $pth` ;; | |
81 | esac | |
5fc71efb KS |
82 | case "$gccversion" in |
83 | '') gccosandvers='' ;; | |
559accf2 JH |
84 | *) gccshortvers=`echo "$gccversion"|sed 's/ .*//'` |
85 | gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"` | |
86 | gccshortvers='' | |
c8036083 MB |
87 | ?X: -pipe has shown a compile time speedup of about 40% on Linux and HP-UX |
88 | ?X: and also worked on cygwin-1.5.9 | |
89 | ?X: If a system fails, disable it in the hints. 99% of gcc uses binutils | |
90 | ccflags="$ccflags -pipe" | |
5fc71efb | 91 | case "$gccosandvers" in |
fcc4de7b JH |
92 | $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr |
93 | $osname$osvers) ;; # looking good | |
5fc71efb KS |
94 | $osname*) cat <<EOM >&4 |
95 | ||
96 | *** WHOA THERE!!! *** | |
97 | ||
98 | Your gcc has not been compiled for the exact release of | |
99 | your operating system ($gccosandvers versus $osname$osvers). | |
100 | ||
101 | In general it is a good idea to keep gcc synchronized with | |
102 | the operating system because otherwise serious problems | |
103 | may ensue when trying to compile software, like Perl. | |
104 | ||
105 | I'm trying to be optimistic here, though, and will continue. | |
106 | If later during the configuration and build icky compilation | |
fcc4de7b JH |
107 | problems appear (headerfile conflicts being the most common |
108 | manifestation), I suggest reinstalling the gcc to match | |
5fc71efb KS |
109 | your operating system release. |
110 | ||
111 | EOM | |
112 | ;; | |
1c7fa146 | 113 | *) gccosandvers='' ;; # failed to parse, better be silent |
5fc71efb KS |
114 | esac |
115 | ;; | |
116 | esac | |
05c8895a JH |
117 | case "$ccname" in |
118 | '') ccname="$cc" ;; | |
119 | esac | |
fd1a35d0 | 120 | |
a7eb1db8 | 121 | # gcc 3.* complain about adding -Idirectories that they already know about, |
d6872425 JH |
122 | # so we will take those off from locincpth. |
123 | case "$gccversion" in | |
124 | 3*) | |
125 | echo "main(){}">try.c | |
a7eb1db8 MB |
126 | for incdir in $locincpth; do |
127 | warn=`$cc $ccflags -I$incdir -c try.c 2>&1 | \ | |
5c7d75a6 | 128 | grep '^c[cp]p*[01]: warning: changing search order '` |
a7eb1db8 MB |
129 | if test "X$warn" != X; then |
130 | locincpth=`echo " $locincpth " | sed "s! $incdir ! !"` | |
131 | fi | |
d6872425 JH |
132 | done |
133 | $rm -f try try.* | |
134 | esac | |
7ab230d2 | 135 |