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