| 1 | # Copyright 2003 Christopher Currie
|
|---|
| 2 | # Copyright 2006 Dave Abrahams
|
|---|
| 3 | # Copyright 2003, 2004, 2005, 2006 Vladimir Prus
|
|---|
| 4 | # Copyright 2005-2007 Mat Marcus
|
|---|
| 5 | # Copyright 2005-2007 Adobe Systems Incorporated
|
|---|
| 6 | # Copyright 2007-2010 Rene Rivera
|
|---|
| 7 | # Distributed under the Boost Software License, Version 1.0.
|
|---|
| 8 | # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
|---|
| 9 |
|
|---|
| 10 | # Please see http://article.gmane.org/gmane.comp.lib.boost.build/3389/
|
|---|
| 11 | # for explanation why it's a separate toolset.
|
|---|
| 12 |
|
|---|
| 13 | import "class" : new ;
|
|---|
| 14 | import feature : feature ;
|
|---|
| 15 | import toolset : flags ;
|
|---|
| 16 | import type ;
|
|---|
| 17 | import common ;
|
|---|
| 18 | import generators ;
|
|---|
| 19 | import path : basename ;
|
|---|
| 20 | import version ;
|
|---|
| 21 | import property-set ;
|
|---|
| 22 | import regex ;
|
|---|
| 23 | import errors ;
|
|---|
| 24 |
|
|---|
| 25 | #############################################################################
|
|---|
| 26 |
|
|---|
| 27 | if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
|
|---|
| 28 | {
|
|---|
| 29 | .debug-configuration = true ;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | feature.extend toolset : mingw ;
|
|---|
| 33 | import gcc ;
|
|---|
| 34 | toolset.inherit-generators mingw : gcc : gcc.mingw.link gcc.mingw.link.dll ;
|
|---|
| 35 | toolset.inherit-flags mingw : gcc ;
|
|---|
| 36 | toolset.inherit-rules mingw : gcc ;
|
|---|
| 37 |
|
|---|
| 38 | generators.override mingw.prebuilt : builtin.prebuilt ;
|
|---|
| 39 | generators.override mingw.searched-lib-generator : searched-lib-generator ;
|
|---|
| 40 |
|
|---|
| 41 | # Override generators.
|
|---|
| 42 | generators.override mingw.compile.c.pch : pch.default-c-pch-generator ;
|
|---|
| 43 | generators.override mingw.compile.c++.pch : pch.default-cpp-pch-generator ;
|
|---|
| 44 |
|
|---|
| 45 | generators.register-c-compiler gcc.compile.c++.preprocess : CPP : PREPROCESSED_CPP : <toolset>mingw ;
|
|---|
| 46 | generators.register-c-compiler gcc.compile.c.preprocess : C : PREPROCESSED_C : <toolset>mingw ;
|
|---|
| 47 | generators.register-c-compiler gcc.compile.c++ : CPP : OBJ : <toolset>mingw ;
|
|---|
| 48 | generators.register-c-compiler gcc.compile.c : C : OBJ : <toolset>mingw ;
|
|---|
| 49 | generators.register-c-compiler gcc.compile.asm : ASM : OBJ : <toolset>mingw ;
|
|---|
| 50 | generators.register-fortran-compiler gcc.compile.fortran : FORTRAN FORTRAN90 : OBJ : <toolset>mingw ;
|
|---|
| 51 |
|
|---|
| 52 | generators.override mingw.compile.c++.preprocess : gcc.compile.c++.preprocess ;
|
|---|
| 53 | generators.override mingw.compile.c.preprocess : gcc.compile.c.preprocess ;
|
|---|
| 54 | generators.override mingw.compile.c++ : gcc.compile.c++ ;
|
|---|
| 55 | generators.override mingw.compile.c : gcc.compile.c ;
|
|---|
| 56 | generators.override mingw.compile.asm : gcc.compile.asm ;
|
|---|
| 57 | generators.override mingw.compile.fortran : gcc.compile.fortran ;
|
|---|
| 58 |
|
|---|
| 59 | # Initializes the mingw toolset for the given version. If necessary, command may
|
|---|
| 60 | # be used to specify where the compiler is located. The parameter 'options' is a
|
|---|
| 61 | # space-delimited list of options, each one specified as
|
|---|
| 62 | # <option-name>option-value. Valid option names are: cxxflags, linkflags and
|
|---|
| 63 | # linker-type. Accepted linker-type values are aix, darwin, gnu, hpux, osf or
|
|---|
| 64 | # sun and the default value will be selected based on the current OS.
|
|---|
| 65 | rule init ( version ? : command * : options * : requirement * )
|
|---|
| 66 | {
|
|---|
| 67 | #1): use user-provided command
|
|---|
| 68 | local tool-command = ;
|
|---|
| 69 | if $(command)
|
|---|
| 70 | {
|
|---|
| 71 | tool-command = [ common.get-invocation-command-nodefault gcc : g++ : $(command) ] ;
|
|---|
| 72 | if ! $(tool-command)
|
|---|
| 73 | {
|
|---|
| 74 | errors.error "toolset gcc initialization:" :
|
|---|
| 75 | "provided command '$(command)' not found" :
|
|---|
| 76 | "initialized from" [ errors.nearest-user-location ] ;
|
|---|
| 77 | }
|
|---|
| 78 | }
|
|---|
| 79 | #2): enforce user-provided version
|
|---|
| 80 | else if $(version)
|
|---|
| 81 | {
|
|---|
| 82 | tool-command = [ common.get-invocation-command-nodefault gcc : "g++-$(version[1])" ] ;
|
|---|
| 83 |
|
|---|
| 84 | #2.1) fallback: check whether "g++" reports the requested version
|
|---|
| 85 | if ! $(tool-command)
|
|---|
| 86 | {
|
|---|
| 87 | tool-command = [ common.get-invocation-command-nodefault gcc : g++ ] ;
|
|---|
| 88 | if $(tool-command)
|
|---|
| 89 | {
|
|---|
| 90 | local tool-command-string = $(tool-command:J=" ") ;
|
|---|
| 91 | local tool-version = [ MATCH "^([0-9.]+)" : [ SHELL "$(tool-command-string) -dumpversion" ] ] ;
|
|---|
| 92 | if $(tool-version) != $(version)
|
|---|
| 93 | {
|
|---|
| 94 | # Permit a match betwen two-digit version specified by the user
|
|---|
| 95 | # (e.g. 4.4) and 3-digit version reported by gcc.
|
|---|
| 96 | # Since only two digits are present in binary name anyway,
|
|---|
| 97 | # insisting that user specify 3-digit version when
|
|---|
| 98 | # configuring Boost.Build while it's not required on
|
|---|
| 99 | # command like would be strange.
|
|---|
| 100 | local stripped = [ MATCH "^([0-9]+\.[0-9]+).*" : $(tool-version) ] ;
|
|---|
| 101 | if $(stripped) != $(version)
|
|---|
| 102 | {
|
|---|
| 103 | errors.error "toolset gcc initialization:" :
|
|---|
| 104 | "version '$(version)' requested but 'g++-$(version)' not found and version '$(tool-version)' of default '$(tool-command)' does not match" :
|
|---|
| 105 | "initialized from" [ errors.nearest-user-location ] ;
|
|---|
| 106 | tool-command = ;
|
|---|
| 107 | }
|
|---|
| 108 | # Use full 3-digit version to be compatible with the 'using gcc ;' case
|
|---|
| 109 | version = $(tool-version) ;
|
|---|
| 110 | }
|
|---|
| 111 | }
|
|---|
| 112 | else
|
|---|
| 113 | {
|
|---|
| 114 | errors.error "toolset gcc initialization:" :
|
|---|
| 115 | "version '$(version)' requested but neither 'g++-$(version)' nor default 'g++' found" :
|
|---|
| 116 | "initialized from" [ errors.nearest-user-location ] ;
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 | }
|
|---|
| 120 | #3) default: no command and no version specified, try using default command "g++"
|
|---|
| 121 | else
|
|---|
| 122 | {
|
|---|
| 123 | tool-command = [ common.get-invocation-command-nodefault gcc : g++ ] ;
|
|---|
| 124 | if ! $(tool-command)
|
|---|
| 125 | {
|
|---|
| 126 | errors.error "toolset gcc initialization:" :
|
|---|
| 127 | "no command provided, default command 'g++' not found" :
|
|---|
| 128 | "initialized from" [ errors.nearest-user-location ] ;
|
|---|
| 129 | }
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | # Information about the gcc command...
|
|---|
| 133 | # The command.
|
|---|
| 134 | local command = $(tool-command) ;
|
|---|
| 135 |
|
|---|
| 136 | # The version as reported by the compiler
|
|---|
| 137 | local real-version ;
|
|---|
| 138 |
|
|---|
| 139 | # The flavor of compiler.
|
|---|
| 140 | local flavor = [ feature.get-values <flavor> : $(options) ] ;
|
|---|
| 141 |
|
|---|
| 142 | flavor ?= mingw ;
|
|---|
| 143 |
|
|---|
| 144 | # - Autodetect the version if not given.
|
|---|
| 145 | if $(command)
|
|---|
| 146 | {
|
|---|
| 147 | # - The 'command' variable can have multiple elements. When calling
|
|---|
| 148 | # the SHELL builtin we need a single string.
|
|---|
| 149 | local command-string = $(command:J=" ") ;
|
|---|
| 150 | real-version = [ MATCH "^([0-9.]+)"
|
|---|
| 151 | : [ SHELL "$(command-string) -dumpversion" ] ] ;
|
|---|
| 152 | version ?= $(real-version) ;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | # - Define the condition for this toolset instance.
|
|---|
| 156 | local condition =
|
|---|
| 157 | [ common.check-init-parameters mingw $(requirement) : version $(version) : flavor $(flavor) ] ;
|
|---|
| 158 |
|
|---|
| 159 | # - Set the toolset generic common options.
|
|---|
| 160 | common.handle-options mingw : $(condition) : $(command) : $(options) ;
|
|---|
| 161 |
|
|---|
| 162 | # - Set the link flags common with the GCC toolset.
|
|---|
| 163 | gcc.init-link-flags mingw gnu $(condition) ;
|
|---|
| 164 | }
|
|---|