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)
11 # The following #// line will be used by the regression test table generation
12 # program as the column heading for HTML tables. Must not include version number.
13 #//<a href="http://www.digitalmars.com/">Digital<br>Mars C++</a>
15 import feature generators common ;
16 import toolset : flags ;
17 import sequence regex ;
19 feature.extend toolset : dmc ;
21 rule init ( version ? : command * : options * )
23 local condition = [ common.check-init-parameters dmc : version $(version) ] ;
25 local command = [ common.get-invocation-command dmc : dmc : $(command) ] ;
28 common.handle-options dmc : $(condition) : $(command) : $(options) ;
32 command = [ common.get-absolute-tool-path $(command[-1]) ] ;
38 # DMC linker is sensitive the the direction of slashes, and
39 # won't link if forward slashes are used in command.
40 root = [ sequence.join [ regex.split $(root) "/" ] : "\\" ] ;
41 flags dmc .root $(condition) : $(root)\\bin\\ ;
45 flags dmc .root $(condition) : "" ;
51 generators.register-linker dmc.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : <toolset>dmc ;
52 generators.register-linker dmc.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>dmc ;
54 generators.register-archiver dmc.archive : OBJ : STATIC_LIB : <toolset>dmc ;
55 generators.register-c-compiler dmc.compile.c++ : CPP : OBJ : <toolset>dmc ;
56 generators.register-c-compiler dmc.compile.c : C : OBJ : <toolset>dmc ;
60 # dmc optlink has some limitation on the amount of debug-info included. Therefore only linenumbers are enabled in debug builds.
61 # flags dmc.compile OPTIONS <debug-symbols>on : -g ;
62 flags dmc.compile OPTIONS <debug-symbols>on : -gl ;
63 flags dmc.link OPTIONS <debug-symbols>on : /CO /NOPACKF /DEBUGLI ;
64 flags dmc.link OPTIONS <debug-symbols>off : /PACKF ;
66 flags dmc.compile OPTIONS <optimization>off : -S -o+none ;
67 flags dmc.compile OPTIONS <optimization>speed : -o+time ;
68 flags dmc.compile OPTIONS <optimization>space : -o+space ;
69 flags dmc.compile OPTIONS <exception-handling>on : -Ae ;
70 flags dmc.compile OPTIONS <rtti>on : -Ar ;
72 # Compiling sources to be linked into a shared lib (dll) the -WD cflag should be used
73 # Compiling sources to be linked into a static lib (lib) or executable the -WA cflag should be used
74 # But for some reason the -WD cflag is always in use.
75 # flags dmc.compile OPTIONS <link>shared : -WD ;
76 # flags dmc.compile OPTIONS <link>static : -WA ;
78 # Note that these two options actually imply multithreading support on DMC
79 # because there is no single-threaded dynamic runtime library. Specifying
80 # <threading>multi would be a bad idea, though, because no option would be
81 # matched when the build uses the default settings of <runtime-link>dynamic
82 # and <threading>single.
83 flags dmc.compile OPTIONS <runtime-debugging>off/<runtime-link>shared : -ND ;
84 flags dmc.compile OPTIONS <runtime-debugging>on/<runtime-link>shared : -ND ;
86 flags dmc.compile OPTIONS <runtime-debugging>off/<runtime-link>static/<threading>single : ;
87 flags dmc.compile OPTIONS <runtime-debugging>on/<runtime-link>static/<threading>single : ;
88 flags dmc.compile OPTIONS <runtime-debugging>off/<runtime-link>static/<threading>multi : -D_MT ;
89 flags dmc.compile OPTIONS <runtime-debugging>on/<runtime-link>static/<threading>multi : -D_MT ;
91 flags dmc.compile OPTIONS : <cflags> ;
92 flags dmc.compile.c++ OPTIONS : <cxxflags> ;
94 flags dmc.compile DEFINES : <define> ;
95 flags dmc.compile INCLUDES : <include> ;
97 flags dmc.link <linkflags> ;
98 flags dmc.archive OPTIONS <arflags> ;
100 flags dmc LIBPATH <library-path> ;
101 flags dmc LIBRARIES <library-file> ;
102 flags dmc FINDLIBS <find-library-sa> ;
103 flags dmc FINDLIBS <find-library-st> ;
105 actions together link bind LIBRARIES
107 "$(.root)link" $(OPTIONS) /NOI /DE /XN "$(>)" , "$(<[1])" ,, $(LIBRARIES) user32.lib kernel32.lib "$(FINDLIBS:S=.lib)" , "$(<[2]:B).def"
110 actions together link.dll bind LIBRARIES
112 echo LIBRARY "$(<[1])" > $(<[2]:B).def
113 echo DESCRIPTION 'A Library' >> $(<[2]:B).def
114 echo EXETYPE NT >> $(<[2]:B).def
115 echo SUBSYSTEM WINDOWS >> $(<[2]:B).def
116 echo CODE EXECUTE READ >> $(<[2]:B).def
117 echo DATA READ WRITE >> $(<[2]:B).def
118 "$(.root)link" $(OPTIONS) /NOI /DE /XN /ENTRY:_DllMainCRTStartup /IMPLIB:"$(<[2])" "$(>)" $(LIBRARIES) , "$(<[1])" ,, user32.lib kernel32.lib "$(FINDLIBS:S=.lib)" , "$(<[2]:B).def"
123 "$(.root)dmc" -c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)"
128 "$(.root)dmc" -cpp -c -Ab $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)"
131 actions together piecemeal archive
133 "$(.root)lib" $(OPTIONS) -c -n -p256 "$(<)" "$(>)"