]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | # 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> | |
14 | ||
15 | import feature generators common ; | |
16 | import toolset : flags ; | |
17 | import sequence regex ; | |
18 | ||
19 | feature.extend toolset : dmc ; | |
20 | ||
21 | rule init ( version ? : command * : options * ) | |
22 | { | |
23 | local condition = [ common.check-init-parameters dmc : version $(version) ] ; | |
24 | ||
25 | local command = [ common.get-invocation-command dmc : dmc : $(command) ] ; | |
26 | command ?= dmc ; | |
27 | ||
28 | common.handle-options dmc : $(condition) : $(command) : $(options) ; | |
29 | ||
30 | if $(command) | |
31 | { | |
32 | command = [ common.get-absolute-tool-path $(command[-1]) ] ; | |
33 | } | |
34 | root = $(command:D) ; | |
35 | ||
36 | if $(root) | |
37 | { | |
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\\ ; | |
42 | } | |
43 | else | |
44 | { | |
45 | flags dmc .root $(condition) : "" ; | |
46 | } | |
47 | } | |
48 | ||
49 | ||
50 | # Declare generators | |
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 ; | |
53 | ||
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 ; | |
57 | ||
58 | ||
59 | # Declare flags | |
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 ; | |
65 | ||
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 ; | |
71 | # FIXME: | |
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 ; | |
77 | ||
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 ; | |
85 | ||
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 ; | |
90 | ||
91 | flags dmc.compile OPTIONS : <cflags> ; | |
92 | flags dmc.compile.c++ OPTIONS : <cxxflags> ; | |
93 | ||
94 | flags dmc.compile DEFINES : <define> ; | |
95 | flags dmc.compile INCLUDES : <include> ; | |
96 | ||
97 | flags dmc.link <linkflags> ; | |
98 | flags dmc.archive OPTIONS <arflags> ; | |
99 | ||
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> ; | |
104 | ||
105 | actions together link bind LIBRARIES | |
106 | { | |
107 | "$(.root)link" $(OPTIONS) /NOI /DE /XN "$(>)" , "$(<[1])" ,, $(LIBRARIES) user32.lib kernel32.lib "$(FINDLIBS:S=.lib)" , "$(<[2]:B).def" | |
108 | } | |
109 | ||
110 | actions together link.dll bind LIBRARIES | |
111 | { | |
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" | |
119 | } | |
120 | ||
121 | actions compile.c | |
122 | { | |
123 | "$(.root)dmc" -c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)" | |
124 | } | |
125 | ||
126 | actions compile.c++ | |
127 | { | |
128 | "$(.root)dmc" -cpp -c -Ab $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)" | |
129 | } | |
130 | ||
131 | actions together piecemeal archive | |
132 | { | |
133 | "$(.root)lib" $(OPTIONS) -c -n -p256 "$(<)" "$(>)" | |
134 | } |