Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / platform / unxgcc.mk
blobbf10e998f5e65540f2cbf07952558715408d5960
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 include $(GBUILDDIR)/platform/com_GCC_defs.mk
22 gb_MKTEMP := mktemp -t gbuild.XXXXXX
24 ifneq ($(origin AR),default)
25 gb_AR := $(AR)
26 endif
28 gb_OSDEFS := \
29 -D$(OS) \
30 -D_PTHREADS \
31 -DUNIX \
32 -DUNX \
33 $(PTHREAD_CFLAGS) \
35 gb_CFLAGS := \
36 $(gb_CFLAGS_COMMON) \
37 -fPIC \
38 -Wdeclaration-after-statement \
39 -Wshadow \
41 gb_CXXFLAGS := \
42 $(gb_CXXFLAGS_COMMON) \
43 -fPIC \
44 -Wshadow \
45 -Woverloaded-virtual \
46 $(CXXFLAGS_CXX11) \
49 # enable debug STL
50 ifeq ($(gb_ENABLE_DBGUTIL),$(true))
51 gb_COMPILERDEFS += \
52 -D_GLIBCXX_DEBUG \
54 endif
56 ifneq ($(strip $(SYSBASE)),)
57 gb_CXXFLAGS += --sysroot=$(SYSBASE)
58 gb_CFLAGS += --sysroot=$(SYSBASE)
59 gb_LinkTarget_LDFLAGS += \
60 -Wl,--sysroot=$(SYSBASE)
61 endif
63 gb_LinkTarget_LDFLAGS += \
64 -Wl,-rpath-link,$(SYSBASE)/lib:$(SYSBASE)/usr/lib \
65 -Wl,-z,combreloc \
67 ifeq ($(HAVE_LD_HASH_STYLE),TRUE)
68 gb_LinkTarget_LDFLAGS += \
69 -Wl,--hash-style=$(WITH_LINKER_HASH_STYLE) \
71 endif
73 ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),)
74 gb_LinkTarget_LDFLAGS += \
75 -Wl,--dynamic-list-cpp-new \
76 -Wl,--dynamic-list-cpp-typeinfo \
77 -Wl,-Bsymbolic-functions \
79 endif
81 ifneq ($(gb_DEBUGLEVEL),0)
82 gb_LINKEROPTFLAGS :=
83 else
84 gb_LINKEROPTFLAGS := -Wl,-O1
85 endif
87 ifeq ($(gb_SYMBOL),$(true))
88 gb_LINKERSTRIPDEBUGFLAGS :=
89 else
90 gb_LINKERSTRIPDEBUGFLAGS := -Wl,-S
91 endif
93 # LinkTarget class
95 define gb_LinkTarget__get_rpath_for_layer
96 $(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
97 endef
99 gb_LinkTarget__RPATHS := \
100 URELIB:\dORIGIN \
101 UREBIN:\dORIGIN \
102 OOO:\dORIGIN \
103 SDKBIN:\dORIGIN/../../program \
104 OXT: \
105 NONE:\dORIGIN/../Library \
107 gb_LinkTarget_CFLAGS := $(gb_CFLAGS)
108 gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS)
110 ifeq ($(gb_SYMBOL),$(true))
111 gb_LinkTarget_CXXFLAGS += $(GGDB2)
112 gb_LinkTarget_CFLAGS += $(GGDB2)
113 endif
115 # note that `cat $(extraobjectlist)` is needed to build with older gcc versions, e.g. 4.1.2 on SLED10
116 # we want to use @$(extraobjectlist) in the long run
117 # link with C compiler if there are no C++ files (pyuno_wrapper depends on this)
118 # But always link with C++ compiler e.g. under -fsanitze=undefined, as sal uses
119 # __ubsan_handle_dynamic_type_cache_miss_abort and __ubsan_vptr_type_cache from
120 # libclang_rt.ubsan_cxx-x86_64.a, and oosplash links against sal but itself only
121 # contains .c sources:
122 define gb_LinkTarget__command_dynamiclink
123 $(call gb_Helper_abbreviate_dirs,\
124 $(if $(CXXOBJECTS)$(GENCXXOBJECTS)$(EXTRAOBJECTLISTS)$(filter-out XTRUE,X$(ENABLE_RUNTIME_OPTIMIZATIONS)),$(gb_CXX),$(gb_CC)) \
125 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
126 $(gb_LTOFLAGS) \
127 $(if $(SOVERSIONSCRIPT),-Wl$(COMMA)--soname=$(notdir $(1)) \
128 -Wl$(COMMA)--version-script=$(SOVERSIONSCRIPT)) \
129 $(subst \d,$$,$(RPATH)) \
130 $(T_LDFLAGS) \
131 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
132 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
133 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
134 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
135 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
136 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),`cat $(extraobjectlist)`) \
137 -Wl$(COMMA)--start-group \
138 $(foreach lib,$(LINKED_STATIC_LIBS),\
139 $(call gb_StaticLibrary_get_target,$(lib))) \
140 $(T_LIBS) \
141 -Wl$(COMMA)--end-group \
142 -Wl$(COMMA)--no-as-needed \
143 $(patsubst lib%.a,-l%,$(patsubst lib%.so,-l%,$(patsubst %.$(gb_Library_UDK_MAJORVER),%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))))) \
144 -o $(1) \
145 $(if $(SOVERSIONSCRIPT),&& ln -sf ../../program/$(notdir $(1)) $(ILIBTARGET)))
146 $(if $(filter Library,$(TARGETTYPE)), $(call gb_Helper_abbreviate_dirs,\
147 $(READELF) -d $(1) | grep SONAME > $(WORKDIR)/LinkTarget/$(2).exports.tmp; \
148 $(NM) --dynamic --extern-only --defined-only --format=posix $(1) \
149 | cut -d' ' -f1-2 \
150 >> $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
151 $(call gb_Helper_replace_if_different_and_touch,$(WORKDIR)/LinkTarget/$(2).exports.tmp, \
152 $(WORKDIR)/LinkTarget/$(2).exports,$(1))))
153 endef
155 define gb_LinkTarget__command_staticlink
156 $(call gb_Helper_abbreviate_dirs,\
157 rm -f $(1) && \
158 $(gb_AR) -rsu $(1) \
159 $(if $(LD_PLUGIN),--plugin $(LD_PLUGIN)) \
160 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
161 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
162 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
163 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
164 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
165 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),@$(extraobjectlist)) \
166 $(if $(findstring s,$(MAKEFLAGS)),2> /dev/null))
167 endef
169 define gb_LinkTarget__command
170 $(call gb_Output_announce,$(2),$(true),LNK,4)
171 $(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2)))
172 $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
173 endef
176 # Library class
178 gb_Library_DEFS :=
179 gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack
180 gb_Library_UDK_MAJORVER := 3
181 gb_Library_SYSPRE := lib
182 gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
183 gb_Library_PLAINEXT := .so
184 gb_Library_DLLEXT := .so
185 gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT)
187 gb_Library_OOOEXT := $(gb_Library_DLLPOSTFIX)$(gb_Library_PLAINEXT)
188 gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
190 gb_Library_FILENAMES := \
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_PRIVATELIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
196 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT).$(gb_Library_UDK_MAJORVER)) \
197 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT).$(gb_Library_UDK_MAJORVER)) \
198 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):$(lib)$(gb_Library_UNOEXT)) \
201 gb_Library_LAYER := \
202 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
203 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
204 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
205 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):NONE) \
206 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):URELIB) \
207 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
208 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
209 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):OXT) \
211 define gb_Library__get_rpath
212 $(if $(1),$(strip -Wl,-z,origin '-Wl,-rpath,$(1)' -Wl,-rpath-link,$(INSTDIR)/program))
213 endef
215 define gb_Library_get_rpath
216 $(call gb_Library__get_rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1))))
217 endef
219 define gb_Library_Library_platform
220 $(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
222 endef
224 gb_Library__set_soversion_script_platform = $(gb_Library__set_soversion_script)
226 gb_Library_get_sdk_link_dir = $(INSTDIR)/$(SDKDIRNAME)/lib
228 gb_Library_get_sdk_link_lib = $(gb_Library_get_versionlink_target)
230 # Executable class
232 gb_Executable_EXT :=
234 gb_Executable_LAYER := \
235 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
236 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
237 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
238 $(foreach exe,$(gb_Executable_NONE),$(exe):NONE) \
241 define gb_Executable__get_rpath
242 $(strip -Wl,-z,origin $(if $(1),'-Wl$(COMMA)-rpath$(COMMA)$(1)') -Wl,-rpath-link,$(INSTDIR)/program)
243 endef
245 define gb_Executable_get_rpath
246 $(call gb_Executable__get_rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1))))
247 endef
249 define gb_Executable_Executable_platform
250 $(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1))
252 endef
255 # CppunitTest class
257 gb_CppunitTest_CPPTESTPRECOMMAND := \
258 $(call gb_Helper_extend_ld_path,$(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/.libs)
259 gb_CppunitTest_get_filename = libtest_$(1).so
260 gb_CppunitTest_get_ilibfilename = $(gb_CppunitTest_get_filename)
262 define gb_CppunitTest_CppunitTest_platform
263 $(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library__get_rpath,$(call gb_LinkTarget__get_rpath_for_layer,NONE))
265 endef
267 define gb_CppunitTest_postprocess
268 $(SRCDIR)/solenv/bin/gdb-core-bt.sh $(1) $(2) $(3)
269 endef
271 # JunitTest class
273 ifneq ($(OOO_TEST_SOFFICE),)
274 gb_JunitTest_SOFFICEARG:=$(OOO_TEST_SOFFICE)
275 else
276 ifneq ($(gb_JunitTest_DEBUGRUN),)
277 gb_JunitTest_SOFFICEARG:=connect:pipe,name=$(USER)
278 else
279 gb_JunitTest_SOFFICEARG:=path:$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice
280 endif
281 endif
283 define gb_JunitTest_JunitTest_platform
284 $(call gb_JunitTest_get_target,$(1)) : DEFS := \
285 -Dorg.openoffice.test.arg.env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
286 -Dorg.openoffice.test.arg.user=$(call gb_Helper_make_url,$(call gb_JunitTest_get_userdir,$(1))) \
287 -Dorg.openoffice.test.arg.workdir=$(call gb_JunitTest_get_userdir,$(1)) \
288 -Dorg.openoffice.test.arg.postprocesscommand=$(SRCDIR)/solenv/bin/gdb-core-bt.sh \
289 -Dorg.openoffice.test.arg.soffice="$(gb_JunitTest_SOFFICEARG)" \
291 endef
293 # PythonTest class
295 gb_PythonTest_PRECOMMAND := $(gb_CppunitTest_CPPTESTPRECOMMAND)
297 # Module class
299 define gb_Module_DEBUGRUNCOMMAND
300 OFFICESCRIPT=`mktemp` && \
301 printf 'if [ -e $(INSTROOT)/program/ooenv ]; then . $(INSTROOT)/program/ooenv; fi\n' > $${OFFICESCRIPT} && \
302 printf "gdb $(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice.bin" >> $${OFFICESCRIPT} && \
303 printf " -ex \"set args --norestore --nologo '--accept=pipe,name=$(USER);urp;' \"" >> $${OFFICESCRIPT} && \
304 $(SHELL) $${OFFICESCRIPT} && \
305 rm $${OFFICESCRIPT}
306 endef
308 # InstallModuleTarget class
310 define gb_InstallModuleTarget_InstallModuleTarget_platform
311 $(call gb_InstallModuleTarget_add_defs,$(1),\
312 $(gb_CPUDEFS) \
313 $(gb_OSDEFS) \
314 -DCOMID=gcc3 \
315 -DSHORTSTDC3=$(gb_SHORTSTDC3) \
316 -DSHORTSTDCPP3=$(gb_SHORTSTDCPP3) \
317 -D_gcc3 \
320 endef
322 # InstallScript class
324 gb_InstallScript_EXT := .ins
326 # CliAssemblyTarget class
328 gb_CliAssemblyTarget_POLICYEXT :=
329 gb_CliAssemblyTarget_get_dll :=
331 # Extension class
333 gb_Extension_LICENSEFILE_DEFAULT := $(INSTROOT)/LICENSE
335 # UnpackedTarget class
337 gb_UnpackedTarget_TARFILE_LOCATION := $(TARFILE_LOCATION)
339 # UnoApiHeadersTarget class
341 ifeq ($(DISABLE_DYNLOADING),TRUE)
342 gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2))
343 else
344 gb_UnoApiHeadersTarget_select_variant = $(2)
345 endif
347 # UIMenubarTarget class
349 define gb_UIMenubarTarget__command
350 $(call gb_Output_announce,$(2),$(true),UIM,1)
351 cp $(3) $(1)
353 endef
355 gb_UIMenubarTarget_UIMenubarTarget_platform :=
357 # Python
358 gb_Python_PRECOMMAND := $(gb_Helper_set_ld_path) PYTHONHOME="$(INSTDIR)/program/python-core-$(PYTHON_VERSION)" PYTHONPATH="$(INSTDIR)/program/python-core-$(PYTHON_VERSION)/lib:$(INSTDIR)/program/python-core-$(PYTHON_VERSION)/lib/lib-dynload"
359 gb_Python_INSTALLED_EXECUTABLE := /bin/sh $(INSTROOT)/program/python
360 # this is passed to gdb as executable when running tests
361 gb_Python_INSTALLED_EXECUTABLE_GDB := $(INSTROOT)/program/python.bin
363 include $(GBUILDDIR)/platform/com_GCC_class.mk
365 # vim: set noet sw=4: