blob: 1d3753ed353281872e74ad73d9af9c10e2ea5280 [file] [log] [blame]
ohair92de5662012-04-10 08:22:03 -07001#
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 MACOSX. 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
53 PLATFORM_SRC = $(BUILDDIR)/../src/solaris
54endif # PLATFORM_SRC
55
56PLATFORM_SRC_MACOS = $(BUILDDIR)/../src/macosx
57
58# BSD build pulls its platform sources from the solaris tree.
59JAVA_SRCDIR_LIST = src/$(PLATFORM) src/solaris src/share
60NATIVE_SRCDIR_LIST = src/$(PLATFORM) src/solaris src/share
61
62# Platform specific closed sources
63ifndef OPENJDK
64 ifndef CLOSED_PLATFORM_SRC
65 CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris
66 endif
67endif
68
69# platform specific include files
70PLATFORM_INCLUDE_NAME = $(OS_NAME)
71PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
72
73# suffix used for make dependencies files.
74DEPEND_SUFFIX = d
75# The suffix applied to the library name for FDLIBM
76FDDLIBM_SUFFIX = a
77# The suffix applied to scripts (.bat for windows, nothing for unix)
78SCRIPT_SUFFIX =
79# CC compiler object code output directive flag value
80CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
81CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
82
83#
84# Default optimization
85#
86
87ifndef OPTIMIZATION_LEVEL
88 ifeq ($(PRODUCT), java)
89 OPTIMIZATION_LEVEL = HIGHER
90 else
91 OPTIMIZATION_LEVEL = LOWER
92 endif
93endif
94ifndef FASTDEBUG_OPTIMIZATION_LEVEL
95 FASTDEBUG_OPTIMIZATION_LEVEL = LOWER
96endif
97
98# For macosx use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
99# <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers>
100CC_OPT/NONE =
101CC_OPT/LOWER = -Os
102CC_OPT/HIGHER = -Os
103CC_OPT/HIGHEST = -Os
104
105CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
106
107# For all platforms, do not omit the frame pointer register usage.
108# We need this frame pointer to make it easy to walk the stacks.
109# This should be the default on X86, but ia64 and amd64 may not have this
110# as the default.
111CFLAGS_REQUIRED_amd64 += -m64 -fno-omit-frame-pointer -D_LITTLE_ENDIAN
112LDFLAGS_COMMON_amd64 += -m64
113CFLAGS_REQUIRED_i586 += -m32 -fno-omit-frame-pointer -D_LITTLE_ENDIAN
114LDFLAGS_COMMON_i586 += -m32
115CFLAGS_REQUIRED_ia64 += -m64 -fno-omit-frame-pointer -D_LITTLE_ENDIAN
116CFLAGS_REQUIRED_sparcv9 += -m64 -mcpu=v9
117LDFLAGS_COMMON_sparcv9 += -m64 -mcpu=v9
118CFLAGS_REQUIRED_sparc += -m32 -mcpu=v9
119LDFLAGS_COMMON_sparc += -m32 -mcpu=v9
120CFLAGS_REQUIRED_arm += -fsigned-char -D_LITTLE_ENDIAN
121CFLAGS_REQUIRED_ppc += -fsigned-char -D_BIG_ENDIAN
122ifeq ($(ZERO_BUILD), true)
123 CFLAGS_REQUIRED = $(ZERO_ARCHFLAG)
124 ifeq ($(ZERO_ENDIANNESS), little)
125 CFLAGS_REQUIRED += -D_LITTLE_ENDIAN
126 endif
127 LDFLAGS_COMMON += $(ZERO_ARCHFLAG)
128else ifeq ($(ARCH), universal)
129 CFLAGS_REQUIRED += -arch i386 -arch x86_64 -D_LITTLE_ENDIAN
130 LDFLAGS_COMMON += -arch i386 -arch x86_64
131else
132 CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
133 LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH))
134endif
135# 16-byte stack re-alignment on 32-bit Darwin
136CFLAGS_REQUIRED_i586 += -mstackrealign
137
138OTHER_CFLAGS = \
139 -F/System/Library/Frameworks/JavaVM.framework/Frameworks \
140 -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks
141
142#
143# Selection of warning messages
144#
145GCC_INHIBIT = -Wno-unused -Wno-parentheses
146GCC_STYLE =
147GCC_WARNINGS = -W -Wall $(GCC_STYLE) $(GCC_INHIBIT)
148
149#
150# Treat compiler warnings as errors, if warnings not allowed
151#
152ifeq ($(COMPILER_WARNINGS_FATAL),true)
153 GCC_WARNINGS += -Werror
154endif
155
156#
157# Misc compiler options
158#
159ifneq ($(ARCH),ppc)
160 CFLAGS_COMMON = -fno-strict-aliasing
161endif
162PIC_CODE_LARGE = -fPIC
163PIC_CODE_SMALL = -fpic
164GLOBAL_KPIC = $(PIC_CODE_LARGE)
165CFLAGS_COMMON += $(GLOBAL_KPIC) $(GCC_WARNINGS)
166ifeq ($(ARCH), amd64)
167 CFLAGS_COMMON += -pipe
168endif
169
170# BSD 64bit machines use Dwarf2, which can be HUGE, have fastdebug use -g1
171DEBUG_FLAG = -g
172ifeq ($(FASTDEBUG), true)
173 ifeq ($(ARCH_DATA_MODEL), 64)
174 DEBUG_FLAG = -g1
175 endif
176endif
177
178# DEBUG_BINARIES overrides everything, use full -g debug information
179ifeq ($(DEBUG_BINARIES), true)
180 DEBUG_FLAG = -g
181 CFLAGS_REQUIRED += $(DEBUG_FLAG)
182endif
183
184CFLAGS_OPT = $(CC_OPT)
185CFLAGS_DBG = $(DEBUG_FLAG)
186CFLAGS_COMMON += $(CFLAGS_REQUIRED)
187
188CXXFLAGS_COMMON = $(GLOBAL_KPIC) -DCC_NOEX $(GCC_WARNINGS)
189CXXFLAGS_OPT = $(CC_OPT)
190CXXFLAGS_DBG = $(DEBUG_FLAG)
191CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
192
193# FASTDEBUG: Optimize the code in the -g versions, gives us a faster debug java
194ifeq ($(FASTDEBUG), true)
195 CFLAGS_DBG += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
196 CXXFLAGS_DBG += $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
197endif
198
199CPP_ARCH_FLAGS = -DARCH='"$(ARCH)"'
200
201# Alpha arch does not like "alpha" defined (potential general arch cleanup issue here)
202ifneq ($(ARCH),alpha)
203 CPP_ARCH_FLAGS += -D$(ARCH)
204else
205 CPP_ARCH_FLAGS += -D_$(ARCH)_
206endif
207CPPFLAGS_COMMON = $(CPP_ARCH_FLAGS) -D_ALLBSD_SOURCE $(VERSION_DEFINES) \
208 -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_REENTRANT
209
210CPPFLAGS_COMMON += -DMACOSX
211
212ifeq ($(ARCH_DATA_MODEL), 64)
213CPPFLAGS_COMMON += -D_LP64=1
214endif
215
216CPPFLAGS_OPT = -DNDEBUG
217CPPFLAGS_DBG = -DDEBUG
218ifneq ($(PRODUCT), java)
219 CPPFLAGS_DBG += -DLOGGING
220endif
221
222# Libraries need to locate other libraries at runtime, and you can tell
223# a library where to look by way of the dynamic runpaths (RPATH or RUNPATH)
224# buried inside the .{so,dylib}. The {$ORIGIN,@loader_path/} says to look
225# relative to where the library itself is and it can be followed
226# with relative paths from that. By default we always look in
227# {$ORIGIN,@loader_path/}, optionally we add relative paths if the Makefile
228# sets LD_RUNPATH_EXTRAS to those relative paths.
229# Except on MacOS X we add a flag -z origin, not sure if this is necessary,
230# but doesn't seem to hurt.
231# The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
232# See 'man {dyld,rtld}' for more information.
233# Try: 'readelf -d lib*.so' to see these settings in a library.
234#
235LDFLAGS_COMMON += -Xlinker -rpath -Xlinker @loader_path/.
236LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=-Xlinker -rpath -Xlinker @loader_path/%)
237LDFLAGS_COMMON += -Xlinker -install_name -Xlinker @rpath/$(@F)
238
239#
240# -L paths for finding and -ljava
241#
242LDFLAGS_COMMON += -L$(LIBDIR)
243
244#
245# -static-libgcc is a gcc-3 flag to statically link libgcc, gcc-2.9x always
246# statically link libgcc but will print a warning with the flag. We don't
247# want the warning, so check gcc version first.
248#
249ifeq ($(CC_MAJORVER),3)
250 OTHER_LDFLAGS += -static-libgcc
251endif
252
253# Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
254# (See Rules.gmk) The gcc 5 compiler might have an option for this?
255AUTOMATIC_PCH_OPTION =
256
257#
258# Post Processing of libraries/executables
259#
260ifeq ($(VARIANT), OPT)
261 ifneq ($(NO_STRIP), true)
262 ifneq ($(DEBUG_BINARIES), true)
263 # Debug 'strip -S' leaves local function Elf symbols (better stack
264 # traces)
265 POST_STRIP_PROCESS = $(STRIP) -S
266 endif
267 endif
268endif
269
270#
271# Use: ld $(LD_MAPFILE_FLAG) mapfile *.o
272#
273LD_MAPFILE_FLAG = -Xlinker --version-script -Xlinker
274
275#
276# Support for Quantify.
277#
278ifdef QUANTIFY
279QUANTIFY_CMD = quantify
280QUANTIFY_OPTIONS = -cache-dir=/tmp/quantify -always-use-cache-dir=yes
281LINK_PRE_CMD = $(QUANTIFY_CMD) $(QUANTIFY_OPTIONS)
282endif
283
284# Darwin does not support linker map files.
285LDNOMAP=true
286
287#
288# Path and option to link against the VM, if you have to. Note that
289# there are libraries that link against only -ljava, but they do get
290# -L to the -ljvm, this is because -ljava depends on -ljvm, whereas
291# the library itself should not.
292#
293VM_NAME = server
294JVMLIB = -L$(LIBDIR)/server -L$(LIBDIR)/client -ljvm
295JAVALIB = -ljava $(JVMLIB)
296
297#
298# We want to privatize JVM symbols on Solaris. This is so the user can
299# write a function called FindClass and this should not override the
300# FindClass that is inside the JVM. At this point in time we are not
301# concerned with other JNI libraries because we hope that there will
302# not be as many clashes there.
303#
304PRIVATIZE_JVM_SYMBOLS = false
305
306USE_PTHREADS = true
307override ALT_CODESET_KEY = _NL_CTYPE_CODESET_NAME
308override AWT_RUNPATH =
309override HAVE_ALTZONE = false
310override HAVE_FILIOH = false
311override HAVE_GETHRTIME = false
312override HAVE_GETHRVTIME = false
313override HAVE_SIGIGNORE = true
314override LEX_LIBRARY = -lfl
315ifeq ($(STATIC_CXX),true)
316override LIBCXX = -Wl,-Bstatic -lstdc++ -lgcc -Wl,-Bdynamic
317else
318override LIBCXX = -lstdc++
319endif
320override LIBPOSIX4 =
321override LIBSOCKET =
322override LIBNSL =
323override LIBTHREAD =
324override LIBDL =
325override MOOT_PRIORITIES = true
326override NO_INTERRUPTIBLE_IO = true
327override OPENWIN_HOME = $(X11_PATH)
328override OPENWIN_LIB = $(OPENWIN_HOME)/lib
329override OTHER_M4FLAGS = -D__GLIBC__ -DGNU_ASSEMBLER
330override SUN_CMM_SUBDIR =
331override THREADS_FLAG = native
332override USE_GNU_M4 = true
333override USING_GNU_TAR = true
334override WRITE_LIBVERSION = false
335
336ifdef ALT_X11_PATH
337 X11_PATH = $(ALT_X11_PATH)
338else
339 X11_PATH = /usr/X11R6
340endif
341
342ifdef ALT_PACKAGE_PATH
343 PACKAGE_PATH = $(ALT_PACKAGE_PATH)
344else
345 PACKAGE_PATH = /opt/local
346endif
347
348# ALSA
349ifdef ALT_ALSA_LIB_PATH
350 ALSA_LIB_PATH = $(ALT_ALSA_LIB_PATH)
351else
352 ALSA_LIB_PATH = $(PACKAGE_PATH)/lib
353endif
354
355ifdef ALT_ALSA_HEADERS_PATH
356 ALSA_HEADERS_PATH = $(ALT_ALSA_HEADERS_PATH)
357else
358 ALSA_HEADERS_PATH = $(PACKAGE_PATH)/include
359endif
360
361# USE_EXECNAME forces the launcher to look up argv[0] on $PATH, and put the
362# resulting resolved absolute name of the executable in the environment
363# variable EXECNAME. That executable name is then used that to locate the
364# installation area.
365override USE_EXECNAME = true
366
367# If your platform has DPS, it will have Type1 fonts too, in which case
368# it is best to enable DPS support until such time as 2D's rasteriser
369# can fully handle Type1 fonts in all cases. Default is "yes".
370# HAVE_DPS should only be "no" if the platform has no DPS headers or libs
371# DPS (Displayable PostScript) is available on Solaris machines
372HAVE_DPS = no
373
374SYSTEM_ZLIB = true
375
376#
377# Japanese manpages
378#
379JA_SOURCE_ENCODING = eucJP
380JA_TARGET_ENCODINGS = UTF-8
381
382# Settings for the JDI - Serviceability Agent binding.
383
384HOTSPOT_SALIB_PATH = $(HOTSPOT_IMPORT_PATH)/jre/lib/$(LIBARCH)
385SALIB_NAME = $(LIB_PREFIX)saproc.$(LIBRARY_SUFFIX)
386
387# The JDI - Serviceability Agent binding is not currently supported
388# on ia64.
389ifeq ($(ARCH), ia64)
390 INCLUDE_SA = false
391else
392 INCLUDE_SA = true
393endif
394
395ifdef CROSS_COMPILE_ARCH
396 # X11 headers are not under /usr/include
397 OTHER_CFLAGS += -I$(OPENWIN_HOME)/include
398 OTHER_CXXFLAGS += -I$(OPENWIN_HOME)/include
399 OTHER_CPPFLAGS += -I$(OPENWIN_HOME)/include
400endif
401
402LIB_LOCATION ?= $(LIBDIR)