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