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 # to block heavy exception handling that try to acquire the solarmutex
21 export LO_LEAN_EXCEPTION
=1
23 include $(GBUILDDIR
)/platform
/com_GCC_defs.mk
25 gb_MKTEMP
:= mktemp
-t gbuild.XXXXXX
27 ifneq ($(origin AR
),default
)
42 -Wdeclaration-after-statement \
45 # At least libstdc++ (which is approximated here with !HAVE_LIBCXX) needs -pthread when including
46 # various C++ headers like <thread>, see <https://gcc.gnu.org/onlinedocs/gcc-8.3.0/libstdc++/manual/
47 # manual/using.html#manual.intro.using.flags>:
48 ifeq ($(HAVE_LIBCXX
),)
49 gb_CXX_LINKFLAGS
:= -pthread
53 $(gb_CXXFLAGS_COMMON
) \
56 -Woverloaded-virtual \
62 ifeq ($(gb_ENABLE_DBGUTIL
),$(true
))
68 ifneq ($(strip $(SYSBASE
)),)
69 gb_CXXFLAGS
+= --sysroot
=$(SYSBASE
)
70 gb_CFLAGS
+= --sysroot
=$(SYSBASE
)
71 gb_LinkTarget_LDFLAGS
+= \
72 -Wl
,--sysroot
=$(SYSBASE
)
75 gb_LinkTarget_LDFLAGS
+= \
76 -Wl
,-rpath-link
,$(SYSBASE
)/lib
:$(SYSBASE
)/usr
/lib \
79 ifeq ($(HAVE_LD_HASH_STYLE
),TRUE
)
80 gb_LinkTarget_LDFLAGS
+= \
81 -Wl
,--hash-style
=$(WITH_LINKER_HASH_STYLE
) \
85 ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS
),)
86 gb_LinkTarget_LDFLAGS
+= -Wl
,-Bsymbolic-functions
89 gb_LINKEROPTFLAGS
:= -Wl
,-O1
90 gb_LINKERSTRIPDEBUGFLAGS
:= -Wl
,-S
94 define gb_LinkTarget__get_rpath_for_layer
95 $(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS
)))
98 gb_LinkTarget__RPATHS
:= \
102 SDKBIN
:\dORIGIN
/..
/..
/program \
104 NONE
:\dORIGIN
/..
/Library \
106 gb_LinkTarget_CFLAGS
:= $(gb_CFLAGS
)
107 gb_LinkTarget_CXXFLAGS
:= $(gb_CXXFLAGS
)
109 # note that `cat $(extraobjectlist)` is needed to build with older gcc versions, e.g. 4.1.2 on SLED10
110 # we want to use @$(extraobjectlist) in the long run
111 # link with C compiler if there are no C++ files (pyuno_wrapper depends on this)
112 # But always link with C++ compiler e.g. under -fsanitize=undefined, as sal uses
113 # __ubsan_handle_dynamic_type_cache_miss_abort and __ubsan_vptr_type_cache from
114 # libclang_rt.ubsan_cxx-x86_64.a, and oosplash links against sal but itself only
115 # contains .c sources:
116 define gb_LinkTarget__command_dynamiclink
117 $(call gb_Helper_abbreviate_dirs
,\
118 $(if
$(CXXOBJECTS
)$(GENCXXOBJECTS
)$(EXTRAOBJECTLISTS
)$(filter-out XTRUE
,X
$(ENABLE_RUNTIME_OPTIMIZATIONS
)),$(gb_CXX
) $(gb_CXX_LINKFLAGS
),$(gb_CC
)) \
119 $(if
$(filter Library CppunitTest
,$(TARGETTYPE
)),$(gb_Library_TARGETTYPEFLAGS
)) \
121 $(if
$(SOVERSIONSCRIPT
),-Wl
$(COMMA
)--soname
=$(notdir $(1)) \
122 -Wl
$(COMMA
)--version-script
=$(SOVERSIONSCRIPT
)) \
123 $(subst \d
,$$,$(RPATH
)) \
125 $(foreach object
,$(COBJECTS
),$(call gb_CObject_get_target
,$(object
))) \
126 $(foreach object
,$(CXXOBJECTS
),$(call gb_CxxObject_get_target
,$(object
))) \
127 $(foreach object
,$(ASMOBJECTS
),$(call gb_AsmObject_get_target
,$(object
))) \
128 $(foreach object
,$(GENCOBJECTS
),$(call gb_GenCObject_get_target
,$(object
))) \
129 $(foreach object
,$(GENCXXOBJECTS
),$(call gb_GenCxxObject_get_target
,$(object
))) \
130 $(foreach extraobjectlist
,$(EXTRAOBJECTLISTS
),`cat $(extraobjectlist)`) \
131 $(if
$(filter TRUE
,$(DISABLE_DYNLOADING
)), \
132 -Wl
$(COMMA
)--start-group \
133 $(patsubst lib
%.a
,-l
%,$(patsubst lib
%.so
,-l
%,$(patsubst %.
$(gb_Library_UDK_MAJORVER
),%,$(foreach lib
,$(LINKED_LIBS
),$(call gb_Library_get_filename
,$(lib
)))))) \
134 $(foreach lib
,$(LINKED_STATIC_LIBS
),$(call gb_StaticLibrary_get_target
,$(lib
))) \
136 $(if
$(CXXOBJECTS
)$(GENCXXOBJECTS
)$(EXTRAOBJECTLISTS
)$(filter-out XTRUE
,X
$(ENABLE_RUNTIME_OPTIMIZATIONS
)),$(T_STDLIBS_CXX
)) \
137 -Wl
$(COMMA
)--end-group \
139 -Wl
$(COMMA
)--start-group \
140 $(foreach lib
,$(LINKED_STATIC_LIBS
),$(call gb_StaticLibrary_get_target
,$(lib
))) \
142 $(if
$(CXXOBJECTS
)$(GENCXXOBJECTS
)$(EXTRAOBJECTLISTS
)$(filter-out XTRUE
,X
$(ENABLE_RUNTIME_OPTIMIZATIONS
)),$(T_STDLIBS_CXX
)) \
143 -Wl
$(COMMA
)--end-group \
144 -Wl
$(COMMA
)--no-as-needed \
145 $(patsubst lib
%.a
,-l
%,$(patsubst lib
%.so
,-l
%,$(patsubst %.
$(gb_Library_UDK_MAJORVER
),%,$(foreach lib
,$(LINKED_LIBS
),$(call gb_Library_get_filename
,$(lib
)))))) \
148 $(if
$(SOVERSIONSCRIPT
),&& ln
-sf ..
/..
/program
/$(notdir $(1)) $(ILIBTARGET
)))
149 $(if
$(filter Library
,$(TARGETTYPE
)), $(call gb_Helper_abbreviate_dirs
,\
150 $(READELF
) -d
$(1) | grep SONAME
> $(WORKDIR
)/LinkTarget
/$(2).exports.tmp
; \
151 $(NM
) $(gb_LTOPLUGINFLAGS
) --dynamic
--extern-only
--defined-only
--format
=posix
$(1) \
153 >> $(WORKDIR
)/LinkTarget
/$(2).exports.tmp
&& \
154 $(call gb_Helper_replace_if_different_and_touch
,$(WORKDIR
)/LinkTarget
/$(2).exports.tmp
, \
155 $(WORKDIR
)/LinkTarget
/$(2).exports
,$(1))))
158 define gb_LinkTarget__command_staticlink
159 $(call gb_Helper_abbreviate_dirs
,\
161 $(gb_AR
) $(gb_LTOPLUGINFLAGS
) -rsu
$(1) \
162 $(if
$(LD_PLUGIN
),--plugin
$(LD_PLUGIN
)) \
163 $(foreach object
,$(COBJECTS
),$(call gb_CObject_get_target
,$(object
))) \
164 $(foreach object
,$(CXXOBJECTS
),$(call gb_CxxObject_get_target
,$(object
))) \
165 $(foreach object
,$(ASMOBJECTS
),$(call gb_AsmObject_get_target
,$(object
))) \
166 $(foreach object
,$(GENCOBJECTS
),$(call gb_GenCObject_get_target
,$(object
))) \
167 $(foreach object
,$(GENCXXOBJECTS
),$(call gb_GenCxxObject_get_target
,$(object
))) \
168 $(foreach extraobjectlist
,$(EXTRAOBJECTLISTS
),@
$(extraobjectlist
)) \
169 $(if
$(findstring s
,$(MAKEFLAGS
)),2> /dev
/null
))
172 define gb_LinkTarget__command
173 $(call gb_Output_announce
,$(2),$(true
),LNK
,4)
174 $(if
$(filter CppunitTest Executable
,$(TARGETTYPE
)),$(call gb_LinkTarget__command_dynamiclink
,$(1),$(2)))
175 $(if
$(filter Library
,$(TARGETTYPE
)),$(if
$(filter TRUE
,$(DISABLE_DYNLOADING
)),$(call gb_LinkTarget__command_staticlink
,$(1)),$(call gb_LinkTarget__command_dynamiclink
,$(1),$(2))))
176 $(if
$(filter StaticLibrary
,$(TARGETTYPE
)),$(call gb_LinkTarget__command_staticlink
,$(1)))
183 gb_Library_SYSPRE
:= lib
184 gb_Library_UNOVERPRE
:= $(gb_Library_SYSPRE
)uno_
186 ifeq ($(DISABLE_DYNLOADING
),TRUE
)
188 gb_Library_PLAINEXT
:= .a
189 gb_Library_DLLEXT
:= .a
193 gb_Library_TARGETTYPEFLAGS
:= -shared
-Wl
,-z
,noexecstack
194 gb_Library_UDK_MAJORVER
:= 3
195 gb_Library_PLAINEXT
:= .so
196 gb_Library_DLLEXT
:= .so
200 gb_Library_RTEXT
:= gcc3
$(gb_Library_PLAINEXT
)
202 gb_Library_OOOEXT
:= $(gb_Library_DLLPOSTFIX
)$(gb_Library_PLAINEXT
)
203 gb_Library_UNOEXT
:= .uno
$(gb_Library_PLAINEXT
)
205 gb_Library_FILENAMES
:= \
206 $(foreach lib
,$(gb_Library_OOOLIBS
),$(lib
):$(gb_Library_SYSPRE
)$(lib
)$(gb_Library_OOOEXT
)) \
207 $(foreach lib
,$(gb_Library_PLAINLIBS_NONE
),$(lib
):$(gb_Library_SYSPRE
)$(lib
)$(gb_Library_PLAINEXT
)) \
208 $(foreach lib
,$(gb_Library_PLAINLIBS_URE
),$(lib
):$(gb_Library_SYSPRE
)$(lib
)$(gb_Library_PLAINEXT
)) \
209 $(foreach lib
,$(gb_Library_PLAINLIBS_OOO
),$(lib
):$(gb_Library_SYSPRE
)$(lib
)$(gb_Library_PLAINEXT
)) \
210 $(foreach lib
,$(gb_Library_PLAINLIBS_OXT
),$(lib
):$(gb_Library_SYSPRE
)$(lib
)$(gb_Library_PLAINEXT
)) \
211 $(foreach lib
,$(gb_Library_PRIVATELIBS_URE
),$(lib
):$(gb_Library_SYSPRE
)$(lib
)$(gb_Library_OOOEXT
)) \
212 $(foreach lib
,$(gb_Library_EXTENSIONLIBS
),$(lib
):$(lib
)$(gb_Library_UNOEXT
)) \
214 ifeq ($(DISABLE_DYNLOADING
),TRUE
)
216 gb_Library_FILENAMES
+= \
217 $(foreach lib
,$(gb_Library_RTVERLIBS
),$(lib
):$(gb_Library_SYSPRE
)$(lib
)$(gb_Library_RTEXT
)) \
218 $(foreach lib
,$(gb_Library_UNOVERLIBS
),$(lib
):$(gb_Library_UNOVERPRE
)$(lib
)$(gb_Library_PLAINEXT
)) \
222 gb_Library_FILENAMES
+= \
223 $(foreach lib
,$(gb_Library_RTVERLIBS
),$(lib
):$(gb_Library_SYSPRE
)$(lib
)$(gb_Library_RTEXT
).
$(gb_Library_UDK_MAJORVER
)) \
224 $(foreach lib
,$(gb_Library_UNOVERLIBS
),$(lib
):$(gb_Library_UNOVERPRE
)$(lib
)$(gb_Library_PLAINEXT
).
$(gb_Library_UDK_MAJORVER
)) \
228 gb_Library_LAYER
:= \
229 $(foreach lib
,$(gb_Library_OOOLIBS
),$(lib
):OOO
) \
230 $(foreach lib
,$(gb_Library_PLAINLIBS_URE
),$(lib
):URELIB
) \
231 $(foreach lib
,$(gb_Library_PLAINLIBS_OOO
),$(lib
):OOO
) \
232 $(foreach lib
,$(gb_Library_PLAINLIBS_OXT
),$(lib
):OXT
) \
233 $(foreach lib
,$(gb_Library_PLAINLIBS_NONE
),$(lib
):NONE
) \
234 $(foreach lib
,$(gb_Library_PRIVATELIBS_URE
),$(lib
):URELIB
) \
235 $(foreach lib
,$(gb_Library_RTVERLIBS
),$(lib
):URELIB
) \
236 $(foreach lib
,$(gb_Library_UNOVERLIBS
),$(lib
):URELIB
) \
237 $(foreach lib
,$(gb_Library_EXTENSIONLIBS
),$(lib
):OXT
) \
239 define gb_Library__get_rpath
240 $(if
$(1),$(strip -Wl
,-z
,origin '-Wl,-rpath,$(1)' -Wl
,-rpath-link
,$(INSTDIR
)/program
))
243 define gb_Library_get_rpath
244 $(call gb_Library__get_rpath
,$(call gb_LinkTarget__get_rpath_for_layer
,$(call gb_Library_get_layer
,$(1))))
247 define gb_Library_Library_platform
248 $(call gb_LinkTarget_get_target
,$(2)) : RPATH
:= $(call gb_Library_get_rpath
,$(1))
252 gb_Library__set_soversion_script_platform
= $(gb_Library__set_soversion_script
)
254 gb_Library_get_sdk_link_dir
= $(INSTDIR
)/$(SDKDIRNAME
)/lib
256 gb_Library_get_sdk_link_lib
= $(gb_Library_get_versionlink_target
)
262 gb_Executable_LAYER
:= \
263 $(foreach exe
,$(gb_Executable_UREBIN
),$(exe
):UREBIN
) \
264 $(foreach exe
,$(gb_Executable_SDK
),$(exe
):SDKBIN
) \
265 $(foreach exe
,$(gb_Executable_OOO
),$(exe
):OOO
) \
266 $(foreach exe
,$(gb_Executable_NONE
),$(exe
):NONE
) \
269 define gb_Executable__get_rpath
270 $(strip -Wl
,-z
,origin $(if
$(1),'-Wl$(COMMA)-rpath$(COMMA)$(1)') -Wl
,-rpath-link
,$(INSTDIR
)/program
)
273 define gb_Executable_get_rpath
274 $(call gb_Executable__get_rpath
,$(call gb_LinkTarget__get_rpath_for_layer
,$(call gb_Executable_get_layer
,$(1))))
277 define gb_Executable_Executable_platform
278 $(call gb_LinkTarget_get_target
,$(2)) : RPATH
:= $(call gb_Executable_get_rpath
,$(1))
285 gb_CppunitTest_CPPTESTPRECOMMAND
:= \
286 $(call gb_Helper_extend_ld_path
,$(WORKDIR
)/UnpackedTarball
/cppunit
/src
/cppunit
/.libs
)
287 gb_CppunitTest_get_filename
= libtest_
$(1).so
288 gb_CppunitTest_get_ilibfilename
= $(gb_CppunitTest_get_filename
)
289 gb_CppunitTest_malloc_check
:= MALLOC_CHECK_
=2 MALLOC_PERTURB_
=153
291 define gb_CppunitTest_CppunitTest_platform
292 $(call gb_LinkTarget_get_target
,$(2)) : RPATH
:= $(call gb_Library__get_rpath
,$(call gb_LinkTarget__get_rpath_for_layer
,NONE
))
296 define gb_CppunitTest_postprocess
297 $(SRCDIR
)/solenv
/bin
/gdb-core-bt.sh
$(1) $(2) $(3)
302 ifneq ($(OOO_TEST_SOFFICE
),)
303 gb_JunitTest_SOFFICEARG
:=$(OOO_TEST_SOFFICE
)
305 ifneq ($(gb_JunitTest_DEBUGRUN
),)
306 gb_JunitTest_SOFFICEARG
:=connect
:pipe
,name
=$(USER
)
308 gb_JunitTest_SOFFICEARG
:=path
:$(INSTROOT
)/$(LIBO_BIN_FOLDER
)/soffice
312 define gb_JunitTest_JunitTest_platform
313 $(call gb_JunitTest_get_target
,$(1)) : DEFS
:= \
314 -Dorg.openoffice.
test.arg.env
=$(gb_Helper_LIBRARY_PATH_VAR
)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
315 -Dorg.openoffice.
test.arg.user
=$(call gb_Helper_make_url
,$(call gb_JunitTest_get_userdir
,$(1))) \
316 -Dorg.openoffice.
test.arg.workdir
=$(call gb_JunitTest_get_userdir
,$(1)) \
317 -Dorg.openoffice.
test.arg.postprocesscommand
=$(SRCDIR
)/solenv
/bin
/gdb-core-bt.sh \
318 -Dorg.openoffice.
test.arg.soffice
="$(gb_JunitTest_SOFFICEARG)" \
324 gb_PythonTest_PRECOMMAND
:= $(gb_CppunitTest_CPPTESTPRECOMMAND
)
328 define gb_Module_DEBUGRUNCOMMAND
329 OFFICESCRIPT
=`mktemp` && \
330 printf
'if [ -e $(INSTROOT)/program/ooenv ]; then . $(INSTROOT)/program/ooenv; fi\n' > $${OFFICESCRIPT} && \
331 printf
"gdb $(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice.bin" >> $${OFFICESCRIPT} && \
332 printf
" -ex \"set args --norestore --nologo '--accept=pipe,name=$(USER);urp;' %s\"" \
333 "$(subst ","\\\"",$(value gb_DBGARGS
))" >> $${OFFICESCRIPT} && \
334 $(SHELL) $${OFFICESCRIPT} && \
338 # InstallModuleTarget class
340 define gb_InstallModuleTarget_InstallModuleTarget_platform
341 $(call gb_InstallModuleTarget_add_defs,$(1),\
350 # InstallScript class
352 gb_InstallScript_EXT := .ins
354 # CliAssemblyTarget class
356 gb_CliAssemblyTarget_POLICYEXT :=
357 gb_CliAssemblyTarget_get_dll :=
361 gb_Extension_LICENSEFILE_DEFAULT := $(INSTROOT)/LICENSE
363 # UnpackedTarget class
365 gb_UnpackedTarget_TARFILE_LOCATION := $(TARFILE_LOCATION)
367 # UnoApiHeadersTarget class
369 ifeq ($(DISABLE_DYNLOADING),TRUE)
370 gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2))
372 gb_UnoApiHeadersTarget_select_variant = $(2)
375 # UIMenubarTarget class
377 define gb_UIMenubarTarget__command
378 $(call gb_Output_announce,$(2),$(true),UIM,1)
383 gb_UIMenubarTarget_UIMenubarTarget_platform :=
386 gb_Python_PRECOMMAND := $(gb_Helper_set_ld_path) PYTHONHOME="$(INSTDIR
)/program
/python-core-
$(PYTHON_VERSION
)" PYTHONPATH="$${PYPATH
:+$$PYPATH:}$(INSTDIR
)/program
/python-core-
$(PYTHON_VERSION
)/lib
:$(INSTDIR
)/program
/python-core-
$(PYTHON_VERSION
)/lib
/lib-dynload
"
387 gb_Python_INSTALLED_EXECUTABLE := /bin/sh $(INSTROOT)/program/python
388 # this is passed to gdb as executable when running tests
389 gb_Python_INSTALLED_EXECUTABLE_GDB := $(INSTROOT)/program/python.bin
391 include $(GBUILDDIR)/platform/com_GCC_class.mk
393 # vim: set noet sw=4: