tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / solenv / gbuild / platform / com_MSC_class.mk
blobb1a825a54dd2637e3939bbfc3e93f75f9d52c888
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # Convert path to file URL.
21 define gb_Helper_make_url
22 file:///$(strip $(1))
23 endef
25 # YaccTarget class
27 define gb_YaccTarget__command
28 $(call gb_Output_announce,$(2),$(true),YAC,3)
29 mkdir -p $(dir $(3)) && \
30 $(call gb_Helper_wsl_path,$(WSL) $(BISON) $(T_YACCFLAGS) --defines=$(4) -o $(5) $(1)) && touch $(3)
32 endef
34 # CObject class
36 # $(call gb_CObject__compiler,flags,source,compiler)
37 define gb_CObject__compiler
38 VSLANG=1033 \
39 $(if $(filter YES,$(LIBRARY_X64)), $(CXX_X64_BINARY), \
40 $(if $(filter YES,$(PE_X86)), $(CXX_X86_BINARY), \
41 $(if $(filter %.c,$(2)), \
42 $(if $(3), $(3), $(gb_CC)), \
43 $(if $(filter -clr,$(1)), \
44 $(MSVC_CXX) -I$(SRCDIR)/solenv/clang-cl, \
45 $(if $(3), $(3), $(gb_CXX))))))
46 endef
48 # Avoid annoying warning D9025 about overriding command-line arguments.
49 gb_Helper_remove_overridden_flags = \
50 $(filter-out -W4 -w -arch:SSE -arch:SSE2 -arch:AVX -arch:AVX2 -Od -O2 -Zc:inline -Zc:inline- \
51 -Zc:dllexportInlines -Zc:dllexportInlines- -EHs -EHa -DNOMINMAX -UNOMINMAX -D_X86_=1 -U_X86_ \
52 -D_AMD64_=1 -U_AMD64_ $(MSVC_ANALYZE_FLAGS) -analyze-,$(1)) \
53 $(lastword $(filter -W4 -w,$(1))) \
54 $(lastword $(filter -Od -O2,$(1))) \
55 $(lastword $(filter -arch:SSE -arch:SSE2 -arch:AVX -arch:AVX2,$(1))) \
56 $(lastword $(filter -EHs -EHa,$(1))) \
57 $(lastword $(filter -DNOMINMAX -UNOMINMAX,$(1))) \
58 $(lastword $(filter -D_X86_=1 -U_X86_,$(1))) \
59 $(lastword $(filter -D_AMD64_=1 -U_AMD64_,$(1))) \
60 $(lastword $(filter -Zc:inline -Zc:inline-,$(1))) \
61 $(lastword $(filter -Zc:dllexportInlines -Zc:dllexportInlines-,$(1))) \
62 $(lastword $(filter $(MSVC_ANALYZE_FLAGS) -analyze-,$(1)))
64 # When gb_LinkTarget_use_clang is used, filter out MSVC flags that Clang doesn't know.
65 # $(call gb_CObject__filter_out_clang_cflags,cflags)
66 define gb_CObject__filter_out_clang_cflags
67 $(filter-out $(gb_FilterOutClangCFLAGS),$(1))
68 endef
70 # $(call gb_CObject__command_pattern,object,flags,source,dep-file,compiler-plugins,compiler)
71 define gb_CObject__command_pattern
72 $(call gb_Helper_abbreviate_dirs,\
73 mkdir -p $(dir $(1)) $(dir $(4)) && \
74 unset INCLUDE && \
75 $(if $(and $(gb_COMPILERDEPFLAGS),$(T_USE_CLANG)), export SHOWINCLUDES_PREFIX="${LO_CLANG_SHOWINCLUDES_PREFIX}" &&) \
76 $(gb_COMPILER_SETUP) \
77 $(call gb_CObject__compiler,$(2),$(3),$(6)) \
78 $(call gb_Helper_remove_overridden_flags, \
79 $(DEFS) \
80 $(if $(filter YES,$(LIBRARY_X64)), ,$(gb_LTOFLAGS)) \
81 $(if $(6), $(call gb_CObject__filter_out_clang_cflags,$(2)),$(2)) \
82 $(if $(WARNINGS_DISABLED),$(gb_CXXFLAGS_DISABLE_WARNINGS)) \
83 $(if $(EXTERNAL_CODE), \
84 $(if $(filter -clr,$(2)),,$(if $(COM_IS_CLANG),-Wno-undef)), \
85 $(gb_DEFS_INTERNAL)) \
86 $(if $(WARNINGS_NOT_ERRORS),$(if $(ENABLE_WERROR),$(if $(PLUGIN_WARNINGS_AS_ERRORS),$(gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS))),$(gb_CFLAGS_WERROR)) \
87 $(if $(filter -clr,$(2)),,$(if $(5),$(gb_COMPILER_PLUGINS))) \
88 $(if $(COMPILER_TEST),-fsyntax-only -ferror-limit=0 -Xclang -verify) \
89 $(PCHFLAGS) \
90 $(if $(COMPILER_TEST),,$(gb_COMPILERDEPFLAGS)) \
91 $(if $(filter YES,$(LIBRARY_X64)), -U_X86_ -D_AMD64_,) \
92 $(if $(filter YES,$(PE_X86)), -D_X86_ -U_AMD64_,)) \
93 $(INCLUDE) \
94 -Fd$(PDBFILE) \
95 -c $(3) \
96 -Fo$(1)) \
97 $(if $(COMPILER_TEST),,$(call gb_create_deps,$(4),$(1),$(3)))
98 endef
100 # PrecompiledHeader class
102 gb_PrecompiledHeader_get_enableflags = \
103 -Yu$(SRCDIR)/$(3).hxx \
104 -FI$(SRCDIR)/$(3).hxx \
105 -Fp$(call gb_PrecompiledHeader_get_target,$(1),$(2)) \
106 $(gb_PCHWARNINGS)
108 gb_PrecompiledHeader_EXT := .pch
110 # MSVC PCH needs extra .obj created during the creation of the PCH file
111 gb_PrecompiledHeader_get_objectfile = $(1).obj
113 # $(call gb_PrecompiledHeader__command,pchfile,pchtarget,source,cxxflags,includes,linktargetmakefilename,compiler)
114 define gb_PrecompiledHeader__command
115 $(call gb_Output_announce,$(2),$(true),PCH,1)
116 $(call gb_Trace_StartRange,$(2),PCH)
117 $(call gb_Helper_abbreviate_dirs,\
118 mkdir -p $(dir $(1)) $(dir $(call gb_PrecompiledHeader_get_dep_target,$(2),$(6))) && \
119 unset INCLUDE && \
120 $(if $(and $(gb_COMPILERDEPFLAGS),$(T_USE_CLANG)), export SHOWINCLUDES_PREFIX="${LO_CLANG_SHOWINCLUDES_PREFIX}" &&) \
121 CCACHE_DISABLE=1 $(gb_COMPILER_SETUP) \
122 $(call gb_CObject__compiler,$(4),$(3),$(7)) \
123 $(call gb_Helper_remove_overridden_flags, \
124 $(4) $(if $(WARNINGS_DISABLED),$(gb_CXXFLAGS_DISABLE_WARNINGS))) \
125 -Fd$(PDBFILE) \
126 $(if $(EXTERNAL_CODE),$(if $(COM_IS_CLANG),-Wno-undef),$(gb_DEFS_INTERNAL)) \
127 $(if $(filter YES,$(LIBRARY_X64)), ,$(gb_LTOFLAGS)) \
128 $(gb_COMPILERDEPFLAGS) \
129 $(gb_NO_PCH_TIMESTAMP) \
130 $(5) \
131 -c $(3) \
132 -Yc$(notdir $(patsubst %.cxx,%.hxx,$(3))) -I$(dir $(patsubst %.cxx,%.hxx,$(3))) -Fp$(1) -Fo$(1).obj) \
133 $(call gb_create_deps,$(call gb_PrecompiledHeader_get_dep_target_tmp,$(2),$(6)),$(1),$(3))
134 $(call gb_Trace_EndRange,$(2),PCH)
135 endef
137 ifeq ($(COM_IS_CLANG),TRUE)
138 # Clang has -fno-pch-timestamp, just checksum the file for CCACHE_PCH_EXTSUM
139 # $(call gb_PrecompiledHeader__sum_command,pchfile,pchtarget,source,cxxflags,includes,linktargetmakefilename,compiler)
140 define gb_PrecompiledHeader__sum_command
141 $(SHA256SUM) $(1) >$(1).sum
142 endef
143 else
144 # MSVC does not generate the same .pch for the same input, so checksum the (preprocessed) input
145 # $(call gb_PrecompiledHeader__sum_command,pchfile,pchtarget,source,cxxflags,includes,linktargetmakefilename,compiler)
146 define gb_PrecompiledHeader__sum_command
147 $(call gb_Helper_abbreviate_dirs,\
148 unset INCLUDE && \
149 CCACHE_DISABLE=1 $(gb_COMPILER_SETUP) \
150 $(call gb_CObject__compiler,$(4),$(3),$(7)) \
151 $(call gb_Helper_remove_overridden_flags, \
152 $(4)$(if $(WARNINGS_DISABLED),$(gb_CXXFLAGS_DISABLE_WARNINGS))) \
153 $(if $(EXTERNAL_CODE),$(if $(COM_IS_CLANG),-Wno-undef),$(gb_DEFS_INTERNAL)) \
154 $(gb_LTOFLAGS) \
155 $(5) \
156 -E $(3) \
157 2>&1 | $(SHA256SUM) >$(1).sum \
159 endef
160 endif
162 # When building a PCH, MSVC also creates a .pdb file with debug info. So for reuse
163 # add the .pdb to the PCH's files and then use the .pdb also for linktargets that reuse the PCH.
164 # call gb_PrecompiledHeader__create_reuse_files,linktarget,pchtarget,linktargetmakefilename
165 define gb_PrecompiledHeader__create_reuse_files
166 rm -f $(call gb_PrecompiledHeader_get_target,$(2),$(3)).pdb; \
167 if test -f $(call gb_LinkTarget_get_pdbfile_in,$(1)); then \
168 cp $(call gb_LinkTarget_get_pdbfile_in,$(1)) $(call gb_PrecompiledHeader_get_target,$(2),$(3)).pdb; \
170 endef
172 # call gb_PrecompiledHeader__copy_reuse_files,linktarget,pchtarget,linktargetmakefilename
173 define gb_PrecompiledHeader__copy_reuse_files
174 rm -f $(call gb_LinkTarget_get_pdbfile_in,$(1)); \
175 if test -f $(call gb_PrecompiledHeader_get_target,$(2),$(3)).pdb; then \
176 cp $(call gb_PrecompiledHeader_get_target,$(2),$(3)).pdb $(call gb_LinkTarget_get_pdbfile_in,$(1)); \
178 endef
180 # AsmObject class
181 ifeq ($(CPUNAME),AARCH64)
182 gb_AsmObject_get_source = $(1)/$(2).S
184 # Code needs a preprocessor step .S -> .asm -> .o
185 define gb_AsmObject__command
186 $(call gb_Output_announce,$(2),$(true),ASM,3)
187 $(call gb_Helper_abbreviate_dirs,\
188 mkdir -p $(dir $(1)) $(dir $(4)) && \
189 $(CC) -nologo -EP -D_M_ARM64 $(SOLARINC) $(3) > $(subst .o,.asm,$(1)) && \
190 "$(ML_EXE)" $(gb_AFLAGS) -g -errorReport:prompt -o $(1) $(subst .o,.asm,$(1)), \
191 ) && \
192 echo "$(1) : $(3)" > $(4)
193 endef
195 else # !AARCH64
196 gb_AsmObject_get_source = $(1)/$(2).asm
198 define gb_AsmObject__command
199 $(call gb_Output_announce,$(2),$(true),ASM,3)
200 $(call gb_Helper_abbreviate_dirs,\
201 mkdir -p $(dir $(1)) $(dir $(4)) && \
202 "$(ML_EXE)" \
203 $(if $(filter X86_64,$(CPUNAME)),, /safeseh) \
204 /c /Cp $(gb_AFLAGS) -D$(COM) /Fo$(1) $(3)) && \
205 echo "$(1) : $(3)" > $(4)
206 endef
208 endif
210 # LinkTarget class
212 gb_LinkTarget_CFLAGS := $(gb_CFLAGS)
213 gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS)
214 gb_LinkTarget_CXXCLRFLAGS := $(gb_CXXCLRFLAGS)
216 gb_LinkTarget_INCLUDE :=\
217 $(SOLARINC) \
218 $(foreach inc,$(subst ;, ,$(JDKINC)),-I$(inc)) \
219 -I$(BUILDDIR)/config_$(gb_Side) \
221 # We must name the .pdb like libname.pdb, not libname.\(dll\|exe\|pyd\).pdb,
222 # otherwise WinDbg does not find it.
223 define gb_LinkTarget__get_pdb_filename
224 $(patsubst %.dll,%.pdb,$(patsubst %.exe,%.pdb,$(patsubst %.bin,%.bin.pdb,$(patsubst %.pyd,%.pdb,$(1)))))
225 endef
227 gb_LinkTarget_get_pdbfile_in = \
228 $(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1)).objects.pdb
230 gb_LinkTarget_get_pdbfile_out = \
231 $(call gb_LinkTarget__get_pdb_filename,$(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1)))
233 gb_LinkTarget_get_ilkfile = \
234 $(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1)).ilk
236 gb_LinkTarget_get_manifestfile = \
237 $(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1)).manifest
239 gb_LinkTarget_get_linksearchpath_for_layer = \
240 -LIBPATH:$(gb_StaticLibrary_WORKDIR) \
241 -LIBPATH:$(INSTDIR)/$(SDKDIRNAME)/lib \
242 $(if $(filter OXT,$(1)),\
243 -LIBPATH:$(WORKDIR)/LinkTarget/ExtensionLibrary, \
244 -LIBPATH:$(gb_Library_DLLDIR))
246 # avoid fatal error LNK1170 for Library_merged
247 define gb_LinkTarget_MergedResponseFile
248 cat $${RESPONSEFILE} | sed 's/ /\n/g' | grep -v '^$$' > $${RESPONSEFILE}.1 && \
249 mv $${RESPONSEFILE}.1 $${RESPONSEFILE} &&
250 endef
252 gb_MSC_SUBSYSTEM_VERSION=$(COMMA)$(if $(filter AARCH64,$(CPUNAME)),6.02,6.01)
254 # the sort on the libraries is used to filter out duplicates to keep commandline
255 # length in check - otherwise the dupes easily hit the limit when linking mergedlib
256 define gb_LinkTarget__command
257 $(call gb_Output_announce,$(2),$(true),LNK,4)
258 $(call gb_Trace_StartRange,$(2),LNK)
259 $(call gb_Helper_abbreviate_dirs,\
260 rm -f $(1) && \
261 RESPONSEFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)), \
262 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
263 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
264 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
265 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
266 $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_target,$(object))) \
267 $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_target,$(object))) \
268 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
269 $(foreach object,$(GENASMOBJECTS),$(call gb_GenAsmObject_get_target,$(object))) \
270 $(foreach object,$(GENNASMOBJECTS),$(call gb_GenNasmObject_get_target,$(object))) \
271 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),$(shell cat $(extraobjectlist))) \
272 $(PCHOBJS) $(NATIVERES)) && \
273 $(if $(filter $(call gb_Library__get_workdir_linktargetname,merged),$(2)),$(call gb_LinkTarget_MergedResponseFile)) \
274 unset INCLUDE && \
275 $(gb_LINK) \
276 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
277 $(if $(filter StaticLibrary,$(TARGETTYPE)),-LIB) \
278 $(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
279 $(if $(T_SYMBOLS),$(if $(filter Executable Library CppunitTest,$(TARGETTYPE)),$(call gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO,$(DEFS))),) \
280 $(if $(filter YES,$(TARGETGUI)), -SUBSYSTEM:WINDOWS$(gb_MSC_SUBSYSTEM_VERSION), -SUBSYSTEM:CONSOLE$(gb_MSC_SUBSYSTEM_VERSION)) \
281 $(if $(filter YES,$(LIBRARY_X64)), -MACHINE:X64) \
282 $(if $(filter YES,$(PE_X86)), -MACHINE:X86) \
283 $(if $(filter YES,$(LIBRARY_X64)), \
284 -LIBPATH:$(COMPATH)/lib/x64 \
285 -LIBPATH:$(WINDOWS_SDK_HOME)/lib/x64 \
286 -LIBPATH:$(UCRTSDKDIR)lib/$(UCRTVERSION)/ucrt/x64 \
287 $(if $(filter 80 81 10,$(WINDOWS_SDK_VERSION)),-LIBPATH:$(WINDOWS_SDK_HOME)/lib/$(WINDOWS_SDK_LIB_SUBDIR)/um/x64)) \
288 $(if $(filter YES,$(PE_X86)), \
289 -LIBPATH:$(COMPATH)/lib/x86 \
290 -LIBPATH:$(WINDOWS_SDK_HOME)/lib/x86 \
291 -LIBPATH:$(UCRTSDKDIR)lib/$(UCRTVERSION)/ucrt/x86 \
292 $(if $(filter 80 81 10,$(WINDOWS_SDK_VERSION)),-LIBPATH:$(WINDOWS_SDK_HOME)/lib/$(WINDOWS_SDK_LIB_SUBDIR)/um/x86)) \
293 $(T_USE_LD) $(T_LDFLAGS) \
294 $(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),/NATVIS:$(SRCDIR)/solenv/vs/LibreOffice.natvis) \
295 @$${RESPONSEFILE} \
296 $(foreach lib,$(sort $(LINKED_LIBS)),$(call gb_Library_get_ilibfilename,$(lib))) \
297 $(foreach lib,$(sort $(LINKED_STATIC_LIBS)),$(call gb_StaticLibrary_get_filename,$(lib))) \
298 $(if $(filter-out StaticLibrary,$(TARGETTYPE)),\
299 $(sort $(T_LIBS)) user32.lib \
300 -manifestfile:$(WORKDIR)/LinkTarget/$(2).manifest \
301 -pdb:$(call gb_LinkTarget__get_pdb_filename,$(WORKDIR)/LinkTarget/$(2))) \
302 $(if $(ILIBTARGET),-out:$(1) -implib:$(ILIBTARGET),-out:$(1)) \
303 | $(GBUILDDIR)/platform/filter-creatingLibrary.awk; RC=$${PIPESTATUS[0]}; rm $${RESPONSEFILE} \
304 $(if $(filter Library,$(TARGETTYPE)),; if [ ! -f $(ILIBTARGET) ]; then rm -f $(1); exit 42; fi) \
305 $(if $(filter Library,$(TARGETTYPE)),&& if [ -f $(WORKDIR)/LinkTarget/$(2).manifest ]; then mt.exe $(MTFLAGS) -nologo -manifest $(WORKDIR)/LinkTarget/$(2).manifest $(SRCDIR)/solenv/gbuild/platform/win_compatibility.manifest -outputresource:$(1)\;2 && touch -r $(1) $(WORKDIR)/LinkTarget/$(2).manifest $(ILIBTARGET); fi) \
306 $(if $(filter Executable,$(TARGETTYPE)),&& if [ -f $(WORKDIR)/LinkTarget/$(2).manifest ]; then mt.exe $(MTFLAGS) -nologo -manifest $(WORKDIR)/LinkTarget/$(2).manifest $(SRCDIR)/solenv/gbuild/platform/win_compatibility.manifest -outputresource:$(1)\;1 && touch -r $(1) $(WORKDIR)/LinkTarget/$(2).manifest; fi) \
307 $(if $(filter Executable,$(TARGETTYPE)),&& mt.exe $(MTFLAGS) -nologo -manifest $(SRCDIR)/solenv/gbuild/platform/DeclareDPIAware.manifest -updateresource:$(1)\;1 ) \
308 $(if $(filter Library,$(TARGETTYPE)),&& \
309 echo $(notdir $(1)) > $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
310 $(gb_DUMPBIN) \
311 -exports $(ILIBTARGET) \
312 >> $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
313 $(call gb_Helper_replace_if_different_and_touch,$(WORKDIR)/LinkTarget/$(2).exports.tmp,$(WORKDIR)/LinkTarget/$(2).exports,$(1))) \
315 $(call gb_Trace_EndRange,$(2),LNK) $(if $(gb_TRACE),;) \
316 exit $$RC)
317 endef
319 define gb_MSVCRT_subst
320 $(if $(MSVC_USE_DEBUG_RUNTIME),$(subst msvcrt,msvcrtd,$(subst msvcprt,msvcprtd,$(subst libcmt,libcmtd,$(subst libvcruntime,libvcruntimed,$(subst libucrt,libucrtd,$(subst libcpmt,libcpmtd,$(subst msvcmrt,msvcmrtd,$(1)))))))),$(1))
321 endef
323 define gb_LinkTarget_use_system_win32_libs
324 $(call gb_LinkTarget_add_libs,$(1),$(foreach lib,$(2),$(call gb_MSVCRT_subst,$(lib)).lib))
325 $(if $(call gb_LinkTarget__is_merged,$(1)),\
326 $(call gb_LinkTarget_add_libs,$(call gb_Library_get_linktarget,merged),$(foreach lib,$(2),$(call gb_MSVCRT_subst,$(lib)).lib)))
327 endef
329 # Flags common for PE executables (EXEs and DLLs).
330 # Enable incremental only when debugging to speed up relinking.
331 gb_Windows_PE_TARGETTYPEFLAGS := \
332 -release \
333 -opt:noref \
334 $(if $(ENABLE_DEBUG),, -incremental:no) \
335 $(if $(filter NO,$(LIBRARY_X64)), -safeseh) \
336 -nxcompat \
337 -dynamicbase \
338 -manifest
340 # link.exe in -LIB mode doesn't understand -debug, use it only for EXEs and DLLs
341 ifeq ($(ENABLE_DBGUTIL),TRUE)
342 # fastlink is faster but pdb files reference .obj files
343 # but don't do that for setup_native DLLs: this produces make error 139 in some configurations
344 gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO = $(if $(filter -U_DLL,$(1)),-debug,-debug:fastlink)
345 else
346 gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO = -debug
347 endif
349 ifeq ($(ENABLE_LTO),TRUE)
350 gb_Windows_PE_TARGETTYPEFLAGS += -LTCG
351 endif
353 # Library class
356 gb_Library_DEFS := -D_DLL
357 gb_Library_TARGETTYPEFLAGS := \
358 -DLL \
359 $(gb_Windows_PE_TARGETTYPEFLAGS)
361 gb_Library_get_rpath :=
363 gb_Library_SYSPRE := i
364 gb_Library_PLAINEXT := .lib
365 gb_Library_PLAINEXT_FOR_BUILD := .lib
367 gb_Library_LAYER := \
368 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
369 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):NONE) \
370 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
371 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
372 $(foreach lib,$(gb_Library_PLAINLIBS_OXT),$(lib):OXT) \
373 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):URELIB) \
374 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
375 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
376 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):OXT) \
377 $(foreach lib,$(gb_Library_PLAINLIBS_SHLXTHDL),$(lib):SHLXTHDL) \
379 gb_Library_ILIBFILENAMES :=\
380 $(foreach lib,$(gb_Library_KNOWNLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
382 gb_Library_DLLEXT := .dll
383 gb_Library_UDK_MAJORVER := 3
384 gb_Library_RTEXT := MSC$(gb_Library_DLLEXT)
385 gb_Library_OOOEXT := $(gb_Library_DLLPOSTFIX)$(gb_Library_DLLEXT)
386 gb_Library_UNOEXT := .uno$(gb_Library_DLLEXT)
387 gb_Library_UNOVEREXT := $(gb_Library_UDK_MAJORVER)$(gb_Library_DLLEXT)
388 gb_Library_RTVEREXT := $(gb_Library_UDK_MAJORVER)$(gb_Library_RTEXT)
390 gb_Library_FILENAMES :=\
391 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(lib)$(gb_Library_OOOEXT)) \
392 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(lib)$(gb_Library_DLLEXT)) \
393 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(lib)$(gb_Library_DLLEXT)) \
394 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(lib)$(gb_Library_DLLEXT)) \
395 $(foreach lib,$(gb_Library_PLAINLIBS_OXT),$(lib):$(lib)$(gb_Library_DLLEXT)) \
396 $(foreach lib,$(gb_Library_PLAINLIBS_SHLXTHDL),$(lib):$(lib)$(gb_Library_DLLEXT)) \
397 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):$(lib)$(gb_Library_OOOEXT)) \
398 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(lib)$(gb_Library_RTVEREXT)) \
399 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(lib)$(gb_Library_UNOVEREXT)) \
400 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):$(lib)$(gb_Library_UNOEXT)) \
402 # An assembly is a special kind of library for CLI
403 define gb_Library_Assembly
404 $(call gb_Library_Library,$(1))
405 $(call gb_Library_get_linktarget_target,$(1)) : NATIVERES :=
407 endef
409 define gb_Library_Library_platform
410 $(call gb_LinkTarget_set_ilibtarget,$(2),$(3))
412 $(call gb_LinkTarget_add_auxtargets,$(2),\
413 $(patsubst %.lib,%.exp,$(3)) \
414 $(call gb_LinkTarget_get_manifestfile,$(2)) \
415 $(call gb_LinkTarget_get_pdbfile_in,$(2)) \
416 $(call gb_LinkTarget_get_pdbfile_out,$(2)) \
417 $(call gb_LinkTarget_get_ilkfile,$(2)) \
420 $(call gb_Library_add_default_nativeres,$(1),$(1)/default)
422 $(call gb_LinkTarget_get_target,$(2)) \
423 $(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile_in,$(2))
425 endef
427 define gb_Library_add_default_nativeres
428 $(call gb_WinResTarget_WinResTarget_init,$(2))
429 $(call gb_WinResTarget_set_rcfile,$(2),include/default)
430 $(call gb_WinResTarget_add_defs,$(2),\
431 -DVERVARIANT="$(LIBO_VERSION_PATCH)" \
432 -DRES_APP_VENDOR="$(OOO_VENDOR)" \
433 -DORG_NAME="$(call gb_Library_get_filename,$(1))"\
434 -DINTERNAL_NAME="$(subst $(gb_Library_DLLEXT),,$(call gb_Library_get_filename,$(1)))" \
435 -DADDITIONAL_VERINFO1="" \
436 -DADDITIONAL_VERINFO2="" \
437 -DADDITIONAL_VERINFO3="" \
439 $(call gb_Library_add_nativeres,$(1),$(2))
440 $(call gb_Library_get_clean_target,$(1)) : $(call gb_WinResTarget_get_clean_target,$(2))
442 endef
444 define gb_Executable_add_default_nativeres
445 $(call gb_WinResTarget_WinResTarget_init,$(1)/default)
446 $(call gb_WinResTarget_set_rcfile,$(1)/default,include/default)
447 $(call gb_WinResTarget_add_defs,$(1)/default,\
448 -DVERVARIANT="$(LIBO_VERSION_PATCH)" \
449 -DRES_APP_VENDOR="$(OOO_VENDOR)" \
450 -DORG_NAME="$(call gb_Executable_get_filename,$(1))"\
451 -DINTERNAL_NAME="$(subst $(gb_Executable_EXT),,$(call gb_Executable_get_filename,$(1)))" \
452 -DADDITIONAL_VERINFO1="$(if $(2),VALUE \"FileDescription\"$(COMMA) \"$(2)\\0\")" \
453 -DADDITIONAL_VERINFO2="" \
454 -DADDITIONAL_VERINFO3="" \
456 $(call gb_Executable_add_nativeres,$(1),$(1)/default)
457 $(call gb_Executable_get_clean_target,$(1)) : $(call gb_WinResTarget_get_clean_target,$(1)/default)
459 endef
461 define gb_LinkTarget_add_nativeres
462 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_WinResTarget_get_target,$(2))
463 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES += $(call gb_WinResTarget_get_target,$(2))
465 endef
467 define gb_LinkTarget_set_nativeres
468 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_WinResTarget_get_target,$(2))
469 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES := $(call gb_WinResTarget_get_target,$(2))
471 endef
473 define gb_Library_get_ilibfilename
474 $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Library_ILIBFILENAMES)))
475 endef
477 gb_Library_get_sdk_link_dir = $(INSTDIR)/$(SDKDIRNAME)/lib
479 gb_Library_get_sdk_link_lib = $(gb_Library_get_ilib_target)
481 # StaticLibrary class
483 gb_StaticLibrary_get_filename = $(1).lib
484 gb_StaticLibrary_PLAINEXT := .lib
486 define gb_StaticLibrary_StaticLibrary_platform
487 $(call gb_LinkTarget_get_target,$(2)) \
488 $(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile_in,$(2))
490 $(call gb_LinkTarget_add_auxtargets,$(2),\
491 $(call gb_LinkTarget_get_pdbfile_in,$(2)) \
494 endef
496 # Executable class
498 gb_Executable_EXT := .exe
499 gb_Executable_EXT_for_build := .exe
500 gb_Executable_TARGETTYPEFLAGS := $(gb_Windows_PE_TARGETTYPEFLAGS)
502 gb_Executable_get_rpath :=
504 # surprisingly some executables have exports so link.exe creates import lib
505 define gb_Executable_Executable_platform
506 $(call gb_LinkTarget_set_ilibtarget,$(2),$(3))
508 $(call gb_LinkTarget_add_auxtargets,$(2),\
509 $(patsubst %.lib,%.exp,$(3)) \
510 $(call gb_LinkTarget_get_pdbfile_out,$(2)) \
511 $(call gb_LinkTarget_get_pdbfile_in,$(2)) \
512 $(call gb_LinkTarget_get_manifestfile,$(2)) \
515 $(call gb_LinkTarget_get_target,$(2)) \
516 $(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE := $(call gb_LinkTarget_get_pdbfile_in,$(2))
518 endef
520 # CppunitTest class
522 gb_CppunitTest_UNITTESTFAILED := $(GBUILDDIR)/platform/unittest-failed-WNT.sh
523 gb_CppunitTest_PYTHONDEPS := $(call gb_Package_get_target,python3)
524 gb_CppunitTest_DEFS := -D_DLL
525 gb_CppunitTest_CPPTESTPRECOMMAND := $(call gb_Helper_prepend_ld_path,$(shell cygpath -u $(gb_Library_DLLDIR)):$(shell cygpath -u $(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/$(if $(MSVC_USE_DEBUG_RUNTIME),DebugDll,ReleaseDll)))
526 gb_CppunitTest_get_filename = test_$(1).dll
527 gb_CppunitTest_get_ilibfilename = itest_$(1).lib
529 define gb_CppunitTest_CppunitTest_platform
530 $(call gb_LinkTarget_set_ilibtarget,$(2),$(3))
532 $(call gb_LinkTarget_add_auxtargets,$(2),\
533 $(patsubst %.lib,%.exp,$(3)) \
534 $(3) \
535 $(call gb_LinkTarget_get_manifestfile,$(2)) \
536 $(call gb_LinkTarget_get_pdbfile_out,$(2)) \
537 $(call gb_LinkTarget_get_pdbfile_in,$(2)) \
538 $(call gb_LinkTarget_get_ilkfile,$(2)) \
541 $(call gb_LinkTarget_get_target,$(2)) \
542 $(call gb_LinkTarget_get_headers_target,$(2)) : PDBFILE = $(call gb_LinkTarget_get_pdbfile_in,$(2))
544 endef
546 # JunitTest class
548 ifneq ($(OOO_TEST_SOFFICE),)
549 gb_JunitTest_SOFFICEARG:=$(OOO_TEST_SOFFICE)
550 else
551 ifneq ($(gb_JunitTest_DEBUGRUN),)
552 gb_JunitTest_SOFFICEARG:=connect:pipe,name=$(USER)
553 else
554 gb_JunitTest_SOFFICEARG:=path:$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice
555 endif
556 endif
559 define gb_JunitTest_JunitTest_platform
560 $(call gb_JunitTest_get_target,$(1)) : DEFS := \
561 -Dorg.openoffice.test.arg.soffice="$(gb_JunitTest_SOFFICEARG)" \
562 -Dorg.openoffice.test.arg.env=PATH="$$$$PATH" \
563 -Dorg.openoffice.test.arg.user=$(call gb_Helper_make_url,$(call gb_JunitTest_get_userdir,$(1)))
564 -Dorg.openoffice.test.arg.workdir=$(call gb_JunitTest_get_userdir,$(1)) \
566 endef
569 define gb_Module_DEBUGRUNCOMMAND
570 printf "\nAttach the debugger to soffice.bin\n\n"
571 OFFICESCRIPT=`mktemp` && \
572 printf "$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice.exe" > $${OFFICESCRIPT} && \
573 printf " --norestore --nologo '--accept=pipe,name=$(USER);urp;'\n" >> $${OFFICESCRIPT} && \
574 $(SHELL) $${OFFICESCRIPT} && \
575 rm $${OFFICESCRIPT}
576 endef
581 # PythonTest class
583 gb_PythonTest_PRECOMMAND := $(gb_CppunitTest_CPPTESTPRECOMMAND)
584 gb_PythonTest_DEPS = $(call gb_Package_get_target,python3) $(call gb_Executable_get_target,python)
586 ifeq ($(strip $(CPPUNITTRACE)),TRUE)
587 override CPPUNITTRACE := '$(DEVENV)' /debugexe
588 endif
590 # WinResTarget class
592 gb_WinResTarget_POSTFIX :=.res
594 define gb_WinResTarget__command
595 $(call gb_Output_announce,$(2),$(true),RC ,1)
596 $(call gb_Helper_abbreviate_dirs,\
597 mkdir -p $(dir $(1)) && \
598 $(gb_RC) \
599 $(DEFS) $(FLAGS) \
600 $(INCLUDE) \
601 -Fo$(1) \
602 $(RCFILE) )
603 endef
605 $(eval $(call gb_Helper_make_dep_targets,\
606 WinResTarget \
609 ifeq ($(gb_FULLDEPS),$(true))
610 gb_WinResTarget__command_target := $(gb_Executable_BINDIR_FOR_BUILD)/makedepend.exe
611 define gb_WinResTarget__command_dep
612 $(call gb_Output_announce,RC:$(2),$(true),DEP,1)
613 $(call gb_Trace_StartRange,RC:$(2),DEP)
614 $(call gb_Helper_abbreviate_dirs,\
615 mkdir -p $(dir $(1)) && \
616 $(call gb_Executable_get_target_for_build,makedepend) \
617 $(INCLUDE) \
618 $(DEFS) \
619 $(RCFILE) \
620 -o .res \
621 -p $(dir $(3)) \
622 -f $(1))
623 $(call gb_Trace_EndRange,RC:$(2),DEP)
624 endef
625 else
626 gb_WinResTarget__command_target =
627 gb_WinResTarget__command_dep =
628 endif
630 # InstallModuleTarget class
632 define gb_InstallModuleTarget_InstallModuleTarget_platform
633 $(call gb_InstallModuleTarget_add_defs,$(1),\
634 $(gb_CPUDEFS) \
635 $(gb_OSDEFS) \
636 -DCOMID=MSC \
639 endef
641 # ExternalProject class
643 # Use the gcc wrappers for an autoconf based project
645 # gb_ExternalProject_register_targets project state_target
646 define gb_ExternalProject_use_autoconf
647 $(call gb_ExternalProject_get_preparation_target,$(1)) : $(call gb_Executable_get_runtime_dependencies,gcc-wrapper) \
648 $(call gb_Executable_get_runtime_dependencies,g++-wrapper)
649 $(call gb_ExternalProject_get_state_target,$(1),$(2)): WRAPPERS := $(gb_AUTOCONF_WRAPPERS)
650 endef
652 # Set INCLUDE and LIB variables and unset MAKE/MAKEFLAGS when using nmake
654 # gb_ExternalProject_use_nmake project state_target
655 define gb_ExternalProject_use_nmake
656 $(call gb_ExternalProject_get_state_target,$(1),$(2)): NMAKE := $(gb_NMAKE_VARS)
657 endef
659 # if ccache is enabled, then split it and use lastword as REAL_FOO
660 # /opt/lo/bin/ccache /cygdrive/c/PROGRA~2/MICROS~2.0/VC/bin/cl.exe
662 gb_AUTOCONF_WRAPPERS = \
663 REAL_CC="$(shell cygpath -w $(filter-out -%,$(CC)))" \
664 REAL_CC_FLAGS="$(filter -%,$(CC))" \
665 CC="$(call gb_Executable_get_target_for_build,gcc-wrapper)" \
666 REAL_CXX="$(shell cygpath -w $(filter-out -%,$(CXX)))" \
667 REAL_CXX_FLAGS="$(filter -%,$(CXX))" \
668 CXX="$(call gb_Executable_get_target_for_build,g++-wrapper)" \
669 LD="$(shell cygpath -w $(COMPATH)/bin/link.exe) -nologo"
671 gb_ExternalProject_INCLUDE := \
672 $(subst -I,,$(subst $(WHITESPACE),;,$(SOLARINC)))
674 # Workaround for openssl build - it puts the CC var into additional pair of quotes. This breaks if
675 # CC consists of more than a single element such as when using "ccache compiler". In case the
676 # variables are exported for openssl, it closes and reopens the quotes after each element.
677 gb_NMAKE_VARS = \
678 CC="$(subst $(WHITESPACE),$(if $(filter openssl,$(1)),\" \", ),$(strip \
679 $(shell cygpath -ws $(filter-out -%,$(CC))) $(filter -%,$(CC))))" \
680 INCLUDE="$(gb_ExternalProject_INCLUDE)" \
681 LIB="$(ILIB)" \
682 MAKEFLAGS= \
683 MAKE=nmake
685 # InstallScript class
687 gb_InstallScript_EXT := .inf
689 # CliAssemblyTarget class
691 gb_CliAssemblyTarget_POLICYEXT := $(gb_Library_DLLEXT)
692 gb_CliAssemblyTarget_get_dll = $(call gb_Library__get_dir_for_layer,NONE)/$(1)$(gb_CliAssemblyTarget_POLICYEXT)
694 # Extension class
696 gb_Extension_LICENSEFILE_DEFAULT := $(INSTROOT)/license.txt
698 # UnpackedTarget class
700 gb_UnpackedTarget_TARFILE_LOCATION := $(shell cygpath -u $(TARFILE_LOCATION))
702 # UIConfig class
704 # use responsefile because cui has too many files for command line
705 define gb_UIConfig__command
706 $(call gb_Helper_abbreviate_dirs,\
707 RESPONSEFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(if $(UI_IMAGELISTS),$(strip $(UI_IMAGELISTS)),/dev/null)) \
708 && tr " " "\000" < $$RESPONSEFILE | tr -d "\r\n" > $$RESPONSEFILE.0 \
709 && $(SORT) -u --files0-from=$$RESPONSEFILE.0 > $@ \
710 && rm $$RESPONSEFILE $$RESPONSEFILE.0 \
713 endef
715 # use file list file because swriter has too many files for command line
716 define gb_UIConfig__gla11y_command
717 $(call gb_ExternalExecutale__check_registration,python)
718 $(call gb_Helper_abbreviate_dirs,\
719 FILES=$(call gb_var2file,$(shell $(gb_MKTEMP)),$(UIFILES)) && \
720 $(gb_UIConfig_LXML_PATH) $(if $(SYSTEM_LIBXML)$(SYSTEM_LIBXSLT),,$(gb_Helper_set_ld_path)) \
721 $(call gb_ExternalExecutable_get_command,python) \
722 $(gb_UIConfig_gla11y_SCRIPT) $(gb_UIConfig_gla11y_PARAMETERS) -o $@ -L $$FILES && \
723 rm $$FILES
726 endef
728 # UIMenubarTarget class
730 define gb_UIMenubarTarget__command
731 $(call gb_Output_announce,$(2),$(true),UIM,1)
732 $(call gb_Trace_StartRange,$(2),UIM)
733 cp $(3) $(1)
734 $(call gb_Trace_EndRange,$(2),UIM)
736 endef
738 gb_UIMenubarTarget_UIMenubarTarget_platform :=
740 # Python
741 gb_Python_HOME := $(INSTDIR_FOR_BUILD)/program/python-core-$(PYTHON_VERSION)
742 gb_Python_PRECOMMAND := PATH="$(shell cygpath -w $(INSTDIR_FOR_BUILD)/program)" PYTHONHOME="$(gb_Python_HOME)" PYTHONPATH="$${PYPATH:+$$PYPATH;}$(gb_Python_HOME)/lib;$(gb_Python_HOME)/lib/lib-dynload:$(INSTDIR_FOR_BUILD)/program"
743 gb_Python_INSTALLED_EXECUTABLE := $(INSTROOT_FOR_BUILD)/$(LIBO_BIN_FOLDER)/python.exe
745 gb_ICU_PRECOMMAND := PATH="$(shell cygpath -w $(WORKDIR_FOR_BUILD)/UnpackedTarball/icu/source/lib)"
747 # vim: set noet sw=4: