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