xref: /aoo42x/main/solenv/gbuild/platform/freebsd.mk (revision c25219e0)
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)
232gb_LinkTarget_CXXFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline
233gb_LinkTarget_CFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline
234
235endif
236
237gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC)))
238gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC)))
239
240define gb_LinkTarget__command_dynamiclink
241$(call gb_Helper_abbreviate_dirs,\
242	mkdir -p $(dir $(1)) && \
243	$(gb_CXX) \
244		$(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \
245		$(subst \d,$$,$(RPATH)) $(LDFLAGS) \
246		$(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \
247		$(patsubst %,-l%,$(EXTERNAL_LIBS)) \
248		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
249		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
250		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
251		-Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \
252		-o $(1))
253endef
254
255define gb_LinkTarget__command_staticlink
256$(call gb_Helper_abbreviate_dirs,\
257	mkdir -p $(dir $(1)) && \
258	$(gb_AR) -rsu $(1) \
259		$(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
260		$(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \
261		$(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \
262		2> /dev/null)
263endef
264
265define gb_LinkTarget__command
266$(call gb_Output_announce,$(2),$(true),LNK,4)
267$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1)))
268$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1)))
269endef
270
271
272# Library class
273
274gb_Library_DEFS :=
275gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack
276gb_Library_SYSPRE := lib
277gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_
278gb_Library_PLAINEXT := .so
279gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT)
280ifeq ($(gb_PRODUCT),$(true))
281gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT)
282else
283gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT)
284endif
285
286ifeq ($(CPUNAME),X86_64)
287gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
288gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
289else
290gb_Library_OOOEXT := $(gb_Library_PLAINEXT)
291gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT)
292endif
293
294gb_Library_PLAINLIBS_NONE += \
295	dl \
296	freetype \
297	jpeg \
298	m \
299	pthread \
300	X11 \
301	Xext \
302	SM \
303	ICE \
304	z \
305	cppunit
306
307gb_Library_FILENAMES := \
308	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \
309	$(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
310	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
311	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \
312	$(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
313	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \
314	$(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \
315	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \
316	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \
317	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \
318
319
320gb_Library_LAYER := \
321	$(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \
322	$(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \
323	$(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \
324	$(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \
325	$(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \
326	$(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \
327	$(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \
328	$(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \
329	$(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \
330
331define gb_Library_get_rpath
332-Wl,-z,origin '-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \
333'-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)'
334endef
335
336define gb_Library_Library_platform
337$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1))
338
339endef
340
341
342# StaticLibrary class
343
344gb_StaticLibrary_DEFS :=
345gb_StaticLibrary_SYSPRE := lib
346gb_StaticLibrary_PLAINEXT := .a
347gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT)
348
349gb_StaticLibrary_FILENAMES := \
350	$(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \
351	$(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \
352
353gb_StaticLibrary_StaticLibrary_platform =
354
355
356# Executable class
357
358gb_Executable_EXT :=
359
360gb_Executable_LAYER := \
361	$(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \
362	$(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \
363	$(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \
364	$(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \
365	$(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \
366
367
368define gb_Executable_get_rpath
369'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \
370-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)
371endef
372
373define gb_Executable_Executable_platform
374$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1))
375
376endef
377
378
379# CppunitTest class
380
381gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
382gb_CppunitTest_SYSPRE := libtest_
383gb_CppunitTest_EXT := .so
384gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT)
385gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename)
386
387define gb_CppunitTest_CppunitTest_platform
388$(call gb_LinkTarget_get_target,$(2)) : RPATH :=
389
390endef
391
392# JunitTest class
393
394define gb_JunitTest_JunitTest_platform
395$(call gb_JunitTest_get_target,$(1)) : DEFS := \
396	-Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/openoffice.org3/program/soffice}" \
397    -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \
398    -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \
399
400endef
401
402# SdiTarget class
403
404gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
405
406# SrsPartMergeTarget
407
408gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
409
410# SrsPartTarget class
411
412gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc
413gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET)
414
415define gb_SrsPartTarget__command_dep
416$(call gb_Helper_abbreviate_dirs,\
417	$(gb_GCCP) \
418		-MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \
419		$(INCLUDE) \
420		$(DEFS) \
421		-c -x c++-header $(2) \
422		-o $(call gb_SrsPartTarget_get_dep_target,$(1)))
423endef
424
425
426# ComponentTarget
427
428gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib
429gb_Library_COMPONENTPREFIXES := \
430    OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \
431    URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \
432    NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \
433
434# UnoApiTarget
435
436gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc
437gb_UnoApiTarget_IDLCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET)
438gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge
439gb_UnoApiTarget_REGMERGECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET)
440gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare
441gb_UnoApiTarget_REGCOMPARECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET)
442gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker
443gb_UnoApiTarget_CPPUMAKERCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET)
444gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview
445gb_UnoApiTarget_REGVIEWCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET)
446
447# vim: set noet sw=4 ts=4:
448