blob: ca5f15971d5756f5dbdff5cc25b828a825887877 [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
kizune43045ca2012-04-04 20:31:50 +040056# Location of the various .properties files specific to Linux platform
57ifndef PLATFORM_PROPERTIES
58 PLATFORM_PROPERTIES = $(BUILDDIR)/../src/solaris/lib
59endif # PLATFORM_SRC
60
duke6e45e102007-12-01 00:00:00 +000061# Platform specific closed sources
62ifndef OPENJDK
63 ifndef CLOSED_PLATFORM_SRC
ohair26e0af62008-03-04 09:52:54 -080064 CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris
duke6e45e102007-12-01 00:00:00 +000065 endif
66endif
67
68# platform specific include files
69PLATFORM_INCLUDE_NAME = $(PLATFORM)
70PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
71
72# suffix used for make dependencies files.
73DEPEND_SUFFIX = d
74# The suffix applied to the library name for FDLIBM
75FDDLIBM_SUFFIX = a
76# The suffix applied to scripts (.bat for windows, nothing for unix)
77SCRIPT_SUFFIX =
78# CC compiler object code output directive flag value
79CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
duke6e45e102007-12-01 00:00:00 +000080
dcubed46b99222011-09-20 19:16:21 -070081# Default OBJCOPY comes from GNU Binutils on Linux:
82DEF_OBJCOPY=/usr/bin/objcopy
83ifdef CROSS_COMPILE_ARCH
84 # don't try to generate .debuginfo files when cross compiling
85 _JUNK_ := $(shell \
86 echo >&2 "INFO: cross compiling for ARCH $(CROSS_COMPILE_ARCH)," \
87 "skipping .debuginfo generation.")
88 OBJCOPY=
89else
90 OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY))
91 ifneq ($(ALT_OBJCOPY),)
92 _JUNK_ := $(shell echo >&2 "INFO: ALT_OBJCOPY=$(ALT_OBJCOPY)")
93 # disable .debuginfo support by setting ALT_OBJCOPY to a non-existent path
94 OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY))
95 endif
96endif
97
98ifdef LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
99# The setting of OBJCOPY above enables the JDK build to import
100# .debuginfo files from the HotSpot build. However, adding FDS
101# support to the JDK build will occur in phases so a different
102# make variable is used to indicate that a particular library
103# supports FDS.
104
105ifeq ($(OBJCOPY),)
106 _JUNK_ := $(shell \
107 echo >&2 "INFO: no objcopy cmd found so cannot create .debuginfo files.")
108else
109 _JUNK_ := $(shell \
110 echo >&2 "INFO: $(OBJCOPY) cmd found so will create .debuginfo files.")
111
112 # Library stripping policies for .debuginfo configs:
113 # all_strip - strips everything from the library
114 # min_strip - strips most stuff from the library; leaves minimum symbols
115 # no_strip - does not strip the library at all
116 #
117 # Oracle security policy requires "all_strip". A waiver was granted on
118 # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE.
119 #
120 DEF_STRIP_POLICY="min_strip"
121 ifeq ($(ALT_STRIP_POLICY),)
122 STRIP_POLICY=$(DEF_STRIP_POLICY)
123 else
124 STRIP_POLICY=$(ALT_STRIP_POLICY)
125 endif
126
127 _JUNK_ := $(shell \
128 echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
129endif
130endif
131
duke6e45e102007-12-01 00:00:00 +0000132#
duke6e45e102007-12-01 00:00:00 +0000133# Default optimization
134#
duke6e45e102007-12-01 00:00:00 +0000135
ohair850fb252008-07-30 19:40:57 -0700136ifndef OPTIMIZATION_LEVEL
137 ifeq ($(PRODUCT), java)
138 OPTIMIZATION_LEVEL = HIGHER
139 else
140 OPTIMIZATION_LEVEL = LOWER
141 endif
duke6e45e102007-12-01 00:00:00 +0000142endif
ohairb99e3e32009-03-31 16:10:31 -0700143ifndef FASTDEBUG_OPTIMIZATION_LEVEL
144 FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
145endif
duke6e45e102007-12-01 00:00:00 +0000146
ohair850fb252008-07-30 19:40:57 -0700147CC_OPT/NONE =
148CC_OPT/LOWER = -O2
149CC_OPT/HIGHER = -O3
150CC_OPT/HIGHEST = -O3
151
152CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
153
duke6e45e102007-12-01 00:00:00 +0000154# For all platforms, do not omit the frame pointer register usage.
155# We need this frame pointer to make it easy to walk the stacks.
156# This should be the default on X86, but ia64 and amd64 may not have this
157# as the default.
158CFLAGS_REQUIRED_amd64 += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
159CFLAGS_REQUIRED_i586 += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
160CFLAGS_REQUIRED_ia64 += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
161CFLAGS_REQUIRED_sparcv9 += -m64 -mcpu=v9
162LDFLAGS_COMMON_sparcv9 += -m64 -mcpu=v9
163CFLAGS_REQUIRED_sparc += -m32 -mcpu=v9
164LDFLAGS_COMMON_sparc += -m32 -mcpu=v9
dholmes70a4d1a2011-03-16 18:54:50 -0400165CFLAGS_REQUIRED_arm += -fsigned-char -D_LITTLE_ENDIAN
166CFLAGS_REQUIRED_ppc += -fsigned-char -D_BIG_ENDIAN
gbenson24e3a5d2009-10-15 13:27:59 +0100167ifeq ($(ZERO_BUILD), true)
168 CFLAGS_REQUIRED = $(ZERO_ARCHFLAG)
169 ifeq ($(ZERO_ENDIANNESS), little)
170 CFLAGS_REQUIRED += -D_LITTLE_ENDIAN
171 endif
172 LDFLAGS_COMMON += $(ZERO_ARCHFLAG)
173else
174 CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
175 LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH))
176endif
duke6e45e102007-12-01 00:00:00 +0000177
ohair8df39292009-01-31 17:31:21 -0800178# If this is a --hash-style=gnu system, use --hash-style=both
179# The gnu .hash section won't work on some Linux systems like SuSE 10.
180_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | $(GREP) -- '--hash-style=gnu')
181ifneq ($(_HAS_HASH_STYLE_GNU),)
182 LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
183endif
184LDFLAGS_COMMON += $(LDFLAGS_HASH_STYLE)
185
duke6e45e102007-12-01 00:00:00 +0000186#
187# Selection of warning messages
188#
189GCC_INHIBIT = -Wno-unused -Wno-parentheses
190GCC_STYLE =
191GCC_WARNINGS = -W -Wall $(GCC_STYLE) $(GCC_INHIBIT)
192
193#
194# Treat compiler warnings as errors, if warnings not allowed
195#
196ifeq ($(COMPILER_WARNINGS_FATAL),true)
197 GCC_WARNINGS += -Werror
198endif
199
200#
201# Misc compiler options
202#
dholmes70a4d1a2011-03-16 18:54:50 -0400203ifneq ($(ARCH),ppc)
duke6e45e102007-12-01 00:00:00 +0000204 CFLAGS_COMMON = -fno-strict-aliasing
dholmes70a4d1a2011-03-16 18:54:50 -0400205endif
duke6e45e102007-12-01 00:00:00 +0000206PIC_CODE_LARGE = -fPIC
207PIC_CODE_SMALL = -fpic
208GLOBAL_KPIC = $(PIC_CODE_LARGE)
ohairab4f1212008-07-27 18:42:57 -0700209CFLAGS_COMMON += $(GLOBAL_KPIC) $(GCC_WARNINGS)
duke6e45e102007-12-01 00:00:00 +0000210ifeq ($(ARCH), amd64)
ohairab4f1212008-07-27 18:42:57 -0700211 CFLAGS_COMMON += -pipe
duke6e45e102007-12-01 00:00:00 +0000212endif
213
214# Linux 64bit machines use Dwarf2, which can be HUGE, have fastdebug use -g1
215DEBUG_FLAG = -g
216ifeq ($(FASTDEBUG), true)
217 ifeq ($(ARCH_DATA_MODEL), 64)
218 DEBUG_FLAG = -g1
219 endif
220endif
221
aphd46bd762009-04-17 15:56:20 +0100222# DEBUG_BINARIES overrides everything, use full -g debug information
223ifeq ($(DEBUG_BINARIES), true)
224 DEBUG_FLAG = -g
225 CFLAGS_REQUIRED += $(DEBUG_FLAG)
226endif
227
ohair850fb252008-07-30 19:40:57 -0700228CFLAGS_OPT = $(CC_OPT)
duke6e45e102007-12-01 00:00:00 +0000229CFLAGS_DBG = $(DEBUG_FLAG)
230CFLAGS_COMMON += $(CFLAGS_REQUIRED)
231
232CXXFLAGS_COMMON = $(GLOBAL_KPIC) -DCC_NOEX $(GCC_WARNINGS)
ohair850fb252008-07-30 19:40:57 -0700233CXXFLAGS_OPT = $(CC_OPT)
duke6e45e102007-12-01 00:00:00 +0000234CXXFLAGS_DBG = $(DEBUG_FLAG)
235CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
236
237# FASTDEBUG: Optimize the code in the -g versions, gives us a faster debug java
238ifeq ($(FASTDEBUG), true)
ohairb99e3e32009-03-31 16:10:31 -0700239 CFLAGS_DBG += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
240 CXXFLAGS_DBG += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
duke6e45e102007-12-01 00:00:00 +0000241endif
242
andrew2ed7e052010-06-03 18:49:35 +0100243CPP_ARCH_FLAGS = -DARCH='"$(ARCH)"'
244
245# Alpha arch does not like "alpha" defined (potential general arch cleanup issue here)
246ifneq ($(ARCH),alpha)
247 CPP_ARCH_FLAGS += -D$(ARCH)
248else
249 CPP_ARCH_FLAGS += -D_$(ARCH)_
250endif
251
252CPPFLAGS_COMMON = $(CPP_ARCH_FLAGS) -DLINUX $(VERSION_DEFINES) \
duke6e45e102007-12-01 00:00:00 +0000253 -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT
254
255ifeq ($(ARCH_DATA_MODEL), 64)
256CPPFLAGS_COMMON += -D_LP64=1
257endif
258
ohair5a916662009-07-08 09:11:24 -0700259CPPFLAGS_OPT = -DNDEBUG
duke6e45e102007-12-01 00:00:00 +0000260CPPFLAGS_DBG = -DDEBUG
ohair850fb252008-07-30 19:40:57 -0700261ifneq ($(PRODUCT), java)
262 CPPFLAGS_DBG += -DLOGGING
263endif
duke6e45e102007-12-01 00:00:00 +0000264
265ifdef LIBRARY
266 # Libraries need to locate other libraries at runtime, and you can tell
267 # a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
268 # buried inside the .so. The $ORIGIN says to look relative to where
269 # the library itself is and it can be followed with relative paths from
270 # that. By default we always look in $ORIGIN, optionally we add relative
271 # paths if the Makefile sets LD_RUNPATH_EXTRAS to those relative paths.
272 # On Linux we add a flag -z origin, not sure if this is necessary, but
273 # doesn't seem to hurt.
274 # The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
275 # Try: 'readelf -d lib*.so' to see these settings in a library.
276 #
dholmes70a4d1a2011-03-16 18:54:50 -0400277 Z_ORIGIN_FLAG/sparc = -Xlinker -z -Xlinker origin
278 Z_ORIGIN_FLAG/i586 = -Xlinker -z -Xlinker origin
279 Z_ORIGIN_FLAG/amd64 = -Xlinker -z -Xlinker origin
280 Z_ORIGIN_FLAG/ia64 = -Xlinker -z -Xlinker origin
281 Z_ORIGIN_FLAG/arm =
282 Z_ORIGIN_FLAG/ppc =
283 Z_ORIGIN_FLAG/zero = -Xlinker -z -Xlinker origin
284
285 LDFLAG_Z_ORIGIN = $(Z_ORIGIN_FLAG/$(ARCH_FAMILY))
286
287 LDFLAGS_COMMON += $(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN
288 LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=$(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN/%)
289
duke6e45e102007-12-01 00:00:00 +0000290endif
291
292EXTRA_LIBS += -lc
293
gbenson24e3a5d2009-10-15 13:27:59 +0100294LDFLAGS_DEFS_OPTION = -Xlinker -z -Xlinker defs
duke6e45e102007-12-01 00:00:00 +0000295LDFLAGS_COMMON += $(LDFLAGS_DEFS_OPTION)
296
297#
298# -L paths for finding and -ljava
299#
300LDFLAGS_OPT = -Xlinker -O1
301LDFLAGS_COMMON += -L$(LIBDIR)/$(LIBARCH)
302LDFLAGS_COMMON += -Wl,-soname=$(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
303
304#
305# -static-libgcc is a gcc-3 flag to statically link libgcc, gcc-2.9x always
306# statically link libgcc but will print a warning with the flag. We don't
307# want the warning, so check gcc version first.
308#
ohaire74b8592011-04-21 18:26:04 -0700309ifeq ($(CC_MAJORVER),3)
310 OTHER_LDFLAGS += -static-libgcc
duke6e45e102007-12-01 00:00:00 +0000311endif
312
313# Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
314# (See Rules.gmk) The gcc 5 compiler might have an option for this?
315AUTOMATIC_PCH_OPTION =
316
317#
318# Post Processing of libraries/executables
319#
320ifeq ($(VARIANT), OPT)
321 ifneq ($(NO_STRIP), true)
aphd46bd762009-04-17 15:56:20 +0100322 ifneq ($(DEBUG_BINARIES), true)
323 # Debug 'strip -g' leaves local function Elf symbols (better stack
324 # traces)
325 POST_STRIP_PROCESS = $(STRIP) -g
326 endif
duke6e45e102007-12-01 00:00:00 +0000327 endif
328endif
329
330#
331# Use: ld $(LD_MAPFILE_FLAG) mapfile *.o
332#
333LD_MAPFILE_FLAG = -Xlinker --version-script -Xlinker
334
335#
336# Support for Quantify.
337#
338ifdef QUANTIFY
339QUANTIFY_CMD = quantify
340QUANTIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
341LINK_PRE_CMD = $(QUANTIFY_CMD) $(QUANTIFY_OPTIONS)
342endif
343
344#
345# Path and option to link against the VM, if you have to. Note that
346# there are libraries that link against only -ljava, but they do get
347# -L to the -ljvm, this is because -ljava depends on -ljvm, whereas
348# the library itself should not.
349#
350VM_NAME = server
351JVMLIB = -L$(LIBDIR)/$(LIBARCH)/$(VM_NAME) -ljvm
352JAVALIB = -ljava $(JVMLIB)
353
354#
355# We want to privatize JVM symbols on Solaris. This is so the user can
356# write a function called FindClass and this should not override the
357# FindClass that is inside the JVM. At this point in time we are not
358# concerned with other JNI libraries because we hope that there will
359# not be as many clashes there.
360#
361PRIVATIZE_JVM_SYMBOLS = false
362
363USE_PTHREADS = true
364override ALT_CODESET_KEY = _NL_CTYPE_CODESET_NAME
365override AWT_RUNPATH =
366override HAVE_ALTZONE = false
367override HAVE_FILIOH = false
368override HAVE_GETHRTIME = false
369override HAVE_GETHRVTIME = false
370override HAVE_SIGIGNORE = true
371override LEX_LIBRARY = -lfl
372ifeq ($(STATIC_CXX),true)
373override LIBCXX = -Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic
374else
375override LIBCXX = -lstdc++
376endif
377override LIBPOSIX4 =
378override LIBSOCKET =
martind5089e02010-06-10 15:54:25 -0700379override LIBNSL =
okutsu953b5b22011-10-05 15:13:40 +0900380override LIBSCF =
duke6e45e102007-12-01 00:00:00 +0000381override LIBTHREAD =
michaelm5ac8c152012-03-06 20:34:38 +0000382override LIBDL = -ldl
duke6e45e102007-12-01 00:00:00 +0000383override MOOT_PRIORITIES = true
384override NO_INTERRUPTIBLE_IO = true
duke6e45e102007-12-01 00:00:00 +0000385ifeq ($(ARCH), amd64)
386override OPENWIN_LIB = $(OPENWIN_HOME)/lib64
387else
388override OPENWIN_LIB = $(OPENWIN_HOME)/lib
389endif
390override OTHER_M4FLAGS = -D__GLIBC__ -DGNU_ASSEMBLER
391override SUN_CMM_SUBDIR =
392override THREADS_FLAG = native
393override USE_GNU_M4 = true
394override USING_GNU_TAR = true
395override WRITE_LIBVERSION = false
396
397# USE_EXECNAME forces the launcher to look up argv[0] on $PATH, and put the
398# resulting resolved absolute name of the executable in the environment
399# variable EXECNAME. That executable name is then used that to locate the
400# installation area.
401override USE_EXECNAME = true
402
403# If your platform has DPS, it will have Type1 fonts too, in which case
404# it is best to enable DPS support until such time as 2D's rasteriser
405# can fully handle Type1 fonts in all cases. Default is "yes".
406# HAVE_DPS should only be "no" if the platform has no DPS headers or libs
407# DPS (Displayable PostScript) is available on Solaris machines
408HAVE_DPS = no
409
410#
411# Japanese manpages
412#
413JA_SOURCE_ENCODING = eucJP
ogino55ad4162011-04-26 21:46:20 -0700414JA_TARGET_ENCODINGS = UTF-8
duke6e45e102007-12-01 00:00:00 +0000415
416# Settings for the JDI - Serviceability Agent binding.
417HOTSPOT_SALIB_PATH = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
418SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
dcubed46b99222011-09-20 19:16:21 -0700419SA_DEBUGINFO_NAME = $(LIB_PREFIX)saproc.debuginfo
duke6e45e102007-12-01 00:00:00 +0000420
421# The JDI - Serviceability Agent binding is not currently supported
422# on Linux-ia64.
423ifeq ($(ARCH), ia64)
424 INCLUDE_SA = false
425else
426 INCLUDE_SA = true
427endif
428
dholmes70a4d1a2011-03-16 18:54:50 -0400429ifdef CROSS_COMPILE_ARCH
430 # X11 headers are not under /usr/include
431 OTHER_CFLAGS += -I$(OPENWIN_HOME)/include
432 OTHER_CXXFLAGS += -I$(OPENWIN_HOME)/include
433 OTHER_CPPFLAGS += -I$(OPENWIN_HOME)/include
434endif