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