summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcbiere <cbiere@190e5f8e-a817-0410-acf6-e9863daed9af>2008-06-16 18:04:21 +0000
committercbiere <cbiere@190e5f8e-a817-0410-acf6-e9863daed9af>2008-06-16 18:04:21 +0000
commitaf7bc4ecc072dbf42b75d4a7e8ecef0e98b26753 (patch)
tree8c53265ae9cf0c783648f861033ed973f17b2701
parent79fab6248ca41f49afd4ece6b23a48b4d873352a (diff)
* Use the preprocessor output to detect the GCC version instead of executing
the compiled binary which is unsuitable for cross-compiling. git-svn-id: https://dist.svn.sourceforge.net/svnroot/dist/trunk/dist@28 190e5f8e-a817-0410-acf6-e9863daed9af
-rw-r--r--mcon/U/gccvers.U32
1 files changed, 12 insertions, 20 deletions
diff --git a/mcon/U/gccvers.U b/mcon/U/gccvers.U
index b7b42fa..6d05184 100644
--- a/mcon/U/gccvers.U
+++ b/mcon/U/gccvers.U
@@ -11,7 +11,7 @@
?RCS: Copyright (c) 2000, Jarkko Hietaniemi
?RCS:
?MAKE:gccversion gccosandvers: cat cpp rm +cc \
- Myread Guess Options Oldconfig Loc osname osvers grep run ccname
+ Myread Guess Options Oldconfig Loc osname osvers grep ccname
?MAKE: -pick add $@ %<
?S:gccversion:
?S: If GNU cc (gcc) is used, this variable holds '1' or '3' (for instance)
@@ -31,20 +31,21 @@
echo " "
echo "Checking for GNU cc in disguise and/or its version number..." >&4
$cat >try.c <<EOM
-#include <stdio.h>
-int main() {
+int main(void) {
#ifdef __GNUC__
-#ifdef __VERSION__
- printf("%s\n", __VERSION__);
-#else
- printf("%s\n", "1");
+gcc_version_major __GNUC__
+#ifdef __GNUC_MINOR__
+gcc_version_minor __GNUC__
+#endif
+#ifdef __GNUC_PATCHLEVEL__
+gcc_version_patchlevel __GNUC_PATCHLEVEL__
#endif
#endif
- exit(0);
}
EOM
-if $cc -o try $ccflags $ldflags try.c >/dev/null 2>&1; then
- gccversion=`$run ./try`
+if $cc -E try.c > try 2>&1
+then
+ gccversion=`sed -n 's/^gcc_version_major[^0-9]*//p' try`
case "$gccversion" in
'') echo "You are not using GNU cc." ;;
*) echo "You are using GNU cc $gccversion."
@@ -52,16 +53,7 @@ if $cc -o try $ccflags $ldflags try.c >/dev/null 2>&1; then
;;
esac
else
- echo " "
- echo "*** WHOA THERE!!! ***" >&4
- echo " Your C compiler \"$cc\" doesn't seem to be working!" >&4
-?X: using -K will prevent aborting--maybe they're cross compiling?
- case "$knowitall" in
- '')
- echo " You'd better start hunting for one and let me know about it." >&4
- exit 1
- ;;
- esac
+ gccversion=''
fi
$rm -f try try.*
case "$gccversion" in