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