Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / platform / mingw.mk
blobb65e1e7503b215e856069b319e430236e61e1710
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 gb_RC := $(WINDRES)
22 gb_COMPILERDEFS += \
23 -D_MT \
24 -D_NATIVE_WCHAR_T_DEFINED \
25 -D_MSC_EXTENSIONS \
26 -D_FORCENAMELESSUNION \
28 gb_RCDEFS := \
29 -DWINVER=0x0502 \
30 -DWIN32 \
32 gb_RCFLAGS :=
34 gb_CFLAGS += \
35 $(gb_CFLAGS_COMMON) \
36 -Wdeclaration-after-statement \
37 -fno-strict-aliasing \
39 gb_CXXFLAGS := \
40 $(gb_CXXFLAGS_COMMON) \
41 -Wno-ctor-dtor-privacy \
42 -Wreturn-type \
43 -Wshadow \
44 -Wuninitialized \
45 -fno-strict-aliasing \
46 -std=gnu++0x \
48 ifneq ($(SYSBASE),)
49 gb_CXXFLAGS += --sysroot=$(SYSBASE)
50 gb_CFLAGS += --sysroot=$(SYSBASE)
51 endif
53 # At least sal defines its own __main, which would cause DLLs linking against
54 # sal to pick up sal's __main instead of the one from MinGW's dllcrt2.o:
55 gb_LinkTarget_LDFLAGS := \
56 -Wl,--export-all-symbols \
57 -Wl,--exclude-symbols,__main \
58 -Wl,--enable-stdcall-fixup \
59 -Wl,--enable-runtime-pseudo-reloc-v2 \
61 ifeq ($(MINGW_GCCLIB_EH),YES)
62 gb_LinkTarget_LDFLAGS += -shared-libgcc
63 endif
65 gb_STDLIBS := \
66 -lmingwthrd \
67 -lmingw32 \
68 -lmingwex \
70 gb_DEBUG_CFLAGS := -g -fno-inline
72 # LinkTarget class
74 gb_LinkTarget_CFLAGS := $(gb_CFLAGS)
75 gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS)
77 ifeq ($(gb_SYMBOL),$(true))
78 gb_LinkTarget_CXXFLAGS += $(GGDB2)
79 gb_LinkTarget_CFLAGS += $(GGDB2)
80 endif
82 gb_LinkTarget_INCLUDE +=\
83 $(foreach inc,$(subst ;, ,$(JDKINC)),-I$(inc)) \
85 define gb_LinkTarget__command_dynamiclinkexecutable
86 $(call gb_Helper_abbreviate_dirs,\
87 $(if $(CXXOBJECTS)$(GENCXXOBJECTS)$(EXTRAOBJECTLISTS),$(gb_CXX),$(gb_CC)) $(strip \
88 $(gb_Executable_TARGETTYPEFLAGS) \
89 $(if $(filter YES,$(TARGETGUI)), -mwindows, -mconsole) \
90 $(T_LDFLAGS) \
91 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
92 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
93 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
94 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
95 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
96 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),@$(extraobjectlist)) \
97 $(NATIVERES) \
98 $(if $(LINKED_STATIC_LIBS),-Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group) \
99 $(patsubst lib%.a,-l%,$(patsubst lib%.dll.a,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_ilibfilename,$(lib))))) \
100 $(T_LIBS) \
101 -Wl$(COMMA)-Map$(COMMA)$(WORKDIR)/LinkTarget/$(2).map \
102 -o $(1)))
103 endef
105 define gb_LinkTarget__command_dynamiclinklibrary
106 $(call gb_Helper_abbreviate_dirs,\
107 $(if $(CXXOBJECTS)$(GENCXXOBJECTS)$(EXTRAOBJECTLISTS),$(gb_CXX),$(gb_CC)) $(strip \
108 $(gb_Library_TARGETTYPEFLAGS) \
109 $(T_LDFLAGS) \
110 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
111 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
112 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
113 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
114 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
115 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),@$(extraobjectlist)) \
116 $(NATIVERES) \
117 $(if $(LINKED_STATIC_LIBS),-Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group) \
118 $(patsubst lib%.a,-l%,$(patsubst lib%.dll.a,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_ilibfilename,$(lib))))) \
119 $(T_LIBS) \
120 -Wl$(COMMA)-Map$(COMMA)$(WORKDIR)/LinkTarget/$(2).map \
121 -Wl$(COMMA)--out-implib$(COMMA)$(ILIBTARGET) \
122 -o $(1) \
123 $(if $(findstring s,$(MAKEFLAGS)),> /dev/null)))
124 endef
126 define gb_LinkTarget__command_staticlinklibrary
127 $(call gb_Helper_abbreviate_dirs,\
128 rm -f $(1) && \
129 $(gb_AR) -rsu $(1) \
130 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
131 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
132 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
133 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
134 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),@$(extraobjectlist)) \
135 $(if $(findstring s,$(MAKEFLAGS)),> /dev/null))
136 endef
138 define gb_LinkTarget__command
139 $(call gb_Output_announce,$(2),$(true),LNK,4)
140 $(if $(filter Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclinkexecutable,$(1),$(2)))
141 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclinklibrary,$(1),$(2)))
142 $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlinklibrary,$(1)))
143 endef
145 define gb_LinkTarget_use_system_win32_libs
146 $(call gb_LinkTarget_add_libs,$(1),$(foreach lib,$(2),-l$(patsubst oldnames,moldname,$(lib))))
147 $(if $(call gb_LinkTarget__is_merged,$(1)),\
148 $(call gb_LinkTarget_add_libs,$(call gb_Library_get_linktarget,merged),$(foreach lib,$(2),-l$(patsubst oldnames,moldname,$(lib)))))
149 endef
151 gb_LinkTarget_get_mapfile = \
152 $(WORKDIR)/LinkTarget/$(patsubst %.dll,%.map,$(call gb_LinkTarget__get_workdir_linktargetname,$(1)))
154 # Library class
156 gb_Library_DEFS := -D_DLL
157 gb_Library_TARGETTYPEFLAGS := -shared
158 gb_Library_get_rpath :=
160 gb_Library_SYSPRE := lib
161 gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
162 gb_Library_UDK_MAJORVER := 3
164 gb_Library_PLAINEXT := .dll.a
166 gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT)
167 gb_Library_RTVEREXT := $(gb_Library_UDK_MAJORVER)$(gb_Library_RTEXT)
168 gb_Library_OOOEXT := $(gb_Library_DLLPOSTFIX)$(gb_Library_PLAINEXT)
169 gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
170 gb_Library_UNOVEREXT := $(gb_Library_UDK_MAJORVER)$(gb_Library_PLAINEXT)
172 gb_Library_DLLEXT := .dll
174 gb_Library_RTDLLEXT := gcc3$(gb_Library_DLLEXT)
175 gb_Library_RTVERDLLEXT := $(gb_Library_UDK_MAJORVER)$(gb_Library_RTDLLEXT)
176 gb_Library_OOODLLEXT := $(gb_Library_DLLPOSTFIX)$(gb_Library_DLLEXT)
177 gb_Library_UNOVERDLLEXT := $(gb_Library_UDK_MAJORVER)$(gb_Library_DLLEXT)
179 gb_Library_LAYER := \
180 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
181 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):NONE) \
182 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
183 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
184 $(foreach lib,$(gb_Library_PLAINLIBS_SHLXTHDL),$(lib):SHLXTHDL) \
185 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):URELIB) \
186 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
187 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
188 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):OXT) \
190 gb_Library_ILIBFILENAMES :=\
191 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
192 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
193 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
194 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
195 $(foreach lib,$(gb_Library_PLAINLIBS_SHLXTHDL),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
196 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
197 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTVEREXT)) \
198 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \
199 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):$(lib)$(gb_Library_UNOEXT)) \
202 gb_Library_FILENAMES :=\
203 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(lib)$(gb_Library_OOODLLEXT)) \
204 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(lib)$(gb_Library_DLLEXT)) \
205 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(lib)$(gb_Library_DLLEXT)) \
206 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(lib)$(gb_Library_DLLEXT)) \
207 $(foreach lib,$(gb_Library_PLAINLIBS_SHLXTHDL),$(lib):$(lib)$(gb_Library_DLLEXT)) \
208 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):$(lib)$(gb_Library_OOODLLEXT)) \
209 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(lib)$(gb_Library_RTVERDLLEXT)) \
210 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(lib)$(gb_Library_UNOVERDLLEXT)) \
211 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):$(lib)$(gb_Library_UNOEXT)) \
213 gb_Library_IARCSYSPRE := lib
214 gb_Library_IARCEXT := .a
216 gb_Library_ILIBEXT := .lib
218 define gb_Library_Library_platform
219 $(call gb_LinkTarget_set_ilibtarget,$(2),$(3))
221 $(call gb_LinkTarget_add_auxtargets,$(2), \
222 $(3) \
223 $(call gb_LinkTarget_get_mapfile,$(2)) \
226 $(call gb_Library_add_default_nativeres,$(1),$(1)/default)
228 endef
230 define gb_Library_add_default_nativeres
231 $(call gb_WinResTarget_WinResTarget_init,$(2))
232 $(call gb_WinResTarget_set_rcfile,$(2),include/default)
233 $(call gb_WinResTarget_add_defs,$(2),\
234 -DVERVARIANT="$(LIBO_VERSION_PATCH)" \
235 -DRES_APP_VENDOR="$(OOO_VENDOR)" \
236 -DADDITIONAL_VERINFO1="" \
237 -DADDITIONAL_VERINFO2="" \
238 -DADDITIONAL_VERINFO3="" \
240 $(call gb_Library_add_nativeres,$(1),$(2))
241 $(call gb_Library_get_clean_target,$(1)) : $(call gb_WinResTarget_get_clean_target,$(2))
243 endef
245 define gb_LinkTarget_add_nativeres
246 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_WinResTarget_get_target,$(2))
247 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES += $(call gb_WinResTarget_get_target,$(2))
249 endef
251 define gb_LinkTarget_set_nativeres
252 $(call gb_LinkTarget_get_target,$(1)) : $(call gb_WinResTarget_get_target,$(2))
253 $(call gb_LinkTarget_get_target,$(1)) : NATIVERES := $(call gb_WinResTarget_get_target,$(2))
255 endef
257 define gb_Library_get_ilibfilename
258 $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Library_ILIBFILENAMES)))
259 endef
261 gb_Library_get_sdk_link_dir = $(INSTDIR)/$(SDKDIRNAME)/lib
263 gb_Library_get_sdk_link_lib = $(gb_Library_get_ilib_target)
265 # Executable class
267 gb_Executable_EXT := .exe
268 gb_Executable_TARGETTYPEFLAGS :=
269 gb_Executable_get_rpath :=
271 define gb_Executable_Executable_platform
273 endef
275 # CppunitTest class
277 gb_CppunitTest_CPPTESTPRECOMMAND := \
278 $(call gb_Helper_extend_ld_path,$(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/.libs)
279 gb_CppunitTest_get_filename = test_$(1).dll
280 gb_CppunitTest_get_ilibfilename = itest_$(1).lib
282 define gb_CppunitTest_CppunitTest_platform
283 $(call gb_LinkTarget_set_ilibtarget,$(2),$(3))
285 $(call gb_LinkTarget_add_auxtargets,$(2),\
286 $(3) \
287 $(call gb_LinkTarget_get_mapfile,$(2)) \
290 endef
292 # WinResTarget class
294 gb_WinResTarget_POSTFIX :=.o
296 define gb_WinResTarget__command
297 $(call gb_Output_announce,$(2),$(true),RC ,3)
298 $(call gb_Helper_abbreviate_dirs,\
299 mkdir -p $(dir $(1)) && \
300 $(gb_RC) \
301 $(DEFS) $(FLAGS) \
302 $(INCLUDE) \
303 -o $(1) \
304 $(RCFILE) )
305 endef
307 $(eval $(call gb_Helper_make_dep_targets,\
308 WinResTarget \
311 ifeq ($(gb_FULLDEPS),$(true))
312 gb_WinResTarget__command_target = $(gb_Executable_BINDIR_FOR_BUILD)/makedepend
313 define gb_WinResTarget__command_dep
314 $(call gb_Output_announce,RC:$(2),$(true),DEP,1)
315 $(call gb_Helper_abbreviate_dirs,\
316 mkdir -p $(dir $(1)) && \
317 $(gb_Executable_BINDIR_FOR_BUILD)/makedepend \
318 $(INCLUDE) \
319 $(DEFS) \
320 $(RCFILE) \
321 -o .res \
322 -p $(dir $(3)) \
323 -f $(1))
324 endef
325 else
326 gb_WinResTarget__command_target =
327 gb_WinResTarget__command_dep =
328 endif
330 # InstallModuleTarget class
332 define gb_InstallModuleTarget_InstallModuleTarget_platform
333 $(call gb_InstallModuleTarget_add_defs,$(1),\
334 $(gb_CPUDEFS) \
335 $(gb_OSDEFS) \
336 -DCOMID=gcc3 \
337 -D_gcc3 \
340 endef
342 # InstallScript class
344 gb_InstallScript_EXT := .inf
346 # CliAssemblyTarget class
348 gb_CliAssemblyTarget_POLICYEXT :=
349 gb_CliAssemblyTarget_get_dll :=
351 # Extension class
353 gb_Extension_LICENSEFILE_DEFAULT := $(INSTROOT)/license.txt
355 # UnpackedTarget class
357 gb_UnpackedTarget_TARFILE_LOCATION := $(TARFILE_LOCATION)
359 # UnoApiHeadersTarget class
361 ifeq ($(DISABLE_DYNLOADING),TRUE)
362 gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2))
363 else
364 gb_UnoApiHeadersTarget_select_variant = $(2)
365 endif
367 # UIMenubarTarget class
369 define gb_UIMenubarTarget__command
370 $(call gb_Output_announce,$(2),$(true),UIM,1)
371 cp $(3) $(1)
373 endef
375 gb_UIMenubarTarget_UIMenubarTarget_platform :=
377 # Python
378 gb_PYTHON_PRECOMMAND := $$(error FIXME)
380 # vim: set noet sw=4: