xref: /aoo42x/main/solenv/gbuild/platform/solaris.mk (revision 3b02a9c8)
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 := C52
26
27gb_MKTEMP := mktemp -t gbuild.XXXXXX
28
29gb_CC := cc
30gb_CXX := CC
31gb_GCCP := cc
32gb_AR := ar
33gb_AWK := /usr/xpg4/bin/awk
34gb_CLASSPATHSEP := :
35
36# use CC/CXX if they are nondefaults
37ifneq ($(origin CC),default)
38gb_CC := $(CC)
39gb_GCCP := $(CC)
40endif
41ifneq ($(origin CXX),default)
42gb_CXX := $(CXX)
43endif
44
45gb_OSDEFS := \
46	-D$(OS) \
47	-D$(GUI) \
48	-DSYSV \
49	-DSUN \
50	-DSUN4 \
51	-D_REENTRANT \
52	-D_POSIX_PTHREAD_SEMANTICS \
53	-D_PTHREADS \
54	-DUNIX \
55
56gb_COMPILERDEFS := \
57	-D$(COM) \
58	-DCPPU_ENV=sunpro5 \
59
60gb_CPUDEFS := -D$(CPUNAME)
61ifeq ($(CPUNAME),SPARC)
62gb_CPUDEFS += -D__sparcv8plus
63endif
64
65gb_CFLAGS := \
66	-temp=/tmp \
67	-KPIC \
68	-mt \
69	-xldscope=hidden \
70	-xCC \
71	-xc99=none \
72
73gb_CXXFLAGS := \
74	-temp=/tmp \
75	-KPIC \
76	-mt \
77	-xldscope=hidden \
78	-features=no%altspell \
79	-library=no%Cstd \
80	+w2 \
81	-erroff=doubunder,identexpected,inllargeuse,inllargeint,notemsource,reftotemp,truncwarn,wnoretvalue,anonnotype \
82
83ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE)
84gb_CFLAGS_WERROR := -errwarn=%all
85gb_CXXFLAGS_WERROR := -xwe
86endif
87
88gb_LinkTarget_EXCEPTIONFLAGS := \
89	-DEXCEPTIONS_ON \
90
91gb_LinkTarget_NOEXCEPTIONFLAGS := \
92	-DEXCEPTIONS_OFF \
93	-noex \
94
95gb_LinkTarget_LDFLAGS := \
96	$(subst -L../lib , ,$(SOLARLIB)) \
97	-temp=/tmp \
98	-w \
99	-mt \
100	-Bdirect \
101	-z defs \
102	-z combreloc \
103	-norunpath \
104	-PIC \
105	-library=no%Cstd \
106
107
108gb_DEBUG_CFLAGS := -g
109
110ifeq ($(gb_DEBUGLEVEL),2)
111gb_COMPILEROPTFLAGS :=
112else
113ifeq ($(CPUNAME),INTEL)
114gb_COMPILEROPTFLAGS := -xarch=generic -xO3
115else # ifeq ($(CPUNAME),SPARC)
116#  -m32 -xarch=sparc        restrict target to 32 bit sparc
117#  -xO3                     optimization level 3
118#  -xspace                  don't do optimizations which do increase binary size
119#  -xprefetch=yes           do prefetching (helps on UltraSparc III)
120gb_COMPILEROPTFLAGS := -m32 -xarch=sparc -xO3 -xspace -xprefetch=yes
121endif
122endif
123
124gb_COMPILERNOOPTFLAGS :=
125
126# Helper class
127
128gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs)
129
130# convert parametters filesystem root to native notation
131# does some real work only on windows, make sure not to
132# break the dummy implementations on unx*
133define gb_Helper_convert_native
134$(1)
135endef
136
137# convert parametters filesystem root to native notation
138# does some real work only on windows, make sure not to
139# break the dummy implementations on unx*
140define gb_Helper_convert_native
141$(1)
142endef
143
144
145# CObject class
146
147define gb_CObject__command
148$(call gb_Output_announce,$(2),$(true),C  ,3)
149$(call gb_Helper_abbreviate_dirs,\
150	rm -f $(4) && \
151	mkdir -p $(dir $(1)) $(dir $(4)) && \
152	$(gb_CC) \
153		-c $(3) \
154		-o $(1) \
155		-xMMD \
156		-xMF $(4) \
157		$(DEFS) \
158		$(T_CFLAGS) \
159		-I$(dir $(3)) \
160		$(INCLUDE))
161endef
162
163
164# CxxObject class
165
166define gb_CxxObject__command
167$(call gb_Output_announce,$(2),$(true),CXX,3)
168$(call gb_Helper_abbreviate_dirs,\
169	mkdir -p $(dir $(1)) $(dir $(4)) && \
170	$(gb_CXX) \
171		$(DEFS) \
172		$(T_CXXFLAGS) \
173		-c $(3) \
174		-o $(1) \
175		-xMMD \
176		-xMF $(4) \
177		-I$(dir $(3)) \
178		$(INCLUDE_STL) $(INCLUDE))
179endef
180
181
182# LinkTarget class
183
184define gb_LinkTarget__get_rpath_for_layer
185$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
186endef
187
188gb_LinkTarget__RPATHS := \
189	URELIB:\dORIGIN \
190	UREBIN:\dORIGIN/../lib:\dORIGIN \
191	OOO:\dORIGIN:\dORIGIN/../ure-link/lib \
192	BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \
193	SDKBIN:\dORIGIN/../../ure-link/lib \
194	NONEBIN:\dORIGIN/../lib:\dORIGIN \
195
196gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR)
197gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR)
198
199
200gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC)))
201gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC)))
202
203define gb_LinkTarget__command_dynamiclink
204$(call gb_Helper_abbreviate_dirs,\
205	mkdir -p $(dir $(1)) && \
206	$(gb_CXX) \
207		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
208		$(if $(VERSIONMAP),$(gb_Library_VERSIONMAPFLAG) $(VERSIONMAP)) \
209		$(subst \d,$$,$(RPATH)) \
210		$(T_LDFLAGS) \
211		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
212		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
213		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
214		$(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \
215		$(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \
216		$(patsubst %,-l%,$(EXTERNAL_LIBS)) \
217		$(LIBS) \
218		-o $(1))
219endef
220
221define gb_LinkTarget__command_staticlink
222$(call gb_Helper_abbreviate_dirs,\
223	mkdir -p $(dir $(1)) && \
224	$(gb_AR) -rsu $(1) \
225		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
226		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
227		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
228		2> /dev/null)
229endef
230
231define gb_LinkTarget__command
232$(call gb_Output_announce,$(2),$(true),LNK,4)
233$(if $(filter Library GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1)))
234$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
235endef
236
237# Library class
238
239gb_Library_DEFS :=
240gb_Library_TARGETTYPEFLAGS := -Bdynamic -z text -G
241gb_Library_SYSPRE := lib
242gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
243gb_Library_PLAINEXT := .so
244gb_Library_RTEXT := C52$(gb_Library_PLAINEXT)
245ifeq ($(gb_PRODUCT),$(true))
246gb_Library_STLEXT := port_sunpro$(gb_Library_PLAINEXT)
247else
248gb_Library_STLEXT := port_sunpro_debug$(gb_Library_PLAINEXT)
249endif
250gb_Library_VERSIONMAPFLAG := -M
251
252ifeq ($(CPUNAME),INTEL)
253gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
254gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
255else # ifeq ($(CPUNAME),SPARC)
256gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
257gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
258endif
259
260gb_STDLIBS := \
261	Crun \
262	m \
263	c \
264
265gb_Library_PLAINLIBS_NONE += \
266	$(gb_STDLIBS) \
267	dl \
268    freetype \
269	nsl \
270	pthread \
271	socket \
272	X11 \
273    Xext \
274    SM \
275    ICE
276
277gb_Library_FILENAMES := \
278	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
279	$(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
280	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
281	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
282	$(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
283	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
284	$(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \
285	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \
286	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \
287	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \
288
289
290gb_Library_LAYER := \
291	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
292	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
293	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
294	$(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \
295	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
296	$(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \
297	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \
298	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \
299	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
300
301define gb_Library_get_rpath
302'-R$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))'
303endef
304
305define gb_Library_Library_platform
306$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
307
308endef
309
310
311# StaticLibrary class
312
313gb_StaticLibrary_DEFS :=
314gb_StaticLibrary_SYSPRE := lib
315gb_StaticLibrary_PLAINEXT := .a
316gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT)
317
318gb_StaticLibrary_FILENAMES := \
319	$(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \
320	$(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \
321
322gb_StaticLibrary_StaticLibrary_platform =
323
324
325# Executable class
326
327gb_Executable_EXT :=
328
329gb_Executable_LAYER := \
330	$(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
331	$(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
332	$(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
333	$(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \
334	$(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \
335
336
337define gb_Executable_get_rpath
338'-R$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))'
339endef
340
341define gb_Executable_Executable_platform
342$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1))
343
344endef
345
346
347# GoogleTest class
348
349gb_GoogleTest_GTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
350gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT)
351
352define gb_GoogleTest_GoogleTest_platform
353$(call gb_LinkTarget_get_target,$(2)) : RPATH :=
354endef
355
356# JunitTest class
357
358define gb_JunitTest_JunitTest_platform
359$(call gb_JunitTest_get_target,$(1)) : DEFS := \
360	-Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(SRCDIR)/instsetoo_native/$(INPATH)/Apache_OpenOffice/installed/install/en-US/openoffice4/program/soffice}" \
361    -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \
362    -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \
363
364endef
365
366# SdiTarget class
367
368gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
369
370# SrsPartMergeTarget
371
372gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
373
374# SrsPartTarget class
375
376gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc
377gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET)
378
379# Sun cc/CC support -xM1/-xMF flags, but unfortunately refuse input files that
380# do not have the right suffix, so use makedepend here...
381define gb_SrsPartTarget__command_dep
382$(call gb_Helper_abbreviate_dirs_native,\
383	$(OUTDIR)/bin/makedepend$(gb_Executable_EXT) \
384		$(INCLUDE) \
385		$(DEFS) \
386		$(2) \
387		-f - \
388	| $(gb_AWK) -f $(GBUILDDIR)/processdeps.awk \
389		-v OBJECTFILE=$(call gb_SrsPartTarget_get_target,$(1)) \
390		-v OUTDIR=$(OUTDIR)/ \
391		-v WORKDIR=$(WORKDIR)/ \
392		-v SRCDIR=$(SRCDIR)/ \
393		-v REPODIR=$(REPODIR)/ \
394	> $(call gb_SrsPartTarget_get_dep_target,$(1)))
395endef
396
397
398# ComponentTarget
399
400gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
401gb_Library_COMPONENTPREFIXES := \
402    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \
403    URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
404    NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \
405
406# UnoApiTarget
407
408gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc
409gb_UnoApiTarget_IDLCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET)
410gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge
411gb_UnoApiTarget_REGMERGECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET)
412gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare
413gb_UnoApiTarget_REGCOMPARECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET)
414gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker
415gb_UnoApiTarget_CPPUMAKERCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET)
416gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview
417gb_UnoApiTarget_REGVIEWCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET)
418
419# vim: set noet sw=4 ts=4:
420