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