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