Imported Upstream version 1.51.0
[platform/upstream/boost.git] / tools / build / v2 / tools / borland.jam
1 # Copyright 2005 Dave Abrahams 
2 # Copyright 2003 Rene Rivera 
3 # Copyright 2003, 2004, 2005 Vladimir Prus 
4 # Distributed under the Boost Software License, Version 1.0. 
5 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 
6
7 #  Support for the Borland's command line compiler
8
9 import property ;
10 import generators ;
11 import os ;
12 import toolset : flags ;
13 import feature : get-values ;
14 import type ;
15 import common ;
16
17 feature.extend toolset : borland ;
18
19 rule init ( version ? : command * : options * )
20 {
21     local condition = [ common.check-init-parameters borland :
22         version $(version) ] ;
23     
24     local command = [ common.get-invocation-command borland : bcc32.exe 
25         : $(command) ] ;
26      
27     common.handle-options borland : $(condition) : $(command) : $(options) ;    
28     
29     if $(command)
30     {
31         command = [ common.get-absolute-tool-path $(command[-1]) ] ;
32     }   
33     root = $(command:D) ;    
34     
35     flags borland.compile STDHDRS $(condition) : $(root)/include/ ;
36     flags borland.link STDLIBPATH $(condition) : $(root)/lib ;
37     flags borland.link RUN_PATH $(condition) : $(root)/bin ;
38     flags borland .root $(condition) : $(root)/bin/ ;    
39 }
40
41
42 # A borland-specific target type
43 type.register BORLAND.TDS : tds ;
44
45 # Declare generators
46
47 generators.register-linker borland.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : <toolset>borland ;
48 generators.register-linker borland.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>borland ;
49
50 generators.register-archiver borland.archive : OBJ : STATIC_LIB : <toolset>borland ;
51 generators.register-c-compiler borland.compile.c++ : CPP : OBJ : <toolset>borland ;
52 generators.register-c-compiler borland.compile.c : C : OBJ : <toolset>borland ;
53 generators.register-standard borland.asm : ASM : OBJ : <toolset>borland ;
54
55 # Declare flags 
56
57 flags borland.compile OPTIONS <debug-symbols>on : -v ;
58 flags borland.link OPTIONS <debug-symbols>on : -v ;
59
60 flags borland.compile OPTIONS <optimization>off : -Od ;
61 flags borland.compile OPTIONS <optimization>speed : -O2 ;
62 flags borland.compile OPTIONS <optimization>space : -O1 ;
63
64 if $(.BORLAND_HAS_FIXED_INLINING_BUGS)
65 {
66     flags borland CFLAGS <inlining>off : -vi- ;
67     flags borland CFLAGS <inlining>on : -vi -w-inl ;
68     flags borland CFLAGS <inlining>full : -vi -w-inl ;
69 }
70 else
71 {
72     flags borland CFLAGS : -vi- ;
73 }
74
75 flags borland.compile OPTIONS <warnings>off : -w- ;
76 flags borland.compile OPTIONS <warnings>all : -w ;
77 flags borland.compile OPTIONS <warnings-as-errors>on : -w! ;
78
79
80 # Deal with various runtime configs...
81
82 # This should be not for DLL
83 flags borland OPTIONS <user-interface>console : -tWC ;
84
85 # -tWR sets -tW as well, so we turn it off here and then turn it 
86 # on again later if we need it:
87 flags borland OPTIONS <runtime-link>shared : -tWR -tWC ;
88 flags borland OPTIONS <user-interface>gui : -tW ;
89
90 flags borland OPTIONS <main-target-type>LIB/<link>shared : -tWD ;
91 # Hmm.. not sure what's going on here.
92 flags borland OPTIONS : -WM- ;
93 flags borland OPTIONS <threading>multi : -tWM ;
94
95
96
97 flags borland.compile OPTIONS <cxxflags> ;
98 flags borland.compile DEFINES <define> ;
99 flags borland.compile INCLUDES <include> ;
100
101 flags borland NEED_IMPLIB <main-target-type>LIB/<link>shared : "" ;
102
103 #
104 # for C++ compiles the following options are turned on by default:
105 #
106 # -j5    stops after 5 errors
107 # -g255  allow an unlimited number of warnings
108 # -q     no banner
109 # -c     compile to object
110 # -P     C++ code regardless of file extention
111 # -a8    8 byte alignment, this option is on in the IDE by default 
112 #        and effects binary compatibility.
113 #
114
115 # -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)"  -I"$(STDHDRS)" -o"$(<)" "$(>)"
116
117
118 actions compile.c++
119 {
120     "$(CONFIG_COMMAND)" -j5 -g255 -q -c -P -a8 -Vx- -Ve- -b- $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)"
121 }
122
123 # For C, we don't pass -P flag
124 actions compile.c
125 {
126     "$(CONFIG_COMMAND)" -j5 -g255 -q -c -a8 -Vx- -Ve- -b- $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)"
127 }
128
129
130 # Declare flags and action for linking
131 toolset.flags borland.link OPTIONS <debug-symbols>on : -v ;
132 toolset.flags borland.link LIBRARY_PATH <library-path> ;
133 toolset.flags borland.link FINDLIBS_ST <find-static-library> ;
134 toolset.flags borland.link FINDLIBS_SA <find-shared-library> ;
135 toolset.flags borland.link LIBRARIES <library-file> ;
136
137 flags borland.link OPTIONS <linkflags> ;
138 flags borland.link OPTIONS <link>shared : -tWD ;
139
140 flags borland.link LIBRARY_PATH_OPTION <toolset>borland : -L : unchecked ;
141 flags borland.link LIBRARY_OPTION <toolset>borland : "" : unchecked ;
142
143
144
145 # bcc32 needs to have ilink32 in the path in order to invoke it, so explicitly
146 # specifying $(BCC_TOOL_PATH)bcc32 doesn't help. You need to add
147 # $(BCC_TOOL_PATH) to the path
148 # The NEED_IMPLIB variable controls whether we need to invoke implib.
149
150 flags borland.archive AROPTIONS <archiveflags> ;
151
152 # Declare action for archives. We don't use response file
153 # since it's hard to get "+-" there.
154 # The /P256 increases 'page' size -- with too low
155 # values tlib fails when building large applications.
156 # CONSIDER: don't know what 'together' is for...
157 actions updated together piecemeal archive
158
159     $(.set-path)$(.root:W)$(.old-path)
160     tlib $(AROPTIONS) /P256 /u /a /C "$(<:W)" +-"$(>:W)"
161 }
162
163
164 if [ os.name ] = CYGWIN
165 {
166     .set-path = "cmd /S /C set \"PATH=" ;
167     .old-path = ";%PATH%\" \"&&\"" ;
168     
169
170     # Couldn't get TLIB to stop being confused about pathnames
171     # containing dashes (it seemed to treat them as option separators
172     # when passed through from bash), so we explicitly write the
173     # command into a .bat file and execute that.  TLIB is also finicky
174     # about pathname style! Forward slashes, too, are treated as
175     # options.
176     actions updated together piecemeal archive
177     { 
178        chdir $(<:D)
179        echo +-$(>:BS) > $(<:BS).rsp
180        $(.set-path)$(.root)$(.old-path) "tlib.exe" $(AROPTIONS) /P256 /C $(<:BS) @$(<:BS).rsp && $(RM) $(<:BS).rsp
181     }    
182 }
183 else if [ os.name ] = NT
184 {
185     .set-path = "set \"PATH=" ;
186     .old-path = ";%PATH%\"
187       " ;
188 }
189 else
190 {
191     .set-path = "PATH=\"" ;
192     .old-path = "\":$PATH
193       export PATH
194       " ;
195 }
196
197 RM = [ common.rm-command ] ;
198
199 nl = "
200 " ;
201
202 actions link
203 {
204     $(.set-path)$(.root:W)$(.old-path) "$(CONFIG_COMMAND)" -v -q $(OPTIONS) -L"$(LIBRARY_PATH:W)" -L"$(STDLIBPATH:W)" -e"$(<[1]:W)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"
205 }
206
207
208 actions link.dll bind LIBRARIES RSP
209 {
210     $(.set-path)$(.root:W)$(.old-path) "$(CONFIG_COMMAND)" -v -q $(OPTIONS) -L"$(LIBRARY_PATH:W)" -L"$(STDLIBPATH:W)" -e"$(<[1]:W)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"  && "$(.root)implib" "$(<[2]:W)" "$(<[1]:W)"
211 }
212
213 # It seems impossible to specify output file with directory when compiling
214 # asm files using bcc32, so use tasm32 directly.
215 # /ml makes all symbol names case-sensitive
216 actions asm
217 {
218     $(.set-path)$(.root:W)$(.old-path) tasm32.exe /ml "$(>)" "$(<)"
219 }
220