xref: /trunk/main/solenv/inc/unxlng.mk (revision 3e6a53ec4966bc78e4eb80339b6629fb1dcd11be) !
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
22
23
24# generic mk file for unxlng (unix linux glibc)
25ASM*=
26AFLAGS*=
27SOLAR_JAVA*=
28# default optimization level for product code
29CDEFAULTOPT*=-O2
30# architecture dependent flags for the C and C++ compiler that can be changed by
31# exporting the variable ARCH_FLAGS="..." in the shell, which is used to start build
32ARCH_FLAGS*=
33# position independent code switch
34PICSWITCH*:=-fpic
35JAVAFLAGSDEBUG=-g
36
37# filter for suppressing verbose messages from linker
38#not needed at the moment
39#LINKOUTPUT_FILTER=" |& $(SOLARENV)/bin/msg_filter"
40
41# _PTHREADS is needed for the stl
42CDEFS+=-DGLIBC=2 -D_PTHREADS -D_REENTRANT -DNEW_SOLAR -D_USE_NAMESPACE=1
43CDEFS+=-DBOOST_DETAIL_NO_CONTAINER_FWD
44
45# enable visibility define in "sal/types.h"
46.IF "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE"
47CDEFS += -DHAVE_GCC_VISIBILITY_FEATURE
48.ENDIF # "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE"
49
50# this is a platform with JAVA support
51.IF "$(SOLAR_JAVA)"!=""
52JAVADEF=-DSOLAR_JAVA
53.IF "$(debug)"==""
54JAVA_RUNTIME=-ljava
55.ELSE
56JAVA_RUNTIME=-ljava_g
57.ENDIF
58.ENDIF
59
60# name of C++ Compiler
61CXX*=g++
62# name of C Compiler
63CC*=gcc
64.IF "$(SYSBASE)"!=""
65CFLAGS_SYSBASE:=--sysroot=$(SYSBASE)
66CXX+:=$(CFLAGS_SYSBASE)
67CC+:=$(CFLAGS_SYSBASE)
68.ENDIF          # "$(SYSBASE)"!=""
69CFLAGS+=-fmessage-length=0 -c
70
71# flags to enable build with symbols; required for crashdump feature
72.IF "$(ENABLE_SYMBOLS)"=="SMALL"
73CFLAGSENABLESYMBOLS=-g1
74.ELSE
75CFLAGSENABLESYMBOLS=-g # was temporarily commented out, reenabled before Beta
76
77.ENDIF
78
79# flags for the C++ Compiler
80CFLAGSCC= -pipe $(ARCH_FLAGS)
81# Flags for enabling exception handling
82.IF "$(COM)"=="CLANG"
83CFLAGSEXCEPTIONS=-fexceptions
84.ELSE
85CFLAGSEXCEPTIONS=-fexceptions -fno-enforce-eh-specs
86.ENDIF
87# Flags for disabling exception handling
88CFLAGS_NO_EXCEPTIONS=-fno-exceptions
89
90# -fpermissive should be removed as soon as possible
91# C++11 is the lowest supported standard (matches the macOS floor).  Our old
92# code base still uses constructs deprecated in C++11 (notably std::auto_ptr and
93# dynamic exception specifications); those remain valid until C++17 and are kept
94# non-fatal via -Wno-error= below.  The compiler floor is GCC 4.8.5 (CentOS 7),
95# which fully supports gnu++11.
96CFLAGSCXX= -pipe $(ARCH_FLAGS) -std=gnu++11
97.IF "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE"
98CFLAGSCXX += -fvisibility-inlines-hidden
99.ENDIF # "$(HAVE_GCC_VISIBILITY_FEATURE)" == "TRUE"
100
101CFLAGS_CREATE_PCH=-x c++-header -I$(INCPCH) -DPRECOMPILED_HEADERS
102CFLAGS_USE_PCH=-I$(SLO)$/pch -DPRECOMPILED_HEADERS -Winvalid-pch
103CFLAGS_USE_EXCEPTIONS_PCH=-I$(SLO)$/pch_ex -DPRECOMPILED_HEADERS -Winvalid-pch
104
105# Compiler flags for compiling static object in multi threaded environment with graphical user interface
106CFLAGSOBJGUIMT=
107# Compiler flags for compiling static object in multi threaded environment with character user interface
108CFLAGSOBJCUIMT=
109# Compiler flags for compiling shared object in multi threaded environment with graphical user interface
110CFLAGSSLOGUIMT=$(PICSWITCH)
111# Compiler flags for compiling shared object in multi threaded environment with character user interface
112CFLAGSSLOCUIMT=$(PICSWITCH)
113# Compiler flags for profiling
114CFLAGSPROF=
115# Compiler flags for debugging
116CFLAGSDEBUG=-g
117CFLAGSDBGUTIL=
118# Compiler flags for enabling optimizations
119.IF "$(PRODUCT)"!=""
120CFLAGSOPT=$(CDEFAULTOPT) -fno-strict-aliasing       # optimizing for products
121.ELSE   # "$(PRODUCT)"!=""
122CFLAGSOPT=                              # no optimizing for non products
123.ENDIF  # "$(PRODUCT)"!=""
124# Compiler flags for disabling optimizations
125CFLAGSNOOPT=-O0
126# Compiler flags for describing the output path
127CFLAGSOUTOBJ=-o
128
129# -Wshadow does not work for C with nested uses of pthread_cleanup_push:
130CFLAGSWARNCC=-Wall -Wextra -Wendif-labels
131CFLAGSWARNCXX=$(CFLAGSWARNCC) -Wshadow -Wno-ctor-dtor-privacy \
132    -Wno-non-virtual-dtor
133CFLAGSWALLCC=$(CFLAGSWARNCC)
134CFLAGSWALLCXX=$(CFLAGSWARNCXX)
135# Keep -Werror, but do not let the C++11 dialect's deprecation/narrowing
136# warnings (std::auto_ptr, dynamic exception specs, braced-init narrowing) break
137# the build.  Mirrors the macOS handling in unxmacc.mk.
138CFLAGSWERRCC=-Werror -Wno-error=deprecated -Wno-error=deprecated-declarations -Wno-error=narrowing
139
140# Once all modules on this platform compile without warnings, set
141# COMPILER_WARN_ERRORS=TRUE here instead of setting MODULES_WITH_WARNINGS (see
142# settings.mk):
143MODULES_WITH_WARNINGS :=
144
145# switches for dynamic and static linking
146STATIC      = -Wl,-Bstatic
147DYNAMIC     = -Wl,-Bdynamic
148
149# name of linker
150LINK*=$(CXX)
151LINKC*=$(CC)
152
153# default linker flags
154.IF "$(SYSBASE)"!=""
155LINKFLAGS_SYSBASE:=-Wl,--sysroot=$(SYSBASE)
156.ENDIF          # "$(SYSBASE)"!=""
157LINKFLAGSDEFS*=-Wl,-z,defs
158LINKFLAGSRUNPATH_URELIB=-Wl,-rpath,\''$$ORIGIN'\'
159LINKFLAGSRUNPATH_UREBIN=-Wl,-rpath,\''$$ORIGIN'\'
160#LINKFLAGSRUNPATH_UREBIN=-Wl,-rpath,\''$$ORIGIN/../lib:$$ORIGIN'\'
161    #TODO: drop $ORIGIN once no URE executable is also shipped in OOo
162LINKFLAGSRUNPATH_OOO=-Wl,-rpath,\''$$ORIGIN'\'
163LINKFLAGSRUNPATH_SDK=-Wl,-rpath,\''$$ORIGIN'\'
164LINKFLAGSRUNPATH_BRAND=-Wl,-rpath,\''$$ORIGIN'\'
165#LINKFLAGSRUNPATH_OOO=-Wl,-rpath,\''$$ORIGIN:$$ORIGIN/../ure-link/lib'\'
166#LINKFLAGSRUNPATH_SDK=-Wl,-rpath,\''$$ORIGIN/../../ure-link/lib'\'
167#LINKFLAGSRUNPATH_BRAND=-Wl,-rpath,\''$$ORIGIN:$$ORIGIN/../basis-link/program:$$ORIGIN/../basis-link/ure-lin
168LINKFLAGSRUNPATH_OXT=
169LINKFLAGSRUNPATH_BOXT=-Wl,-rpath,\''$$ORIGIN'\'
170#LINKFLAGSRUNPATH_BOXT=-Wl,-rpath,\''$$ORIGIN/../../../basis-link/program'\'
171LINKFLAGSRUNPATH_NONE=
172LINKFLAGS=-Wl,-z,combreloc $(LINKFLAGSDEFS) $(LINKFLAGS_SYSBASE)
173.IF "$(HAVE_LD_BSYMBOLIC_FUNCTIONS)"  == "TRUE"
174LINKFLAGS += -Wl,-Bsymbolic-functions -Wl,--dynamic-list-cpp-new -Wl,--dynamic-list-cpp-typeinfo
175.ENDIF
176
177# linker flags for linking applications
178LINKFLAGSAPPGUI= -Wl,-export-dynamic -Wl,--noinhibit-exec \
179    -Wl,-rpath-link,$(LB):$(SOLARLIBDIR):$(SYSBASE)/lib:$(SYSBASE)/usr/lib
180LINKFLAGSAPPCUI= -Wl,-export-dynamic -Wl,--noinhibit-exec \
181    -Wl,-rpath-link,$(LB):$(SOLARLIBDIR):$(SYSBASE)/lib:$(SYSBASE)/usr/lib
182
183# linker flags for linking shared libraries
184LINKFLAGSSHLGUI= -shared
185LINKFLAGSSHLCUI= -shared
186
187LINKFLAGSTACK=
188LINKFLAGSPROF=
189LINKFLAGSDEBUG=-g
190LINKFLAGSOPT=
191
192# linker flags for optimization (symbol hashtable)
193# for now, applied to symbol scoped libraries, only
194LINKFLAGSOPTIMIZE*=-Wl,-O1
195LINKVERSIONMAPFLAG=$(LINKFLAGSOPTIMIZE) -Wl,--version-script
196
197SONAME_SWITCH=-Wl,-h
198
199# Sequence of libs does matter !
200
201STDLIBCPP=-lstdc++
202
203# default objectfilenames to link
204STDOBJVCL=$(L)$/salmain.o
205STDOBJGUI=
206STDSLOGUI=
207STDOBJCUI=
208STDSLOCUI=
209
210.IF "$(ALLOC)" == "TCMALLOC"
211STDLIBGUIMT+=-ltcmalloc
212STDLIBCUIMT+=-ltcmalloc
213STDSHLGUIMT+=-ltcmalloc
214STDSHLCUIMT+=-ltcmalloc
215.ENDIF
216
217.IF "$(ALLOC)" == "JEMALLOC"
218STDLIBGUIMT+=-ljemalloc
219STDLIBCUIMT+=-ljemalloc
220STDSHLGUIMT+=-ljemalloc
221STDSHLCUIMT+=-ljemalloc
222.ENDIF
223
224.IF "$(HAVE_LD_HASH_STYLE)"  == "TRUE"
225LINKFLAGS += -Wl,--hash-style=both
226.ELSE
227LINKFLAGS += -Wl,-zdynsort
228.ENDIF
229
230.IF "$(HAVE_LD_UNDEFINED_VERSION)" == "TRUE"
231LINKFLAGS += -Wl,--undefined-version
232.ENDIF
233
234# libraries for linking applications
235STDLIBGUIMT+=-Wl,--as-needed -ldl -lpthread -lm -Wl,--no-as-needed
236STDLIBCUIMT+=-Wl,--as-needed -ldl -lpthread -lm -Wl,--no-as-needed
237# libraries for linking shared libraries
238STDSHLGUIMT+=-Wl,--as-needed -ldl -lpthread -lm -Wl,--no-as-needed
239STDSHLCUIMT+=-Wl,--as-needed -ldl -lpthread -lm -Wl,--no-as-needed
240
241X11LINK_DYNAMIC = -Wl,--as-needed -lXext -lX11 -Wl,--no-as-needed
242
243LIBSALCPPRT*=-Wl,--whole-archive -lsalcpprt -Wl,--no-whole-archive
244
245#FILLUPARC=$(STATIC) -lsupc++ $(DYNAMIC)
246
247# name of library manager
248LIBMGR*=ar
249LIBFLAGS=-r
250
251# tool for generating import libraries
252IMPLIB=
253IMPLIBFLAGS=
254
255MAPSYM=
256MAPSYMFLAGS=
257
258RC=irc
259RCFLAGS=-fo$@ $(RCFILES)
260RCLINK=
261RCLINKFLAGS=
262RCSETVERSION=
263
264# platform specific identifier for shared libs
265DLLPRE=lib
266DLLPOST=.so
267PCHPOST=.gch
268