Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / solenv / gbuild / platform / macosx.mk
blobbe25f6563cd042a7b8f054516e21b151227c5929
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_SDKDIR := $(MACOSX_SDK_PATH)
22 include $(GBUILDDIR)/platform/com_GCC_defs.mk
24 # Darwin mktemp -t expects a prefix, not a pattern
25 gb_MKTEMP ?= /usr/bin/mktemp -t gbuild
27 gb_OSDEFS := \
28 -D$(OS) \
29 -D_PTHREADS \
30 -DUNIX \
31 -DUNX \
32 -D_REENTRANT \
33 -DNO_PTHREAD_PRIORITY \
34 -DMAC_OS_X_VERSION_MIN_REQUIRED=$(MAC_OS_X_VERSION_MIN_REQUIRED) \
35 -DMAC_OS_X_VERSION_MAX_ALLOWED=$(MAC_OS_X_VERSION_MIN_REQUIRED) \
36 $(LFS_CFLAGS) \
39 gb_CFLAGS := \
40 $(gb_CFLAGS_COMMON) \
41 -fPIC \
42 -fno-strict-aliasing \
43 -Wshadow
45 gb_CXXFLAGS := \
46 $(gb_CXXFLAGS_COMMON) \
47 -fPIC \
48 -Woverloaded-virtual \
49 -Wshadow \
50 -Wno-ctor-dtor-privacy \
51 -fno-strict-aliasing \
52 -fsigned-char \
53 $(CXXFLAGS_CXX11)
55 #-fsigned-char \ might be removed?
57 # these are to get g++ to switch to Objective-C++ mode
58 # (see toolkit module for a case where it is necessary to do it this way)
59 gb_OBJCXXFLAGS := -x objective-c++ -fobjc-exceptions
61 gb_OBJCFLAGS := -x objective-c -fobjc-exceptions
63 # LinkTarget class
65 define gb_LinkTarget__get_rpath_for_layer
66 $(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
67 endef
69 gb_LinkTarget__RPATHS := \
70 URELIB:@__________________________________________________URELIB/ \
71 UREBIN: \
72 OOO:@__________________________________________________OOO/ \
73 SDKBIN: \
74 OXT: \
75 NONE:@__________________________________________________NONE/ \
77 # $(call gb_LinkTarget__get_installname,libfilename,layerprefix)
78 define gb_LinkTarget__get_installname
79 $(if $(2),-install_name '$(2)$(1)')
80 endef
82 gb_LinkTarget_CFLAGS := $(gb_CFLAGS)
83 gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS)
84 gb_LinkTarget_OBJCXXFLAGS := $(gb_CXXFLAGS) $(gb_OBJCXXFLAGS)
85 gb_LinkTarget_OBJCFLAGS := $(gb_CFLAGS) $(gb_OBJCFLAGS)
87 define gb_LinkTarget__get_layer
88 $(if $(filter Executable,$(1)),\
89 $$(call gb_Executable_get_layer,$(2)),\
90 $$(call gb_Library_get_layer,$(2)))
91 endef
93 # We cannot sign executables early since Mojave/Catalina would treat them as
94 # restricted binary and ignore any DYLD_LIBRARY_PATH setting - So all
95 # signing is handled by the solenv/bin/macosx-codesign-app-bundle script.
96 # And the soffice executable needs to be signed last in
97 # macosx-codesign-app-bundle, as codesign would fail complaining that other
98 # parts of the app have not yet been signed:
100 define gb_LinkTarget__command_dynamiclink
101 $(call gb_Helper_abbreviate_dirs,\
102 FILELIST=$(call gb_var2file,$(shell $(gb_MKTEMP)), \
103 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
104 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
105 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
106 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
107 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
108 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
109 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
110 $(foreach object,$(GENNASMOBJECTS),$(call gb_GenNasmObject_get_target,$(object))) \
111 $(foreach object,$(GENOBJCOBJECTS),$(call gb_GenObjCObject_get_target,$(object))) \
112 $(foreach object,$(GENOBJCXXOBJECTS),$(call gb_GenObjCxxObject_get_target,$(object))) \
113 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),$(shell cat $(extraobjectlist)))) && \
114 cat $${FILELIST} | tr "[:space:]" "\n" | grep -v '^$$' > $${FILELIST}.1 && \
115 mv $${FILELIST}.1 $${FILELIST} && \
116 $(if $(CXXOBJECTS)$(OBJCXXOBJECTS)$(GENCXXOBJECTS)$(EXTRAOBJECTLISTS),$(gb_CXX),$(gb_CC)) \
117 $(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
118 $(if $(filter Bundle,$(TARGETTYPE)),$(gb_Bundle_TARGETTYPEFLAGS)) \
119 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
120 $(subst \d,$$,$(RPATH)) \
121 $(T_USE_LD) $(T_LDFLAGS) \
122 $(patsubst lib%.dylib,-l%,$(patsubst %.$(gb_Library_UDK_MAJORVER),%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib))))) \
123 -Wl$(COMMA)-filelist$(COMMA)$${FILELIST} \
124 $(T_LIBS) \
125 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \
126 -o $(1) && \
127 rm -f $${FILELIST} && \
128 $(if $(SOVERSIONSCRIPT),ln -sf $(1) $(ILIBTARGET),:) && \
129 $(if $(filter Executable,$(TARGETTYPE)), \
130 $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl app $(LAYER) $(1) &&) \
131 $(if $(filter Library Bundle CppunitTest,$(TARGETTYPE)),\
132 $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl shl $(LAYER) $(1) &&) \
133 $(if $(filter Library,$(TARGETTYPE)),\
134 otool -l $(1) | grep -A 5 LC_ID_DYLIB \
135 > $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
136 $(NM) -g -P $(1) | cut -d' ' -f1-2 | grep -v U$$ \
137 >> $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
138 $(call gb_Helper_replace_if_different_and_touch,$(WORKDIR)/LinkTarget/$(2).exports.tmp, \
139 $(WORKDIR)/LinkTarget/$(2).exports,$(1)) &&) \
141 endef
143 # parameters: 1-linktarget 2-cobjects 3-cxxobjects
144 define gb_LinkTarget__command_staticlink
145 $(call gb_Helper_abbreviate_dirs,\
146 rm -f $(1) && \
147 $(gb_AR) -rsu $(1) \
148 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
149 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
150 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
151 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
152 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
153 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
154 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
155 $(foreach object,$(GENNASMOBJECTS),$(call gb_GenNasmObject_get_target,$(object))) \
156 $(foreach object,$(GENOBJCOBJECTS),$(call gb_GenObjCObject_get_target,$(object))) \
157 $(foreach object,$(GENOBJCXXOBJECTS),$(call gb_GenObjCxxObject_get_target,$(object))) \
158 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),$(shell cat $(extraobjectlist))) \
159 $(if $(findstring s,$(MAKEFLAGS)),2> /dev/null))
160 endef
162 define gb_LinkTarget__command
163 $(call gb_Output_announce,$(2),$(true),LNK,4)
164 $(call gb_Trace_StartRange,$(2),LNK)
165 $(if $(filter Library Bundle CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2)))
166 $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
167 $(call gb_Trace_EndRange,$(2),LNK)
168 endef
170 define gb_LinkTarget_use_system_darwin_frameworks
171 $(call gb_LinkTarget_add_libs,$(1),$(foreach fw,$(2),-framework $(fw)))
172 $(if $(call gb_LinkTarget__is_merged,$(1)),\
173 $(call gb_LinkTarget_add_libs,$(call gb_Library_get_linktarget,merged),$(foreach fw,$(2),-framework $(fw))))
174 endef
177 # Library class
179 gb_Library_DEFS :=
180 gb_Library_TARGETTYPEFLAGS := -dynamiclib
181 gb_Bundle_TARGETTYPEFLAGS := -bundle
182 gb_Library_UDK_MAJORVER := 3
183 gb_Library_SYSPRE := lib
184 gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
185 gb_Library_PLAINEXT := .dylib
186 gb_Library_PLAINEXT_FOR_BUILD := .dylib
187 gb_Library_DLLEXT := .dylib
188 gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT)
190 gb_Library_OOOEXT := $(gb_Library_DLLPOSTFIX)$(gb_Library_PLAINEXT)
191 gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
193 gb_Library_FILENAMES := \
194 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
195 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
196 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
197 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
198 $(foreach lib,$(gb_Library_PLAINLIBS_OXT),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
199 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
200 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT).$(gb_Library_UDK_MAJORVER)) \
201 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT).$(gb_Library_UDK_MAJORVER)) \
202 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):$(lib)$(gb_Library_UNOEXT)) \
205 gb_Library_LAYER := \
206 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
207 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
208 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
209 $(foreach lib,$(gb_Library_PLAINLIBS_OXT),$(lib):OXT) \
210 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):NONE) \
211 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):URELIB) \
212 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
213 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
214 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):OXT) \
216 define gb_Library_get_rpath
217 $(call gb_LinkTarget__get_installname,$(call gb_Library_get_filename,$(1)),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1))))
218 endef
220 define gb_Library_Library_platform
221 $(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
222 $(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Library_get_layer,$(1))
224 endef
226 gb_Library__set_soversion_script_platform = $(gb_Library__set_soversion_script)
228 gb_Library_get_sdk_link_dir = $(WORKDIR)/LinkTarget/Library
230 gb_Library_get_sdk_link_lib = $(gb_Library_get_versionlink_target)
232 # bundle is a special kind of library that exists only on Darwin/OSX
233 # set the TARGETTYPE to Bundle, and clear install_name(RPATH)
234 define gb_Library_Bundle
235 $(call gb_Library_Library,$(1))
236 $(call gb_LinkTarget_set_targettype,$(call gb_Library_get_linktarget,$(1)),Bundle)
237 $(call gb_Library_get_linktarget_target,$(1)) : RPATH :=
238 endef
240 # Executable class
242 gb_Executable_EXT :=
243 gb_Executable_TARGETTYPEFLAGS := -bind_at_load
245 gb_Executable_LAYER := \
246 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
247 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
248 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
249 $(foreach exe,$(gb_Executable_NONE),$(exe):NONE) \
252 gb_Executable_get_rpath :=
254 define gb_Executable_Executable_platform
255 $(call gb_LinkTarget_get_target,$(2)) : RPATH :=
256 $(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Executable_get_layer,$(1))
258 endef
261 # CppunitTest class
263 gb_CppunitTest_UNITTESTFAILED := $(GBUILDDIR)/platform/unittest-failed-MACOSX.sh
264 gb_CppunitTest_PYTHONDEPS := $(call gb_Library_get_target,pyuno_wrapper) $(if $(SYSTEM_PYTHON),,$(call gb_GeneratedPackage_get_target,python3))
265 gb_CppunitTest_CPPTESTPRECOMMAND := \
266 $(call gb_Helper_extend_ld_path,$(gb_Library_DLLDIR):$(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/.libs)
267 gb_CppunitTest_get_filename = libtest_$(1).dylib
268 gb_CppunitTest_get_ilibfilename = $(gb_CppunitTest_get_filename)
269 gb_CppunitTest_malloc_check := -o "env MallocScribble=1" -o "env MallocPreScribble=1"
271 define gb_CppunitTest_CppunitTest_platform
272 $(call gb_LinkTarget_get_target,$(2)) : RPATH :=
273 $(call gb_LinkTarget_get_target,$(2)) : LAYER := NONE
275 endef
277 # JunitTest class
279 ifneq ($(OOO_TEST_SOFFICE),)
280 gb_JunitTest_SOFFICEARG:=$(OOO_TEST_SOFFICE)
281 else
282 ifneq ($(gb_JunitTest_DEBUGRUN),)
283 gb_JunitTest_SOFFICEARG:=connect:pipe,name=$(USER)
284 else
285 gb_JunitTest_SOFFICEARG:=path:$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice
286 endif
287 endif
289 define gb_JunitTest_JunitTest_platform
290 $(call gb_JunitTest_get_target,$(1)) : DEFS := \
291 -Dorg.openoffice.test.arg.soffice="$(gb_JunitTest_SOFFICEARG)" \
292 -Dorg.openoffice.test.arg.env=DYLD_LIBRARY_PATH"$$$${DYLD_LIBRARY_PATH+=$$$$DYLD_LIBRARY_PATH}" \
293 -Dorg.openoffice.test.arg.user=$(call gb_Helper_make_url,$(call gb_JunitTest_get_userdir,$(1))) \
294 -Dorg.openoffice.test.arg.workdir=$(call gb_JunitTest_get_userdir,$(1)) \
296 endef
298 # PythonTest class
300 gb_PythonTest_UNITTESTFAILED := $(GBUILDDIR)/platform/unittest-failed-MACOSX.sh
301 gb_PythonTest_DEPS := $(call gb_GeneratedPackage_get_target,python3) $(call gb_Package_get_target,python_shell)
302 gb_PythonTest_PRECOMMAND := $(gb_Helper_LIBRARY_PATH_VAR)=$${$(gb_Helper_LIBRARY_PATH_VAR):+$$$(gb_Helper_LIBRARY_PATH_VAR):}$(INSTROOT)/$(LIBO_URE_LIB_FOLDER)
303 ifneq ($(LIBO_LIB_FOLDER),$(LIBO_URE_LIB_FOLDER))
304 gb_PythonTest_PRECOMMAND := $(gb_PythonTest_PRECOMMAND):$(INSTROOT)/$(LIBO_LIB_FOLDER)
305 endif
306 gb_PythonTest_PRECOMMAND := $(gb_PythonTest_PRECOMMAND):$(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/.libs
308 # UITest class
310 gb_UITest_DEPS := $(call gb_GeneratedPackage_get_target,python3)
312 # Module class
314 define gb_Module_DEBUGRUNCOMMAND
315 lldb -f $(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice -- --norestore --nologo \
316 '"--accept=pipe,name=$(USER)\;urp"'
317 endef
319 # InstallModuleTarget class
321 define gb_InstallModuleTarget_InstallModuleTarget_platform
322 $(call gb_InstallModuleTarget_add_defs,$(1),\
323 $(gb_CPUDEFS) \
324 $(gb_OSDEFS) \
325 -DCOMID=gcc3 \
326 -D_gcc3 \
329 endef
331 # InstallScript class
333 gb_InstallScript_EXT := .ins
335 # CliAssemblyTarget class
337 gb_CliAssemblyTarget_POLICYEXT :=
338 gb_CliAssemblyTarget_get_dll :=
340 # Extension class
342 gb_Extension_LICENSEFILE_DEFAULT := $(INSTROOT)/Resources/LICENSE
344 # UnpackedTarget class
346 gb_UnpackedTarget_TARFILE_LOCATION := $(TARFILE_LOCATION)
348 # UnoApiHeadersTarget class
350 ifeq ($(DISABLE_DYNLOADING),TRUE)
351 gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2))
352 else
353 gb_UnoApiHeadersTarget_select_variant = $(2)
354 endif
356 # UIMenubarTarget class
358 define gb_UIMenubarTarget__command
359 $(call gb_Output_announce,$(2),$(true),UIM,1)
360 $(call gb_Trace_StartRange,$(2),UIM)
361 $(call gb_ExternalExecutable_get_command,xsltproc) --nonet -o $(1) $(UI_MENUBAR_XSLT) $(3)
362 $(call gb_Trace_EndRange,$(2),UIM)
364 endef
366 define gb_UIMenubarTarget_UIMenubarTarget_platform
367 $(call gb_UIMenubarTarget_get_target,$(1)) : UI_MENUBAR_XSLT := $(SRCDIR)/solenv/bin/macosx_menubar_modification.xsl
368 $(call gb_UIMenubarTarget_get_target,$(1)) : $(SRCDIR)/solenv/bin/macosx_menubar_modification.xsl
369 $(call gb_UIMenubarTarget_get_target,$(1)) :| $(call gb_ExternalExecutable_get_dependencies,xsltproc)
371 endef
373 # Python
374 gb_Python_PRECOMMAND := PYTHONPATH="$$PYPATH"
375 gb_Python_INSTALLED_EXECUTABLE := $(INSTROOT)/$(LIBO_LIB_FOLDER)/LibreOfficePython.framework/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/Resources/Python.app/Contents/MacOS/LibreOfficePython
376 # this is passed to gdb as executable when running tests
377 gb_Python_INSTALLED_EXECUTABLE_GDB := $(gb_Python_INSTALLED_EXECUTABLE)
379 include $(GBUILDDIR)/platform/com_GCC_class.mk
381 # vim: set noet sw=4: