blob: 515691dd29303280dc047fd04e975e12584c6d1c [file] [log] [blame]
duke6e45e102007-12-01 00:00:00 +00001#
dholmes70a4d1a2011-03-16 18:54:50 -04002# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
duke6e45e102007-12-01 00:00:00 +00003# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# This code is free software; you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 2 only, as
ohair2283b9d2010-05-25 15:58:33 -07007# published by the Free Software Foundation. Oracle designates this
duke6e45e102007-12-01 00:00:00 +00008# particular file as subject to the "Classpath" exception as provided
ohair2283b9d2010-05-25 15:58:33 -07009# by Oracle in the LICENSE file that accompanied this code.
duke6e45e102007-12-01 00:00:00 +000010#
11# This code is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14# version 2 for more details (a copy is included in the LICENSE file that
15# accompanied this code).
16#
17# You should have received a copy of the GNU General Public License version
18# 2 along with this work; if not, write to the Free Software Foundation,
19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20#
ohair2283b9d2010-05-25 15:58:33 -070021# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22# or visit www.oracle.com if you need additional information or have any
23# questions.
duke6e45e102007-12-01 00:00:00 +000024#
25
26#
27# Makefile to specify compiler flags for programs and libraries
28# targeted to Linux. Should not contain any rules.
29#
30# WARNING: This file is shared with other workspaces.
31# So when it includes other files, it must use JDK_TOPDIR.
32#
33
34# Warning: the following variables are overriden by Defs.gmk. Set
35# values will be silently ignored:
36# CFLAGS (set $(OTHER_CFLAGS) instead)
37# CPPFLAGS (set $(OTHER_CPPFLAGS) instead)
38# CXXFLAGS (set $(OTHER_CXXFLAGS) instead)
39# LDFLAGS (set $(OTHER_LDFAGS) instead)
40# LDLIBS (set $(EXTRA_LIBS) instead)
41# LDLIBS_COMMON (set $(EXTRA_LIBS) instead)
42
43# Get shared JDK settings
44include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
45
46# Part of INCREMENTAL_BUILD mechanism.
47# Compiler emits things like: path/file.o: file.h
48# We want something like: relative_path/file.o relative_path/file.d: file.h
49CC_DEPEND = -MM
50CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)& $(dir $@)$*.$(DEPEND_SUFFIX)!g'
51
52ifndef PLATFORM_SRC
ohair26e0af62008-03-04 09:52:54 -080053 PLATFORM_SRC = $(BUILDDIR)/../src/solaris
duke6e45e102007-12-01 00:00:00 +000054endif # PLATFORM_SRC
55
56# Platform specific closed sources
57ifndef OPENJDK
58 ifndef CLOSED_PLATFORM_SRC
ohair26e0af62008-03-04 09:52:54 -080059 CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris
duke6e45e102007-12-01 00:00:00 +000060 endif
61endif
62
63# platform specific include files
64PLATFORM_INCLUDE_NAME = $(PLATFORM)
65PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
66
67# suffix used for make dependencies files.
68DEPEND_SUFFIX = d
69# The suffix applied to the library name for FDLIBM
70FDDLIBM_SUFFIX = a
71# The suffix applied to scripts (.bat for windows, nothing for unix)
72SCRIPT_SUFFIX =
73# CC compiler object code output directive flag value
74CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
75CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
76
77#
duke6e45e102007-12-01 00:00:00 +000078# Default optimization
79#
duke6e45e102007-12-01 00:00:00 +000080
ohair850fb252008-07-30 19:40:57 -070081ifndef OPTIMIZATION_LEVEL
82 ifeq ($(PRODUCT), java)
83 OPTIMIZATION_LEVEL = HIGHER
84 else
85 OPTIMIZATION_LEVEL = LOWER
86 endif
duke6e45e102007-12-01 00:00:00 +000087endif
ohairb99e3e32009-03-31 16:10:31 -070088ifndef FASTDEBUG_OPTIMIZATION_LEVEL
89 FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
90endif
duke6e45e102007-12-01 00:00:00 +000091
ohair850fb252008-07-30 19:40:57 -070092CC_OPT/NONE =
93CC_OPT/LOWER = -O2
94CC_OPT/HIGHER = -O3
95CC_OPT/HIGHEST = -O3
96
97CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
98
duke6e45e102007-12-01 00:00:00 +000099# For all platforms, do not omit the frame pointer register usage.
100# We need this frame pointer to make it easy to walk the stacks.
101# This should be the default on X86, but ia64 and amd64 may not have this
102# as the default.
103CFLAGS_REQUIRED_amd64 += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
104CFLAGS_REQUIRED_i586 += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
105CFLAGS_REQUIRED_ia64 += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
106CFLAGS_REQUIRED_sparcv9 += -m64 -mcpu=v9
107LDFLAGS_COMMON_sparcv9 += -m64 -mcpu=v9
108CFLAGS_REQUIRED_sparc += -m32 -mcpu=v9
109LDFLAGS_COMMON_sparc += -m32 -mcpu=v9
dholmes70a4d1a2011-03-16 18:54:50 -0400110CFLAGS_REQUIRED_arm += -fsigned-char -D_LITTLE_ENDIAN
111CFLAGS_REQUIRED_ppc += -fsigned-char -D_BIG_ENDIAN
gbenson24e3a5d2009-10-15 13:27:59 +0100112ifeq ($(ZERO_BUILD), true)
113 CFLAGS_REQUIRED = $(ZERO_ARCHFLAG)
114 ifeq ($(ZERO_ENDIANNESS), little)
115 CFLAGS_REQUIRED += -D_LITTLE_ENDIAN
116 endif
117 LDFLAGS_COMMON += $(ZERO_ARCHFLAG)
118else
119 CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
120 LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH))
121endif
duke6e45e102007-12-01 00:00:00 +0000122
ohair8df39292009-01-31 17:31:21 -0800123# If this is a --hash-style=gnu system, use --hash-style=both
124# The gnu .hash section won't work on some Linux systems like SuSE 10.
125_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | $(GREP) -- '--hash-style=gnu')
126ifneq ($(_HAS_HASH_STYLE_GNU),)
127 LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
128endif
129LDFLAGS_COMMON += $(LDFLAGS_HASH_STYLE)
130
duke6e45e102007-12-01 00:00:00 +0000131#
132# Selection of warning messages
133#
134GCC_INHIBIT = -Wno-unused -Wno-parentheses
135GCC_STYLE =
136GCC_WARNINGS = -W -Wall $(GCC_STYLE) $(GCC_INHIBIT)
137
138#
139# Treat compiler warnings as errors, if warnings not allowed
140#
141ifeq ($(COMPILER_WARNINGS_FATAL),true)
142 GCC_WARNINGS += -Werror
143endif
144
145#
146# Misc compiler options
147#
dholmes70a4d1a2011-03-16 18:54:50 -0400148ifneq ($(ARCH),ppc)
duke6e45e102007-12-01 00:00:00 +0000149 CFLAGS_COMMON = -fno-strict-aliasing
dholmes70a4d1a2011-03-16 18:54:50 -0400150endif
duke6e45e102007-12-01 00:00:00 +0000151PIC_CODE_LARGE = -fPIC
152PIC_CODE_SMALL = -fpic
153GLOBAL_KPIC = $(PIC_CODE_LARGE)
ohairab4f1212008-07-27 18:42:57 -0700154CFLAGS_COMMON += $(GLOBAL_KPIC) $(GCC_WARNINGS)
duke6e45e102007-12-01 00:00:00 +0000155ifeq ($(ARCH), amd64)
ohairab4f1212008-07-27 18:42:57 -0700156 CFLAGS_COMMON += -pipe
duke6e45e102007-12-01 00:00:00 +0000157endif
158
159# Linux 64bit machines use Dwarf2, which can be HUGE, have fastdebug use -g1
160DEBUG_FLAG = -g
161ifeq ($(FASTDEBUG), true)
162 ifeq ($(ARCH_DATA_MODEL), 64)
163 DEBUG_FLAG = -g1
164 endif
165endif
166
aphd46bd762009-04-17 15:56:20 +0100167# DEBUG_BINARIES overrides everything, use full -g debug information
168ifeq ($(DEBUG_BINARIES), true)
169 DEBUG_FLAG = -g
170 CFLAGS_REQUIRED += $(DEBUG_FLAG)
171endif
172
ohair850fb252008-07-30 19:40:57 -0700173CFLAGS_OPT = $(CC_OPT)
duke6e45e102007-12-01 00:00:00 +0000174CFLAGS_DBG = $(DEBUG_FLAG)
175CFLAGS_COMMON += $(CFLAGS_REQUIRED)
176
177CXXFLAGS_COMMON = $(GLOBAL_KPIC) -DCC_NOEX $(GCC_WARNINGS)
ohair850fb252008-07-30 19:40:57 -0700178CXXFLAGS_OPT = $(CC_OPT)
duke6e45e102007-12-01 00:00:00 +0000179CXXFLAGS_DBG = $(DEBUG_FLAG)
180CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
181
182# FASTDEBUG: Optimize the code in the -g versions, gives us a faster debug java
183ifeq ($(FASTDEBUG), true)
ohairb99e3e32009-03-31 16:10:31 -0700184 CFLAGS_DBG += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
185 CXXFLAGS_DBG += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
duke6e45e102007-12-01 00:00:00 +0000186endif
187
andrew2ed7e052010-06-03 18:49:35 +0100188CPP_ARCH_FLAGS = -DARCH='"$(ARCH)"'
189
190# Alpha arch does not like "alpha" defined (potential general arch cleanup issue here)
191ifneq ($(ARCH),alpha)
192 CPP_ARCH_FLAGS += -D$(ARCH)
193else
194 CPP_ARCH_FLAGS += -D_$(ARCH)_
195endif
196
197CPPFLAGS_COMMON = $(CPP_ARCH_FLAGS) -DLINUX $(VERSION_DEFINES) \
duke6e45e102007-12-01 00:00:00 +0000198 -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT
199
200ifeq ($(ARCH_DATA_MODEL), 64)
201CPPFLAGS_COMMON += -D_LP64=1
202endif
203
ohair5a916662009-07-08 09:11:24 -0700204CPPFLAGS_OPT = -DNDEBUG
duke6e45e102007-12-01 00:00:00 +0000205CPPFLAGS_DBG = -DDEBUG
ohair850fb252008-07-30 19:40:57 -0700206ifneq ($(PRODUCT), java)
207 CPPFLAGS_DBG += -DLOGGING
208endif
duke6e45e102007-12-01 00:00:00 +0000209
210ifdef LIBRARY
211 # Libraries need to locate other libraries at runtime, and you can tell
212 # a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
213 # buried inside the .so. The $ORIGIN says to look relative to where
214 # the library itself is and it can be followed with relative paths from
215 # that. By default we always look in $ORIGIN, optionally we add relative
216 # paths if the Makefile sets LD_RUNPATH_EXTRAS to those relative paths.
217 # On Linux we add a flag -z origin, not sure if this is necessary, but
218 # doesn't seem to hurt.
219 # The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
220 # Try: 'readelf -d lib*.so' to see these settings in a library.
221 #
dholmes70a4d1a2011-03-16 18:54:50 -0400222 Z_ORIGIN_FLAG/sparc = -Xlinker -z -Xlinker origin
223 Z_ORIGIN_FLAG/i586 = -Xlinker -z -Xlinker origin
224 Z_ORIGIN_FLAG/amd64 = -Xlinker -z -Xlinker origin
225 Z_ORIGIN_FLAG/ia64 = -Xlinker -z -Xlinker origin
226 Z_ORIGIN_FLAG/arm =
227 Z_ORIGIN_FLAG/ppc =
228 Z_ORIGIN_FLAG/zero = -Xlinker -z -Xlinker origin
229
230 LDFLAG_Z_ORIGIN = $(Z_ORIGIN_FLAG/$(ARCH_FAMILY))
231
232 LDFLAGS_COMMON += $(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN
233 LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=$(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN/%)
234
duke6e45e102007-12-01 00:00:00 +0000235endif
236
237EXTRA_LIBS += -lc
238
gbenson24e3a5d2009-10-15 13:27:59 +0100239LDFLAGS_DEFS_OPTION = -Xlinker -z -Xlinker defs
duke6e45e102007-12-01 00:00:00 +0000240LDFLAGS_COMMON += $(LDFLAGS_DEFS_OPTION)
241
242#
243# -L paths for finding and -ljava
244#
245LDFLAGS_OPT = -Xlinker -O1
246LDFLAGS_COMMON += -L$(LIBDIR)/$(LIBARCH)
247LDFLAGS_COMMON += -Wl,-soname=$(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
248
249#
250# -static-libgcc is a gcc-3 flag to statically link libgcc, gcc-2.9x always
251# statically link libgcc but will print a warning with the flag. We don't
252# want the warning, so check gcc version first.
253#
ohaire74b8592011-04-21 18:26:04 -0700254ifeq ($(CC_MAJORVER),3)
255 OTHER_LDFLAGS += -static-libgcc
duke6e45e102007-12-01 00:00:00 +0000256endif
257
258# Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
259# (See Rules.gmk) The gcc 5 compiler might have an option for this?
260AUTOMATIC_PCH_OPTION =
261
262#
263# Post Processing of libraries/executables
264#
265ifeq ($(VARIANT), OPT)
266 ifneq ($(NO_STRIP), true)
aphd46bd762009-04-17 15:56:20 +0100267 ifneq ($(DEBUG_BINARIES), true)
268 # Debug 'strip -g' leaves local function Elf symbols (better stack
269 # traces)
270 POST_STRIP_PROCESS = $(STRIP) -g
271 endif
duke6e45e102007-12-01 00:00:00 +0000272 endif
273endif
274
275#
276# Use: ld $(LD_MAPFILE_FLAG) mapfile *.o
277#
278LD_MAPFILE_FLAG = -Xlinker --version-script -Xlinker
279
280#
281# Support for Quantify.
282#
283ifdef QUANTIFY
284QUANTIFY_CMD = quantify
285QUANTIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
286LINK_PRE_CMD = $(QUANTIFY_CMD) $(QUANTIFY_OPTIONS)
287endif
288
289#
290# Path and option to link against the VM, if you have to. Note that
291# there are libraries that link against only -ljava, but they do get
292# -L to the -ljvm, this is because -ljava depends on -ljvm, whereas
293# the library itself should not.
294#
295VM_NAME = server
296JVMLIB = -L$(LIBDIR)/$(LIBARCH)/$(VM_NAME) -ljvm
297JAVALIB = -ljava $(JVMLIB)
298
299#
300# We want to privatize JVM symbols on Solaris. This is so the user can
301# write a function called FindClass and this should not override the
302# FindClass that is inside the JVM. At this point in time we are not
303# concerned with other JNI libraries because we hope that there will
304# not be as many clashes there.
305#
306PRIVATIZE_JVM_SYMBOLS = false
307
308USE_PTHREADS = true
309override ALT_CODESET_KEY = _NL_CTYPE_CODESET_NAME
310override AWT_RUNPATH =
311override HAVE_ALTZONE = false
312override HAVE_FILIOH = false
313override HAVE_GETHRTIME = false
314override HAVE_GETHRVTIME = false
315override HAVE_SIGIGNORE = true
316override LEX_LIBRARY = -lfl
317ifeq ($(STATIC_CXX),true)
318override LIBCXX = -Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic
319else
320override LIBCXX = -lstdc++
321endif
322override LIBPOSIX4 =
323override LIBSOCKET =
martind5089e02010-06-10 15:54:25 -0700324override LIBNSL =
duke6e45e102007-12-01 00:00:00 +0000325override LIBTHREAD =
326override MOOT_PRIORITIES = true
327override NO_INTERRUPTIBLE_IO = true
duke6e45e102007-12-01 00:00:00 +0000328ifeq ($(ARCH), amd64)
329override OPENWIN_LIB = $(OPENWIN_HOME)/lib64
330else
331override OPENWIN_LIB = $(OPENWIN_HOME)/lib
332endif
333override OTHER_M4FLAGS = -D__GLIBC__ -DGNU_ASSEMBLER
334override SUN_CMM_SUBDIR =
335override THREADS_FLAG = native
336override USE_GNU_M4 = true
337override USING_GNU_TAR = true
338override WRITE_LIBVERSION = false
339
340# USE_EXECNAME forces the launcher to look up argv[0] on $PATH, and put the
341# resulting resolved absolute name of the executable in the environment
342# variable EXECNAME. That executable name is then used that to locate the
343# installation area.
344override USE_EXECNAME = true
345
346# If your platform has DPS, it will have Type1 fonts too, in which case
347# it is best to enable DPS support until such time as 2D's rasteriser
348# can fully handle Type1 fonts in all cases. Default is "yes".
349# HAVE_DPS should only be "no" if the platform has no DPS headers or libs
350# DPS (Displayable PostScript) is available on Solaris machines
351HAVE_DPS = no
352
353#
354# Japanese manpages
355#
356JA_SOURCE_ENCODING = eucJP
357JA_TARGET_ENCODINGS = eucJP
358
359# Settings for the JDI - Serviceability Agent binding.
360HOTSPOT_SALIB_PATH = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
361SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
362
363# The JDI - Serviceability Agent binding is not currently supported
364# on Linux-ia64.
365ifeq ($(ARCH), ia64)
366 INCLUDE_SA = false
367else
368 INCLUDE_SA = true
369endif
370
dholmes70a4d1a2011-03-16 18:54:50 -0400371ifdef CROSS_COMPILE_ARCH
372 # X11 headers are not under /usr/include
373 OTHER_CFLAGS += -I$(OPENWIN_HOME)/include
374 OTHER_CXXFLAGS += -I$(OPENWIN_HOME)/include
375 OTHER_CPPFLAGS += -I$(OPENWIN_HOME)/include
376endif