xref: /aoo41x/main/solenv/gbuild/platform/freebsd.mk (revision ead13252)
1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2011 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28GUI := UNX
29COM := GCC
30
31gb_MKTEMP := gmktemp -t gbuild.XXXXXX
32
33gb_CC := cc
34gb_CXX := g++
35gb_GCCP := gcc
36gb_AR := ar
37gb_AWK := awk
38gb_CLASSPATHSEP := :
39
40# normalize setsolar and configure env.
41ifeq ($(CPU),X)
42CPUNAME := X86_64
43endif
44
45# use CC/CXX if they are nondefaults
46ifneq ($(origin CC),default)
47gb_CC := $(CC)
48gb_GCCP := $(CC)
49endif
50ifneq ($(origin CXX),default)
51gb_CXX := $(CXX)
52endif
53
54gb_OSDEFS := \
55	-D$(OS) \
56	-D_PTHREADS \
57	-DUNIX \
58	-DUNX \
59	$(PTHREAD_CFLAGS) \
60
61ifeq ($(GXX_INCLUDE_PATH),)
62GXX_INCLUDE_PATH=$(COMPATH)/include/c++/$(shell gcc -dumpversion)
63endif
64
65gb_COMPILERDEFS := \
66	-D$(COM) \
67	-DHAVE_GCC_VISIBILITY_FEATURE \
68	-DCPPU_ENV=gcc3 \
69	-DGXX_INCLUDE_PATH=$(GXX_INCLUDE_PATH) \
70
71ifeq ($(CPUNAME),X86_64)
72gb_CPUDEFS := -D$(CPUNAME)
73else
74gb_CPUDEFS := -DX86
75endif
76
77gb_CFLAGS := \
78	-Wall \
79	-Wendif-labels \
80	-Wextra \
81	-Wshadow \
82	-fPIC \
83	-fmessage-length=0 \
84	-fno-common \
85	-fno-strict-aliasing \
86	-fvisibility=hidden \
87	-pipe \
88
89gb_CXXFLAGS := \
90	-Wall \
91	-Wendif-labels \
92	-Wextra \
93	-Wno-ctor-dtor-privacy \
94	-Wno-non-virtual-dtor \
95	-Wshadow \
96	-fPIC \
97	-fmessage-length=0 \
98	-fno-common \
99	-fno-strict-aliasing \
100	-fno-use-cxa-atexit \
101	-fvisibility-inlines-hidden \
102	-fvisibility=hidden \
103	-pipe \
104
105ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE)
106gb_CFLAGS_WERROR := -Werror
107gb_CXXFLAGS_WERROR := -Werror
108endif
109
110ifneq ($(strip $(SYSBASE)),)
111#gb_CXXFLAGS += --sysroot=$(SYSBASE)
112#gb_CFLAGS += --sysroot=$(SYSBASE)
113endif
114gb_LinkTarget_EXCEPTIONFLAGS := \
115	-DEXCEPTIONS_ON \
116	-fexceptions \
117	-fno-enforce-eh-specs \
118
119gb_LinkTarget_NOEXCEPTIONFLAGS := \
120	-DEXCEPTIONS_OFF \
121	-fno-exceptions \
122
123gb_LinkTarget_LDFLAGS := \
124	-Wl,-rpath-link=$(SOLARLIBDIR):$(SYSBASE)/lib:$(SYSBASE)/usr/lib \
125	-Wl,-z,combreloc \
126	-Wl,-z,defs \
127	$(subst -L../lib , ,$(SOLARLIB)) \
128
129ifeq ($(HAVE_LD_HASH_STYLE),TRUE)
130gb_LinkTarget_LDFLAGS += \
131	-Wl,--hash-style=both \
132
133endif
134
135ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),)
136gb_LinkTarget_LDFLAGS += \
137	-Wl,--dynamic-list-cpp-new \
138	-Wl,--dynamic-list-cpp-typeinfo \
139	-Wl,-Bsymbolic-functions \
140
141endif
142
143ifeq ($(gb_DEBUGLEVEL),2)
144gb_COMPILEROPTFLAGS := -O0
145else
146gb_COMPILEROPTFLAGS := -Os
147endif
148
149gb_COMPILERNOOPTFLAGS := -O0
150
151# Helper class
152
153gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs)
154
155
156# CObject class
157
158define gb_CObject__command
159$(call gb_Output_announce,$(2),$(true),C  ,3)
160$(call gb_Helper_abbreviate_dirs,\
161	mkdir -p $(dir $(1)) && \
162	mkdir -p $(dir $(call gb_CObject_get_dep_target,$(2))) && \
163	$(gb_CC) \
164		$(DEFS) $(CFLAGS) \
165		-c $(3) \
166		-o $(1) \
167		-MMD -MT $(call gb_CObject_get_target,$(2)) \
168		-MF $(call gb_CObject_get_dep_target,$(2)) \
169		-I$(dir $(3)) \
170		$(INCLUDE))
171endef
172
173
174# CxxObject class
175
176define gb_CxxObject__command
177$(call gb_Output_announce,$(2),$(true),CXX,3)
178$(call gb_Helper_abbreviate_dirs,\
179	mkdir -p $(dir $(1)) && \
180	mkdir -p $(dir $(call gb_CxxObject_get_dep_target,$(2))) && \
181	$(gb_CXX) \
182		$(DEFS) $(CXXFLAGS) \
183		-c $(3) \
184		-o $(1) \
185		-MMD -MT $(call gb_CxxObject_get_target,$(2)) \
186		-MF $(call gb_CxxObject_get_dep_target,$(2)) \
187		-I$(dir $(3)) \
188		$(INCLUDE_STL) $(INCLUDE))
189endef
190
191
192# LinkTarget class
193
194define gb_LinkTarget__get_rpath_for_layer
195$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS)))
196endef
197
198gb_LinkTarget__RPATHS := \
199	URELIB:\dORIGIN \
200	UREBIN:\dORIGIN/../lib:\dORIGIN \
201	OOO:\dORIGIN:\dORIGIN/../ure-link/lib \
202	BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \
203	SDKBIN:\dORIGIN/../../ure-link/lib \
204	NONEBIN:\dORIGIN/../lib:\dORIGIN \
205
206gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) $(gb_COMPILEROPTFLAGS)
207gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR)
208
209ifeq ($(gb_DEBUGLEVEL),2)
210gb_LinkTarget_CXXFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline
211gb_LinkTarget_CFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline
212
213endif
214
215gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC)))
216gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC)))
217
218define gb_LinkTarget__command_dynamiclink
219$(call gb_Helper_abbreviate_dirs,\
220	mkdir -p $(dir $(1)) && \
221	$(gb_CXX) \
222		$(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
223		$(subst \d,$$,$(RPATH)) $(LDFLAGS) \
224		$(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \
225		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
226		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
227		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
228		-Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \
229		-o $(1))
230endef
231
232define gb_LinkTarget__command_staticlink
233$(call gb_Helper_abbreviate_dirs,\
234	mkdir -p $(dir $(1)) && \
235	$(gb_AR) -rsu $(1) \
236		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
237		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
238		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
239		2> /dev/null)
240endef
241
242define gb_LinkTarget__command
243$(call gb_Output_announce,$(2),$(true),LNK,4)
244$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1)))
245$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
246endef
247
248
249# Library class
250
251gb_Library_DEFS :=
252gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack
253gb_Library_SYSPRE := lib
254gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
255gb_Library_PLAINEXT := .so
256gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT)
257ifeq ($(gb_PRODUCT),$(true))
258gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT)
259else
260gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT)
261endif
262
263ifeq ($(CPUNAME),X86_64)
264gb_Library_OOOEXT := fx$(gb_Library_PLAINEXT)
265gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
266else
267gb_Library_OOOEXT := fi$(gb_Library_PLAINEXT)
268gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
269endif
270
271gb_Library_PLAINLIBS_NONE += \
272	dl \
273	jpeg \
274	m \
275	pthread \
276	X11 \
277	z
278
279gb_Library_FILENAMES := \
280	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
281	$(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
282	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
283	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
284	$(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
285	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
286	$(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \
287	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \
288	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \
289	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \
290
291
292gb_Library_LAYER := \
293	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
294	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
295	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
296	$(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \
297	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
298	$(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \
299	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \
300	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \
301	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
302
303define gb_Library_get_rpath
304-Wl,-z,origin -Wl,-rpath,'$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \
305-Wl,-rpath-link,'$(gb_Library_OUTDIRLOCATION)'
306endef
307
308define gb_Library_Library_platform
309$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
310
311endef
312
313
314# StaticLibrary class
315
316gb_StaticLibrary_DEFS :=
317gb_StaticLibrary_SYSPRE := lib
318gb_StaticLibrary_PLAINEXT := .a
319gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT)
320
321gb_StaticLibrary_FILENAMES := \
322	$(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \
323	$(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \
324
325gb_StaticLibrary_StaticLibrary_platform =
326
327
328# Executable class
329
330gb_Executable_EXT :=
331
332gb_Executable_LAYER := \
333	$(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
334	$(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
335	$(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
336	$(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \
337	$(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \
338
339
340define gb_Executable_get_rpath
341'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \
342-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)
343endef
344
345define gb_Executable_Executable_platform
346$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1))
347
348endef
349
350
351# CppunitTest class
352
353gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
354gb_CppunitTest_SYSPRE := libtest_
355gb_CppunitTest_EXT := .so
356gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT)
357gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename)
358
359define gb_CppunitTest_CppunitTest_platform
360$(call gb_LinkTarget_get_target,$(2)) : RPATH :=
361
362endef
363
364# JunitTest class
365
366define gb_JunitTest_JunitTest_platform
367$(call gb_JunitTest_get_target,$(1)) : DEFS := \
368	-Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/openoffice.org3/program/soffice}" \
369    -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \
370    -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \
371
372endef
373
374# SdiTarget class
375
376gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
377
378# SrsPartMergeTarget
379
380gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
381
382# SrsPartTarget class
383
384gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc
385gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET)
386
387define gb_SrsPartTarget__command_dep
388$(call gb_Helper_abbreviate_dirs,\
389	$(gb_GCCP) \
390		-MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \
391		$(INCLUDE) \
392		$(DEFS) \
393		-c -x c++-header $(2) \
394		-o $(call gb_SrsPartTarget_get_dep_target,$(1)))
395endef
396
397
398# ComponentTarget
399
400gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
401gb_Library_COMPONENTPREFIXES := \
402    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \
403    URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
404
405
406# vim: set noet sw=4 ts=4:
407