xref: /trunk/main/solenv/gbuild/platform/linux.mk (revision 5f9a7a39)
1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2011 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28GUI := UNX
29COM := GCC
30
31gb_MKTEMP := mktemp -t gbuild.XXXXXX
32
33gb_CC := gcc
34gb_CXX := g++
35gb_GCCP := gcc
36gb_AR := ar
37gb_AWK := awk
38gb_CLASSPATHSEP := :
39
40# normalize setsolar and configure env.
41ifeq ($(CPU),X)
42CPUNAME := X86_64
43endif
44
45# use CC/CXX if they are nondefaults
46ifneq ($(origin CC),default)
47gb_CC := $(CC)
48gb_GCCP := $(CC)
49endif
50ifneq ($(origin CXX),default)
51gb_CXX := $(CXX)
52endif
53
54gb_OSDEFS := \
55	-D$(OS) \
56	-D_PTHREADS \
57	-DUNIX \
58	-DUNX \
59	$(PTHREAD_CFLAGS) \
60
61ifeq ($(GXX_INCLUDE_PATH),)
62GXX_INCLUDE_PATH=$(COMPATH)/include/c++/$(shell gcc -dumpversion)
63endif
64
65gb_COMPILERDEFS := \
66	-D$(COM) \
67	-DHAVE_GCC_VISIBILITY_FEATURE \
68	-DCPPU_ENV=gcc3 \
69	-DGXX_INCLUDE_PATH=$(GXX_INCLUDE_PATH) \
70
71ifeq ($(CPUNAME),X86_64)
72gb_CPUDEFS := -D$(CPUNAME)
73else
74gb_CPUDEFS := -DX86
75endif
76
77gb_CFLAGS := \
78	-Wall \
79	-Wendif-labels \
80	-Wextra \
81	-Wshadow \
82	-fPIC \
83	-fmessage-length=0 \
84	-fno-common \
85	-fno-strict-aliasing \
86	-fvisibility=hidden \
87	-pipe \
88
89gb_CXXFLAGS := \
90	-Wall \
91	-Wendif-labels \
92	-Wextra \
93	-Wno-ctor-dtor-privacy \
94	-Wno-non-virtual-dtor \
95	-Wshadow \
96	-fPIC \
97	-fmessage-length=0 \
98	-fno-common \
99	-fno-strict-aliasing \
100	-fno-use-cxa-atexit \
101	-fvisibility-inlines-hidden \
102	-fvisibility=hidden \
103	-pipe \
104
105ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE)
106gb_CFLAGS_WERROR := -Werror
107gb_CXXFLAGS_WERROR := -Werror
108endif
109
110ifneq ($(strip $(SYSBASE)),)
111gb_CXXFLAGS += --sysroot=$(SYSBASE)
112gb_CFLAGS += --sysroot=$(SYSBASE)
113endif
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,--sysroot=$(SYSBASE) \
125	-Wl,-rpath-link,$(SYSBASE)/lib:$(SYSBASE)/usr/lib \
126	-Wl,-z,combreloc \
127	-Wl,-z,defs \
128	$(subst -L../lib , ,$(SOLARLIB)) \
129
130ifeq ($(HAVE_LD_HASH_STYLE),TRUE)
131gb_LinkTarget_LDFLAGS += \
132	-Wl,--hash-style=both \
133
134endif
135
136ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),)
137gb_LinkTarget_LDFLAGS += \
138	-Wl,--dynamic-list-cpp-new \
139	-Wl,--dynamic-list-cpp-typeinfo \
140	-Wl,-Bsymbolic-functions \
141
142endif
143
144ifeq ($(gb_DEBUGLEVEL),2)
145gb_COMPILEROPTFLAGS := -O0
146else
147gb_COMPILEROPTFLAGS := -Os
148endif
149
150gb_COMPILERNOOPTFLAGS := -O0
151
152# Helper class
153
154gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs)
155
156# convert parametters filesystem root to native notation
157# does some real work only on windows, make sure not to
158# break the dummy implementations on unx*
159define gb_Helper_convert_native
160$(1)
161endef
162
163# CObject class
164
165define gb_CObject__command
166$(call gb_Output_announce,$(2),$(true),C  ,3)
167$(call gb_Helper_abbreviate_dirs,\
168	mkdir -p $(dir $(1)) && \
169	mkdir -p $(dir $(call gb_CObject_get_dep_target,$(2))) && \
170	$(gb_CC) \
171		$(DEFS) $(CFLAGS) \
172		-c $(3) \
173		-o $(1) \
174		-MMD -MT $(call gb_CObject_get_target,$(2)) \
175		-MF $(call gb_CObject_get_dep_target,$(2)) \
176		-I$(dir $(3)) \
177		$(INCLUDE))
178endef
179
180
181# CxxObject class
182
183define gb_CxxObject__command
184$(call gb_Output_announce,$(2),$(true),CXX,3)
185$(call gb_Helper_abbreviate_dirs,\
186	mkdir -p $(dir $(1)) && \
187	mkdir -p $(dir $(call gb_CxxObject_get_dep_target,$(2))) && \
188	$(gb_CXX) \
189		$(DEFS) $(CXXFLAGS) \
190		-c $(3) \
191		-o $(1) \
192		-MMD -MT $(call gb_CxxObject_get_target,$(2)) \
193		-MF $(call gb_CxxObject_get_dep_target,$(2)) \
194		-I$(dir $(3)) \
195		$(INCLUDE_STL) $(INCLUDE))
196endef
197
198
199# LinkTarget class
200
201define gb_LinkTarget__get_rpath_for_layer
202$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
203endef
204
205gb_LinkTarget__RPATHS := \
206	URELIB:\dORIGIN \
207	UREBIN:\dORIGIN/../lib:\dORIGIN \
208	OOO:\dORIGIN:\dORIGIN/../ure-link/lib \
209	BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \
210	SDKBIN:\dORIGIN/../../ure-link/lib \
211	NONEBIN:\dORIGIN/../lib:\dORIGIN \
212
213gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) $(gb_COMPILEROPTFLAGS)
214gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR)
215
216ifeq ($(gb_DEBUGLEVEL),2)
217gb_LinkTarget_CXXFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline
218gb_LinkTarget_CFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline
219
220endif
221
222gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC)))
223gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC)))
224
225define gb_LinkTarget__command_dynamiclink
226$(call gb_Helper_abbreviate_dirs,\
227	mkdir -p $(dir $(1)) && \
228	$(gb_CXX) \
229		$(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
230		$(subst \d,$$,$(RPATH)) $(LDFLAGS) \
231		$(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \
232		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
233		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
234		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
235		-Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \
236		-o $(1))
237endef
238
239define gb_LinkTarget__command_staticlink
240$(call gb_Helper_abbreviate_dirs,\
241	mkdir -p $(dir $(1)) && \
242	$(gb_AR) -rsu $(1) \
243		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
244		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
245		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
246		2> /dev/null)
247endef
248
249define gb_LinkTarget__command
250$(call gb_Output_announce,$(2),$(true),LNK,4)
251$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1)))
252$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
253endef
254
255
256# Library class
257
258gb_Library_DEFS :=
259gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack
260gb_Library_SYSPRE := lib
261gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
262gb_Library_PLAINEXT := .so
263gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT)
264ifeq ($(gb_PRODUCT),$(true))
265gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT)
266else
267gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT)
268endif
269
270ifeq ($(CPUNAME),X86_64)
271gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
272gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
273else
274gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
275gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
276endif
277
278gb_Library_PLAINLIBS_NONE += \
279	dl \
280    freetype \
281	jpeg \
282	m \
283	pthread \
284	X11 \
285    Xext \
286    SM \
287    ICE \
288	z
289
290gb_Library_FILENAMES := \
291	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
292	$(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
293	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
294	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
295	$(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
296	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
297	$(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \
298	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \
299	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \
300	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \
301
302
303gb_Library_LAYER := \
304	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
305	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
306	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
307	$(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \
308	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
309	$(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \
310	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \
311	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \
312	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
313
314define gb_Library_get_rpath
315'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \
316'-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)'
317endef
318
319define gb_Library_Library_platform
320$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
321
322endef
323
324
325# StaticLibrary class
326
327gb_StaticLibrary_DEFS :=
328gb_StaticLibrary_SYSPRE := lib
329gb_StaticLibrary_PLAINEXT := .a
330gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT)
331
332gb_StaticLibrary_FILENAMES := \
333	$(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \
334	$(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \
335
336gb_StaticLibrary_StaticLibrary_platform =
337
338
339# Executable class
340
341gb_Executable_EXT :=
342
343gb_Executable_LAYER := \
344	$(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
345	$(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
346	$(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
347	$(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \
348	$(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \
349
350
351define gb_Executable_get_rpath
352'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \
353-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)
354endef
355
356define gb_Executable_Executable_platform
357$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1))
358
359endef
360
361
362# CppunitTest class
363
364gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
365gb_CppunitTest_SYSPRE := libtest_
366gb_CppunitTest_EXT := .so
367gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT)
368gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename)
369
370define gb_CppunitTest_CppunitTest_platform
371$(call gb_LinkTarget_get_target,$(2)) : RPATH :=
372
373endef
374
375# JunitTest class
376
377define gb_JunitTest_JunitTest_platform
378$(call gb_JunitTest_get_target,$(1)) : DEFS := \
379	-Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/openoffice.org3/program/soffice}" \
380    -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \
381    -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \
382
383endef
384
385# SdiTarget class
386
387gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
388
389# SrsPartMergeTarget
390
391gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
392
393# SrsPartTarget class
394
395gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc
396gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET)
397
398define gb_SrsPartTarget__command_dep
399$(call gb_Helper_abbreviate_dirs,\
400	$(gb_GCCP) \
401		-MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \
402		$(INCLUDE) \
403		$(DEFS) \
404		-c -x c++-header $(2) \
405		-o $(call gb_SrsPartTarget_get_dep_target,$(1)))
406endef
407
408
409# ComponentTarget
410
411gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
412gb_Library_COMPONENTPREFIXES := \
413    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \
414    URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
415
416
417# vim: set noet sw=4 ts=4:
418