xref: /aoo42x/main/solenv/gbuild/platform/macosx.mk (revision 3b02a9c8)
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
110# these are to get g++ to switch to Objective-C++ mode
111# (see toolkit module for a case where it is necessary to do it this way)
112gb_OBJCXXFLAGS := -x objective-c++ -fobjc-exceptions
113
114ifneq ($(MACOSX_DEPLOYMENT_TARGET),)
115	gb_CXXFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_$(subst .,_,$(MACOSX_DEPLOYMENT_TARGET))
116endif
117
118ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE)
119gb_CFLAGS_WERROR := -Werror -Wno-error=deprecated
120gb_CXXFLAGS_WERROR := -Werror -Wno-error=deprecated
121endif
122
123gb_LinkTarget_EXCEPTIONFLAGS := \
124	-DEXCEPTIONS_ON \
125	-fexceptions
126
127ifeq ($(COM),GCC)
128    gb_LinkTarget_EXCEPTIONFLAGS += -fno-enforce-eh-specs
129endif
130
131gb_LinkTarget_NOEXCEPTIONFLAGS := \
132	-DEXCEPTIONS_OFF \
133	-fno-exceptions
134
135gb_LinkTarget_LDFLAGS := \
136	-Wl,-syslibroot,$(gb_SDKDIR) \
137	$(subst -L../lib , ,$(SOLARLIB)) \
138#man ld says: obsolete	-Wl,-multiply_defined,suppress \
139
140ifeq ($(ENABLE_SYMBOLS),SMALL)
141gb_DEBUG_CFLAGS := -g1
142else
143gb_DEBUG_CFLAGS := -g3
144endif
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# convert parametters filesystem root to native notation
166# does some real work only on windows, make sure not to
167# break the dummy implementations on unx*
168define gb_Helper_convert_native
169$(1)
170endef
171
172
173# CObject class
174
175define gb_CObject__command
176$(call gb_Output_announce,$(2),$(true),C  ,3)
177$(call gb_Helper_abbreviate_dirs,\
178	mkdir -p $(dir $(1)) $(dir $(4)) && \
179	$(gb_CC) \
180		$(DEFS) \
181		$(T_CFLAGS) \
182		-c $(3) \
183		-o $(1) \
184		-MMD -MT $(1) \
185		-MF $(4) \
186		-I$(dir $(3)) \
187		$(INCLUDE))
188endef
189
190
191# CxxObject class
192
193# N.B: $(CXXFLAGS) may contain -x objective-c++, which must come before -c
194define gb_CxxObject__command
195$(call gb_Output_announce,$(2),$(true),CXX,3)
196$(call gb_Helper_abbreviate_dirs,\
197	mkdir -p $(dir $(1)) $(dir $(4)) && \
198	$(gb_CXX) \
199		$(DEFS) \
200		$(T_CXXFLAGS) \
201		-c $(3) \
202		-o $(1) \
203		-MMD -MT $(1) \
204		-MF $(4) \
205		-I$(dir $(3)) \
206		$(INCLUDE_STL) $(INCLUDE))
207endef
208
209
210# ObjCxxObject class
211
212define gb_ObjCxxObject__command
213$(call gb_Output_announce,$(2),$(true),OCX,3)
214$(call gb_Helper_abbreviate_dirs,\
215	mkdir -p $(dir $(1)) $(dir $(4)) && \
216	$(gb_CXX) \
217		$(DEFS) \
218		$(T_OBJCXXFLAGS) \
219		-c $(3) \
220		-o $(1) \
221		-MMD -MT $(1) \
222		-MF $(4) \
223		-I$(dir $(3)) \
224		$(INCLUDE_STL) $(INCLUDE))
225endef
226
227
228# LinkTarget class
229
230define gb_LinkTarget__get_rpath_for_layer
231$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
232endef
233
234gb_LinkTarget__RPATHS := \
235	URELIB:@__________________________________________________URELIB/ \
236	UREBIN: \
237	OOO:@__________________________________________________OOO/ \
238	BRAND: \
239	SDKBIN: \
240	NONEBIN: \
241
242define gb_LinkTarget__get_installname
243$(if $(2),-install_name '$(2)$(1)',)
244endef
245
246gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR)
247gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR)
248gb_LinkTarget_OBJCXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) $(gb_OBJCXXFLAGS)
249
250gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC)))
251gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC)))
252
253# FIXME framework handling very hackish
254define gb_LinkTarget__get_liblinkflags
255$(patsubst lib%.dylib,-l%,$(foreach lib,$(filter-out $(gb_Library__FRAMEWORKS),$(1)),$(call gb_Library_get_filename,$(lib)))) \
256$(addprefix -framework ,$(filter $(gb_Library__FRAMEWORKS),$(1)))
257endef
258
259define gb_LinkTarget__get_layer
260$(if $(filter Executable,$(1)),\
261	$$(call gb_Executable_get_layer,$(2)),\
262	$$(call gb_Library_get_layer,$(2)))
263endef
264
265# FIXME the DYLIB_FILE mess is only necessary because
266# solver layout is different from installation layout
267define gb_LinkTarget__command_dynamiclink
268$(call gb_Helper_abbreviate_dirs,\
269	mkdir -p $(dir $(1)) && \
270	DYLIB_FILE=`$(gb_MKTEMP)` && \
271	$(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \
272		$(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
273		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
274		$(subst \d,$$,$(RPATH)) \
275		$(T_LDFLAGS) \
276		$(patsubst lib%.dylib,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \
277		$(patsubst %,-l%,$(EXTERNAL_LIBS)) \
278		> $${DYLIB_FILE} && \
279	$(gb_CXX) \
280		$(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \
281		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
282		$(subst \d,$$,$(RPATH)) \
283		$(T_LDFLAGS) \
284		$(if $(VERSIONMAP),$(gb_Library_VERSIONMAPFLAG) $(VERSIONMAP)) \
285		$(call gb_LinkTarget__get_liblinkflags,$(LINKED_LIBS)) \
286		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
287		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
288		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
289		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
290		$(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \
291		$(LIBS) \
292		-o $(1) \
293		`cat $${DYLIB_FILE}` && \
294	$(if $(filter Library,$(TARGETTYPE)),\
295		$(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl Library $(LAYER) $(1) && \
296		ln -sf $(1) $(patsubst %.dylib,%.jnilib,$(1)) &&) \
297	rm -f $${DYLIB_FILE})
298endef
299
300# parameters: 1-linktarget 2-cobjects 3-cxxobjects
301define gb_LinkTarget__command_staticlink
302$(call gb_Helper_abbreviate_dirs,\
303	mkdir -p $(dir $(1)) && \
304	$(gb_AR) -rsu $(1) \
305		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
306		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
307		$(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \
308		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
309		2> /dev/null)
310endef
311
312define gb_LinkTarget__command
313$(call gb_Output_announce,$(2),$(true),LNK,4)
314$(if $(filter Library GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2)))
315$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
316endef
317
318
319# Library class
320
321gb_Library_DEFS :=
322gb_Library_TARGETTYPEFLAGS := -dynamiclib -single_module
323gb_Library_VERSIONMAPFLAG := -Wl,-exported_symbols_list
324gb_Library_SYSPRE := lib
325gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
326gb_Library_PLAINEXT := .dylib
327gb_Library_RTEXT := $(COMID)$(gb_Library_PLAINEXT)
328
329gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
330gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
331
332gb_Library__FRAMEWORKS := \
333	Cocoa \
334
335gb_Library_PLAINLIBS_NONE += \
336	Cocoa \
337	objc \
338	m \
339	pthread
340
341gb_Library_FILENAMES := \
342	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
343	$(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
344	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
345	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
346	$(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
347	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
348	$(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \
349	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \
350	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \
351	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \
352
353
354gb_Library_LAYER := \
355	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
356	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
357	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
358	$(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \
359	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
360	$(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \
361	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \
362	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \
363	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
364
365define gb_Library_get_rpath
366$(call gb_LinkTarget__get_installname,$(call gb_Library_get_filename,$(1)),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1))))
367endef
368
369define gb_Library_Library_platform
370$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
371$(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Library_get_layer,$(1))
372
373endef
374
375
376# StaticLibrary class
377
378gb_StaticLibrary_DEFS :=
379gb_StaticLibrary_SYSPRE := lib
380gb_StaticLibrary_PLAINEXT := .a
381gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT)
382
383gb_StaticLibrary_FILENAMES := \
384	$(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \
385	$(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \
386
387gb_StaticLibrary_StaticLibrary_platform =
388
389
390# Executable class
391
392gb_Executable_EXT :=
393gb_Executable_TARGETTYPEFLAGS := -bind_at_load
394
395gb_Executable_LAYER := \
396	$(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
397	$(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
398	$(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
399	$(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \
400	$(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \
401
402
403define gb_Executable_get_rpath
404$(call gb_LinkTarget__get_installname,$(1),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1))))
405endef
406
407define gb_Executable_Executable_platform
408$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1))
409$(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Executable_get_layer,$(1))
410
411endef
412
413
414# GoogleTest class
415
416gb_GoogleTest_GTESTPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib
417gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT)
418
419define gb_GoogleTest_GoogleTest_platform
420$(call gb_LinkTarget_get_target,$(2)) : RPATH :=
421endef
422
423# JunitTest class
424
425define gb_JunitTest_JunitTest_platform
426$(call gb_JunitTest_get_target,$(1)) : DEFS := \
427	-Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(SRCDIR)/instsetoo_native/$(INPATH)/Apache_OpenOffice/installed/install/en-US/openoffice4/program/soffice}" \
428    -Dorg.openoffice.test.arg.env=DYLD_LIBRARY_PATH \
429    -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \
430
431endef
432
433# SdiTarget class
434
435gb_SdiTarget_SVIDLPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib
436
437# SrsPartMergeTarget
438
439gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib
440
441# SrsPartTarget class
442
443gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc
444gb_SrsPartTarget_RSCCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET)
445
446define gb_SrsPartTarget__command_dep
447$(call gb_Helper_abbreviate_dirs,\
448	$(gb_GCCP) \
449		-MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \
450		$(INCLUDE) \
451		$(DEFS) \
452		-c -x c++-header $(2) \
453		-o $(call gb_SrsPartTarget_get_dep_target,$(1)))
454endef
455
456
457# ComponentTarget
458
459gb_XSLTPROCPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib
460gb_Library_COMPONENTPREFIXES := \
461    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \
462    URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
463    NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \
464
465# UnoApiTarget
466
467gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc
468gb_UnoApiTarget_IDLCCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET)
469gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge
470gb_UnoApiTarget_REGMERGECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET)
471gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare
472gb_UnoApiTarget_REGCOMPARECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET)
473gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker
474gb_UnoApiTarget_CPPUMAKERCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET)
475gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview
476gb_UnoApiTarget_REGVIEWCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET)
477
478
479# vim: set noet sw=4 ts=4:
480