bump product version to 6.3.0.0.beta1
[LibreOffice.git] / solenv / gbuild / platform / macosx.mk
blobeec2b052cb7e94779948c52c1524e6864cec6396
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_MAX_ALLOWED) \
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 sign executables right after linking below. But not dylibs,
94 # because many of them are built by ad-hoc or 3rd-party mechanisms. So
95 # as we would need to sign those separately anyway, we do it for the
96 # gbuild-built ones, too, after an app bundle has been constructed, in
97 # the solenv/bin/macosx-codesign-app-bundle script.
98 # And the soffice executable needs to be signed last in
99 # macosx-codesign-app-bundle, as codesign would fail complaining that other
100 # parts of the app have not yet been signed:
102 define gb_LinkTarget__command_dynamiclink
103 $(call gb_Helper_abbreviate_dirs,\
104 FILELIST=$(call var2file,$(shell $(gb_MKTEMP)),100, \
105 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
106 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
107 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
108 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
109 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
110 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
111 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
112 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),$(shell cat $(extraobjectlist)))) && \
113 cat $${FILELIST} | tr "[:space:]" "\n" | grep -v '^$$' > $${FILELIST}.1 && \
114 mv $${FILELIST}.1 $${FILELIST} && \
115 $(if $(CXXOBJECTS)$(OBJCXXOBJECTS)$(GENCXXOBJECTS)$(EXTRAOBJECTLISTS),$(gb_CXX),$(gb_CC)) \
116 $(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
117 $(if $(filter Bundle,$(TARGETTYPE)),$(gb_Bundle_TARGETTYPEFLAGS)) \
118 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
119 $(subst \d,$$,$(RPATH)) \
120 $(T_LDFLAGS) \
121 $(patsubst lib%.dylib,-l%,$(patsubst %.$(gb_Library_UDK_MAJORVER),%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib))))) \
122 -Wl$(COMMA)-filelist$(COMMA)$${FILELIST} \
123 $(T_LIBS) \
124 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \
125 -o $(1) && \
126 rm -f $${FILELIST} && \
127 $(if $(SOVERSIONSCRIPT),ln -sf $(1) $(ILIBTARGET),:) && \
128 $(if $(filter Executable,$(TARGETTYPE)), \
129 $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl app $(LAYER) $(1) &&) \
130 $(if $(filter Library Bundle CppunitTest,$(TARGETTYPE)),\
131 $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl shl $(LAYER) $(1) &&) \
132 $(if $(MACOSX_CODESIGNING_IDENTITY), \
133 $(if $(filter Executable,$(TARGETTYPE)), \
134 $(if $(filter-out $(call gb_Executable_get_target,soffice_bin),$(1)), \
135 codesign --identifier=$(MACOSX_BUNDLE_IDENTIFIER).$(notdir $(1)) --sign $(MACOSX_CODESIGNING_IDENTITY) --options=runtime --force $(1) &&))) \
136 $(if $(filter Library,$(TARGETTYPE)),\
137 otool -l $(1) | grep -A 5 LC_ID_DYLIB \
138 > $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
139 $(NM) -g -P $(1) | cut -d' ' -f1-2 | grep -v U$$ \
140 >> $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
141 $(call gb_Helper_replace_if_different_and_touch,$(WORKDIR)/LinkTarget/$(2).exports.tmp, \
142 $(WORKDIR)/LinkTarget/$(2).exports,$(1)) &&) \
144 endef
146 # parameters: 1-linktarget 2-cobjects 3-cxxobjects
147 define gb_LinkTarget__command_staticlink
148 $(call gb_Helper_abbreviate_dirs,\
149 rm -f $(1) && \
150 $(gb_AR) -rsu $(1) \
151 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
152 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
153 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
154 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
155 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
156 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
157 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
158 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),@$(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 $(if $(filter Library Bundle CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2)))
165 $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
166 endef
168 define gb_LinkTarget_use_system_darwin_frameworks
169 $(call gb_LinkTarget_add_libs,$(1),$(foreach fw,$(2),-framework $(fw)))
170 $(if $(call gb_LinkTarget__is_merged,$(1)),\
171 $(call gb_LinkTarget_add_libs,$(call gb_Library_get_linktarget,merged),$(foreach fw,$(2),-framework $(fw))))
172 endef
175 # Library class
177 gb_Library_DEFS :=
178 gb_Library_TARGETTYPEFLAGS := -dynamiclib -single_module
179 gb_Bundle_TARGETTYPEFLAGS := -bundle
180 gb_Library_UDK_MAJORVER := 3
181 gb_Library_SYSPRE := lib
182 gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
183 gb_Library_PLAINEXT := .dylib
184 gb_Library_DLLEXT := .dylib
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_PLAINLIBS_OXT),$(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_RTEXT).$(gb_Library_UDK_MAJORVER)) \
198 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT).$(gb_Library_UDK_MAJORVER)) \
199 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):$(lib)$(gb_Library_UNOEXT)) \
202 gb_Library_LAYER := \
203 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
204 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
205 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
206 $(foreach lib,$(gb_Library_PLAINLIBS_OXT),$(lib):OXT) \
207 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):NONE) \
208 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):URELIB) \
209 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
210 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
211 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):OXT) \
213 define gb_Library_get_rpath
214 $(call gb_LinkTarget__get_installname,$(call gb_Library_get_filename,$(1)),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1))))
215 endef
217 define gb_Library_Library_platform
218 $(call gb_LinkTarget_get_target,$(2)) : \
219 RPATH := $(call gb_Library_get_rpath,$(1))
220 $(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Library_get_layer,$(1))
222 endef
224 gb_Library__set_soversion_script_platform = $(gb_Library__set_soversion_script)
226 gb_Library_get_sdk_link_dir = $(WORKDIR)/LinkTarget/Library
228 gb_Library_get_sdk_link_lib = $(gb_Library_get_versionlink_target)
230 # bundle is a special kind of library that exists only on Darwin/OSX
231 # set the TARGETTYPE to Bundle, and clear install_name(RPATH)
232 define gb_Library_Bundle
233 $(call gb_Library_Library,$(1))
234 $(call gb_LinkTarget_set_targettype,$(call gb_Library_get_linktarget,$(1)),Bundle)
235 $(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,$(1))) : \
236 RPATH :=
237 endef
239 # Executable class
241 gb_Executable_EXT :=
242 gb_Executable_TARGETTYPEFLAGS := -bind_at_load
244 gb_Executable_LAYER := \
245 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
246 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
247 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
248 $(foreach exe,$(gb_Executable_NONE),$(exe):NONE) \
251 gb_Executable_get_rpath :=
253 define gb_Executable_Executable_platform
254 $(call gb_LinkTarget_get_target,$(2)) : RPATH :=
255 $(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Executable_get_layer,$(1))
257 endef
260 # CppunitTest class
262 gb_CppunitTest_UNITTESTFAILED := $(GBUILDDIR)/platform/unittest-failed-MACOSX.sh
263 gb_CppunitTest_PYTHONDEPS := $(call gb_Library_get_target,pyuno_wrapper) $(if $(SYSTEM_PYTHON),,$(call gb_GeneratedPackage_get_target,python3))
264 gb_CppunitTest_CPPTESTPRECOMMAND := \
265 $(call gb_Helper_extend_ld_path,$(gb_Library_DLLDIR):$(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/.libs)
266 gb_CppunitTest_get_filename = libtest_$(1).dylib
267 gb_CppunitTest_get_ilibfilename = $(gb_CppunitTest_get_filename)
269 define gb_CppunitTest_CppunitTest_platform
270 $(call gb_LinkTarget_get_target,$(2)) : RPATH :=
271 $(call gb_LinkTarget_get_target,$(2)) : LAYER := NONE
273 endef
275 # JunitTest class
277 ifneq ($(OOO_TEST_SOFFICE),)
278 gb_JunitTest_SOFFICEARG:=$(OOO_TEST_SOFFICE)
279 else
280 ifneq ($(gb_JunitTest_DEBUGRUN),)
281 gb_JunitTest_SOFFICEARG:=connect:pipe,name=$(USER)
282 else
283 gb_JunitTest_SOFFICEARG:=path:$(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice
284 endif
285 endif
287 define gb_JunitTest_JunitTest_platform
288 $(call gb_JunitTest_get_target,$(1)) : DEFS := \
289 -Dorg.openoffice.test.arg.soffice="$(gb_JunitTest_SOFFICEARG)" \
290 -Dorg.openoffice.test.arg.env=DYLD_LIBRARY_PATH"$$$${DYLD_LIBRARY_PATH+=$$$$DYLD_LIBRARY_PATH}" \
291 -Dorg.openoffice.test.arg.user=$(call gb_Helper_make_url,$(call gb_JunitTest_get_userdir,$(1))) \
292 -Dorg.openoffice.test.arg.workdir=$(call gb_JunitTest_get_userdir,$(1)) \
294 endef
296 # PythonTest class
298 gb_PythonTest_UNITTESTFAILED := $(GBUILDDIR)/platform/unittest-failed-MACOSX.sh
299 gb_PythonTest_DEPS := $(call gb_GeneratedPackage_get_target,python3) $(call gb_Package_get_target,python_shell)
300 gb_PythonTest_PRECOMMAND := $(gb_Helper_LIBRARY_PATH_VAR)=$${$(gb_Helper_LIBRARY_PATH_VAR):+$$$(gb_Helper_LIBRARY_PATH_VAR):}$(INSTROOT)/$(LIBO_URE_LIB_FOLDER)
301 ifneq ($(LIBO_LIB_FOLDER),$(LIBO_URE_LIB_FOLDER))
302 gb_PythonTest_PRECOMMAND := $(gb_PythonTest_PRECOMMAND):$(INSTROOT)/$(LIBO_LIB_FOLDER)
303 endif
304 gb_PythonTest_PRECOMMAND := $(gb_PythonTest_PRECOMMAND):$(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/.libs
306 # Module class
308 define gb_Module_DEBUGRUNCOMMAND
309 lldb -f $(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice -- --norestore --nologo \
310 '"--accept=pipe,name=$(USER)\;urp"'
311 endef
313 # InstallModuleTarget class
315 define gb_InstallModuleTarget_InstallModuleTarget_platform
316 $(call gb_InstallModuleTarget_add_defs,$(1),\
317 $(gb_CPUDEFS) \
318 $(gb_OSDEFS) \
319 -DCOMID=gcc3 \
320 -D_gcc3 \
323 endef
325 # InstallScript class
327 gb_InstallScript_EXT := .ins
329 # CliAssemblyTarget class
331 gb_CliAssemblyTarget_POLICYEXT :=
332 gb_CliAssemblyTarget_get_dll :=
334 # Extension class
336 gb_Extension_LICENSEFILE_DEFAULT := $(INSTROOT)/Resources/LICENSE
338 # UnpackedTarget class
340 gb_UnpackedTarget_TARFILE_LOCATION := $(TARFILE_LOCATION)
342 # UnoApiHeadersTarget class
344 ifneq ($(filter TRUE,$(DISABLE_DYNLOADING)),)
345 gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2))
346 else
347 gb_UnoApiHeadersTarget_select_variant = $(2)
348 endif
350 # UIMenubarTarget class
352 define gb_UIMenubarTarget__command
353 $(call gb_Output_announce,$(2),$(true),UIM,1)
354 $(call gb_ExternalExecutable_get_command,xsltproc) --nonet -o $(1) $(UI_MENUBAR_XSLT) $(3)
356 endef
358 define gb_UIMenubarTarget_UIMenubarTarget_platform
359 $(call gb_UIMenubarTarget_get_target,$(1)) : UI_MENUBAR_XSLT := $(SRCDIR)/solenv/bin/macosx_menubar_modification.xsl
360 $(call gb_UIMenubarTarget_get_target,$(1)) : $(SRCDIR)/solenv/bin/macosx_menubar_modification.xsl
361 $(call gb_UIMenubarTarget_get_target,$(1)) :| $(call gb_ExternalExecutable_get_dependencies,xsltproc)
363 endef
365 # Python
366 gb_Python_PRECOMMAND := PYTHONPATH="$$PYPATH"
367 gb_Python_INSTALLED_EXECUTABLE := $(INSTROOT)/$(LIBO_LIB_FOLDER)/LibreOfficePython.framework/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/Resources/Python.app/Contents/MacOS/LibreOfficePython
368 # this is passed to gdb as executable when running tests
369 gb_Python_INSTALLED_EXECUTABLE_GDB := $(gb_Python_INSTALLED_EXECUTABLE)
371 include $(GBUILDDIR)/platform/com_GCC_class.mk
373 # vim: set noet sw=4: