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