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