xref: /aoo4110/main/solenv/gbuild/platform/macosx.mk (revision b1cdbd2c)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24GUI := UNX
25COM := S5ABI
26COMID := s5abi
27#COM := S5ABI
28#COMID := s5abi
29
30# Darwin mktemp -t expects a prefix, not a pattern
31gb_MKTEMP ?= /usr/bin/mktemp -t gbuild.
32
33gb_CC := cc
34gb_CXX := g++
35gb_GCCP := gcc
36gb_AR := ar
37gb_AWK := awk
38gb_CLASSPATHSEP := :
39
40# use CC/CXX if they are nondefaults
41ifneq ($(origin CC),default)
42gb_CC := $(CC)
43gb_GCCP := $(CC)
44endif
45ifneq ($(origin CXX),default)
46gb_CXX := $(CXX)
47endif
48
49gb_OSDEFS := \
50	-D$(OS) \
51	-D_PTHREADS \
52	-DUNIX \
53	-DUNX \
54	-D_REENTRANT \
55	-DNO_PTHREAD_PRIORITY \
56	-DQUARTZ \
57	$(EXTRA_CDEFS) \
58
59gb_COMPILERDEFS := \
60	-D$(COM) \
61	-DHAVE_GCC_VISIBILITY_FEATURE \
62	-DCPPU_ENV=$(COMID)
63#	-DGXX_INCLUDE_PATH=$(GXX_INCLUDE_PATH) \
64
65ifeq ($(CPUNAME),POWERPC)
66gb_CPUDEFS := -DPOWERPC -DPPC
67else ifeq ($(CPUNAME),INTEL)
68gb_CPUDEFS := -DX86
69else ifeq ($(CPUNAME),X86_64)
70gb_CPUDEFS := -DX86_64
71endif
72
73ifeq ($(strip $(SYSBASE)),)
74	gb_SDKDIR := $(MACOSX_SDK_PATH)
75else
76	gb_SDKDIR := $(SYSBASE)/MacOSX$(MACOSX_DEPLOYMENT_TARGET).sdk
77endif
78
79
80gb_CFLAGS := \
81	-isysroot $(gb_SDKDIR) \
82	-Wall \
83	-Wendif-labels \
84	-Wextra \
85	-Wshadow \
86	-fPIC \
87	-fmessage-length=0 \
88	-fno-common \
89	-fno-strict-aliasing \
90	-pipe \
91
92gb_CXXFLAGS := \
93	-isysroot $(gb_SDKDIR) \
94	-Wall \
95	-Wendif-labels \
96	-Wextra \
97	-Wno-ctor-dtor-privacy \
98	-Wno-non-virtual-dtor \
99	-fPIC \
100	-fmessage-length=0 \
101	-fno-common \
102	-fno-strict-aliasing \
103	-fsigned-char \
104	-pipe
105
106ifneq ($(COM),GCC)
107	gb_CXXFLAGS += -DHAVE_STL_INCLUDE_PATH -I../v1/
108endif
109
110ifeq ($(MACOSX_DEPLOYMENT_TARGET),$(filter $(MACOSX_DEPLOYMENT_TARGET), 10.7 10.8))
111       gb_CXXFLAGS += -std=c++11 -stdlib=libc++
112       gb_macos_LDFLAGS := -std=c++11 -stdlib=libc++
113endif
114
115# these are to get g++ to switch to Objective-C++ mode
116# (see toolkit module for a case where it is necessary to do it this way)
117gb_OBJCXXFLAGS := -x objective-c++ -fobjc-exceptions
118gb_OBJCFLAGS := -x objective-c -fobjc-exceptions
119
120ifneq ($(MACOSX_DEPLOYMENT_TARGET),)
121	gb_CXXFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_$(subst .,_,$(MACOSX_DEPLOYMENT_TARGET))
122endif
123
124ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE)
125gb_CFLAGS_WERROR := -Werror -Wno-error=deprecated
126gb_CXXFLAGS_WERROR := -Werror -Wno-error=deprecated
127endif
128
129gb_LinkTarget_EXCEPTIONFLAGS := \
130	-DEXCEPTIONS_ON \
131	-fexceptions
132
133ifeq ($(COM),GCC)
134    gb_LinkTarget_EXCEPTIONFLAGS += -fno-enforce-eh-specs
135endif
136
137gb_LinkTarget_NOEXCEPTIONFLAGS := \
138	-DEXCEPTIONS_OFF \
139	-fno-exceptions
140
141gb_LinkTarget_LDFLAGS := \
142	-Wl,-syslibroot,$(gb_SDKDIR) \
143	$(subst -L../lib , ,$(SOLARLIB)) \
144#man ld says: obsolete	-Wl,-multiply_defined,suppress \
145
146ifeq ($(gb_DEBUGLEVEL),2)
147gb_COMPILEROPTFLAGS := -O0
148else
149gb_COMPILEROPTFLAGS := -O2
150endif
151
152gb_COMPILERNOOPTFLAGS := -O0
153
154# Helper class
155
156gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs)
157
158# convert parametters filesystem root to native notation
159# does some real work only on windows, make sure not to
160# break the dummy implementations on unx*
161define gb_Helper_convert_native
162$(1)
163endef
164
165
166# CObject class
167
168define gb_CObject__command
169$(call gb_Output_announce,$(2),$(true),C  ,3)
170$(call gb_Helper_abbreviate_dirs,\
171	mkdir -p $(dir $(1)) && \
172	mkdir -p $(dir $(call gb_CObject_get_dep_target,$(2))) && \
173	$(gb_CC) \
174		$(DEFS) $(CFLAGS) \
175		-c $(3) \
176		-o $(1) \
177		-MMD -MT $(call gb_CObject_get_target,$(2)) \
178		-MF $(call gb_CObject_get_dep_target,$(2)) \
179		-I$(dir $(3)) \
180		$(INCLUDE))
181endef
182
183
184# CxxObject class
185
186# N.B: $(CXXFLAGS) may contain -x objective-c++, which must come before -c
187define gb_CxxObject__command
188$(call gb_Output_announce,$(2),$(true),CXX,3)
189$(call gb_Helper_abbreviate_dirs,\
190	mkdir -p $(dir $(1)) && \
191	mkdir -p $(dir $(call gb_CxxObject_get_dep_target,$(2))) && \
192	$(gb_CXX) \
193		$(DEFS) $(CXXFLAGS) \
194		-c $(3) \
195		-o $(1) \
196		-MMD -MT $(call gb_CxxObject_get_target,$(2)) \
197		-MF $(call gb_CxxObject_get_dep_target,$(2)) \
198		-I$(dir $(3)) \
199		$(INCLUDE_STL) $(INCLUDE))
200endef
201
202
203# ObjCxxObject class
204
205define gb_ObjCxxObject__command
206$(call gb_Output_announce,$(2),$(true),OCX,3)
207$(call gb_Helper_abbreviate_dirs,\
208	mkdir -p $(dir $(1)) && \
209	mkdir -p $(dir $(call gb_ObjCxxObject_get_dep_target,$(2))) && \
210	$(gb_CXX) \
211		$(DEFS) $(OBJCXXFLAGS) \
212		-c $(3) \
213		-o $(1) \
214		-MMD -MT $(call gb_ObjCxxObject_get_target,$(2)) \
215		-MF $(call gb_ObjCxxObject_get_dep_target,$(2)) \
216		-I$(dir $(3)) \
217		$(INCLUDE_STL) $(INCLUDE))
218endef
219
220
221# LinkTarget class
222
223define gb_LinkTarget__get_rpath_for_layer
224$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
225endef
226
227gb_LinkTarget__RPATHS := \
228	URELIB:@__________________________________________________URELIB/ \
229	UREBIN: \
230	OOO:@__________________________________________________OOO/ \
231	BRAND: \
232	SDKBIN: \
233	NONEBIN: \
234
235define gb_LinkTarget__get_installname
236$(if $(2),-install_name '$(2)$(1)',)
237endef
238
239gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) $(gb_COMPILEROPTFLAGS)
240gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR)
241gb_LinkTarget_OBJCXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) $(gb_OBJCXXFLAGS) $(gb_COMPILEROPTFLAGS)
242
243ifeq ($(gb_DEBUGLEVEL),2)
244gb_LinkTarget_CFLAGS += -g
245gb_LinkTarget_CXXFLAGS += -g
246gb_LinkTarget_OBJCXXFLAGS += -g
247endif
248
249gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC)))
250gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC)))
251
252# FIXME framework handling very hackish
253define gb_LinkTarget__get_liblinkflags
254$(patsubst lib%.dylib,-l%,$(foreach lib,$(filter-out $(gb_Library__FRAMEWORKS),$(1)),$(call gb_Library_get_filename,$(lib)))) \
255$(addprefix -framework ,$(filter $(gb_Library__FRAMEWORKS),$(1)))
256endef
257
258define gb_LinkTarget__get_layer
259$(if $(filter Executable,$(1)),\
260	$$(call gb_Executable_get_layer,$(2)),\
261	$$(call gb_Library_get_layer,$(2)))
262endef
263
264# FIXME the DYLIB_FILE mess is only necessary because
265# solver layout is different from installation layout
266define gb_LinkTarget__command_dynamiclink
267$(call gb_Helper_abbreviate_dirs,\
268	mkdir -p $(dir $(1)) && \
269	DYLIB_FILE=`$(gb_MKTEMP)` && \
270	$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
271		$(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
272		$(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
273		$(subst \d,$$,$(RPATH)) $(LDFLAGS) \
274		$(patsubst lib%.dylib,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \
275		$(patsubst %,-l%,$(EXTERNAL_LIBS)) \
276		> $${DYLIB_FILE} && \
277	$(gb_CXX) \
278		$(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
279		$(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
280		$(subst \d,$$,$(RPATH)) $(LDFLAGS) \
281		$(call gb_LinkTarget__get_liblinkflags,$(LINKED_LIBS)) \
282		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
283		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
284		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
285		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
286		$(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \
287		-o $(1) \
288		`cat $${DYLIB_FILE}` && \
289	$(if $(filter Library CppunitTest,$(TARGETTYPE)),\
290		$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl Library $(LAYER) $(1) && \
291		ln -sf $(1) $(patsubst %.dylib,%.jnilib,$(1)) &&) \
292	rm -f $${DYLIB_FILE})
293endef
294
295# parameters: 1-linktarget 2-cobjects 3-cxxobjects
296define gb_LinkTarget__command_staticlink
297$(call gb_Helper_abbreviate_dirs,\
298	mkdir -p $(dir $(1)) && \
299	$(gb_AR) -rsu $(1) \
300		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
301		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
302		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
303		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
304		2> /dev/null)
305endef
306
307define gb_LinkTarget__command
308$(call gb_Output_announce,$(2),$(true),LNK,4)
309$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2)))
310$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
311endef
312
313
314# Library class
315
316gb_Library_DEFS :=
317gb_Library_TARGETTYPEFLAGS := -dynamiclib -single_module
318gb_Library_SYSPRE := lib
319gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
320gb_Library_PLAINEXT := .dylib
321gb_Library_RTEXT := $(COMID)$(gb_Library_PLAINEXT)
322
323gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
324gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
325
326gb_Library__FRAMEWORKS := \
327	Cocoa \
328
329gb_Library_PLAINLIBS_NONE += \
330	Cocoa \
331	objc \
332	jpeg \
333	m \
334	pthread \
335	z \
336	cppunit
337
338gb_Library_FILENAMES := \
339	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
340	$(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
341	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
342	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
343	$(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
344	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
345	$(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \
346	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \
347	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \
348	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \
349
350
351gb_Library_LAYER := \
352	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
353	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
354	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
355	$(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \
356	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
357	$(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \
358	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \
359	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \
360	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
361
362define gb_Library_get_rpath
363$(call gb_LinkTarget__get_installname,$(call gb_Library_get_filename,$(1)),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1))))
364endef
365
366define gb_Library_Library_platform
367$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
368$(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Library_get_layer,$(1))
369
370endef
371
372
373# StaticLibrary class
374
375gb_StaticLibrary_DEFS :=
376gb_StaticLibrary_SYSPRE := lib
377gb_StaticLibrary_PLAINEXT := .a
378gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT)
379
380gb_StaticLibrary_FILENAMES := \
381	$(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \
382	$(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \
383
384gb_StaticLibrary_StaticLibrary_platform =
385
386
387# Executable class
388
389gb_Executable_EXT :=
390gb_Executable_TARGETTYPEFLAGS := -bind_at_load
391
392gb_Executable_LAYER := \
393	$(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
394	$(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
395	$(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
396	$(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \
397	$(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \
398
399
400define gb_Executable_get_rpath
401$(call gb_LinkTarget__get_installname,$(1),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1))))
402endef
403
404define gb_Executable_Executable_platform
405$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1))
406$(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Executable_get_layer,$(1))
407
408endef
409
410
411# CppunitTest class
412
413gb_CppunitTest_CPPTESTPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib
414gb_CppunitTest_SYSPRE := libtest_
415gb_CppunitTest_EXT := .dylib
416gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT)
417gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename)
418
419define gb_CppunitTest_CppunitTest_platform
420$(call gb_LinkTarget_get_target,$(2)) : RPATH :=
421$(call gb_LinkTarget_get_target,$(2)) : LAYER := NONE
422
423endef
424
425# JunitTest class
426
427define gb_JunitTest_JunitTest_platform
428$(call gb_JunitTest_get_target,$(1)) : DEFS := \
429	-Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/OpenOffice.org.app/Contents/MacOS/soffice}" \
430    -Dorg.openoffice.test.arg.env=DYLD_LIBRARY_PATH \
431    -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \
432
433endef
434
435# SdiTarget class
436
437gb_SdiTarget_SVIDLPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib
438
439# SrsPartMergeTarget
440
441gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib
442
443# SrsPartTarget class
444
445gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc
446gb_SrsPartTarget_RSCCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET)
447
448define gb_SrsPartTarget__command_dep
449$(call gb_Helper_abbreviate_dirs,\
450	$(gb_GCCP) \
451		-MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \
452		$(INCLUDE) \
453		$(DEFS) \
454		-c -x c++-header $(2) \
455		-o $(call gb_SrsPartTarget_get_dep_target,$(1)))
456endef
457
458
459# ComponentTarget
460
461gb_XSLTPROCPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib
462gb_Library_COMPONENTPREFIXES := \
463    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \
464    URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
465
466
467# vim: set noet sw=4 ts=4:
468