3 # (C) Copyright Christof Meerwald 2003.
4 # (C) Copyright Aleksey Gurtovoy 2004.
5 # (C) Copyright Arjan Knepper 2006.
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)
13 [[bbv2.reference.tools.compiler.dmc]]
14 = Digital Mars C/C++ Compiler
16 The `dmc` module supports the http://www.digitalmars.com/[Digital Mars
19 The module is initialized using the following syntax:
22 using dmc : [version] : [c++-compile-command] : [compiler options] ;
25 This statement may be repeated several times, if you want to configure
26 several versions of the compiler.
28 If the command is not specified, Boost.Build will search for a binary
31 The following options can be provided, using
32 _`<option-name>option-value syntax`_:
35 Specifies additional compiler flags that will be used when compiling C
39 Specifies additional compiler flags that will be used when compiling C++
43 Specifies additional compiler flags that will be used when compiling both C
47 Specifies additional command line options that will be passed to the linker.
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>
55 import feature generators common ;
56 import toolset : flags ;
57 import sequence regex ;
59 feature.extend toolset : dmc ;
61 rule init ( version ? : command * : options * )
63 local condition = [ common.check-init-parameters dmc : version $(version) ] ;
65 local command = [ common.get-invocation-command dmc : dmc : $(command) ] ;
68 common.handle-options dmc : $(condition) : $(command) : $(options) ;
72 command = [ common.get-absolute-tool-path $(command[-1]) ] ;
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\\ ;
85 flags dmc .root $(condition) : "" ;
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 ;
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 ;
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 ;
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 ;
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 ;
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 ;
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 ;
131 flags dmc.compile OPTIONS : <cflags> ;
132 flags dmc.compile.c++ OPTIONS : <cxxflags> ;
134 flags dmc.compile DEFINES : <define> ;
135 flags dmc.compile INCLUDES : <include> ;
137 flags dmc.link <linkflags> ;
138 flags dmc.archive OPTIONS <arflags> ;
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> ;
145 actions together link bind LIBRARIES
147 "$(.root)link" $(OPTIONS) /NOI /DE /XN "$(>)" , "$(<[1])" ,, $(LIBRARIES) user32.lib kernel32.lib "$(FINDLIBS:S=.lib)" , "$(<[2]:B).def"
150 actions together link.dll bind LIBRARIES
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"
163 "$(.root)dmc" -c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)"
168 "$(.root)dmc" -cpp -c -Ab $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)"
171 actions together piecemeal archive
173 "$(.root)lib" $(OPTIONS) -c -n -p256 "$(<)" "$(>)"