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