| 1 | #============================================================================
|
|---|
| 2 | # Jam configuration and actions for Win32
|
|---|
| 3 | # Copyright (C)2003 by Matze Braun <matzebraun@users.sourceforge.net>
|
|---|
| 4 | # Copyright (C)2004 by Eric Sunshine <sunshine@sunshineco.com>
|
|---|
| 5 | #
|
|---|
| 6 | # This library is free software; you can redistribute it and/or modify it
|
|---|
| 7 | # under the terms of the GNU Library General Public License as published by
|
|---|
| 8 | # the Free Software Foundation; either version 2 of the License, or (at your
|
|---|
| 9 | # option) any later version.
|
|---|
| 10 | #
|
|---|
| 11 | # This library is distributed in the hope that it will be useful, but
|
|---|
| 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|---|
| 13 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
|
|---|
| 14 | # License for more details.
|
|---|
| 15 | #
|
|---|
| 16 | # You should have received a copy of the GNU Library General Public License
|
|---|
| 17 | # along with this library; if not, write to the Free Software Foundation,
|
|---|
| 18 | # Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 19 | #
|
|---|
| 20 | #============================================================================
|
|---|
| 21 | SHELL ?= "/bin/sh" ;
|
|---|
| 22 |
|
|---|
| 23 | CMD.WINDRES ?= windres ;
|
|---|
| 24 | # DLL-tools not used by this script, but clients might have a need for them.
|
|---|
| 25 | CMD.DLLTOOL ?= dlltool ;
|
|---|
| 26 | CMD.DLLWRAP ?= dllwrap ;
|
|---|
| 27 |
|
|---|
| 28 | USE_DLLWRAP ?= no ;
|
|---|
| 29 |
|
|---|
| 30 | NASM.FLAGS += -f win32 -DEXTERNC_UNDERSCORE ;
|
|---|
| 31 | CCFLAGS += -pipe ;
|
|---|
| 32 | C++FLAGS += -pipe ;
|
|---|
| 33 | LINKLIBS += -L/usr/lib/w32api -lgdi32 -lshell32 ;
|
|---|
| 34 | PLUGIN.LFLAGS += -mwindows ;
|
|---|
| 35 | WINDRES.FLAGS = --use-temp-file ;
|
|---|
| 36 |
|
|---|
| 37 | if "$(USE_DLLWRAP)" = "yes"
|
|---|
| 38 | {
|
|---|
| 39 | PLUGIN.LFLAGS = [ Filter $(PLUGIN.LFLAGS) : -shared ] ;
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | # Natively-built Jam 2.5 (and probably earlier) on Cygwin fails to perform
|
|---|
| 43 | # library scanning properly and think that all object files need to be rebuilt
|
|---|
| 44 | # (along with everything which depends upon them) when "jam install" follows
|
|---|
| 45 | # "jam all", so disable this feature.
|
|---|
| 46 | if $(OS) = "CYGWIN"
|
|---|
| 47 | {
|
|---|
| 48 | NOARSCAN = true ;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | #----------------------------------------------------------------------------
|
|---|
| 52 | # resource handling
|
|---|
| 53 | # Unfortunately we can't simply specify resources on the source list, because
|
|---|
| 54 | # Mingw/Cygwin have the limitation that they can only link 1 resource file
|
|---|
| 55 | # in. So we have to concatenate all resourcefiles here before compiling them.
|
|---|
| 56 |
|
|---|
| 57 | actions GenerateWin32VersionRc
|
|---|
| 58 | {
|
|---|
| 59 | cat > $(<) << __EOF__
|
|---|
| 60 | // This file is generated automatically.
|
|---|
| 61 |
|
|---|
| 62 | 1 VERSIONINFO
|
|---|
| 63 | FILEVERSION
|
|---|
| 64 | __EOF__
|
|---|
| 65 |
|
|---|
| 66 | # Remove any RC tag
|
|---|
| 67 | echo '$(PACKAGE_VERSION_LIST[1]),$(PACKAGE_VERSION_LIST[2]),$(PACKAGE_VERSION_LIST[3]),$(PACKAGE_VERSION_LIST[4])' | $(SED) 's/RC\([0-9]\)//g' | $(SED) 's/[^0123456789._,]//g' >> $(<)
|
|---|
| 68 |
|
|---|
| 69 | cat >> $(<) << __EOF__
|
|---|
| 70 | PRODUCTVERSION
|
|---|
| 71 | __EOF__
|
|---|
| 72 |
|
|---|
| 73 | # Remove any RC tag
|
|---|
| 74 | echo '$(PACKAGE_VERSION_LIST[1]),$(PACKAGE_VERSION_LIST[2]),$(PACKAGE_VERSION_LIST[3]),$(PACKAGE_VERSION_LIST[4])' | $(SED) 's/RC\([0-9]\)//g' | $(SED) 's/[^0123456789._,]//g' >> $(<)
|
|---|
| 75 |
|
|---|
| 76 | cat >> $(<) << __EOF__
|
|---|
| 77 | #ifdef CS_DEBUG
|
|---|
| 78 | FILEFLAGS 0x1
|
|---|
| 79 | #else
|
|---|
| 80 | FILEFLAGS 0x0
|
|---|
| 81 | #endif
|
|---|
| 82 | {
|
|---|
| 83 | BLOCK "StringFileInfo"
|
|---|
| 84 | {
|
|---|
| 85 | BLOCK "040904E4"
|
|---|
| 86 | {
|
|---|
| 87 | VALUE "ProductName", "$(PRODUCT_NAME)"
|
|---|
| 88 | VALUE "ProductVersion", "$(PACKAGE_VERSION)"
|
|---|
| 89 | VALUE "FileVersion", "$(PACKAGE_VERSION)"
|
|---|
| 90 | VALUE "LegalCopyright", "$(PACKAGE_COPYRIGHT)"
|
|---|
| 91 | VALUE "FileDescription", "$(PRODUCT_DESCRIPTION)"
|
|---|
| 92 | #ifdef CS_DEBUG
|
|---|
| 93 | VALUE "Comments", "Debug build"
|
|---|
| 94 | #else
|
|---|
| 95 | VALUE "Comments", "Release build"
|
|---|
| 96 | #endif
|
|---|
| 97 | VALUE "WWW", "$(PACKAGE_HOMEPAGE)"
|
|---|
| 98 | }
|
|---|
| 99 | }
|
|---|
| 100 | BLOCK "VarFileInfo"
|
|---|
| 101 | {
|
|---|
| 102 | VALUE "Translation", 0x409, 1200
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | }
|
|---|
| 106 | __EOF__
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | actions GenerateWin32ManifestRc
|
|---|
| 110 | {
|
|---|
| 111 | cat > $(<) << __EOF__
|
|---|
| 112 | // This file is generated automatically.
|
|---|
| 113 | 1 24 "$(MANIFEST_NAME)"
|
|---|
| 114 | __EOF__
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | actions GenerateWin32Manifest
|
|---|
| 118 | {
|
|---|
| 119 | cat > $(<) << __EOF__
|
|---|
| 120 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|---|
| 121 | <!-- This file is generated automatically. -->
|
|---|
| 122 | <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
|---|
| 123 | <assemblyIdentity
|
|---|
| 124 | __EOF__
|
|---|
| 125 |
|
|---|
| 126 | # Filter out non-numerical characters from the version number. Windows does
|
|---|
| 127 | # not like them.
|
|---|
| 128 | echo '$(PACKAGE_VERSION_LIST[1]).$(PACKAGE_VERSION_LIST[2]).$(PACKAGE_VERSION_LIST[3]).$(PACKAGE_VERSION_LIST[4])' | $(SED) 's/RC\([0-9]\)//g' | $(SED) 's/[^0123456789.]//g' | $(SED) 's/\(.*\)/ version="\1"/' >> $(<)
|
|---|
| 129 |
|
|---|
| 130 | cat >> $(<) << __EOF__
|
|---|
| 131 | processorArchitecture="X86"
|
|---|
| 132 | name="$(PRODUCT_NAME)"
|
|---|
| 133 | type="win32"
|
|---|
| 134 | />
|
|---|
| 135 | <description>$(PRODUCT_DESCRIPTION)</description>
|
|---|
| 136 | <dependency>
|
|---|
| 137 | <dependentAssembly>
|
|---|
| 138 | <assemblyIdentity
|
|---|
| 139 | type="win32"
|
|---|
| 140 | name="Microsoft.Windows.Common-Controls"
|
|---|
| 141 | version="6.0.0.0"
|
|---|
| 142 | processorArchitecture="X86"
|
|---|
| 143 | publicKeyToken="6595b64144ccf1df"
|
|---|
| 144 | language="*"
|
|---|
| 145 | />
|
|---|
| 146 | </dependentAssembly>
|
|---|
| 147 | </dependency>
|
|---|
| 148 | </assembly>
|
|---|
| 149 | __EOF__
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | actions GenerateWin32MetadataRc
|
|---|
| 153 | {
|
|---|
| 154 | cat > $(<) << __EOF__
|
|---|
| 155 | // This file is automatically generated.
|
|---|
| 156 |
|
|---|
| 157 | 17485 RCDATA
|
|---|
| 158 | {
|
|---|
| 159 | __EOF__
|
|---|
| 160 |
|
|---|
| 161 | cat $(>) | $(SED) "s:\":\"\":g" | $(SED) "s:\(.*\): \"\1\",:g" >> $(<)
|
|---|
| 162 |
|
|---|
| 163 | cat >> $(<) << __EOF__
|
|---|
| 164 | "\0"
|
|---|
| 165 | }
|
|---|
| 166 | __EOF__
|
|---|
| 167 |
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | actions GenerateIconRc
|
|---|
| 171 | {
|
|---|
| 172 | echo '1 ICON "$(>)"' > $(<)
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | actions together CompileResources
|
|---|
| 176 | {
|
|---|
| 177 | cat $(>) | $(CMD.WINDRES) $(WINDRES.FLAGS) $(RCFLAGS) --include-dir=$(>:D) -o $(<)
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | rule CompileResources
|
|---|
| 181 | {
|
|---|
| 182 | Depends $(<) : $(>) ;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | ## Win32Resource basename : rcfiles
|
|---|
| 186 | ## Specify .rc files for the target known as basename. The .rc files should
|
|---|
| 187 | ## already have SEARCH set appropriately.
|
|---|
| 188 | rule Win32Resource
|
|---|
| 189 | {
|
|---|
| 190 | local target = $($(<)_TARGET) ;
|
|---|
| 191 | local rcobject = [ DoObjectGrist $(<)_resource.o ] ;
|
|---|
| 192 | LOCATE on $(rcobject) = $(LOCATE_TARGET) ;
|
|---|
| 193 | SEARCH on $(rcobject) = $(LOCATE_TARGET) ;
|
|---|
| 194 |
|
|---|
| 195 | # only add 1 resource object per target
|
|---|
| 196 | if ! $($(<)_HASWIN32RESOURCE)
|
|---|
| 197 | {
|
|---|
| 198 | $(<)_HASWIN32RESOURCE = yes ;
|
|---|
| 199 | ExtraObjects $(<) : $(rcobject) ;
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | CompileResources $(rcobject) : $(>) ;
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | ## Win32RcFlags basename : rcfiles
|
|---|
| 206 | ## Specify flags passed to the resource compiler when compiling resources
|
|---|
| 207 | ## for the target known as basename.
|
|---|
| 208 | rule Win32RcFlags
|
|---|
| 209 | {
|
|---|
| 210 | local rcobject = [ DoObjectGrist $(<)_resource.o ] ;
|
|---|
| 211 | RCFLAGS on $(rcobject) += $(>) ;
|
|---|
| 212 | }
|
|---|
| 213 |
|
|---|
| 214 | if $(USE_DLLWRAP) = "yes"
|
|---|
| 215 | {
|
|---|
| 216 | rule GenerateExportDefs
|
|---|
| 217 | {
|
|---|
| 218 | SEARCH on $(<) = $(LOCATE_TARGET) ;
|
|---|
| 219 | MakeLocate $(<) : $(LOCATE_TARGET) ;
|
|---|
| 220 | Depends $(<) : $(>) ;
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | actions GenerateExportDefs
|
|---|
| 224 | {
|
|---|
| 225 | echo "EXPORTS" > $(<)
|
|---|
| 226 | echo " plugin_compiler" >> $(<)
|
|---|
| 227 | $(SED) '/<implementation>/!d;s:[ ]*<implementation>\(..*\)</implementation>: \1_scfInitialize:;p;s:_scfInitialize:_scfFinalize:;p;s:_scfFinalize:_Create:' < $(>) >> $(<)
|
|---|
| 228 | }
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | #----------------------------------------------------------------------------
|
|---|
| 232 | # linking part
|
|---|
| 233 |
|
|---|
| 234 | ## ConstructApplicationTarget target : options
|
|---|
| 235 | ## Constructs the application target name (ie. foo.exe for foo)
|
|---|
| 236 | rule ConstructApplicationTarget
|
|---|
| 237 | {
|
|---|
| 238 | return $(<).exe ;
|
|---|
| 239 | }
|
|---|
| 240 | rule ConstructStaticLibraryTarget
|
|---|
| 241 | {
|
|---|
| 242 | local libbase = [ LibraryBaseName $(<) ] ;
|
|---|
| 243 | return lib$(libbase)$(SUFLIB) ;
|
|---|
| 244 | }
|
|---|
| 245 | rule ConstructSharedLibraryTarget
|
|---|
| 246 | {
|
|---|
| 247 | local libbase = [ LibraryBaseName $(<) ] ;
|
|---|
| 248 | return $(libbase)-$(COMPILER.C++.TYPE).dll ;
|
|---|
| 249 | }
|
|---|
| 250 | rule ConstructSharedLibraryLinkLib
|
|---|
| 251 | {
|
|---|
| 252 | local libbase = [ LibraryBaseName $(<) ] ;
|
|---|
| 253 | return lib$(libbase)$(SUFLIB) ;
|
|---|
| 254 | }
|
|---|
| 255 | rule ConstructPluginTarget
|
|---|
| 256 | {
|
|---|
| 257 | return $(<).dll ;
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | # Also invoked by msvcgen.jam.
|
|---|
| 261 | rule MakeVersionRc
|
|---|
| 262 | {
|
|---|
| 263 | # normalize version list
|
|---|
| 264 | local v1, v2, v3, v4 ;
|
|---|
| 265 | v1 = $(PACKAGE_VERSION_LIST[1]) ;
|
|---|
| 266 | if ! $(v1) { v1 = 0 ; }
|
|---|
| 267 | v2 = $(PACKAGE_VERSION_LIST[2]) ;
|
|---|
| 268 | if ! $(v2) { v2 = 0 ; }
|
|---|
| 269 | v3 = $(PACKAGE_VERSION_LIST[3]) ;
|
|---|
| 270 | if ! $(v3) { v3 = 0 ; }
|
|---|
| 271 | v4 = $(PACKAGE_VERSION_LIST[4]) ;
|
|---|
| 272 | if ! $(v4) { v4 = 0 ; }
|
|---|
| 273 | PACKAGE_VERSION_LIST on $(<) = $(v1) $(v2) $(v3) $(v4) ;
|
|---|
| 274 |
|
|---|
| 275 | local desc = [ Description $(>) ] ;
|
|---|
| 276 | if ! $(desc) { desc = "$(>)" ; }
|
|---|
| 277 | PRODUCT_DESCRIPTION on $(<) = $(desc) ;
|
|---|
| 278 |
|
|---|
| 279 | local name ;
|
|---|
| 280 | if $(PACKAGE_LONGNAME) { name = $(PACKAGE_LONGNAME) ; }
|
|---|
| 281 | else if $(PACKAGE_NAME) { name = $(PACKAGE_NAME) ; }
|
|---|
| 282 | else { name = $(>) ; }
|
|---|
| 283 | PRODUCT_NAME on $(<) = $(name) ;
|
|---|
| 284 |
|
|---|
| 285 | GenerateWin32VersionRc $(<) ;
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 | rule MakeManifestFile
|
|---|
| 289 | {
|
|---|
| 290 | # normalize version list
|
|---|
| 291 | local v1, v2, v3, v4 ;
|
|---|
| 292 | v1 = $(PACKAGE_VERSION_LIST[1]) ;
|
|---|
| 293 | if ! $(v1) { v1 = 0 ; }
|
|---|
| 294 | v2 = $(PACKAGE_VERSION_LIST[2]) ;
|
|---|
| 295 | if ! $(v2) { v2 = 0 ; }
|
|---|
| 296 | v3 = $(PACKAGE_VERSION_LIST[3]) ;
|
|---|
| 297 | if ! $(v3) { v3 = 0 ; }
|
|---|
| 298 | v4 = $(PACKAGE_VERSION_LIST[4]) ;
|
|---|
| 299 | if ! $(v4) { v4 = 0 ; }
|
|---|
| 300 | PACKAGE_VERSION_LIST on $(<) = $(v1) $(v2) $(v3) $(v4) ;
|
|---|
| 301 |
|
|---|
| 302 | local desc = [ Description $(>) ] ;
|
|---|
| 303 | if ! $(desc) { desc = "$(>)" ; }
|
|---|
| 304 | PRODUCT_DESCRIPTION on $(<) = $(desc) ;
|
|---|
| 305 |
|
|---|
| 306 | local name ;
|
|---|
| 307 | if $(PACKAGE_NAME) { name = $(PACKAGE_NAME).$(>) ; }
|
|---|
| 308 | else { name = $(>) ; }
|
|---|
| 309 | PRODUCT_NAME on $(<) = $(name) ;
|
|---|
| 310 |
|
|---|
| 311 | GenerateWin32Manifest $(<) ;
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | rule MakeManifestRc
|
|---|
| 315 | {
|
|---|
| 316 | manifestfile = $(<:S=.manifest) ;
|
|---|
| 317 | MakeLocate $(manifestfile) : [ on $(<) GetVar LOCATE ] ;
|
|---|
| 318 | MakeManifestFile $(manifestfile) : $(>) ;
|
|---|
| 319 | MANIFEST_NAME on $(<) = $(manifestfile:G=) ;
|
|---|
| 320 | GenerateWin32ManifestRc $(<) ;
|
|---|
| 321 | Depends $(<) : $(manifestfile) ;
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | rule MakeMetadataRc
|
|---|
| 325 | {
|
|---|
| 326 | local metafile = $($(>)_METAFILE) ;
|
|---|
| 327 | local metarc = $(<) ;
|
|---|
| 328 | Depends $(metarc) : $(metafile) ;
|
|---|
| 329 | GenerateWin32MetadataRc $(metarc) : $(metafile) ;
|
|---|
| 330 | Clean $(>)clean : $(metarc) ;
|
|---|
| 331 | Clean clean : $(metarc) ;
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | rule AppResourceWin32
|
|---|
| 335 | {
|
|---|
| 336 | local options = $(2) ;
|
|---|
| 337 |
|
|---|
| 338 | local versionrc = [ DoObjectGrist _versionrc.rc ] ;
|
|---|
| 339 | LOCATE on $(versionrc) = $(LOCATE_TARGET) ;
|
|---|
| 340 | SEARCH on $(versionrc) = $(LOCATE_TARGET) ;
|
|---|
| 341 |
|
|---|
| 342 | MakeLocate $(versionrc) : $(LOCATE_TARGET) ;
|
|---|
| 343 | MakeVersionRc $(versionrc) : $(<) ;
|
|---|
| 344 | Clean $(<)clean : $(versionrc) ;
|
|---|
| 345 | Clean clean : $(versionrc) ;
|
|---|
| 346 | Win32Resource $(<) : $(versionrc) ;
|
|---|
| 347 |
|
|---|
| 348 | if ! [ IsElem nomanifest : $(options) ]
|
|---|
| 349 | {
|
|---|
| 350 | local manifestrc = [ DoObjectGrist _manifestrc.rc ] ;
|
|---|
| 351 | LOCATE on $(manifestrc) = $(LOCATE_TARGET) ;
|
|---|
| 352 | SEARCH on $(manifestrc) = $(LOCATE_TARGET) ;
|
|---|
| 353 |
|
|---|
| 354 | MakeLocate $(manifestrc) : $(LOCATE_TARGET) ;
|
|---|
| 355 | MakeManifestRc $(manifestrc) : $(<) ;
|
|---|
| 356 | Clean $(<)clean : $(manifestrc) ;
|
|---|
| 357 | Clean clean : $(manifestrc) ;
|
|---|
| 358 | Win32Resource $(<) : $(manifestrc) ;
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | local icon = [ ApplicationIcon win32 : $(<) ] ;
|
|---|
| 362 | if ! $(icon)
|
|---|
| 363 | {
|
|---|
| 364 | local apptype = gui ;
|
|---|
| 365 | if [ IsElem console : $(>) ] { apptype = console ; }
|
|---|
| 366 | icon = [ ApplicationIconDefault win32 : $(apptype) ] ;
|
|---|
| 367 | }
|
|---|
| 368 | if $(icon)
|
|---|
| 369 | {
|
|---|
| 370 | local iconcopy = [ DoObjectGrist $(icon) ] ;
|
|---|
| 371 | MakeLocate $(iconcopy) : $(LOCATE_TARGET) ;
|
|---|
| 372 | Depends $(iconcopy) : $(icon) ;
|
|---|
| 373 | Copy $(iconcopy) : $(icon) ;
|
|---|
| 374 | Clean $(<)clean : $(iconcopy) ;
|
|---|
| 375 | Clean clean : $(iconcopy) ;
|
|---|
| 376 |
|
|---|
| 377 | local iconrc = [ DoObjectGrist $(<)_iconrc.rc ] ;
|
|---|
| 378 | MakeLocate $(iconrc) : $(LOCATE_TARGET) ;
|
|---|
| 379 | Depends $(iconrc) : $(iconcopy) ;
|
|---|
| 380 | GenerateIconRc $(iconrc) : $(iconcopy) ;
|
|---|
| 381 | Clean $(<)clean : $(iconrc) ;
|
|---|
| 382 | Clean clean : $(iconrc) ;
|
|---|
| 383 |
|
|---|
| 384 | Win32Resource $(<) : $(iconrc) ;
|
|---|
| 385 | }
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | rule PluginResourceWin32
|
|---|
| 389 | {
|
|---|
| 390 | local versionrc, metarc ;
|
|---|
| 391 |
|
|---|
| 392 | versionrc = [ DoObjectGrist $(<)_versionrc.rc ] ;
|
|---|
| 393 | MakeLocate $(versionrc) : $(LOCATE_TARGET) ;
|
|---|
| 394 | MakeVersionRc $(versionrc) : $(<) ;
|
|---|
| 395 |
|
|---|
| 396 | if $(EMBED_META) = "yes"
|
|---|
| 397 | {
|
|---|
| 398 | metarc = [ DoObjectGrist $(<)_metarc.rc ] ;
|
|---|
| 399 | MakeLocate $(metarc) : $(LOCATE_TARGET) ;
|
|---|
| 400 | MakeMetadataRc $(metarc) : $(<) ;
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | Clean clean : $(versionrc) $(metarc) ;
|
|---|
| 404 | Clean $(<)clean : $(versionrc) $(metarc) ;
|
|---|
| 405 |
|
|---|
| 406 | Win32Resource $(<) : $(versionrc) $(metarc) ;
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | # SystemLinkApplication target : objects : options
|
|---|
| 410 | rule SystemLinkApplication
|
|---|
| 411 | {
|
|---|
| 412 | local target = $($(<)_TARGET) ;
|
|---|
| 413 |
|
|---|
| 414 | Depends $(target) : $(>) ;
|
|---|
| 415 | if ! [ IsElem console : $(3) ] && $(MODE) = optimize
|
|---|
| 416 | {
|
|---|
| 417 | # Like the MSVC projects build GUI applications as such in optimize builds.
|
|---|
| 418 | # In debug mode, let everything be console apps.
|
|---|
| 419 | EXTRALFLAGS on $(target) += -mwindows ;
|
|---|
| 420 | }
|
|---|
| 421 | LinkApplication $(target) : $(>) ;
|
|---|
| 422 | # setup clean rules
|
|---|
| 423 | Clean clean : $(target) ;
|
|---|
| 424 | Clean $(<)clean : $(target) ;
|
|---|
| 425 |
|
|---|
| 426 | AppResourceWin32 $(<) : $(3) ;
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | rule SystemInstallApplication
|
|---|
| 430 | {
|
|---|
| 431 | local suffix = $(4) ;
|
|---|
| 432 | if "$(suffix)"
|
|---|
| 433 | {
|
|---|
| 434 | local target_suffixed = $(<)-$(suffix) ;
|
|---|
| 435 | local installed =
|
|---|
| 436 | [ DoInstallFile $(<) : $(bindir) $(2) : $(target_suffixed) : $(INSTALL_PROGRAM) ] ;
|
|---|
| 437 | Depends install_bin : $(installed) ;
|
|---|
| 438 | NotFile $(target_suffixed) ;
|
|---|
| 439 | local linktarget = $(<:D=$(bindir)) ;
|
|---|
| 440 | Depends install_bin : [
|
|---|
| 441 | InstallSymLink $(linktarget) : $(target_suffixed) ] ;
|
|---|
| 442 | }
|
|---|
| 443 | else
|
|---|
| 444 | {
|
|---|
| 445 | Depends install_bin :
|
|---|
| 446 | [ DoInstall $(<) : $(bindir) $(2) : $(INSTALL_PROGRAM) ] ;
|
|---|
| 447 | }
|
|---|
| 448 | }
|
|---|
| 449 |
|
|---|
| 450 | rule SystemDoFileListEntryApplications
|
|---|
| 451 | {
|
|---|
| 452 | local target = $($(<)_TARGET) ;
|
|---|
| 453 | local entries = [ DoFileListEntries $(target) : : $(2) ] ;
|
|---|
| 454 | if $(LINK.DEBUG.INFO.SEPARATE) = "yes"
|
|---|
| 455 | {
|
|---|
| 456 | local debugfile = $($(target)_DEBUGFILE) ;
|
|---|
| 457 | entries += [ DoFileListEntries $(debugfile) : : debug-$(2) ] ;
|
|---|
| 458 | }
|
|---|
| 459 | return $(entries) ;
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 |
|
|---|
| 463 | rule SystemInstallPlugin
|
|---|
| 464 | {
|
|---|
| 465 | Depends install_plugin : [ DoInstall $(<) : $(plugindir) $(2) :
|
|---|
| 466 | $(INSTALL_PROGRAM) ] ;
|
|---|
| 467 | }
|
|---|
| 468 |
|
|---|
| 469 | rule SystemDoFileListEntryPlugin
|
|---|
| 470 | {
|
|---|
| 471 | local target = $($(<)_TARGET) ;
|
|---|
| 472 | local entries = [ DoFileListEntries $(target) : : $(2) ] ;
|
|---|
| 473 | if $(LINK.DEBUG.INFO.SEPARATE) = "yes"
|
|---|
| 474 | {
|
|---|
| 475 | local debugfile = $($(target)_DEBUGFILE) ;
|
|---|
| 476 | entries += [ DoFileListEntries $(debugfile) : : debug-$(2) ] ;
|
|---|
| 477 | }
|
|---|
| 478 | if $(EMBED_META) != "yes" || $(OBJCOPY.AVAILABLE) != "yes"
|
|---|
| 479 | {
|
|---|
| 480 | entries += [ DoFileListEntries $($(<)_METAFILE) : : $(2) ] ;
|
|---|
| 481 | }
|
|---|
| 482 | return $(entries) ;
|
|---|
| 483 | }
|
|---|
| 484 |
|
|---|
| 485 | # SystemLinkPlugin target : objects : options
|
|---|
| 486 | rule SystemLinkPlugin
|
|---|
| 487 | {
|
|---|
| 488 | local target = $($(<)_TARGET) ;
|
|---|
| 489 |
|
|---|
| 490 | if $(USE_DLLWRAP) = "yes"
|
|---|
| 491 | {
|
|---|
| 492 | local exportdefs = [ DoObjectGrist $(<).def ] ;
|
|---|
| 493 | NAME on $(exportdefs) = $(<) ;
|
|---|
| 494 | GenerateExportDefs $(exportdefs) : $($(<)_METAFILE) ;
|
|---|
| 495 | Depends $(target) : $(exportdefs) ;
|
|---|
| 496 | EXPORTDEFS on $(target) = $(exportdefs) ;
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 | Depends $(target) : $(>) ;
|
|---|
| 500 | LinkPlugin $(target) : $(>) ;
|
|---|
| 501 | PluginResourceWin32 $(<) ;
|
|---|
| 502 |
|
|---|
| 503 | if $(EMBED_META) != "yes"
|
|---|
| 504 | {
|
|---|
| 505 | PluginMetaData $(<) : $($(<)_METAFILE) : $(3) ;
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | Clean clean : $(target) ;
|
|---|
| 509 | Clean $(<)clean : $(target) ;
|
|---|
| 510 | }
|
|---|
| 511 |
|
|---|
| 512 | rule MakeDllDefFile
|
|---|
| 513 | {
|
|---|
| 514 | local def = $(<) ;
|
|---|
| 515 | local objects = $(>) ;
|
|---|
| 516 |
|
|---|
| 517 | MakeLocate $(def) : $(LOCATE.OBJECTS)/libs ;
|
|---|
| 518 | WriteDefHeader $(def) ;
|
|---|
| 519 | for i in $(objects)
|
|---|
| 520 | {
|
|---|
| 521 | local drectve = $(i).drectve ;
|
|---|
| 522 | MakeLocate $(drectve) : [ on $(i) GetVar LOCATE ] ;
|
|---|
| 523 | Depends $(drectve) : $(i) ;
|
|---|
| 524 | Depends $(def) : $(drectve) ;
|
|---|
| 525 | ExtractDrectve $(drectve) : $(i) ;
|
|---|
| 526 | DrectveToDef $(def) : $(drectve) ;
|
|---|
| 527 | Clean clean : $(drectve) ;
|
|---|
| 528 | Clean $(def)clean : $(drectve) ;
|
|---|
| 529 | }
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | # SystemLinkSharedLibrary barename : target : objects : linklib
|
|---|
| 533 | rule SystemLinkSharedLibrary
|
|---|
| 534 | {
|
|---|
| 535 | local barename = $(1) ;
|
|---|
| 536 | local target = $(2) ;
|
|---|
| 537 | local objects = $(3) ;
|
|---|
| 538 | local linklib = $(4) ;
|
|---|
| 539 | LFlags $(target) : $(LINKLIBS) ;
|
|---|
| 540 |
|
|---|
| 541 | # The "crystalspace" library is so massive that it blows Jam's command line
|
|---|
| 542 | # length limit when all object files are passed in at once to some command.
|
|---|
| 543 | # However, a DLL, like an executable, needs to be built with all objects at
|
|---|
| 544 | # once.
|
|---|
| 545 | # Problem is, since dllwrap etc. don't support response files, there is no
|
|---|
| 546 | # way to pass all objects at once to it. But, a static library can be built
|
|---|
| 547 | # piecemeal, so we take the detour of creating a static library out of the
|
|---|
| 548 | # DLL objects first.
|
|---|
| 549 | # However, another bug hits us: on MinGW, symbols exported from objects in
|
|---|
| 550 | # static libraries are not automatically exported from the DLL.
|
|---|
| 551 | # We work this around by constructing a .DEF file with all exports of the
|
|---|
| 552 | # DLL. Conveniently (somewhat), all exported symbols are into a section
|
|---|
| 553 | # ".drectve" of an object file by gcc. After extracting these sections and
|
|---|
| 554 | # some postprocessing, we finally have all .DEF entries. Phew.
|
|---|
| 555 | local lib = $(target).a ;
|
|---|
| 556 | MakeLocate $(lib) $(lib)($(objects:BS)) : $(LOCATE.OBJECTS)/libs ;
|
|---|
| 557 | Depends $(lib) : $(lib)($(objects:BS)) ;
|
|---|
| 558 | local i ;
|
|---|
| 559 | for i in $(objects)
|
|---|
| 560 | {
|
|---|
| 561 | Depends $(lib)($(i:BS)) : $(i) ;
|
|---|
| 562 | }
|
|---|
| 563 | Archive $(lib) : $(objects) ;
|
|---|
| 564 | Ranlib $(lib) ;
|
|---|
| 565 | #RmTemps $(lib) : $(objects) ;
|
|---|
| 566 |
|
|---|
| 567 | Depends $(target) : $(lib) ;
|
|---|
| 568 |
|
|---|
| 569 | local def = $(target).def ;
|
|---|
| 570 | MakeDllDefFile $(def) : $(objects) ;
|
|---|
| 571 | Depends $(target) : $(def) ;
|
|---|
| 572 | Clean clean : $(def) ;
|
|---|
| 573 | Clean $(barename)clean : $(def) ;
|
|---|
| 574 | Depends $(barename)clean : $(def)clean ;
|
|---|
| 575 |
|
|---|
| 576 | EXPORTDEFS on $(target) = $(def) ;
|
|---|
| 577 | IMPLIB on $(target) = $(linklib) ;
|
|---|
| 578 | Depends $(linklib) : $(target) ;
|
|---|
| 579 | LinkSharedLibrary $(target) : $(lib) ;
|
|---|
| 580 |
|
|---|
| 581 | Clean clean : $(target) ;
|
|---|
| 582 | Clean $(barename)clean : $(target) ;
|
|---|
| 583 | }
|
|---|
| 584 |
|
|---|
| 585 | actions ExtractDrectve
|
|---|
| 586 | {
|
|---|
| 587 | $(CMD.OBJCOPY) -j .drectve -O binary $(>) $(<).tmp
|
|---|
| 588 | echo >> $(<).tmp # Cheap trick to ensure there's always a .tmp file;
|
|---|
| 589 | # the action should not break with no .drectve - no exports
|
|---|
| 590 | # is a valid scenario.
|
|---|
| 591 | $(CMD.STRINGS) -n 1 $(<).tmp > $(<) # Run strings since the section data may be
|
|---|
| 592 | # padded with zeroes, get rid of those.
|
|---|
| 593 | rm $(<).tmp
|
|---|
| 594 | }
|
|---|
| 595 |
|
|---|
| 596 | actions WriteDefHeader
|
|---|
| 597 | {
|
|---|
| 598 | echo "EXPORTS" > $(<)
|
|---|
| 599 | }
|
|---|
| 600 |
|
|---|
| 601 | actions piecemeal together DrectveToDef
|
|---|
| 602 | {
|
|---|
| 603 | for d in $(>)
|
|---|
| 604 | do
|
|---|
| 605 | sed -e "s/ /\\
|
|---|
| 606 | /g" $d | sed -e "s/-export:\(.*\)/\1/g" | sed -e "s/,data/ DATA/g" >> $(<)
|
|---|
| 607 | done
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | actions GenerateImportLib
|
|---|
| 611 | {
|
|---|
| 612 | $(CMD.DLLTOOL) -d $(>) -l $(<)
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | actions LinkApplication bind NEEDLIBS bind EXTRAOBJECTS
|
|---|
| 616 | {
|
|---|
| 617 | $(CMD.LINK) -o $(<) $(>) $(EXTRAOBJECTS) $(NEEDLIBS) $(LINKLIBS) $(EXTRALFLAGS)
|
|---|
| 618 | }
|
|---|
| 619 |
|
|---|
| 620 | if $(USE_DLLWRAP) != "yes"
|
|---|
| 621 | {
|
|---|
| 622 | actions LinkPlugin bind NEEDLIBS bind EXTRAOBJECTS
|
|---|
| 623 | {
|
|---|
| 624 | $(CMD.LINK) -o $(<) $(>) $(EXTRAOBJECTS) $(NEEDLIBS) $(LINKLIBS)
|
|---|
| 625 | }
|
|---|
| 626 | }
|
|---|
| 627 | else
|
|---|
| 628 | {
|
|---|
| 629 | actions LinkPlugin bind NEEDLIBS bind EXTRAOBJECTS bind EXPORTDEFS
|
|---|
| 630 | {
|
|---|
| 631 | $(CMD.DLLWRAP) --driver-name=$(CMD.LINK[1]) --dllname $(<:B) --def=$(EXPORTDEFS) -o $(<) $(>) $(EXTRAOBJECTS) $(NEEDLIBS) $(LINKLIBS)
|
|---|
| 632 | }
|
|---|
| 633 | }
|
|---|
| 634 |
|
|---|
| 635 | actions LinkSharedLibrary bind NEEDLIBS bind EXTRAOBJECTS bind EXPORTDEFS bind IMPLIB
|
|---|
| 636 | {
|
|---|
| 637 | $(CMD.DLLWRAP) --driver-name=$(CMD.LINK[1]) --dllname $(<:B).dll --def=$(EXPORTDEFS) --implib $(IMPLIB) -o $(<) $(>) $(EXTRAOBJECTS) $(NEEDLIBS) $(LINKLIBS)
|
|---|
| 638 | }
|
|---|