1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24GUI := WNT 25COM := MSC 26 27# set tmpdir to some mixed case path, suitable for native tools 28gb_TMPDIR:=$(if $(TMPDIR),$(shell cygpath -m $(TMPDIR)),$(shell cygpath -m /tmp)) 29gb_MKTEMP := mktemp --tmpdir=$(gb_TMPDIR) gbuild.XXXXXX 30 31ifeq ($(CPUNAME),INTEL) 32gb_AS := ml 33else ifeq ($(CPUNAME),X86_64) 34gb_AS := ml64 35endif 36 37gb_CC := cl 38gb_CXX := cl 39gb_LINK := link 40gb_MT := mt 41gb_AWK := awk 42gb_CLASSPATHSEP := ; 43gb_RC := rc 44 45# use CC/CXX if they are nondefaults 46ifneq ($(origin AS),default) 47gb_AS := $(AS) 48endif 49ifneq ($(origin CC),default) 50gb_CC := $(CC) 51gb_GCCP := $(CC) 52endif 53ifneq ($(origin CXX),default) 54gb_CXX := $(CXX) 55endif 56 57gb_OSDEFS := \ 58 -DWINVER=0x0500 \ 59 -D_WIN32_IE=0x0500 \ 60 -DNT351 \ 61 -DWIN32 \ 62 -DWNT \ 63 64gb_COMPILERDEFS := \ 65 -DMSC \ 66 -D_CRT_NON_CONFORMING_SWPRINTFS \ 67 -D_CRT_NONSTDC_NO_DEPRECATE \ 68 -D_CRT_SECURE_NO_DEPRECATE \ 69 -D_MT \ 70 -D_DLL \ 71 -DCPPU_ENV=$(COMNAME) \ 72 -DFULL_DESK \ 73 -DM1500 \ 74 75gb_CPUDEFS := -D$(ALIGN) -D$(CPUNAME) 76ifeq ($(CPUNAME),INTEL) 77gb_CPUDEFS += -D_X86_=1 78endif 79ifeq ($(CPUNAME),X86_64) 80gb_CPUDEFS += -D_AMD64_=1 81endif 82 83ifeq ($(CPUNAME),INTEL) 84gb_COMPILERDEFS += -DBOOST_MEM_FN_ENABLE_CDECL 85endif 86 87gb_RCDEFS := \ 88 -DWINVER=0x0400 \ 89 -DWIN32 \ 90 91gb_RCFLAGS := \ 92 -V 93 94gb_CFLAGS := \ 95 -Gd \ 96 -GR \ 97 -Gs \ 98 -GS \ 99 -nologo \ 100 -Wall \ 101 -wd4005 \ 102 -wd4061 \ 103 -wd4127 \ 104 -wd4180 \ 105 -wd4189 \ 106 -wd4191 \ 107 -wd4217 \ 108 -wd4250 \ 109 -wd4251 \ 110 -wd4255 \ 111 -wd4275 \ 112 -wd4290 \ 113 -wd4294 \ 114 -wd4350 \ 115 -wd4355 \ 116 -wd4365 \ 117 -wd4503 \ 118 -wd4505 \ 119 -wd4511 \ 120 -wd4512 \ 121 -wd4514 \ 122 -wd4611 \ 123 -wd4619 \ 124 -wd4625 \ 125 -wd4626 \ 126 -wd4640 \ 127 -wd4668 \ 128 -wd4675 \ 129 -wd4692 \ 130 -wd4710 \ 131 -wd4711 \ 132 -wd4738 \ 133 -wd4786 \ 134 -wd4800 \ 135 -wd4820 \ 136 -wd4826 \ 137 -Zc:wchar_t- \ 138 -Zm500 \ 139 140gb_CXXFLAGS := \ 141 -Gd \ 142 -GR \ 143 -Gs \ 144 -GS \ 145 -Gy \ 146 -nologo \ 147 -Wall \ 148 -wd4005 \ 149 -wd4061 \ 150 -wd4127 \ 151 -wd4180 \ 152 -wd4189 \ 153 -wd4191 \ 154 -wd4217 \ 155 -wd4250 \ 156 -wd4251 \ 157 -wd4275 \ 158 -wd4290 \ 159 -wd4294 \ 160 -wd4350 \ 161 -wd4355 \ 162 -wd4365 \ 163 -wd4503 \ 164 -wd4505 \ 165 -wd4511 \ 166 -wd4512 \ 167 -wd4514 \ 168 -wd4611 \ 169 -wd4619 \ 170 -wd4625 \ 171 -wd4626 \ 172 -wd4640 \ 173 -wd4668 \ 174 -wd4675 \ 175 -wd4692 \ 176 -wd4710 \ 177 -wd4711 \ 178 -wd4738 \ 179 -wd4786 \ 180 -wd4800 \ 181 -wd4820 \ 182 -wd4826 \ 183 -Zc:wchar_t- \ 184 -Zm500 \ 185 186gb_STDLIBS := \ 187 uwinapi \ 188 kernel32 \ 189 msvcrt \ 190 oldnames \ 191 192# Compiler flags that must NOT reach makedepend. gbuild hands the same flag 193# list to the compiler and to makedepend, and makedepend is an X11-era tool 194# that parses the list itself rather than ignoring what it does not know. 195# Empty by default, so a VC9 build passes exactly what it passed before. 196gb_MakeDepend_FILTEROUT := 197 198# The UCRT compiler generation -- COMEX 14, i.e. VS2015 (cl 19.00) and every 199# toolset since. This mirrors solenv/inc/wntmsc14.mk, which carries the same 200# delta for the dmake half of the build. The two have to agree: a module built 201# by one links against libraries built by the other. See that file for the 202# reasoning behind each of these. 203ifeq ($(COMEX),14) 204 205# C++14, not 17. std::tr1 -- which boost/tr1 and the stlport shims name 206# directly -- is only present while _HAS_CXX17 is 0; the tree is still full of 207# empty exception specifications, which C++20 removes; and <hash_map> and 208# <hash_set> become a hard #error under C++17. /std:c++03 is not an escape, 209# a modern cl rejects it outright (D9002). 210gb_CXXFLAGS += -std:c++14 211 212# ...and makedepend must never see it. -s is one of makedepend's OWN options 213# -- the start delimiter it writes above the dependencies, which has to begin 214# with '#'. It reads -std:c++14 as that option with an illegal value, prints 215# 216# makedepend.exe: error: -s flag's value should start with '#'. 217# 218# and exits before scanning anything. The .d file is still created and still 219# holds its target line, so make is happy and the build succeeds -- but it 220# lists no prerequisites at all, and every header change stops triggering a 221# rebuild. Nothing about that is visible from a clean build, which is why it 222# is called out at this length. 223gb_MakeDepend_FILTEROUT += -std:% 224 225# Without this MSVC reports __cplusplus as 199711L whatever /std: says, and 226# the shims in main/stlport/systemstl branch on that value. 227gb_CXXFLAGS += -Zc:__cplusplus 228 229# The two halves of the old snprintf shim are not symmetric. The UCRT 230# declares a real snprintf and refuses to compile with the name taken (C1189); 231# it has never declared snwprintf, because the wide C99 name has never existed 232# in any MSVC CRT. So one half is dropped and the other kept. 233gb_CFLAGS += -Dsnwprintf=_snwprintf 234gb_CXXFLAGS += -Dsnwprintf=_snwprintf 235 236# stdext::hash_map and stdext::hash_set are deprecated to the point of a hard 237# #error. These are the stdext containers, not std::unordered_map, so 238# replacing them is a refactor and not a build fix. 239gb_CFLAGS += -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS 240gb_CXXFLAGS += -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS 241 242# Warnings a modern cl adds in volume, every one of them a report about old 243# code: C4996 deprecated CRT and POSIX names, C4577 noexcept without an 244# exception handling mode (this build passes -EHa, which is one, but the 245# warning fires on the empty specifications anyway), C5040 an exception 246# specification on a function pointer type. 247gb_CFLAGS += -wd4996 248gb_CXXFLAGS += -wd4996 -wd4577 -wd5040 249 250endif 251 252ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE) 253gb_CFLAGS_WERROR := -WX 254gb_CXXFLAGS_WERROR := -WX 255endif 256 257gb_LinkTarget_EXCEPTIONFLAGS := \ 258 -DEXCEPTIONS_ON \ 259 -EHa \ 260 261gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS) 262 263 264gb_LinkTarget_NOEXCEPTIONFLAGS := \ 265 -DEXCEPTIONS_OFF \ 266 267gb_NoexPrecompiledHeader_NOEXCEPTIONFLAGS := $(gb_LinkTarget_NOEXCEPTIONFLAGS) 268 269ifeq ($(CPUNAME),INTEL) 270gb_LinkTarget_LDFLAGS := \ 271 -MACHINE:IX86 \ 272 -NODEFAULTLIB \ 273 $(patsubst %,-LIBPATH:%,$(filter-out .,$(subst ;, ,$(subst \,/,$(ILIB))))) \ 274 275endif 276ifeq ($(CPUNAME),X86_64) 277gb_LinkTarget_LDFLAGS := \ 278 -MACHINE:X64 \ 279 -NODEFAULTLIB \ 280 $(patsubst %,-LIBPATH:%,$(filter-out .,$(subst ;, ,$(subst \,/,$(ILIB))))) \ 281 282endif 283 284gb_DEBUG_CFLAGS := -Zi 285 286ifeq ($(gb_DEBUGGING),TRUE) 287gb_LinkTarget_LDFLAGS += -DEBUG 288endif 289 290# this does not use CFLAGS so it is not overridable 291ifneq ($(ENABLE_CRASHDUMP),) 292gb_CFLAGS+=-Zi 293gb_CXXFLAGS+=-Zi 294endif 295 296ifeq ($(gb_DEBUGLEVEL),2) 297gb_COMPILEROPTFLAGS := 298else 299gb_COMPILEROPTFLAGS := -Ob1 -Oxs -Oy- 300endif 301 302gb_COMPILERNOOPTFLAGS := -Od 303 304 305# Helper class 306gb_Helper_SRCDIR_NATIVE := $(shell cygpath -m $(SRCDIR) | $(gb_AWK) -- '{ print tolower(substr($$0,1,1)) substr($$0,2) }') 307gb_Helper_WORKDIR_NATIVE := $(shell cygpath -m $(WORKDIR) | $(gb_AWK) -- '{ print tolower(substr($$0,1,1)) substr($$0,2) }') 308gb_Helper_OUTDIR_NATIVE := $(shell cygpath -m $(OUTDIR) | $(gb_AWK) -- '{ print tolower(substr($$0,1,1)) substr($$0,2) }') 309gb_Helper_REPODIR_NATIVE := $(shell cygpath -m $(REPODIR) | $(gb_AWK) -- '{ print tolower(substr($$0,1,1)) substr($$0,2) }') 310 311define gb_Helper_abbreviate_dirs_native 312R=$(gb_Helper_REPODIR_NATIVE) && $(subst $(REPODIR)/,$$R/,$(subst $(gb_Helper_REPODIR_NATIVE)/,$$R/,O=$(gb_Helper_OUTDIR_NATIVE) && W=$(gb_Helper_WORKDIR_NATIVE) && S=$(gb_Helper_SRCDIR_NATIVE))) && \ 313$(subst $(REPODIR)/,$$R/,$(subst $(SRCDIR)/,$$S/,$(subst $(OUTDIR)/,$$O/,$(subst $(WORKDIR)/,$$W/,$(subst $(gb_Helper_REPODIR_NATIVE)/,$$R/,$(subst $(gb_Helper_SRCDIR_NATIVE)/,$$S/,$(subst $(gb_Helper_OUTDIR_NATIVE)/,$$O/,$(subst $(gb_Helper_WORKDIR_NATIVE)/,$$W/,$(1))))))))) 314endef 315 316# convert parameters filesystem root to native notation 317# does some real work only on windows, make sure not to 318# break the dummy implementations on unx* 319define gb_Helper_convert_native 320$(patsubst -I$(OUTDIR)%,-I$(gb_Helper_OUTDIR_NATIVE)%, \ 321$(patsubst $(OUTDIR)%,$(gb_Helper_OUTDIR_NATIVE)%, \ 322$(patsubst $(WORKDIR)%,$(gb_Helper_WORKDIR_NATIVE)%, \ 323$(patsubst $(SRCDIR)%,$(gb_Helper_SRCDIR_NATIVE)%, \ 324$(1))))) 325endef 326 327# convert parameters filesystem root to native notation 328# does some real work only on windows, make sure not to 329# break the dummy implementations on unx* 330define gb_Helper_convert_native 331$(patsubst -I$(OUTDIR)%,-I$(gb_Helper_OUTDIR_NATIVE)%, \ 332$(patsubst $(OUTDIR)%,$(gb_Helper_OUTDIR_NATIVE)%, \ 333$(patsubst $(WORKDIR)%,$(gb_Helper_WORKDIR_NATIVE)%, \ 334$(patsubst $(SRCDIR)%,$(gb_Helper_SRCDIR_NATIVE)%, \ 335$(1))))) 336endef 337 338 339# AsmObject class 340 341gb_AsmObject_EXT := .asm 342 343define gb_AsmObject__command 344$(call gb_Output_announce,$(2),$(true),ASM,3) 345$(call gb_Helper_abbreviate_dirs_native,\ 346 mkdir -p $(dir $(1)) && \ 347 unset INCLUDE && \ 348 $(gb_AS) \ 349 $(DEFS) \ 350 -safeseh \ 351 -Cp \ 352 -coff \ 353 -Fo$(1) \ 354 -c $(3)) 355endef 356 357# CObject class 358 359ifeq ($(gb_FULLDEPS),$(true)) 360define gb_Object__command_deponcompile 361$(call gb_Helper_abbreviate_dirs_native,\ 362 $(OUTDIR)/bin/makedepend$(gb_Executable_EXT) \ 363 $(filter-out -DPRECOMPILED_HEADERS $(gb_MakeDepend_FILTEROUT),$(4)) $(filter-out $(gb_MakeDepend_FILTEROUT),$(5)) \ 364 -I$(dir $(3)) \ 365 $(filter-out -I$(COMPATH)% %/pch -I$(JAVA_HOME)%,$(6)) \ 366 $(3) \ 367 -f - \ 368 | $(gb_AWK) -f $(GBUILDDIR)/processdeps.awk \ 369 -v OBJECTFILE=$(1) \ 370 -v OUTDIR=$(OUTDIR)/ \ 371 -v WORKDIR=$(WORKDIR)/ \ 372 -v SRCDIR=$(SRCDIR)/ \ 373 -v REPODIR=$(REPODIR)/ \ 374 > $(2)) 375endef 376else 377gb_Object__command_deponcompile = 378endif 379 380define gb_CObject__command 381$(call gb_Output_announce,$(2),$(true),C ,3) 382$(call gb_Helper_abbreviate_dirs_native,\ 383 mkdir -p $(dir $(1)) $(dir $(4)) && \ 384 unset INCLUDE && \ 385 $(gb_CC) \ 386 $(DEFS) \ 387 $(T_CFLAGS) \ 388 -Fd$(PDBFILE) \ 389 $(CFLAGS) \ 390 $(PCHFLAGS) \ 391 -I$(dir $(3)) \ 392 $(INCLUDE) \ 393 -c $(3) \ 394 -Fo$(1)) 395$(call gb_Object__command_deponcompile,$(1),$(4),$(3),$(DEFS),$(T_CFLAGS),$(INCLUDE)) 396endef 397 398 399# CxxObject class 400 401define gb_CxxObject__command 402$(call gb_Output_announce,$(2),$(true),CXX,3) 403$(call gb_Helper_abbreviate_dirs_native,\ 404 mkdir -p $(dir $(1)) $(dir $(4)) && \ 405 unset INCLUDE && \ 406 $(gb_CXX) \ 407 $(DEFS) \ 408 $(T_CXXFLAGS) \ 409 -Fd$(PDBFILE) \ 410 $(CXXFLAGS) \ 411 $(PCHFLAGS) \ 412 -I$(dir $(3)) \ 413 $(INCLUDE_STL) $(INCLUDE) \ 414 -c $(3) \ 415 -Fo$(1)) 416$(call gb_Object__command_deponcompile,$(1),$(4),$(3),$(DEFS),$(T_CXXFLAGS),$(INCLUDE)) 417endef 418 419 420# PrecompiledHeader class 421 422gb_PrecompiledHeader_get_enableflags = -DPRECOMPILED_HEADERS -Yu$(1).hxx \ 423 -Fp$(call gb_PrecompiledHeader_get_target,$(1)) 424 425ifeq ($(gb_FULLDEPS),$(true)) 426define gb_PrecompiledHeader__command_deponcompile 427$(call gb_Helper_abbreviate_dirs_native,\ 428 $(OUTDIR)/bin/makedepend$(gb_Executable_EXT) \ 429 $(filter-out $(gb_MakeDepend_FILTEROUT),$(4) $(5)) \ 430 -I$(dir $(3)) \ 431 $(filter-out -I$(COMPATH)% -I$(JAVA_HOME)%,$(6)) \ 432 $(3) \ 433 -f - \ 434 | $(gb_AWK) -f $(GBUILDDIR)/processdeps.awk \ 435 -v OBJECTFILE=$(1) \ 436 -v OUTDIR=$(OUTDIR)/ \ 437 -v WORKDIR=$(WORKDIR)/ \ 438 -v SRCDIR=$(SRCDIR)/ \ 439 -v REPODIR=$(REPODIR)/ \ 440 > $(call gb_PrecompiledHeader_get_dep_target,$(2))) 441endef 442else 443gb_PrecompiledHeader__command_deponcompile = 444endif 445 446 447define gb_PrecompiledHeader__command 448$(call gb_Output_announce,$(2),$(true),PCH,1) 449$(call gb_Helper_abbreviate_dirs_native,\ 450 mkdir -p $(dir $(1)) $(dir $(call gb_PrecompiledHeader_get_dep_target,$(2))) && \ 451 unset INCLUDE && \ 452 $(gb_CXX) \ 453 $(4) $(5) -Fd$(PDBFILE) \ 454 -I$(dir $(3)) \ 455 $(6) \ 456 -c $(3) \ 457 -DPRECOMPILED_HEADERS \ 458 -Yc$(notdir $(patsubst %.cxx,%.hxx,$(3))) -Fp$(1) -Fo$(1).obj) 459$(call gb_PrecompiledHeader__command_deponcompile,$(1),$(2),$(3),$(4),$(5),$(6)) 460endef 461 462# NoexPrecompiledHeader class 463 464gb_NoexPrecompiledHeader_get_enableflags = -Yu$(1).hxx \ 465 -Fp$(call gb_NoexPrecompiledHeader_get_target,$(1)) 466 467ifeq ($(gb_FULLDEPS),$(true)) 468define gb_NoexPrecompiledHeader__command_deponcompile 469$(call gb_Helper_abbreviate_dirs_native,\ 470 $(OUTDIR)/bin/makedepend$(gb_Executable_EXT) \ 471 $(filter-out $(gb_MakeDepend_FILTEROUT),$(4) $(5)) \ 472 -I$(dir $(3)) \ 473 $(filter-out -I$(COMPATH)% -I$(JAVA_HOME)%,$(6)) \ 474 $(3) \ 475 -f - \ 476 | $(gb_AWK) -f $(GBUILDDIR)/processdeps.awk \ 477 -v OBJECTFILE=$(1) \ 478 -v OUTDIR=$(OUTDIR)/ \ 479 -v WORKDIR=$(WORKDIR)/ \ 480 -v SRCDIR=$(SRCDIR)/ \ 481 -v REPODIR=$(REPODIR)/ \ 482 > $(call gb_NoexPrecompiledHeader_get_dep_target,$(2))) 483endef 484else 485gb_NoexPrecompiledHeader__command_deponcompile = 486endif 487 488 489define gb_NoexPrecompiledHeader__command 490$(call gb_Output_announce,$(2),$(true),PCH,1) 491$(call gb_Helper_abbreviate_dirs_native,\ 492 mkdir -p $(dir $(1)) $(dir $(call gb_NoexPrecompiledHeader_get_dep_target,$(2))) && \ 493 unset INCLUDE && \ 494 $(gb_CXX) \ 495 $(4) $(5) -Fd$(PDBFILE) \ 496 -I$(dir $(3)) \ 497 $(6) \ 498 -c $(3) \ 499 -DPRECOMPILED_HEADERS \ 500 -Yc$(notdir $(patsubst %.cxx,%.hxx,$(3))) -Fp$(1) -Fo$(1).obj) 501$(call gb_NoexPrecompiledHeader__command_deponcompile,$(1),$(2),$(3),$(4),$(5),$(6)) 502endef 503 504# LinkTarget class 505 506gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) 507gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 508 509gb_LinkTarget_INCLUDE :=\ 510 $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) \ 511 $(foreach inc,$(subst ;, ,$(JDKINC)),-I$(inc)) \ 512 513gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 514 515gb_LinkTarget_get_pdbfile = $(call gb_LinkTarget_get_target,)pdb/$(1).pdb 516 517# Runs the linker command to generate the binary. 518# If a .manifest file is generated, embeds it into the binary. 519define gb_LinkTarget__command 520$(call gb_Output_announce,$(2),$(true),LNK,4) 521$(call gb_Helper_abbreviate_dirs_native,\ 522 mkdir -p $(dir $(1)) && \ 523 rm -f $(1) && \ 524 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),100, \ 525 $(call gb_Helper_convert_native,\ 526 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \ 527 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 528 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \ 529 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 530 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 531 $(PCHOBJS) $(NATIVERES))) && \ 532 $(gb_LINK) \ 533 $(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 534 $(if $(filter StaticLibrary,$(TARGETTYPE)),$(gb_StaticLibrary_TARGETTYPEFLAGS)) \ 535 $(if $(filter GoogleTest Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \ 536 $(if $(filter YES,$(gb_Executable_TARGETGUI)), -SUBSYSTEM:WINDOWS, -SUBSYSTEM:CONSOLE) \ 537 $(T_LDFLAGS) \ 538 @$${RESPONSEFILE} \ 539 $(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib))) \ 540 $(patsubst %,%.lib,$(EXTERNAL_LIBS)) \ 541 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_filename,$(lib))) \ 542 $(LIBS) \ 543 $(if $(DLLTARGET),-out:$(DLLTARGET) -implib:$(1),-out:$(1)); \ 544 RC=$$?; \ 545 if [ -f $(if $(DLLTARGET),$(DLLTARGET),$(1)).manifest ]; then \ 546 $(gb_MT) \ 547 -manifest $(if $(DLLTARGET),$(DLLTARGET),$(1)).manifest \ 548 -outputresource:$(if $(DLLTARGET),$(DLLTARGET),$(1)); \ 549 fi; \ 550 rm $${RESPONSEFILE} \ 551 $(if $(DLLTARGET),; if [ ! -f $(DLLTARGET) ]; then rm -f $(1) && false; fi) ; exit $$RC) 552endef 553 554 555# Library class 556 557gb_Library_DEFS := -D_DLL_ 558ifeq ($(CPUNAME),INTEL) 559gb_Library_TARGETTYPEFLAGS := -DLL -OPT:NOREF -SAFESEH -NXCOMPAT -DYNAMICBASE 560endif 561ifeq ($(CPUNAME),X86_64) 562gb_Library_TARGETTYPEFLAGS := -DLL -OPT:NOREF -NXCOMPAT -DYNAMICBASE 563endif 564gb_Library_get_rpath := 565 566gb_Library_SYSPRE := i 567gb_Library_PLAINEXT := .lib 568 569gb_Library_PLAINLIBS_NONE += \ 570 advapi32 \ 571 comdlg32 \ 572 d3d9 \ 573 d3dx \ 574 ddraw \ 575 gdi32 \ 576 gdiplus \ 577 glu32 \ 578 gnu_getopt \ 579 imm32\ 580 kernel32 \ 581 msimg32 \ 582 msvcrt \ 583 mpr \ 584 oldnames \ 585 ole32 \ 586 oleaut32 \ 587 opengl32 \ 588 shell32 \ 589 shlwapi \ 590 strmiids \ 591 user32 \ 592 uuid \ 593 uwinapi \ 594 version \ 595 winmm \ 596 winspool \ 597 ws2_32 \ 598 wsock32 599 600# The CRT split in three when the UCRT arrived: msvcrt.lib is the startup and 601# import library, vcruntime.lib the compiler runtime, ucrt.lib the C library 602# proper. This build links -NODEFAULTLIB, so the /DEFAULTLIB directives cl 603# emits are ignored and every part has to be named -- but gbuild refuses to 604# link a library it has not been told about, so they are registered here 605# first. Both statements sit together because doing only one of them fails 606# late and confusingly ("Cannot link against library/libraries ..."). 607ifeq ($(COMEX),14) 608gb_Library_PLAINLIBS_NONE += \ 609 ucrt \ 610 vcruntime 611 612gb_STDLIBS += vcruntime ucrt 613endif 614 615gb_Library_LAYER := \ 616 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 617 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):OOO) \ 618 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):OOO) \ 619 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 620 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 621 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):OOO) \ 622 $(foreach lib,$(gb_Library_STLLIBS),$(lib):OOO) \ 623 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):OOO) \ 624 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 625 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):OOO) \ 626 627gb_Library_FILENAMES :=\ 628 $(foreach lib,$(gb_Library_TARGETS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 629 630gb_Library_DLLEXT := .dll 631gb_Library_MAJORVER := 3 632gb_Library_RTEXT := MSC$(gb_Library_DLLEXT) 633 634ifeq ($(USE_SYSTEM_STL),YES) 635ifeq ($(gb_PRODUCT),$(true)) 636gb_Library_STLEXT := msvcprt.lib 637else 638gb_Library_STLEXT := msvcprt.lib 639endif 640else 641ifeq ($(gb_PRODUCT),$(true)) 642gb_Library_STLEXT := port_vc7145$(gb_Library_DLLEXT) 643else 644gb_Library_STLEXT := port_vc7145_stldebug$(gb_Library_DLLEXT) 645endif 646endif 647 648gb_Library_OOOEXT := $(gb_Library_DLLEXT) 649gb_Library_UNOEXT := .uno$(gb_Library_DLLEXT) 650gb_Library_UNOVEREXT := $(gb_Library_MAJORVER)$(gb_Library_DLLEXT) 651gb_Library_RTVEREXT := $(gb_Library_MAJORVER)$(gb_Library_RTEXT) 652 653gb_Library_DLLFILENAMES :=\ 654 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(lib)$(gb_Library_OOOEXT)) \ 655 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(lib)$(gb_Library_DLLEXT)) \ 656 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(lib)$(gb_Library_DLLEXT)) \ 657 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(lib)$(gb_Library_DLLEXT)) \ 658 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(lib)$(gb_Library_RTEXT)) \ 659 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(lib)$(gb_Library_RTVEREXT)) \ 660 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(lib)$(gb_Library_STLEXT)) \ 661 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 662 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 663 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(lib)$(gb_Library_UNOVEREXT)) \ 664 665define gb_Library_Library_platform 666$(call gb_LinkTarget_set_dlltarget,$(2),$(3)) 667 668$(call gb_LinkTarget_set_auxtargets,$(2),\ 669 $(patsubst %.lib,%.exp,$(call gb_LinkTarget_get_target,$(2))) \ 670 $(3).manifest \ 671 $(call gb_LinkTarget_get_pdbfile,$(2)) \ 672 $(patsubst %.dll,%.pdb,$(3)) \ 673 $(patsubst %.dll,%.ilk,$(3)) \ 674) 675 676$(call gb_Library_get_target,$(1)) \ 677$(call gb_Library_get_clean_target,$(1)) : AUXTARGETS := $(OUTDIR)/bin/$(notdir $(3)) 678 679ifneq ($(ENABLE_CRASHDUMP),) 680$(call gb_Library_get_target,$(1)) \ 681$(call gb_Library_get_clean_target,$(1)) : AUXTARGETS += \ 682 $(OUTDIR)/bin/$(notdir $(patsubst %.dll,%.pdb,$(3))) \ 683 $(OUTDIR)/bin/$(notdir $(patsubst %.dll,%.ilk,$(3))) \ 684 685$(call gb_Deliver_add_deliverable,$(OUTDIR)/bin/$(notdir $(patsubst %.dll,%.pdb,$(3))),$(patsubst %.dll,%.pdb,$(3)),$(1)) 686$(call gb_Deliver_add_deliverable,$(OUTDIR)/bin/$(notdir $(patsubst %.dll,%.ilk,$(3))),$(patsubst %.dll,%.ilk,$(3)),$(1)) 687endif 688 689$(call gb_Deliver_add_deliverable,$(OUTDIR)/bin/$(notdir $(3)),$(3),$(1)) 690 691$(call gb_LinkTarget_get_target,$(2)) \ 692$(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile,$(2)) 693ifeq ($(gb_FULLDEPS),$(true)) 694$(call gb_LinkTarget_get_dep_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile,$(2)) 695endif 696endef 697 698define gb_Library_add_default_nativeres 699$(call gb_WinResTarget_WinResTarget_init,$(1)/$(2)) 700$(call gb_WinResTarget_add_file,$(1)/$(2),solenv/inc/shlinfo) 701$(call gb_WinResTarget_set_defs,$(1)/$(2),\ 702 $$(DEFS) \ 703 -DADDITIONAL_VERINFO1 \ 704 -DADDITIONAL_VERINFO2 \ 705 -DADDITIONAL_VERINFO3 \ 706) 707$(call gb_Library_add_nativeres,$(1),$(2)) 708$(call gb_Library_get_clean_target,$(1)) : $(call gb_WinResTarget_get_clean_target,$(1)/$(2)) 709 710endef 711 712define gb_Library_add_nativeres 713$(call gb_LinkTarget_get_target,$(call gb_Library__get_linktargetname,$(1))) : $(call gb_WinResTarget_get_target,$(1)/$(2)) 714$(call gb_LinkTarget_get_target,$(call gb_Library__get_linktargetname,$(1))) : NATIVERES += $(call gb_WinResTarget_get_target,$(1)/$(2)) 715 716endef 717 718define gb_Library_get_dllname 719$(patsubst $(1):%,%,$(filter $(1):%,$(gb_Library_DLLFILENAMES))) 720endef 721 722 723# StaticLibrary class 724 725gb_StaticLibrary_DEFS := 726gb_StaticLibrary_TARGETTYPEFLAGS := -LIB 727gb_StaticLibrary_SYSPRE := 728gb_StaticLibrary_PLAINEXT := .lib 729gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 730 731gb_StaticLibrary_FILENAMES := \ 732 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 733 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 734 735gb_StaticLibrary_FILENAMES := $(patsubst salcpprt:salcpprt%,salcpprt:cpprtl%,$(gb_StaticLibrary_FILENAMES)) 736 737define gb_StaticLibrary_StaticLibrary_platform 738$(call gb_LinkTarget_get_target,$(2)) \ 739$(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile,$(2)) 740 741$(call gb_LinkTarget_set_auxtargets,$(2),\ 742 $(call gb_LinkTarget_get_pdbfile,$(2)) \ 743) 744 745endef 746 747# Executable class 748 749gb_Executable_EXT := .exe 750ifeq ($(CPUNAME),INTEL) 751gb_Executable_TARGETTYPEFLAGS := -RELEASE -BASE:0x1b000000 -OPT:NOREF -INCREMENTAL:NO -DEBUG -SAFESEH -NXCOMPAT -DYNAMICBASE 752endif 753ifeq ($(CPUNAME),X86_64) 754gb_Executable_TARGETTYPEFLAGS := -RELEASE -BASE:0x1b000000 -OPT:NOREF -INCREMENTAL:NO -DEBUG -NXCOMPAT -DYNAMICBASE 755endif 756gb_Executable_get_rpath := 757gb_Executable_TARGETGUI := 758 759gb_InBuild_Library_Path := $(OUTDIR)/bin 760gb_Augment_Library_Path := PATH="$${PATH}:$(gb_InBuild_Library_Path)" 761 762define gb_Executable_Executable_platform 763$(call gb_LinkTarget_set_auxtargets,$(2),\ 764 $(patsubst %.exe,%.pdb,$(call gb_LinkTarget_get_target,$(2))) \ 765 $(call gb_LinkTarget_get_pdbfile,$(2)) \ 766 $(call gb_LinkTarget_get_target,$(2)).manifest \ 767) 768 769# VC9 linked an external <exe>.manifest beside every executable, because the 770# CRT it used was a side-by-side assembly that had to be named there. The UCRT 771# is not an assembly, so a modern link emits no manifest at all -- and 772# delivering an auxiliary target that was never produced fails the build with 773# "cp: cannot stat ...xml2cmp.exe.manifest". The link rule itself already 774# copes, embedding a manifest only "if [ -f ... ]"; only this delivery list 775# assumed one. 776ifeq ($(COMEX),14) 777$(call gb_Executable_get_target,$(1)) \ 778$(call gb_Executable_get_clean_target,$(1)) : AUXTARGETS := 779else 780$(call gb_Executable_get_target,$(1)) \ 781$(call gb_Executable_get_clean_target,$(1)) : AUXTARGETS := $(call gb_Executable_get_target,$(1)).manifest 782endif 783 784$(call gb_LinkTarget_get_target,$(2)) \ 785$(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile,$(2)) 786 787endef 788 789# GoogleTest class 790 791gb_GoogleTest_GTESTPRECOMMAND := PATH="$${PATH}:$(OUTDIR)/bin" 792gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) 793 794define gb_GoogleTest_GoogleTest_platform 795endef 796 797# JunitTest class 798 799define gb_JunitTest_JunitTest_platform 800$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 801 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(SRCDIR)/instsetoo_native/$(INPATH)/Apache_OpenOffice/installed/install/en-US/OpenOffice 4/program/soffice.exe}" \ 802 -Dorg.openoffice.test.arg.env=PATH \ 803 -Dorg.openoffice.test.arg.user=file:///$(call gb_JunitTest_get_userdir,$(1)) \ 804 805endef 806 807 808# Ant class 809 810define gb_Ant_add_dependencies 811__ant_out:=$(shell $(gb_Ant_ANTCOMMAND) -Ddependencies.outfile=`cygpath -m $(WORKDIR)/Ant/$(1)/deps` -f `cygpath -m $(2)` dependencies) 812$$(eval $(foreach dep,$(shell cat $(WORKDIR)/Ant/$(1)/deps),$$(call gb_Ant_add_dependency,$(call gb_Ant_get_target,$(1)),$(shell cygpath -u $(dep))))) 813 814endef 815 816 817 818# SdiTarget class 819 820gb_SdiTarget_SVIDLPRECOMMAND := PATH="$${PATH}:$(OUTDIR)/bin" 821 822# SrsPartMergeTarget 823 824gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := PATH="$${PATH}:$(OUTDIR)/bin" 825 826# SrsPartTarget class 827 828gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc.exe 829gb_SrsPartTarget_RSCCOMMAND := SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 830 831ifeq ($(gb_FULLDEPS),$(true)) 832define gb_SrsPartTarget__command_dep 833$(call gb_Helper_abbreviate_dirs_native,\ 834 $(OUTDIR)/bin/makedepend$(gb_Executable_EXT) \ 835 $(INCLUDE) \ 836 $(DEFS) \ 837 $(2) \ 838 -f - \ 839 | $(gb_AWK) -f $(GBUILDDIR)/processdeps.awk \ 840 -v OBJECTFILE=$(call gb_SrsPartTarget_get_target,$(1)) \ 841 -v OUTDIR=$(OUTDIR)/ \ 842 -v WORKDIR=$(WORKDIR)/ \ 843 -v SRCDIR=$(SRCDIR)/ \ 844 -v REPODIR=$(REPODIR)/ \ 845 > $(call gb_SrsPartTarget_get_dep_target,$(1))) 846endef 847else 848gb_SrsPartTarget__command_dep = 849endif 850 851# WinResTarget class 852 853gb_WinResTarget_POSTFIX :=.res 854 855define gb_WinResTarget__command 856$(call gb_Output_announce,$(2),$(true),RES,3) 857$(call gb_Helper_abbreviate_dirs_native,\ 858 mkdir -p $(dir $(1)) && \ 859 $(gb_RC) \ 860 $(DEFS) $(FLAGS) \ 861 -I$(dir $(3)) \ 862 $(INCLUDE) \ 863 -Fo$(1) \ 864 $(RCFILE) ) 865endef 866 867$(eval $(call gb_Helper_make_dep_targets,\ 868 WinResTarget \ 869)) 870 871ifeq ($(gb_FULLDEPS),$(true)) 872define gb_WinResTarget__command_dep 873$(call gb_Helper_abbreviate_dirs_native,\ 874 $(OUTDIR)/bin/makedepend$(gb_Executable_EXT) \ 875 $(INCLUDE) \ 876 $(DEFS) \ 877 $(2) \ 878 -f - \ 879 | $(gb_AWK) -f $(GBUILDDIR)/processdeps.awk \ 880 -v OBJECTFILE=$(call gb_WinResTarget_get_target,$(1)) \ 881 -v OUTDIR=$(OUTDIR)/ \ 882 -v WORKDIR=$(WORKDIR)/ \ 883 -v SRCDIR=$(SRCDIR)/ \ 884 -v REPODIR=$(REPODIR)/ \ 885 > $(call gb_WinResTarget_get_dep_target,$(1))) 886endef 887else 888gb_WinResTarget__command_dep = 889endif 890 891# ComponentTarget 892 893gb_XSLTPROCPRECOMMAND := PATH="$${PATH}:$(OUTDIR)/bin" 894gb_Library_COMPONENTPREFIXES := \ 895 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 896 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 897 NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \ 898 899# Configuration 900gb_CFGEXPRECOMMAND := PATH="$${PATH}:$(OUTDIR)/bin" 901 902# UnoApiTarget 903 904gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc.exe 905gb_UnoApiTarget_IDLCCOMMAND := SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET) 906gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge.exe 907gb_UnoApiTarget_REGMERGECOMMAND := SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET) 908gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare.exe 909gb_UnoApiTarget_REGCOMPARECOMMAND := SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET) 910gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker.exe 911gb_UnoApiTarget_CPPUMAKERCOMMAND := SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET) 912gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview.exe 913gb_UnoApiTarget_REGVIEWCOMMAND := SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET) 914 915# vim: set noet sw=4 ts=4: 916