This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Warn if the version of the operating system used to compile gcc
[metaconfig.git] / U / perl / gccvers.U
CommitLineData
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:
5fc71efb
KS
11?MAKE:gccversion gccosandvers: cat cpp rm +cc \
12 Mcc Myread Guess Options Oldconfig Loc osname osvers
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
21?S: version used to compile the gcc. It is set to '' if not gcc.
22?S:.
fd1a35d0
JH
23?F:!gccvers
24?D:gccversion=''
25?LINT:change cpp
26?LINT:extern ldflags
27?X: Check if they have gcc in any guise.
28echo " "
29echo "Checking for GNU cc in disguise and/or its version number..." >&4
30$cat >gccvers.c <<EOM
31#include <stdio.h>
32int main() {
33#ifdef __GNUC__
34#ifdef __VERSION__
35 printf("%s\n", __VERSION__);
36#else
37 printf("%s\n", "1");
38#endif
39#endif
40 exit(0);
41}
42EOM
43if $cc $ldflags -o gccvers gccvers.c; then
44 gccversion=`./gccvers`
45 case "$gccversion" in
46 '') echo "You are not using GNU cc." ;;
47 *) echo "You are using GNU cc $gccversion."
48 ;;
49 esac
50else
51 echo " "
52 echo "*** WHOA THERE!!! ***" >&4
53 echo " Your C compiler \"$cc\" doesn't seem to be working!" >&4
54?X: using -K will prevent aborting--maybe they're cross compiling?
55 case "$knowitall" in
56 '')
57 echo " You'd better start hunting for one and let me know about it." >&4
58 exit 1
59 ;;
60 esac
61fi
62$rm -f gccvers*
63case "$gccversion" in
641*) cpp=`./loc gcc-cpp $cpp $pth` ;;
65esac
5fc71efb
KS
66case "$gccversion" in
67'') gccosandvers='' ;;
68*) gccosandvers=`gcc -v 2>&1|grep '/specs$'|sed 's!.*/[^-]*-[^-]*-\([^/]*\)/'$gccversion'/specs$!\1!'`
69 case "$gccosandvers" in
70 $osname$osvers) ;;
71 $osname*) cat <<EOM >&4
72
73*** WHOA THERE!!! ***
74
75 Your gcc has not been compiled for the exact release of
76 your operating system ($gccosandvers versus $osname$osvers).
77
78 In general it is a good idea to keep gcc synchronized with
79 the operating system because otherwise serious problems
80 may ensue when trying to compile software, like Perl.
81
82 I'm trying to be optimistic here, though, and will continue.
83 If later during the configuration and build icky compilation
84 problems appear, I suggest reinstalling the gcc to match
85 your operating system release.
86
87EOM
88 ;;
89 *) ;; # failed to parse, better be silent
90 esac
91 ;;
92esac
93
94
95
fd1a35d0 96