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