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