xref: /aoo42x/main/solenv/gbuild/platform/linux.mk (revision 9e1b801e)
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
144ifeq ($(ENABLE_SYMBOLS),SMALL)
145gb_DEBUG_CFLAGS := -ggdb1 -finline-limit=0 -fno-inline -fno-default-inline
146else
147gb_DEBUG_CFLAGS := -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline
148endif
149
150ifeq ($(gb_DEBUGLEVEL),2)
151gb_COMPILEROPTFLAGS := -O0
152else
153gb_COMPILEROPTFLAGS := -Os
154endif
155
156gb_COMPILERNOOPTFLAGS := -O0
157
158# Helper class
159
160gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs)
161
162# convert parametters filesystem root to native notation
163# does some real work only on windows, make sure not to
164# break the dummy implementations on unx*
165define gb_Helper_convert_native
166$(1)
167endef
168
169# CObject class
170
171# $(call gb_CObject__command,object,relative-source,source,dep-file)
172define gb_CObject__command
173$(call gb_Output_announce,$(2),$(true),C  ,3)
174$(call gb_Helper_abbreviate_dirs,\
175	mkdir -p $(dir $(1)) $(dir $(4)) && \
176	$(gb_CC) \
177		$(DEFS) \
178		$(T_CFLAGS) \
179		-c $(3) \
180		-o $(1) \
181		-MMD -MT $(1) \
182		-MF $(4) \
183		-I$(dir $(3)) \
184		$(INCLUDE))
185endef
186
187# convert parametters filesystem root to native notation
188# does some real work only on windows, make sure not to
189# break the dummy implementations on unx*
190define gb_Helper_convert_native
191$(1)
192endef
193
194# CxxObject class
195
196# $(call gb_CxxObject__command,object,relative-source,source,dep-file)
197define gb_CxxObject__command
198$(call gb_Output_announce,$(2),$(true),CXX,3)
199$(call gb_Helper_abbreviate_dirs,\
200	mkdir -p $(dir $(1)) $(dir $(4)) && \
201	$(gb_CXX) \
202		$(DEFS) \
203		$(T_CXXFLAGS) \
204		-c $(3) \
205		-o $(1) \
206		-MMD -MT $(1) \
207		-MF $(4) \
208		-I$(dir $(3)) \
209		$(INCLUDE_STL) $(INCLUDE))
210endef
211
212
213# LinkTarget class
214
215define gb_LinkTarget__get_rpath_for_layer
216$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
217endef
218
219gb_LinkTarget__RPATHS := \
220	URELIB:\dORIGIN \
221	UREBIN:\dORIGIN/../lib:\dORIGIN \
222	OOO:\dORIGIN:\dORIGIN/../ure-link/lib \
223	BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \
224	SDKBIN:\dORIGIN/../../ure-link/lib \
225	NONEBIN:\dORIGIN/../lib:\dORIGIN \
226
227gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR)
228gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR)
229
230
231gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC)))
232gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC)))
233
234define gb_LinkTarget__command_dynamiclink
235$(call gb_Helper_abbreviate_dirs,\
236	mkdir -p $(dir $(1)) && \
237	$(gb_CXX) \
238		$(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
239		$(subst \d,$$,$(RPATH)) \
240		$(T_LDFLAGS) \
241		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
242		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
243		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
244		-Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \
245		$(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \
246		$(patsubst %,-l%,$(EXTERNAL_LIBS)) \
247		$(LIBS) \
248		-lc \
249		-o $(1))
250endef
251
252define gb_LinkTarget__command_staticlink
253$(call gb_Helper_abbreviate_dirs,\
254	mkdir -p $(dir $(1)) && \
255	$(gb_AR) -rsu $(1) \
256		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
257		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
258		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
259		2> /dev/null)
260endef
261
262define gb_LinkTarget__command
263$(call gb_Output_announce,$(2),$(true),LNK,4)
264$(if $(filter Library GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1)))
265$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
266endef
267
268
269# Library class
270
271gb_Library_DEFS :=
272gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack
273gb_Library_SYSPRE := lib
274gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
275gb_Library_PLAINEXT := .so
276gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT)
277ifeq ($(gb_PRODUCT),$(true))
278gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT)
279else
280gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT)
281endif
282
283ifeq ($(CPUNAME),X86_64)
284gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
285gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
286else
287gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
288gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
289endif
290
291gb_Library_PLAINLIBS_NONE += \
292	fontconfig \
293	Xrender \
294	dl \
295	freetype \
296	m \
297	pthread \
298	X11 \
299	Xext \
300	SM \
301	ICE
302
303gb_Library_FILENAMES := \
304	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
305	$(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
306	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
307	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
308	$(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
309	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
310	$(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \
311	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \
312	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \
313	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \
314
315
316gb_Library_LAYER := \
317	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
318	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
319	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
320	$(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \
321	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
322	$(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \
323	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \
324	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \
325	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
326
327define gb_Library_get_rpath
328'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \
329'-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)'
330endef
331
332define gb_Library_Library_platform
333$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
334
335endef
336
337
338# StaticLibrary class
339
340gb_StaticLibrary_DEFS :=
341gb_StaticLibrary_SYSPRE := lib
342gb_StaticLibrary_PLAINEXT := .a
343gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT)
344
345gb_StaticLibrary_FILENAMES := \
346	$(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \
347	$(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \
348
349gb_StaticLibrary_StaticLibrary_platform =
350
351
352# Executable class
353
354gb_Executable_EXT :=
355
356gb_Executable_LAYER := \
357	$(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
358	$(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
359	$(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
360	$(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \
361	$(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \
362
363
364define gb_Executable_get_rpath
365'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \
366-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)
367endef
368
369define gb_Executable_Executable_platform
370$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1))
371
372endef
373
374
375# GoogleTest class
376
377gb_GoogleTest_GTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
378gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT)
379
380define gb_GoogleTest_GoogleTest_platform
381$(call gb_LinkTarget_get_target,$(2)) : RPATH := -Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)
382endef
383
384# JunitTest class
385
386define gb_JunitTest_JunitTest_platform
387$(call gb_JunitTest_get_target,$(1)) : DEFS := \
388	-Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(SRCDIR)/instsetoo_native/$(INPATH)/Apache_OpenOffice/installed/install/en-US/openoffice4/program/soffice}" \
389    -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \
390    -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \
391
392endef
393
394# SdiTarget class
395
396gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
397
398# SrsPartMergeTarget
399
400gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
401
402# SrsPartTarget class
403
404gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc
405gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET)
406
407define gb_SrsPartTarget__command_dep
408$(call gb_Helper_abbreviate_dirs,\
409	$(gb_GCCP) \
410		-MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \
411		$(INCLUDE) \
412		$(DEFS) \
413		-c -x c++-header $(2) \
414		-o $(call gb_SrsPartTarget_get_dep_target,$(1)))
415endef
416
417
418# ComponentTarget
419
420gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
421gb_Library_COMPONENTPREFIXES := \
422    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \
423    URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
424    NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \
425
426# UnoApiTarget
427
428gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc
429gb_UnoApiTarget_IDLCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET)
430gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge
431gb_UnoApiTarget_REGMERGECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET)
432gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare
433gb_UnoApiTarget_REGCOMPARECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET)
434gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker
435gb_UnoApiTarget_CPPUMAKERCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET)
436gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview
437gb_UnoApiTarget_REGVIEWCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET)
438
439# vim: set noet sw=4 ts=4:
440