]>
Commit | Line | Data |
---|---|---|
1 | # Digital Mars C++ | |
2 | ||
3 | # (C) Copyright Christof Meerwald 2003. | |
4 | # (C) Copyright Aleksey Gurtovoy 2004. | |
5 | # (C) Copyright Arjan Knepper 2006. | |
6 | # | |
7 | # Distributed under the Boost Software License, Version 1.0. (See | |
8 | # accompanying file LICENSE_1_0.txt or copy at | |
9 | # http://www.boost.org/LICENSE_1_0.txt) | |
10 | ||
11 | #| tag::doc[] | |
12 | ||
13 | [[bbv2.reference.tools.compiler.dmc]] | |
14 | = Digital Mars C/C++ Compiler | |
15 | ||
16 | The `dmc` module supports the http://www.digitalmars.com/[Digital Mars | |
17 | C++ compiler.] | |
18 | ||
19 | The module is initialized using the following syntax: | |
20 | ||
21 | ---- | |
22 | using dmc : [version] : [c++-compile-command] : [compiler options] ; | |
23 | ---- | |
24 | ||
25 | This statement may be repeated several times, if you want to configure | |
26 | several versions of the compiler. | |
27 | ||
28 | If the command is not specified, Boost.Build will search for a binary | |
29 | named `dmc` in PATH. | |
30 | ||
31 | The following options can be provided, using | |
32 | _`<option-name>option-value syntax`_: | |
33 | ||
34 | `cflags`:: | |
35 | Specifies additional compiler flags that will be used when compiling C | |
36 | sources. | |
37 | ||
38 | `cxxflags`:: | |
39 | Specifies additional compiler flags that will be used when compiling C++ | |
40 | sources. | |
41 | ||
42 | `compileflags`:: | |
43 | Specifies additional compiler flags that will be used when compiling both C | |
44 | and C++ sources. | |
45 | ||
46 | `linkflags`:: | |
47 | Specifies additional command line options that will be passed to the linker. | |
48 | ||
49 | |# # end::doc[] | |
50 | ||
51 | # The following #// line will be used by the regression test table generation | |
52 | # program as the column heading for HTML tables. Must not include version number. | |
53 | #//<a href="http://www.digitalmars.com/">Digital<br>Mars C++</a> | |
54 | ||
55 | import feature generators common ; | |
56 | import toolset : flags ; | |
57 | import sequence regex ; | |
58 | ||
59 | feature.extend toolset : dmc ; | |
60 | ||
61 | rule init ( version ? : command * : options * ) | |
62 | { | |
63 | local condition = [ common.check-init-parameters dmc : version $(version) ] ; | |
64 | ||
65 | local command = [ common.get-invocation-command dmc : dmc : $(command) ] ; | |
66 | command ?= dmc ; | |
67 | ||
68 | common.handle-options dmc : $(condition) : $(command) : $(options) ; | |
69 | ||
70 | if $(command) | |
71 | { | |
72 | command = [ common.get-absolute-tool-path $(command[-1]) ] ; | |
73 | } | |
74 | root = $(command:D) ; | |
75 | ||
76 | if $(root) | |
77 | { | |
78 | # DMC linker is sensitive the the direction of slashes, and | |
79 | # won't link if forward slashes are used in command. | |
80 | root = [ sequence.join [ regex.split $(root) "/" ] : "\\" ] ; | |
81 | flags dmc .root $(condition) : $(root)\\bin\\ ; | |
82 | } | |
83 | else | |
84 | { | |
85 | flags dmc .root $(condition) : "" ; | |
86 | } | |
87 | } | |
88 | ||
89 | ||
90 | # Declare generators | |
91 | generators.register-linker dmc.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : <toolset>dmc ; | |
92 | generators.register-linker dmc.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>dmc ; | |
93 | ||
94 | generators.register-archiver dmc.archive : OBJ : STATIC_LIB : <toolset>dmc ; | |
95 | generators.register-c-compiler dmc.compile.c++ : CPP : OBJ : <toolset>dmc ; | |
96 | generators.register-c-compiler dmc.compile.c : C : OBJ : <toolset>dmc ; | |
97 | ||
98 | ||
99 | # Declare flags | |
100 | # dmc optlink has some limitation on the amount of debug-info included. Therefore only linenumbers are enabled in debug builds. | |
101 | # flags dmc.compile OPTIONS <debug-symbols>on : -g ; | |
102 | flags dmc.compile OPTIONS <debug-symbols>on : -gl ; | |
103 | flags dmc.link OPTIONS <debug-symbols>on : /CO /NOPACKF /DEBUGLI ; | |
104 | flags dmc.link OPTIONS <debug-symbols>off : /PACKF ; | |
105 | ||
106 | flags dmc.compile OPTIONS <optimization>off : -S -o+none ; | |
107 | flags dmc.compile OPTIONS <optimization>speed : -o+time ; | |
108 | flags dmc.compile OPTIONS <optimization>space : -o+space ; | |
109 | flags dmc.compile OPTIONS <exception-handling>on : -Ae ; | |
110 | flags dmc.compile OPTIONS <rtti>on : -Ar ; | |
111 | # FIXME: | |
112 | # Compiling sources to be linked into a shared lib (dll) the -WD cflag should be used | |
113 | # Compiling sources to be linked into a static lib (lib) or executable the -WA cflag should be used | |
114 | # But for some reason the -WD cflag is always in use. | |
115 | # flags dmc.compile OPTIONS <link>shared : -WD ; | |
116 | # flags dmc.compile OPTIONS <link>static : -WA ; | |
117 | ||
118 | # Note that these two options actually imply multithreading support on DMC | |
119 | # because there is no single-threaded dynamic runtime library. Specifying | |
120 | # <threading>multi would be a bad idea, though, because no option would be | |
121 | # matched when the build uses the default settings of <runtime-link>dynamic | |
122 | # and <threading>single. | |
123 | flags dmc.compile OPTIONS <runtime-debugging>off/<runtime-link>shared : -ND ; | |
124 | flags dmc.compile OPTIONS <runtime-debugging>on/<runtime-link>shared : -ND ; | |
125 | ||
126 | flags dmc.compile OPTIONS <runtime-debugging>off/<runtime-link>static/<threading>single : ; | |
127 | flags dmc.compile OPTIONS <runtime-debugging>on/<runtime-link>static/<threading>single : ; | |
128 | flags dmc.compile OPTIONS <runtime-debugging>off/<runtime-link>static/<threading>multi : -D_MT ; | |
129 | flags dmc.compile OPTIONS <runtime-debugging>on/<runtime-link>static/<threading>multi : -D_MT ; | |
130 | ||
131 | flags dmc.compile OPTIONS : <cflags> ; | |
132 | flags dmc.compile.c++ OPTIONS : <cxxflags> ; | |
133 | ||
134 | flags dmc.compile DEFINES : <define> ; | |
135 | flags dmc.compile INCLUDES : <include> ; | |
136 | ||
137 | flags dmc.link <linkflags> ; | |
138 | flags dmc.archive OPTIONS <arflags> ; | |
139 | ||
140 | flags dmc LIBPATH <library-path> ; | |
141 | flags dmc LIBRARIES <library-file> ; | |
142 | flags dmc FINDLIBS <find-library-sa> ; | |
143 | flags dmc FINDLIBS <find-library-st> ; | |
144 | ||
145 | actions together link bind LIBRARIES | |
146 | { | |
147 | "$(.root)link" $(OPTIONS) /NOI /DE /XN "$(>)" , "$(<[1])" ,, $(LIBRARIES) user32.lib kernel32.lib "$(FINDLIBS:S=.lib)" , "$(<[2]:B).def" | |
148 | } | |
149 | ||
150 | actions together link.dll bind LIBRARIES | |
151 | { | |
152 | echo LIBRARY "$(<[1])" > $(<[2]:B).def | |
153 | echo DESCRIPTION 'A Library' >> $(<[2]:B).def | |
154 | echo EXETYPE NT >> $(<[2]:B).def | |
155 | echo SUBSYSTEM WINDOWS >> $(<[2]:B).def | |
156 | echo CODE EXECUTE READ >> $(<[2]:B).def | |
157 | echo DATA READ WRITE >> $(<[2]:B).def | |
158 | "$(.root)link" $(OPTIONS) /NOI /DE /XN /ENTRY:_DllMainCRTStartup /IMPLIB:"$(<[2])" "$(>)" $(LIBRARIES) , "$(<[1])" ,, user32.lib kernel32.lib "$(FINDLIBS:S=.lib)" , "$(<[2]:B).def" | |
159 | } | |
160 | ||
161 | actions compile.c | |
162 | { | |
163 | "$(.root)dmc" -c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)" | |
164 | } | |
165 | ||
166 | actions compile.c++ | |
167 | { | |
168 | "$(.root)dmc" -cpp -c -Ab $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)" | |
169 | } | |
170 | ||
171 | actions together piecemeal archive | |
172 | { | |
173 | "$(.root)lib" $(OPTIONS) -c -n -p256 "$(<)" "$(>)" | |
174 | } |