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