1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2000, 2010 Oracle and/or its affiliates.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # This file is part of OpenOffice.org.
11 # OpenOffice.org is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU Lesser General Public License version 3
13 # only, as published by the Free Software Foundation.
15 # OpenOffice.org is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Lesser General Public License version 3 for more details
19 # (a copy is included in the LICENSE file that accompanied this code).
21 # You should have received a copy of the GNU Lesser General Public License
22 # version 3 along with OpenOffice.org. If not, see
23 # <http://www.openoffice.org/license.html>
24 # for a copy of the LGPLv3 License.
26 #*************************************************************************
28 # generic mk file for gcc on unix systems
33 # default optimization level for product code
35 # architecture dependent flags for the C and C++ compiler that can be changed by
36 # exporting the variable ARCH_FLAGS="..." in the shell, which is used to start build
38 # position independent code switch
42 # filter for supressing verbose messages from linker
43 #not needed at the moment
44 #LINKOUTPUT_FILTER=" |& $(SOLARENV)/bin/msg_filter"
46 # _PTHREADS is needed for the stl
47 CDEFS
+=-D_PTHREADS
-D_REENTRANT
-DNEW_SOLAR
-D_USE_NAMESPACE
=1
49 # enable visibility define in "sal/types.h"
50 .IF
"$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE"
51 CDEFS
+= -DHAVE_GCC_VISIBILITY_FEATURE
52 .ENDIF
# "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE"
54 .IF
"$(HAVE_SFINAE_ANONYMOUS_BROKEN)" == "TRUE"
55 CDEFS
+= -DHAVE_SFINAE_ANONYMOUS_BROKEN
56 .ENDIF
# "$(HAVE_SFINAE_ANONYMOUS_BROKEN)" == "TRUE"
58 # this is a platform with JAVA support
59 .IF
"$(SOLAR_JAVA)"!=""
68 # name of C++ Compiler
73 CFLAGS_SYSBASE
:=-isystem
$(SYSBASE
)$/usr
$/include
74 CXX
+:=$(CFLAGS_SYSBASE
)
75 CC
+:=$(CFLAGS_SYSBASE
)
76 .ENDIF
# "$(SYSBASE)"!=""
77 CFLAGS
+=-fmessage-length
=0 -c
79 # flags to enable build with symbols
80 CFLAGSENABLESYMBOLS
=-g
82 # flags for the C++ Compiler
83 CFLAGSCC
= -pipe
$(ARCH_FLAGS
)
84 # Flags for enabling exception handling
85 CFLAGSEXCEPTIONS
=-fexceptions
87 .IF
"$(COM_GCC_IS_CLANG)" != "TRUE"
88 CFLAGSEXCEPTIONS
+=-fno-enforce-eh-specs
91 # Flags for disabling exception handling
92 CFLAGS_NO_EXCEPTIONS
=-fno-exceptions
94 # -fpermissive should be removed as soon as possible
95 CFLAGSCXX
= -pipe
$(ARCH_FLAGS
)
96 .IF
"$(HAVE_THREADSAFE_STATICS)" != "TRUE"
97 CFLAGSCXX
+= -fno-threadsafe-statics
99 .IF
"$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE" && "$(HAVE_GCC_VISIBILITY_BROKEN)" != "TRUE"
100 CFLAGSCXX
+=-fvisibility-inlines-hidden
101 .ENDIF
# "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE"
102 .IF
"$(HAVE_CXX0X)" == "TRUE"
103 CFLAGSCXX
+=-std
=gnu
++0x
104 .IF
"$(GCCNUMVER)" <= "000400059999"
105 CFLAGSCXX
+=-Wno-deprecated-declarations
107 .ENDIF
# "$(HAVE_CXX0X)" == "TRUE"
109 .IF
"$(PRODUCT)"!="full"
111 CFLAGSCXX
+= -D_GLIBCXX_DEBUG
114 # Compiler flags for compiling static object in multi threaded environment with graphical user interface
116 # Compiler flags for compiling static object in multi threaded environment with character user interface
118 # Compiler flags for compiling shared object in multi threaded environment with graphical user interface
119 CFLAGSSLOGUIMT
=$(PICSWITCH
)
120 # Compiler flags for compiling shared object in multi threaded environment with character user interface
121 CFLAGSSLOCUIMT
=$(PICSWITCH
)
122 # Compiler flags for profiling
124 # Compiler flags for debugging
128 GCCNUMVERSION_CMD
=-dumpversion
$(PIPEERROR
) $(AWK
) -v num
=true
-f
$(SOLARENV
)/bin
/getcompver.awk
129 GCCNUMVER
:=$(shell @
-$(CXX
) $(GCCNUMVERSION_CMD
))
131 # Compiler flags for enabling optimizations
133 CFLAGSOPT
=$(CDEFAULTOPT
) # optimizing for products
134 .IF
"$(GCCNUMVER)" <= "000400059999"
135 #At least SLED 10.2 gcc 4.3 overly agressively optimizes uno::Sequence into
136 #junk, so only strict-alias on >= 4.6.0
137 CFLAGSOPT
+=-fno-strict-aliasing
139 .ELSE
# "$(PRODUCT)"!=""
140 CFLAGSOPT
= # no optimizing for non products
141 .ENDIF
# "$(PRODUCT)"!=""
143 # Compiler flags for disabling optimizations
145 # Compiler flags for describing the output path
148 # -Wshadow does not work for C with nested uses of pthread_cleanup_push:
149 CFLAGSWARNBOTH
=-Wall
-Wextra
-Wendif-labels
150 CFLAGSWARNCC
=$(CFLAGSWARNBOTH
) -Wdeclaration-after-statement
151 CFLAGSWARNCXX
=$(CFLAGSWARNBOTH
) -Wshadow
-Wno-ctor-dtor-privacy
152 CFLAGSWALLCC
=$(CFLAGSWARNCC
)
153 CFLAGSWALLCXX
=$(CFLAGSWARNCXX
)
154 CFLAGSWERRCC
=-Werror
-DLIBO_WERROR
156 .IF
"$(COM_GCC_IS_CLANG)" != "TRUE"
157 # Only GCC 4.6 has a fix for <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302>
158 # "-Wnon-virtual-dtor should't complain of protected dtor" and supports #pragma
159 # GCC diagnostic push/pop required e.g. in cppuhelper/propertysetmixin.hxx to
160 # silence warnings about a protected, non-virtual dtor in a class with virtual
161 # members and friends:
162 .IF
"$(GCCNUMVER)" <= "000400059999"
163 CFLAGSWARNCXX
+= -Wno-non-virtual-dtor
165 CFLAGSWARNCXX
+= -Wnon-virtual-dtor
168 CFLAGSWARNCXX
+= -Wnon-virtual-dtor
171 COMPILER_WARN_ERRORS
=TRUE
173 # switches for dynamic and static linking
174 STATIC
= -Wl
,-Bstatic
175 DYNAMIC
= -Wl
,-Bdynamic
181 # default linker flags
183 LINKFLAGS_SYSBASE
:=-Wl
,--sysroot
=$(SYSBASE
)
184 .ENDIF
# "$(SYSBASE)"!=""
186 # The DT RPATH value is used first, before any other path, specifically before
187 # the path defined in the LD_LIBRARY_PATH environment variable. This is
188 # problematic since it does not allow the user to overwrite the value.
189 # Therefore DT_RPATH is deprecated. The introduction of the new variant,
190 # DT_RUNPATH, corrects this oversight by requiring the value is used after the
191 # path in LD_LIBRARY_PATH.
193 # The linker option --enable-new-dtags must be used to also add DT_RUNPATH
194 # entry. This will cause both, DT_RPATH and DT_RUNPATH entries, to be created
196 LINKFLAGSDEFS
*=-Wl
,-z
,defs
197 LINKFLAGSRUNPATH_URELIB
=-Wl
,-z
,origin -Wl
,-rpath
,\''$$ORIGIN'\',--enable-new-dtags
198 LINKFLAGSRUNPATH_UREBIN
=-Wl
,-z
,origin -Wl
,-rpath
,\''$$ORIGIN/../lib:$$ORIGIN'\',--enable-new-dtags
199 #TODO: drop $ORIGIN once no URE executable is also shipped in OOo
200 LINKFLAGSRUNPATH_OOO
=-Wl
,-z
,origin -Wl
,-rpath
,\''$$ORIGIN:$$ORIGIN/../ure-link/lib'\',--enable-new-dtags
201 LINKFLAGSRUNPATH_SDKBIN
=-Wl
,-z
,origin -Wl
,-rpath
,\''$$ORIGIN/../../ure-link/lib'\',--enable-new-dtags
202 LINKFLAGSRUNPATH_OXT
=
203 LINKFLAGSRUNPATH_NONE
=
204 # flag -Wl,-z,noexecstack sets the NX bit on the stack
205 LINKFLAGS
=-Wl
,-z
,noexecstack
-Wl
,-z
,combreloc
$(LINKFLAGSDEFS
) $(LINKFLAGS_SYSBASE
)
206 .IF
"$(HAVE_LD_BSYMBOLIC_FUNCTIONS)" == "TRUE"
207 LINKFLAGS
+= -Wl
,-Bsymbolic-functions
-Wl
,--dynamic-list-cpp-new
-Wl
,--dynamic-list-cpp-typeinfo
210 # linker flags for linking applications
211 LINKFLAGSAPPGUI
= -Wl
,-export-dynamic \
212 -Wl
,-rpath-link
,$(LB
):$(SOLARLIBDIR
):$(SYSBASE
)/lib
:$(SYSBASE
)/usr
/lib
213 LINKFLAGSAPPCUI
= -Wl
,-export-dynamic \
214 -Wl
,-rpath-link
,$(LB
):$(SOLARLIBDIR
):$(SYSBASE
)/lib
:$(SYSBASE
)/usr
/lib
216 # linker flags for linking shared libraries
217 LINKFLAGSSHLGUI
= -shared
218 LINKFLAGSSHLCUI
= -shared
225 # linker flags for optimization (symbol hashtable)
226 # for now, applied to symbol scoped libraries, only
227 LINKFLAGSOPTIMIZE
*=-Wl
,-O1
228 LINKVERSIONMAPFLAG
=$(LINKFLAGSOPTIMIZE
) -Wl
,--version-script
232 # Sequence of libs does matter !
236 # default objectfilenames to link
242 .IF
"$(ALLOC)" == "TCMALLOC"
243 STDLIBGUIMT
+=-ltcmalloc
244 STDLIBCUIMT
+=-ltcmalloc
245 STDSHLGUIMT
+=-ltcmalloc
246 STDSHLCUIMT
+=-ltcmalloc
249 .IF
"$(ALLOC)" == "JEMALLOC"
250 STDLIBGUIMT
+=-ljemalloc
251 STDLIBCUIMT
+=-ljemalloc
252 STDSHLGUIMT
+=-ljemalloc
253 STDSHLCUIMT
+=-ljemalloc
256 .IF
"$(HAVE_LD_HASH_STYLE)" == "TRUE"
257 LINKFLAGS
+= -Wl
,--hash-style
=$(WITH_LINKER_HASH_STYLE
)
260 # libraries for linking applications
261 STDLIBGUIMT
+=-Wl
,--as-needed
$(DL_LIB
) $(PTHREAD_LIBS
) -lm
-Wl
,--no-as-needed
262 STDLIBCUIMT
+=-Wl
,--as-needed
$(DL_LIB
) $(PTHREAD_LIBS
) -lm
-Wl
,--no-as-needed
263 # libraries for linking shared libraries
264 STDSHLGUIMT
+=-Wl
,--as-needed
$(DL_LIB
) $(PTHREAD_LIBS
) -lm
-Wl
,--no-as-needed
265 STDSHLCUIMT
+=-Wl
,--as-needed
$(DL_LIB
) $(PTHREAD_LIBS
) -lm
-Wl
,--no-as-needed
267 X11LINK_DYNAMIC
= -Wl
,--as-needed
-lXext
-lX11
-Wl
,--no-as-needed
269 LIBSALCPPRT
*=-Wl
,--whole-archive
-lsalcpprt
-Wl
,--no-whole-archive
271 # name of library manager
275 # tool for generating import libraries
283 RCFLAGS
=-fo
$@
$(RCFILES
)
288 # platform specific identifier for shared libs