summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-03-10 11:38:38 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-03-10 11:38:38 +0000
commitd6dcfb28dc8671918489e9fb268bc36b1ca2a12f (patch)
tree598a1ca99b6bce4bd31e6bb6ada3e3459e8a8492
parent4fb5e74381515c01e164880e6023b08c40bb650a (diff)
downloadbuildsystem-d6dcfb28dc8671918489e9fb268bc36b1ca2a12f.tar.gz
buildsystem-d6dcfb28dc8671918489e9fb268bc36b1ca2a12f.tar.bz2
Make toolchain autodetection more robust.
svn path=/trunk/tools/buildsystem/; revision=10125
-rw-r--r--makefiles/Makefile.gcc24
-rw-r--r--makefiles/Makefile.tools36
2 files changed, 26 insertions, 34 deletions
diff --git a/makefiles/Makefile.gcc b/makefiles/Makefile.gcc
index fa2660b..3115889 100644
--- a/makefiles/Makefile.gcc
+++ b/makefiles/Makefile.gcc
@@ -62,20 +62,14 @@ endif
###############################################################################
# Determine if the compiler supports simultaneous build & dep.
-ccvsn := $(shell $(CC) --version)
-# "<binary name> (GCC) x.y.z (foo bar baz)"
-ifeq ($(word 2,$(ccvsn)),(GCC))
- # If the major version (x, above) is not 2, then assume build & dep.
- # This will break if using a version of GCC < 2, but that's unlikely.
- GCCVER := $(word 1,$(subst ., ,$(word 3, $(ccvsn))))
- ifneq ($(GCCVER),2)
- CC_CAN_BUILD_AND_DEP ?= yes
- endif
-else
- # Older versions of GCC just output the version number
- GCCVER := $(word 1,$(subst ., ,$(ccvsn)))
- ifneq ($(GCCVER),2)
- CC_CAN_BUILD_AND_DEP ?= yes
- endif
+ccvsn := $(shell $(CC) -dumpversion)
+# ccvsn = x.y.z
+GCCVER := $(word 1,$(subst ., ,$(ccvsn)))
+# GCCVER = x
+
+# If the major version (x, above) is not 2, then assume build & dep.
+# This will break if using a version of GCC < 2, but that's unlikely.
+ifneq ($(GCCVER),2)
+ CC_CAN_BUILD_AND_DEP ?= yes
endif
diff --git a/makefiles/Makefile.tools b/makefiles/Makefile.tools
index db5d7cb..72d6262 100644
--- a/makefiles/Makefile.tools
+++ b/makefiles/Makefile.tools
@@ -287,29 +287,27 @@ endif
# Auto-detect the toolchain
###############################################################################
+# Check for GCC first, as that's most likely
# TODO: Using shell redirection like this probably hurts portability
-ccvsn := $(shell $(CC) --version 2>&1)
-ifeq ($(ccvsn),)
- # Version string is blank
- ifeq ($(HOST),riscos)
- # For some reason we never see the output of SCL apps, so assume Norcroft.
- ccvsn := Norcroft
- endif
-endif
-
-# "<binary name> (GCC) x.y.z (foo bar baz)"
-ifeq ($(word 2,$(ccvsn)),(GCC))
+ccspecs := $(shell $(CC) -dumpspecs 2>&1)
+ifeq ($(findstring libgcc,$(ccspecs)),libgcc)
+ # Looks like GCC
toolchain := gcc
else
- # Older versions of GCC just output the version number, so examine the
- # binary name in the hope of detecting more GCC.
- ifeq ($(findstring gcc,$(CC)),gcc)
- toolchain := gcc
+ # Not GCC, so enquire further
+ ccvsn := $(shell $(CC) --version 2>&1)
+ ifeq ($(ccvsn),)
+ # Version string is blank
+ ifeq ($(HOST),riscos)
+ # For some reason we never see the output of SCL apps, so assume Norcroft.
+ ccvsn := Norcroft
+ endif
+ endif
+
+ # "Norcroft ..."
+ ifeq ($(word 1,$(ccvsn)),Norcroft)
+ toolchain := norcroft
endif
-endif
-# "Norcroft ..."
-ifeq ($(word 1,$(ccvsn)),Norcroft)
- toolchain := norcroft
endif
ifeq ($(toolchain),)