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