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