Index: gcc.jam =================================================================== --- gcc.jam (revision 44702) +++ gcc.jam (working copy) @@ -72,15 +72,22 @@ import rc ; -# Initializes the gcc toolset for the given version. If necessary, command may +# Initializes the gcc toolset and gives it an identity. +# If necessary, command may # be used to specify where the compiler is located. The parameter 'options' is a # space-delimited list of options, each one specified as # option-value. Valid option names are: cxxflags, linkflags and # linker-type. Accepted linker-type values are gnu, darwin, osf, hpux or sun # and the default value will be selected based on the current OS. # Example: -# using gcc : 3.4 : : foo bar sun ; -rule init ( version ? : command * : options * ) +# using gcc : myid : : foo bar sun ; +# this will define a subfeature value myid which allows +# to specify the compiler by gcc-myid. +# Please note that the values for subfeatures and +# are automatically probed from the compiler. +# The version is from gcc -dumpversion, and flavor is from -dumpmachine with +# all "-" convertet to "_". +rule init ( identity ? : command * : options * ) { # Information about the gcc command... # The command. @@ -91,6 +98,9 @@ local bin ; # The flavor of compiler. local flavor = [ feature.get-values : $(options) ] ; + # The version of compiler. + local version ; + identity ?= autoconfig ; # Autodetect the root and bin dir if not given. if $(command) { @@ -103,16 +113,19 @@ # The 'command' variable can have multiple elements. When calling # the SHELL builtin we need a single string. local command-string = $(command:J=" ") ; - local machine = [ MATCH "^([^ ]+)" + local nl = " +" ; + local machine = [ MATCH "^([^ $(nl)]+)" : [ SHELL "$(command-string) -dumpmachine" ] ] ; - version ?= [ MATCH "^([0-9.]+)" + version = [ MATCH "^([0-9.]+)" : [ SHELL "$(command-string) -dumpversion" ] ] ; - switch $(machine:L) - { - case *mingw* : flavor ?= mingw ; - } + flavor ?= [ regex.replace $(machine) "-" "_" ] ; } + local requirement = + $(version) + $(flavor) ; + local condition ; if $(flavor) { @@ -120,12 +133,25 @@ : version $(version) : flavor $(flavor) ] ; + + # the identity subfeature is optional and must not be part of the + # condition, so declare it outside of chek-init-parameters + if ! $(.identity-declared) { + feature.subfeature toolset gcc : identity : : optional ; + .identity-declared = true ; + } + feature.extend-subfeature toolset gcc : identity : $(identity) ; + + # the generators are also conditioned on version and flavor + gcc_register $(requirement) ; + + # allow shorthand specification by identity to request correct + # compiler. + toolset.add-requirements $(identity):$(requirement) ; } else { - condition = [ common.check-init-parameters gcc - : version $(version) - ] ; + errors.user-error "Could not detect gcc variant." ; } common.handle-options gcc : $(condition) : $(command) : $(options) ; @@ -206,9 +232,14 @@ JAMSHELL = % ; } -generators.register-c-compiler gcc.compile.c++ : CPP : OBJ : gcc ; -generators.register-c-compiler gcc.compile.c : C : OBJ : gcc ; -generators.register-c-compiler gcc.compile.asm : ASM : OBJ : gcc ; +rule gcc_register ( requirement * ) { + generators.register-c-compiler gcc.compile.c++ : CPP : OBJ + : gcc $(requirement) ; + generators.register-c-compiler gcc.compile.c : C : OBJ + : gcc $(requirement) ; + generators.register-c-compiler gcc.compile.asm : ASM : OBJ + : gcc $(requirement) ; +} # pch support