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