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