blob: 9ecdd4d7156e18483b6d28e2593d64c18b4e042b [file] [log] [blame]
duke6e45e102007-12-01 00:00:00 +00001#
xdonod10b8cf2008-07-02 12:55:45 -07002# Copyright 1999-2008 Sun Microsystems, Inc. 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
7# published by the Free Software Foundation. Sun designates this
8# particular file as subject to the "Classpath" exception as provided
9# by Sun in the LICENSE file that accompanied this code.
10#
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#
21# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22# CA 95054 USA or visit www.sun.com if you need additional information or
23# have any questions.
24#
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#
78# Default HPI libraries. Build will build only native, unless
79# overriden at the make command line. This makes it convenient for
80# people doing, say, a pthreads port -- they can create a posix
81# directory here, and say "gnumake HPIS=posix" at the top
82# level.
83#
84HPIS = native
85
86#
87# Default optimization
88#
duke6e45e102007-12-01 00:00:00 +000089
ohair850fb252008-07-30 19:40:57 -070090ifndef OPTIMIZATION_LEVEL
91 ifeq ($(PRODUCT), java)
92 OPTIMIZATION_LEVEL = HIGHER
93 else
94 OPTIMIZATION_LEVEL = LOWER
95 endif
duke6e45e102007-12-01 00:00:00 +000096endif
97
ohair850fb252008-07-30 19:40:57 -070098CC_OPT/NONE =
99CC_OPT/LOWER = -O2
100CC_OPT/HIGHER = -O3
101CC_OPT/HIGHEST = -O3
102
103CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
104
duke6e45e102007-12-01 00:00:00 +0000105# For all platforms, do not omit the frame pointer register usage.
106# We need this frame pointer to make it easy to walk the stacks.
107# This should be the default on X86, but ia64 and amd64 may not have this
108# as the default.
109CFLAGS_REQUIRED_amd64 += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
110CFLAGS_REQUIRED_i586 += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
111CFLAGS_REQUIRED_ia64 += -fno-omit-frame-pointer -D_LITTLE_ENDIAN
112CFLAGS_REQUIRED_sparcv9 += -m64 -mcpu=v9
113LDFLAGS_COMMON_sparcv9 += -m64 -mcpu=v9
114CFLAGS_REQUIRED_sparc += -m32 -mcpu=v9
115LDFLAGS_COMMON_sparc += -m32 -mcpu=v9
116CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
117LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH))
118
ohair8df39292009-01-31 17:31:21 -0800119# If this is a --hash-style=gnu system, use --hash-style=both
120# The gnu .hash section won't work on some Linux systems like SuSE 10.
121_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | $(GREP) -- '--hash-style=gnu')
122ifneq ($(_HAS_HASH_STYLE_GNU),)
123 LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
124endif
125LDFLAGS_COMMON += $(LDFLAGS_HASH_STYLE)
126
duke6e45e102007-12-01 00:00:00 +0000127#
128# Selection of warning messages
129#
130GCC_INHIBIT = -Wno-unused -Wno-parentheses
131GCC_STYLE =
132GCC_WARNINGS = -W -Wall $(GCC_STYLE) $(GCC_INHIBIT)
133
134#
135# Treat compiler warnings as errors, if warnings not allowed
136#
137ifeq ($(COMPILER_WARNINGS_FATAL),true)
138 GCC_WARNINGS += -Werror
139endif
140
141#
142# Misc compiler options
143#
144ifeq ($(ARCH),ppc)
145 CFLAGS_COMMON = -fsigned-char
146else # ARCH
147 CFLAGS_COMMON = -fno-strict-aliasing
148endif # ARCH
149PIC_CODE_LARGE = -fPIC
150PIC_CODE_SMALL = -fpic
151GLOBAL_KPIC = $(PIC_CODE_LARGE)
ohairab4f1212008-07-27 18:42:57 -0700152CFLAGS_COMMON += $(GLOBAL_KPIC) $(GCC_WARNINGS)
duke6e45e102007-12-01 00:00:00 +0000153ifeq ($(ARCH), amd64)
ohairab4f1212008-07-27 18:42:57 -0700154 CFLAGS_COMMON += -pipe
duke6e45e102007-12-01 00:00:00 +0000155endif
156
157# Linux 64bit machines use Dwarf2, which can be HUGE, have fastdebug use -g1
158DEBUG_FLAG = -g
159ifeq ($(FASTDEBUG), true)
160 ifeq ($(ARCH_DATA_MODEL), 64)
161 DEBUG_FLAG = -g1
162 endif
163endif
164
ohair850fb252008-07-30 19:40:57 -0700165CFLAGS_OPT = $(CC_OPT)
duke6e45e102007-12-01 00:00:00 +0000166CFLAGS_DBG = $(DEBUG_FLAG)
167CFLAGS_COMMON += $(CFLAGS_REQUIRED)
168
169CXXFLAGS_COMMON = $(GLOBAL_KPIC) -DCC_NOEX $(GCC_WARNINGS)
ohair850fb252008-07-30 19:40:57 -0700170CXXFLAGS_OPT = $(CC_OPT)
duke6e45e102007-12-01 00:00:00 +0000171CXXFLAGS_DBG = $(DEBUG_FLAG)
172CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
173
174# FASTDEBUG: Optimize the code in the -g versions, gives us a faster debug java
175ifeq ($(FASTDEBUG), true)
ohair850fb252008-07-30 19:40:57 -0700176 CFLAGS_DBG += $(CC_OPT/LOWER)
177 CXXFLAGS_DBG += $(CC_OPT/LOWER)
duke6e45e102007-12-01 00:00:00 +0000178endif
179
180CPPFLAGS_COMMON = -D$(ARCH) -DARCH='"$(ARCH)"' -DLINUX $(VERSION_DEFINES) \
181 -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT
182
183ifeq ($(ARCH_DATA_MODEL), 64)
184CPPFLAGS_COMMON += -D_LP64=1
185endif
186
187CPPFLAGS_OPT =
188CPPFLAGS_DBG = -DDEBUG
ohair850fb252008-07-30 19:40:57 -0700189ifneq ($(PRODUCT), java)
190 CPPFLAGS_DBG += -DLOGGING
191endif
duke6e45e102007-12-01 00:00:00 +0000192
193ifdef LIBRARY
194 # Libraries need to locate other libraries at runtime, and you can tell
195 # a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
196 # buried inside the .so. The $ORIGIN says to look relative to where
197 # the library itself is and it can be followed with relative paths from
198 # that. By default we always look in $ORIGIN, optionally we add relative
199 # paths if the Makefile sets LD_RUNPATH_EXTRAS to those relative paths.
200 # On Linux we add a flag -z origin, not sure if this is necessary, but
201 # doesn't seem to hurt.
202 # The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
203 # Try: 'readelf -d lib*.so' to see these settings in a library.
204 #
205 LDFLAGS_COMMON += -Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$ORIGIN
206 LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$ORIGIN/%)
207endif
208
209EXTRA_LIBS += -lc
210
211LDFLAGS_DEFS_OPTION = -z defs
212LDFLAGS_COMMON += $(LDFLAGS_DEFS_OPTION)
213
214#
215# -L paths for finding and -ljava
216#
217LDFLAGS_OPT = -Xlinker -O1
218LDFLAGS_COMMON += -L$(LIBDIR)/$(LIBARCH)
219LDFLAGS_COMMON += -Wl,-soname=$(LIB_PREFIX)$(LIBRARY).$(LIBRARY_SUFFIX)
220
221#
222# -static-libgcc is a gcc-3 flag to statically link libgcc, gcc-2.9x always
223# statically link libgcc but will print a warning with the flag. We don't
224# want the warning, so check gcc version first.
225#
226CC_VER_MAJOR := $(shell $(CC) -dumpversion | $(SED) 's/egcs-//' | $(CUT) -d'.' -f1)
227ifeq ("$(CC_VER_MAJOR)", "3")
228OTHER_LDFLAGS += -static-libgcc
229endif
230
231# Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
232# (See Rules.gmk) The gcc 5 compiler might have an option for this?
233AUTOMATIC_PCH_OPTION =
234
235#
236# Post Processing of libraries/executables
237#
238ifeq ($(VARIANT), OPT)
239 ifneq ($(NO_STRIP), true)
240 # Debug 'strip -g' leaves local function Elf symbols (better stack traces)
241 POST_STRIP_PROCESS = $(STRIP) -g
242 endif
243endif
244
245#
246# Use: ld $(LD_MAPFILE_FLAG) mapfile *.o
247#
248LD_MAPFILE_FLAG = -Xlinker --version-script -Xlinker
249
250#
251# Support for Quantify.
252#
253ifdef QUANTIFY
254QUANTIFY_CMD = quantify
255QUANTIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
256LINK_PRE_CMD = $(QUANTIFY_CMD) $(QUANTIFY_OPTIONS)
257endif
258
259#
260# Path and option to link against the VM, if you have to. Note that
261# there are libraries that link against only -ljava, but they do get
262# -L to the -ljvm, this is because -ljava depends on -ljvm, whereas
263# the library itself should not.
264#
265VM_NAME = server
266JVMLIB = -L$(LIBDIR)/$(LIBARCH)/$(VM_NAME) -ljvm
267JAVALIB = -ljava $(JVMLIB)
268
269#
270# We want to privatize JVM symbols on Solaris. This is so the user can
271# write a function called FindClass and this should not override the
272# FindClass that is inside the JVM. At this point in time we are not
273# concerned with other JNI libraries because we hope that there will
274# not be as many clashes there.
275#
276PRIVATIZE_JVM_SYMBOLS = false
277
278USE_PTHREADS = true
279override ALT_CODESET_KEY = _NL_CTYPE_CODESET_NAME
280override AWT_RUNPATH =
281override HAVE_ALTZONE = false
282override HAVE_FILIOH = false
283override HAVE_GETHRTIME = false
284override HAVE_GETHRVTIME = false
285override HAVE_SIGIGNORE = true
286override LEX_LIBRARY = -lfl
287ifeq ($(STATIC_CXX),true)
288override LIBCXX = -Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic
289else
290override LIBCXX = -lstdc++
291endif
292override LIBPOSIX4 =
293override LIBSOCKET =
294override LIBTHREAD =
295override MOOT_PRIORITIES = true
296override NO_INTERRUPTIBLE_IO = true
297override OPENWIN_HOME = /usr/X11R6
298ifeq ($(ARCH), amd64)
299override OPENWIN_LIB = $(OPENWIN_HOME)/lib64
300else
301override OPENWIN_LIB = $(OPENWIN_HOME)/lib
302endif
303override OTHER_M4FLAGS = -D__GLIBC__ -DGNU_ASSEMBLER
304override SUN_CMM_SUBDIR =
305override THREADS_FLAG = native
306override USE_GNU_M4 = true
307override USING_GNU_TAR = true
308override WRITE_LIBVERSION = false
309
310# USE_EXECNAME forces the launcher to look up argv[0] on $PATH, and put the
311# resulting resolved absolute name of the executable in the environment
312# variable EXECNAME. That executable name is then used that to locate the
313# installation area.
314override USE_EXECNAME = true
315
316# If your platform has DPS, it will have Type1 fonts too, in which case
317# it is best to enable DPS support until such time as 2D's rasteriser
318# can fully handle Type1 fonts in all cases. Default is "yes".
319# HAVE_DPS should only be "no" if the platform has no DPS headers or libs
320# DPS (Displayable PostScript) is available on Solaris machines
321HAVE_DPS = no
322
323#
324# Japanese manpages
325#
326JA_SOURCE_ENCODING = eucJP
327JA_TARGET_ENCODINGS = eucJP
328
329# Settings for the JDI - Serviceability Agent binding.
330HOTSPOT_SALIB_PATH = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
331SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
332
333# The JDI - Serviceability Agent binding is not currently supported
334# on Linux-ia64.
335ifeq ($(ARCH), ia64)
336 INCLUDE_SA = false
337else
338 INCLUDE_SA = true
339endif
340