xref: /aoo42x/main/solenv/gbuild/platform/linux.mk (revision 64c5c8b7)
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
27gb_MKTEMP := mktemp -t gbuild.XXXXXX
28
29gb_CC := gcc
30gb_CXX := g++
31gb_GCCP := gcc
32gb_AR := ar
33gb_AWK := awk
34gb_CLASSPATHSEP := :
35
36# normalize setsolar and configure env.
37ifeq ($(CPU),X)
38CPUNAME := X86_64
39endif
40
41# use CC/CXX if they are nondefaults
42ifneq ($(origin CC),default)
43gb_CC := $(CC)
44gb_GCCP := $(CC)
45endif
46ifneq ($(origin CXX),default)
47gb_CXX := $(CXX)
48endif
49
50gb_OSDEFS := \
51	-D$(OS) \
52	-D_PTHREADS \
53	-DUNIX \
54	-DUNX \
55	$(PTHREAD_CFLAGS) \
56
57ifeq ($(GXX_INCLUDE_PATH),)
58GXX_INCLUDE_PATH=$(COMPATH)/include/c++/$(shell gcc -dumpversion)
59endif
60
61gb_COMPILERDEFS := \
62	-D$(COM) \
63	-DHAVE_GCC_VISIBILITY_FEATURE \
64	-DCPPU_ENV=gcc3 \
65	-DGXX_INCLUDE_PATH=$(GXX_INCLUDE_PATH) \
66
67ifeq ($(CPUNAME),X86_64)
68gb_CPUDEFS := -D$(CPUNAME)
69else
70gb_CPUDEFS := -DX86
71endif
72
73gb_CFLAGS := \
74	-Wall \
75	-Wendif-labels \
76	-Wextra \
77	-Wshadow \
78	-fPIC \
79	-fmessage-length=0 \
80	-fno-common \
81	-fno-strict-aliasing \
82	-fvisibility=hidden \
83	-pipe \
84
85gb_CXXFLAGS := \
86	-Wall \
87	-Wendif-labels \
88	-Wextra \
89	-Wno-ctor-dtor-privacy \
90	-Wno-non-virtual-dtor \
91	-Wshadow \
92	-fPIC \
93	-fmessage-length=0 \
94	-fno-common \
95	-fno-strict-aliasing \
96	-fuse-cxa-atexit \
97	-fvisibility-inlines-hidden \
98	-fvisibility=hidden \
99	-pipe \
100
101ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE)
102gb_CFLAGS_WERROR := -Werror
103gb_CXXFLAGS_WERROR := -Werror
104endif
105
106ifneq ($(strip $(SYSBASE)),)
107gb_CXXFLAGS += --sysroot=$(SYSBASE)
108gb_CFLAGS += --sysroot=$(SYSBASE)
109gb_LinkTarget_LDFLAGS := -Wl,--sysroot=$(SYSBASE)
110endif
111gb_LinkTarget_EXCEPTIONFLAGS := \
112	-DEXCEPTIONS_ON \
113	-fexceptions \
114	-fno-enforce-eh-specs \
115
116gb_LinkTarget_NOEXCEPTIONFLAGS := \
117	-DEXCEPTIONS_OFF \
118	-fno-exceptions \
119
120gb_LinkTarget_LDFLAGS += \
121	-Wl,-rpath-link,$(SYSBASE)/lib:$(SYSBASE)/usr/lib \
122	-Wl,-z,combreloc \
123	-Wl,-z,defs \
124	$(subst -L../lib , ,$(SOLARLIB)) \
125
126ifeq ($(HAVE_LD_HASH_STYLE),TRUE)
127gb_LinkTarget_LDFLAGS += \
128	-Wl,--hash-style=both \
129
130endif
131
132ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),)
133gb_LinkTarget_LDFLAGS += \
134	-Wl,--dynamic-list-cpp-new \
135	-Wl,--dynamic-list-cpp-typeinfo \
136	-Wl,-Bsymbolic-functions \
137
138endif
139
140ifeq ($(gb_DEBUGLEVEL),0)
141gb_LinkTarget_LDFLAGS += -Wl,-O1
142endif
143
144gb_DEBUG_CFLAGS := -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline
145
146ifeq ($(gb_DEBUGLEVEL),2)
147gb_COMPILEROPTFLAGS := -O0
148else
149gb_COMPILEROPTFLAGS := -Os
150endif
151
152gb_COMPILERNOOPTFLAGS := -O0
153
154# Helper class
155
156gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs)
157
158# convert parametters filesystem root to native notation
159# does some real work only on windows, make sure not to
160# break the dummy implementations on unx*
161define gb_Helper_convert_native
162$(1)
163endef
164
165# CObject class
166
167# $(call gb_CObject__command,object,relative-source,source,dep-file)
168define gb_CObject__command
169$(call gb_Output_announce,$(2),$(true),C  ,3)
170$(call gb_Helper_abbreviate_dirs,\
171	mkdir -p $(dir $(1)) $(dir $(4)) && \
172	$(gb_CC) \
173		$(DEFS) \
174		$(T_CFLAGS) \
175		-c $(3) \
176		-o $(1) \
177		-MMD -MT $(1) \
178		-MF $(4) \
179		-I$(dir $(3)) \
180		$(INCLUDE))
181endef
182
183# convert parametters filesystem root to native notation
184# does some real work only on windows, make sure not to
185# break the dummy implementations on unx*
186define gb_Helper_convert_native
187$(1)
188endef
189
190# CxxObject class
191
192# $(call gb_CxxObject__command,object,relative-source,source,dep-file)
193define gb_CxxObject__command
194$(call gb_Output_announce,$(2),$(true),CXX,3)
195$(call gb_Helper_abbreviate_dirs,\
196	mkdir -p $(dir $(1)) $(dir $(4)) && \
197	$(gb_CXX) \
198		$(DEFS) \
199		$(T_CXXFLAGS) \
200		-c $(3) \
201		-o $(1) \
202		-MMD -MT $(1) \
203		-MF $(4) \
204		-I$(dir $(3)) \
205		$(INCLUDE_STL) $(INCLUDE))
206endef
207
208
209# LinkTarget class
210
211define gb_LinkTarget__get_rpath_for_layer
212$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
213endef
214
215gb_LinkTarget__RPATHS := \
216	URELIB:\dORIGIN \
217	UREBIN:\dORIGIN/../lib:\dORIGIN \
218	OOO:\dORIGIN:\dORIGIN/../ure-link/lib \
219	BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \
220	SDKBIN:\dORIGIN/../../ure-link/lib \
221	NONEBIN:\dORIGIN/../lib:\dORIGIN \
222
223gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR)
224gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR)
225
226
227gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC)))
228gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC)))
229
230define gb_LinkTarget__command_dynamiclink
231$(call gb_Helper_abbreviate_dirs,\
232	mkdir -p $(dir $(1)) && \
233	$(gb_CXX) \
234		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
235		$(subst \d,$$,$(RPATH)) \
236		$(T_LDFLAGS) \
237		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
238		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
239		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
240		-Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \
241		$(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \
242		$(patsubst %,-l%,$(EXTERNAL_LIBS)) \
243		$(LIBS) \
244		-lc \
245		-o $(1))
246endef
247
248define gb_LinkTarget__command_staticlink
249$(call gb_Helper_abbreviate_dirs,\
250	mkdir -p $(dir $(1)) && \
251	$(gb_AR) -rsu $(1) \
252		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
253		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
254		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
255		2> /dev/null)
256endef
257
258define gb_LinkTarget__command
259$(call gb_Output_announce,$(2),$(true),LNK,4)
260$(if $(filter Library GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1)))
261$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
262endef
263
264
265# Library class
266
267gb_Library_DEFS :=
268gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack
269gb_Library_SYSPRE := lib
270gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
271gb_Library_PLAINEXT := .so
272gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT)
273ifeq ($(gb_PRODUCT),$(true))
274gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT)
275else
276gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT)
277endif
278
279ifeq ($(CPUNAME),X86_64)
280gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
281gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
282else
283gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
284gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
285endif
286
287gb_Library_PLAINLIBS_NONE += \
288	fontconfig \
289	Xrender \
290	dl \
291	freetype \
292	m \
293	pthread \
294	X11 \
295	Xext \
296	SM \
297	ICE
298
299gb_Library_FILENAMES := \
300	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
301	$(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
302	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
303	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
304	$(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
305	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
306	$(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \
307	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \
308	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \
309	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \
310
311
312gb_Library_LAYER := \
313	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
314	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
315	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
316	$(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \
317	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
318	$(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \
319	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \
320	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \
321	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
322
323define gb_Library_get_rpath
324'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \
325'-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)'
326endef
327
328define gb_Library_Library_platform
329$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
330
331endef
332
333
334# StaticLibrary class
335
336gb_StaticLibrary_DEFS :=
337gb_StaticLibrary_SYSPRE := lib
338gb_StaticLibrary_PLAINEXT := .a
339gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT)
340
341gb_StaticLibrary_FILENAMES := \
342	$(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \
343	$(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \
344
345gb_StaticLibrary_StaticLibrary_platform =
346
347
348# Executable class
349
350gb_Executable_EXT :=
351
352gb_Executable_LAYER := \
353	$(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
354	$(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
355	$(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
356	$(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \
357	$(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \
358
359
360define gb_Executable_get_rpath
361'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \
362-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)
363endef
364
365define gb_Executable_Executable_platform
366$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1))
367
368endef
369
370
371# GoogleTest class
372
373gb_GoogleTest_GTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
374gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT)
375
376define gb_GoogleTest_GoogleTest_platform
377$(call gb_LinkTarget_get_target,$(2)) : RPATH := -Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)
378endef
379
380# JunitTest class
381
382define gb_JunitTest_JunitTest_platform
383$(call gb_JunitTest_get_target,$(1)) : DEFS := \
384	-Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(SRCDIR)/instsetoo_native/$(INPATH)/Apache_OpenOffice/installed/install/en-US/openoffice4/program/soffice}" \
385    -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \
386    -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \
387
388endef
389
390# SdiTarget class
391
392gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
393
394# SrsPartMergeTarget
395
396gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
397
398# SrsPartTarget class
399
400gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc
401gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET)
402
403define gb_SrsPartTarget__command_dep
404$(call gb_Helper_abbreviate_dirs,\
405	$(gb_GCCP) \
406		-MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \
407		$(INCLUDE) \
408		$(DEFS) \
409		-c -x c++-header $(2) \
410		-o $(call gb_SrsPartTarget_get_dep_target,$(1)))
411endef
412
413
414# ComponentTarget
415
416gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
417gb_Library_COMPONENTPREFIXES := \
418    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \
419    URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
420    NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \
421
422# UnoApiTarget
423
424gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc
425gb_UnoApiTarget_IDLCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET)
426gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge
427gb_UnoApiTarget_REGMERGECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET)
428gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare
429gb_UnoApiTarget_REGCOMPARECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET)
430gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker
431gb_UnoApiTarget_CPPUMAKERCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET)
432gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview
433gb_UnoApiTarget_REGVIEWCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET)
434
435# vim: set noet sw=4 ts=4:
436