Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / platform / macosx.mk
blob27e0a9126d35de4cecc219a8628053478f14288b
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 avoid flashing windows during tests
21 export VCL_HIDE_WINDOWS=1
23 gb_SDKDIR := $(MACOSX_SDK_PATH)
25 include $(GBUILDDIR)/platform/com_GCC_defs.mk
27 # Darwin mktemp -t expects a prefix, not a pattern
28 gb_MKTEMP ?= /usr/bin/mktemp -t gbuild.
30 gb_OSDEFS := \
31 -D$(OS) \
32 -D_PTHREADS \
33 -DUNIX \
34 -DUNX \
35 -D_REENTRANT \
36 -DNO_PTHREAD_PRIORITY \
37 -DMAC_OS_X_VERSION_MIN_REQUIRED=$(MAC_OS_X_VERSION_MIN_REQUIRED) \
38 -DMAC_OS_X_VERSION_MAX_ALLOWED=$(MAC_OS_X_VERSION_MAX_ALLOWED) \
39 -DMACOSX_SDK_VERSION=$(MACOSX_SDK_VERSION) \
40 $(EXTRA_CDEFS) \
43 gb_CFLAGS := \
44 $(gb_CFLAGS_COMMON) \
45 -fPIC \
46 -fno-strict-aliasing \
47 -Wshadow
49 gb_CXXFLAGS := \
50 $(gb_CXXFLAGS_COMMON) \
51 -fPIC \
52 -Woverloaded-virtual \
53 -Wshadow \
54 -Wno-ctor-dtor-privacy \
55 -fno-strict-aliasing \
56 -fsigned-char \
57 $(CXXFLAGS_CXX11)
59 #-fsigned-char \ might be removed?
61 # these are to get g++ to switch to Objective-C++ mode
62 # (see toolkit module for a case where it is necessary to do it this way)
63 gb_OBJCXXFLAGS := -x objective-c++ -fobjc-exceptions
65 gb_OBJCFLAGS := -x objective-c -fobjc-exceptions
67 # LinkTarget class
69 define gb_LinkTarget__get_rpath_for_layer
70 $(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
71 endef
73 gb_LinkTarget__RPATHS := \
74 URELIB:@__________________________________________________URELIB/ \
75 UREBIN: \
76 OOO:@__________________________________________________OOO/ \
77 SDKBIN: \
78 OXT: \
79 NONE:@__________________________________________________NONE/ \
81 # $(call gb_LinkTarget__get_installname,libfilename,layerprefix)
82 define gb_LinkTarget__get_installname
83 $(if $(2),-install_name '$(2)$(1)')
84 endef
86 gb_LinkTarget_CFLAGS := $(gb_CFLAGS)
87 gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS)
88 gb_LinkTarget_OBJCXXFLAGS := $(gb_CXXFLAGS) $(gb_OBJCXXFLAGS)
89 gb_LinkTarget_OBJCFLAGS := $(gb_CFLAGS) $(gb_OBJCFLAGS)
91 ifeq ($(gb_SYMBOL),$(true))
92 gb_LinkTarget_CFLAGS += $(gb_DEBUG_CFLAGS)
93 gb_LinkTarget_CXXFLAGS += $(gb_DEBUG_CFLAGS)
94 gb_LinkTarget_OBJCFLAGS += $(gb_DEBUG_CFLAGS)
95 gb_LinkTarget_OBJCXXFLAGS += $(gb_DEBUG_CFLAGS)
96 endif
98 define gb_LinkTarget__get_layer
99 $(if $(filter Executable,$(1)),\
100 $$(call gb_Executable_get_layer,$(2)),\
101 $$(call gb_Library_get_layer,$(2)))
102 endef
104 # We sign executables right after linking below. But not dylibs,
105 # because many of them are built by ad-hoc or 3rd-party mechanisms. So
106 # as we would need to sign those separately anyway, we do it for the
107 # gbuild-built ones, too, after an app bundle has been constructed, in
108 # the solenv/bin/macosx-codesign-app-bundle script.
109 # And the soffice executable needs to be signed last in
110 # macosx-codesign-app-bundle, as codesign would fail complaining that other
111 # parts of the app have not yet been signed:
113 define gb_LinkTarget__command_dynamiclink
114 $(call gb_Helper_abbreviate_dirs,\
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 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
123 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
124 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
125 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
126 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
127 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
128 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
129 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),`cat $(extraobjectlist)`) \
130 $(T_LIBS) \
131 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \
132 -o $(1) && \
133 $(if $(SOVERSIONSCRIPT),ln -sf $(1) $(ILIBTARGET),:) && \
134 $(if $(filter Executable,$(TARGETTYPE)), \
135 $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl app $(LAYER) $(1) &&) \
136 $(if $(filter Library Bundle CppunitTest,$(TARGETTYPE)),\
137 $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl shl $(LAYER) $(1) &&) \
138 $(if $(MACOSX_CODESIGNING_IDENTITY), \
139 $(if $(filter Executable,$(TARGETTYPE)), \
140 $(if $(filter-out $(call gb_Executable_get_target,soffice_bin),$(1)), \
141 codesign --identifier=$(MACOSX_BUNDLE_IDENTIFIER).$(notdir $(1)) --sign $(MACOSX_CODESIGNING_IDENTITY) --force $(1) &&))) \
142 $(if $(filter Library,$(TARGETTYPE)),\
143 otool -l $(1) | grep -A 5 LC_ID_DYLIB \
144 > $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
145 $(NM) -g -P $(1) | cut -d' ' -f1-2 | grep -v U$$ \
146 >> $(WORKDIR)/LinkTarget/$(2).exports.tmp && \
147 $(call gb_Helper_replace_if_different_and_touch,$(WORKDIR)/LinkTarget/$(2).exports.tmp, \
148 $(WORKDIR)/LinkTarget/$(2).exports,$(1)) &&) \
150 endef
152 # parameters: 1-linktarget 2-cobjects 3-cxxobjects
153 define gb_LinkTarget__command_staticlink
154 $(call gb_Helper_abbreviate_dirs,\
155 rm -f $(1) && \
156 $(gb_AR) -rsu $(1) \
157 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
158 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
159 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \
160 $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \
161 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
162 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \
163 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
164 $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),@$(extraobjectlist)) \
165 $(if $(findstring s,$(MAKEFLAGS)),2> /dev/null))
166 endef
168 define gb_LinkTarget__command
169 $(call gb_Output_announce,$(2),$(true),LNK,4)
170 $(if $(filter Library Bundle CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2)))
171 $(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
172 endef
174 define gb_LinkTarget_use_system_darwin_frameworks
175 $(call gb_LinkTarget_add_libs,$(1),$(foreach fw,$(2),-framework $(fw)))
176 $(if $(call gb_LinkTarget__is_merged,$(1)),\
177 $(call gb_LinkTarget_add_libs,$(call gb_Library_get_linktarget,merged),$(foreach fw,$(2),-framework $(fw))))
178 endef
181 # Library class
183 gb_Library_DEFS :=
184 gb_Library_TARGETTYPEFLAGS := -dynamiclib -single_module
185 gb_Bundle_TARGETTYPEFLAGS := -bundle
186 gb_Library_UDK_MAJORVER := 3
187 gb_Library_SYSPRE := lib
188 gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
189 gb_Library_PLAINEXT := .dylib
190 gb_Library_DLLEXT := .dylib
191 gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT)
193 gb_Library_OOOEXT := $(gb_Library_DLLPOSTFIX)$(gb_Library_PLAINEXT)
194 gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
196 gb_Library_FILENAMES := \
197 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
198 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
199 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
200 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
201 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
202 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT).$(gb_Library_UDK_MAJORVER)) \
203 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT).$(gb_Library_UDK_MAJORVER)) \
204 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):$(lib)$(gb_Library_UNOEXT)) \
207 gb_Library_LAYER := \
208 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
209 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
210 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
211 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):NONE) \
212 $(foreach lib,$(gb_Library_PRIVATELIBS_URE),$(lib):URELIB) \
213 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
214 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
215 $(foreach lib,$(gb_Library_EXTENSIONLIBS),$(lib):OXT) \
217 define gb_Library_get_rpath
218 $(call gb_LinkTarget__get_installname,$(call gb_Library_get_filename,$(1)),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1))))
219 endef
221 define gb_Library_Library_platform
222 $(call gb_LinkTarget_get_target,$(2)) : \
223 RPATH := $(call gb_Library_get_rpath,$(1))
224 $(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Library_get_layer,$(1))
226 endef
228 gb_Library__set_soversion_script_platform = $(gb_Library__set_soversion_script)
230 gb_Library_get_sdk_link_dir = $(WORKDIR)/LinkTarget/Library
232 gb_Library_get_sdk_link_lib = $(gb_Library_get_versionlink_target)
234 # bundle is a special kind of library that exists only on Darwin/OSX
235 # set the TARGETTYPE to Bundle, and clear install_name(RPATH)
236 define gb_Library_Bundle
237 $(call gb_Library_Library,$(1))
238 $(call gb_LinkTarget_set_targettype,$(call gb_Library_get_linktarget,$(1)),Bundle)
239 $(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,$(1))) : \
240 RPATH :=
241 endef
243 # Executable class
245 gb_Executable_EXT :=
246 gb_Executable_TARGETTYPEFLAGS := -bind_at_load
248 gb_Executable_LAYER := \
249 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
250 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
251 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
252 $(foreach exe,$(gb_Executable_NONE),$(exe):NONE) \
255 gb_Executable_get_rpath :=
257 define gb_Executable_Executable_platform
258 $(call gb_LinkTarget_get_target,$(2)) : RPATH :=
259 $(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Executable_get_layer,$(1))
261 endef
264 # CppunitTest class
266 gb_CppunitTest_CPPTESTPRECOMMAND := \
267 $(call gb_Helper_extend_ld_path,$(gb_Library_DLLDIR):$(WORKDIR)/UnpackedTarball/cppunit/src/cppunit/.libs)
268 gb_CppunitTest_get_filename = libtest_$(1).dylib
269 gb_CppunitTest_get_ilibfilename = $(gb_CppunitTest_get_filename)
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_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 OFFICESCRIPT=$$($(gb_MKTEMP)) && \
310 printf '%s\n' "set args --norestore --nologo '--accept=pipe,name=$(USER);urp;'" > $${OFFICESCRIPT} && \
311 gdb -x $${OFFICESCRIPT} $(INSTROOT)/$(LIBO_BIN_FOLDER)/soffice && \
312 rm $${OFFICESCRIPT}
313 endef
315 # InstallModuleTarget class
317 define gb_InstallModuleTarget_InstallModuleTarget_platform
318 $(call gb_InstallModuleTarget_add_defs,$(1),\
319 $(gb_CPUDEFS) \
320 $(gb_OSDEFS) \
321 -DCOMID=gcc3 \
322 -D_gcc3 \
325 endef
327 # InstallScript class
329 gb_InstallScript_EXT := .ins
331 # CliAssemblyTarget class
333 gb_CliAssemblyTarget_POLICYEXT :=
334 gb_CliAssemblyTarget_get_dll :=
336 # Extension class
338 gb_Extension_LICENSEFILE_DEFAULT := $(INSTROOT)/LICENSE
340 # UnpackedTarget class
342 gb_UnpackedTarget_TARFILE_LOCATION := $(TARFILE_LOCATION)
344 # UnoApiHeadersTarget class
346 ifneq ($(filter TRUE,$(DISABLE_DYNLOADING)),)
347 gb_UnoApiHeadersTarget_select_variant = $(if $(filter udkapi,$(1)),comprehensive,$(2))
348 else
349 gb_UnoApiHeadersTarget_select_variant = $(2)
350 endif
352 # UIMenubarTarget class
354 define gb_UIMenubarTarget__command
355 $(call gb_Output_announce,$(2),$(true),UIM,1)
356 $(call gb_ExternalExecutable_get_command,xsltproc) -o $(1) $(UI_MENUBAR_XSLT) $(3)
358 endef
360 define gb_UIMenubarTarget_UIMenubarTarget_platform
361 $(call gb_UIMenubarTarget_get_target,$(1)) : UI_MENUBAR_XSLT := $(SRCDIR)/solenv/bin/macosx_menubar_modification.xsl
362 $(call gb_UIMenubarTarget_get_target,$(1)) : $(SRCDIR)/solenv/bin/macosx_menubar_modification.xsl
363 $(call gb_UIMenubarTarget_get_target,$(1)) :| $(call gb_ExternalExecutable_get_dependencies,xsltproc)
365 endef
367 # Python
368 gb_Python_PRECOMMAND :=
369 gb_Python_INSTALLED_EXECUTABLE := $(INSTROOT)/$(LIBO_LIB_FOLDER)/LibreOfficePython.framework/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/Resources/Python.app/Contents/MacOS/LibreOfficePython
370 # this is passed to gdb as executable when running tests
371 gb_Python_INSTALLED_EXECUTABLE_GDB := $(gb_Python_INSTALLED_EXECUTABLE)
373 include $(GBUILDDIR)/platform/com_GCC_class.mk
375 # vim: set noet sw=4: