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