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