1 #
   2 # Copyright (c) 2011, 2020, 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 WIN_AWT_LIB := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt/awt.lib
  27 
  28 LIBAWT_DEFAULT_HEADER_DIRS := \
  29     libawt/awt/image \
  30     libawt/awt/image/cvutils \
  31     libawt/java2d \
  32     libawt/java2d/loops \
  33     libawt/java2d/pipe \
  34     #
  35 
  36 ################################################################################
  37 
  38 BUILD_LIBMLIB_CFLAGS := -D__USE_J2D_NAMES -D__MEDIALIB_OLD_NAMES -DMLIB_NO_LIBSUNMATH
  39 
  40 ifeq ($(call isTargetCpuBits, 64), true)
  41   BUILD_LIBMLIB_CFLAGS += -DMLIB_OS64BIT
  42 endif
  43 
  44 $(eval $(call SetupJdkLibrary, BUILD_LIBMLIB_IMAGE, \
  45     NAME := mlib_image, \
  46     EXTRA_SRC := common/awt/medialib, \
  47     EXCLUDE_FILES := mlib_c_ImageBlendTable.c, \
  48     EXCLUDE_SRC_PATTERNS := $(BUILD_LIBMLIB_EXCLUDE_SRC_PATTERNS), \
  49     OPTIMIZATION := HIGHEST, \
  50     CFLAGS := $(CFLAGS_JDKLIB) \
  51         $(BUILD_LIBMLIB_CFLAGS), \
  52     DISABLED_WARNINGS_gcc := unused-function, \
  53     LDFLAGS := $(LDFLAGS_JDKLIB) \
  54         $(call SET_SHARED_LIBRARY_ORIGIN), \
  55     LIBS := $(JDKLIB_LIBS), \
  56     LIBS_unix := $(LIBM) $(LIBDL), \
  57 ))
  58 
  59 $(BUILD_LIBMLIB_IMAGE): $(call FindLib, java.base, java)
  60 
  61 TARGETS += $(BUILD_LIBMLIB_IMAGE)
  62 
  63 ################################################################################
  64 
  65 LIBAWT_EXTRA_SRC := \
  66     common/awt/debug \
  67     $(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
  68     #
  69 
  70 ifeq ($(call isTargetOs, windows), true)
  71   LIBAWT_EXTRA_SRC += \
  72       $(TOPDIR)/src/$(MODULE)/share/native/common/awt/utility \
  73       $(TOPDIR)/src/$(MODULE)/share/native/common/font \
  74       $(TOPDIR)/src/$(MODULE)/share/native/common/java2d/opengl \
  75       $(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt/systemscale \
  76       #
  77 endif
  78 
  79 ifeq ($(call isTargetOs, linux macosx aix), true)
  80   LIBAWT_EXFILES += awt_Font.c CUPSfuncs.c fontpath.c X11Color.c
  81 endif
  82 
  83 ifeq ($(call isTargetOs, macosx), true)
  84   LIBAWT_EXFILES += initIDs.c awt/image/cvutils/img_colors.c
  85 endif
  86 
  87 ifeq ($(call isTargetOs, windows), true)
  88   LIBAWT_EXFILES += \
  89       java2d/d3d/D3DShaderGen.c \
  90       awt/image/cvutils/img_colors.c \
  91       #
  92 endif
  93 
  94 LIBAWT_EXTRA_HEADER_DIRS := \
  95     $(LIBAWT_DEFAULT_HEADER_DIRS) \
  96     $(call GetJavaHeaderDir, java.base) \
  97     libawt/awt/medialib \
  98     libawt/java2d/d3d \
  99     libawt/java2d/opengl \
 100     libawt/java2d/windows \
 101     libawt/windows \
 102     common/awt/medialib \
 103     libmlib_image \
 104     include \
 105     java.base:libjava \
 106     java.base:include \
 107     #
 108 
 109 LIBAWT_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES $(X_CFLAGS)
 110 
 111 LIBAWT_CFLAGS += -DMLIB_NO_LIBSUNMATH
 112 
 113 ifeq ($(call isTargetOs, windows), true)
 114   LIBAWT_CFLAGS += -EHsc -DUNICODE -D_UNICODE
 115   ifeq ($(call isTargetCpuBits, 64), true)
 116     LIBAWT_CFLAGS += -DMLIB_OS64BIT
 117   endif
 118 
 119   LIBAWT_RCFLAGS ?= -I$(TOPDIR)/src/java.base/windows/native/launcher/icons
 120   LIBAWT_VERSIONINFO_RESOURCE := $(TOPDIR)/src/$(MODULE)/windows/native/libawt/windows/awt.rc
 121 endif
 122 
 123 ifeq ($(call isTargetOs, linux), true)
 124   # FIXME: This is probably not what we want to do, but keep it now for compatibility.
 125   LIBAWT_CFLAGS += $(EXPORT_ALL_SYMBOLS)
 126 endif
 127 
 128 # Turn off all warnings for debug_mem.c This is needed because the specific warning
 129 # about initializing a declared 'extern' cannot be turned off individually. Only
 130 # applies to debug builds.
 131 ifeq ($(TOOLCHAIN_TYPE), gcc)
 132   BUILD_LIBAWT_debug_mem.c_CFLAGS := -w
 133   # This option improves performance of MaskFill in Java2D by 20% for some gcc
 134   LIBAWT_CFLAGS += -fgcse-after-reload
 135 endif
 136 
 137 $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \
 138     NAME := awt, \
 139     EXTRA_SRC := $(LIBAWT_EXTRA_SRC), \
 140     EXCLUDES := $(LIBAWT_EXCLUDES), \
 141     EXCLUDE_FILES := $(LIBAWT_EXFILES), \
 142     OPTIMIZATION := LOW, \
 143     CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_CFLAGS), \
 144     EXTRA_HEADER_DIRS := $(LIBAWT_EXTRA_HEADER_DIRS), \
 145     DISABLED_WARNINGS_gcc := sign-compare unused-result maybe-uninitialized \
 146         format-nonliteral parentheses unused-value unused-function, \
 147     DISABLED_WARNINGS_clang := logical-op-parentheses extern-initializer \
 148         sign-compare format-nonliteral, \
 149     DISABLED_WARNINGS_microsoft := 4244 4267 4996, \
 150     LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \
 151     LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \
 152     LDFLAGS_windows := -delayload:user32.dll -delayload:gdi32.dll \
 153         -delayload:shell32.dll -delayload:winmm.dll \
 154         -delayload:winspool.drv -delayload:imm32.dll \
 155         -delayload:ole32.dll -delayload:comdlg32.dll \
 156         -delayload:comctl32.dll -delayload:shlwapi.dll, \
 157     LIBS_unix := -ljvm -ljava $(LIBM), \
 158     LIBS_linux :=  $(LIBDL), \
 159     LIBS_aix := $(LIBDL),\
 160     LIBS_macosx := -lmlib_image \
 161         -framework Cocoa \
 162         -framework OpenGL \
 163         -framework JavaNativeFoundation \
 164         -framework JavaRuntimeSupport \
 165         -framework ApplicationServices \
 166         -framework AudioToolbox, \
 167     LIBS_windows := kernel32.lib user32.lib gdi32.lib winspool.lib \
 168         imm32.lib ole32.lib uuid.lib shell32.lib \
 169         comdlg32.lib winmm.lib comctl32.lib shlwapi.lib \
 170         delayimp.lib jvm.lib $(WIN_JAVA_LIB) advapi32.lib, \
 171     VERSIONINFO_RESOURCE := $(LIBAWT_VERSIONINFO_RESOURCE), \
 172     EXTRA_RCFLAGS := $(LIBAWT_RCFLAGS), \
 173 ))
 174 
 175 $(BUILD_LIBAWT): $(call FindLib, java.base, java)
 176 
 177 ifeq ($(call isTargetOs, macosx), true)
 178   $(BUILD_LIBAWT): $(BUILD_LIBMLIB_IMAGE)
 179 endif
 180 
 181 TARGETS += $(BUILD_LIBAWT)
 182 
 183 ################################################################################
 184 
 185 ifeq ($(call isTargetOs, windows macosx), false)
 186   ifeq ($(ENABLE_HEADLESS_ONLY), false)
 187 
 188     LIBAWT_XAWT_EXTRA_SRC := \
 189         common/awt \
 190         common/java2d \
 191         common/font \
 192         #
 193 
 194     LIBAWT_XAWT_EXCLUDES := medialib debug
 195 
 196     LIBAWT_XAWT_EXTRA_HEADER_DIRS := \
 197         $(LIBAWT_DEFAULT_HEADER_DIRS) \
 198         libawt_xawt/awt \
 199         include \
 200         common/awt/debug \
 201         common/awt/systemscale \
 202         common/font \
 203         common/java2d/opengl \
 204         common/java2d/x11 \
 205         #
 206 
 207     LIBAWT_XAWT_CFLAGS += -DXAWT -DXAWT_HACK \
 208         $(FONTCONFIG_CFLAGS) \
 209         $(CUPS_CFLAGS)
 210 
 211     ifeq ($(call isTargetOs, linux), true)
 212       ifeq ($(DISABLE_XRENDER), true)
 213         LIBAWT_XAWT_CFLAGS += -DDISABLE_XRENDER_BY_DEFAULT=true
 214       endif
 215     endif
 216 
 217     LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm
 218 
 219     ifeq ($(call isTargetOs, linux), true)
 220       LIBAWT_XAWT_LIBS += -lpthread
 221     endif
 222 
 223     ifeq ($(TOOLCHAIN_TYPE), gcc)
 224       # Turn off all warnings for the following files since they contain warnings
 225       # that cannot be turned of individually.
 226       # redefining a macro
 227       BUILD_LIBAWT_XAWT_gtk2_interface.c_CFLAGS := -w
 228       # comparison between pointer and integer
 229       BUILD_LIBAWT_XAWT_awt_Font.c_CFLAGS := -w
 230       # initializing a declared 'extern'
 231       BUILD_LIBAWT_XAWT_debug_mem.c_CFLAGS := -w
 232     endif
 233 
 234     $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_XAWT, \
 235         NAME := awt_xawt, \
 236         EXTRA_SRC := $(LIBAWT_XAWT_EXTRA_SRC), \
 237         EXTRA_HEADER_DIRS := $(LIBAWT_XAWT_EXTRA_HEADER_DIRS), \
 238         EXCLUDES := $(LIBAWT_XAWT_EXCLUDES), \
 239         OPTIMIZATION := LOW, \
 240         CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_XAWT_CFLAGS) \
 241             $(X_CFLAGS), \
 242         WARNINGS_AS_ERRORS_xlc := false, \
 243         DISABLED_WARNINGS_gcc := type-limits pointer-to-int-cast \
 244             unused-result maybe-uninitialized format \
 245             format-security int-to-pointer-cast parentheses \
 246             implicit-fallthrough undef unused-function, \
 247         DISABLED_WARNINGS_clang := parentheses format undef \
 248             logical-op-parentheses format-nonliteral int-conversion, \
 249         LDFLAGS := $(LDFLAGS_JDKLIB) \
 250             $(call SET_SHARED_LIBRARY_ORIGIN) \
 251             -L$(INSTALL_LIBRARIES_HERE), \
 252         LIBS :=  $(X_LIBS) $(LIBAWT_XAWT_LIBS), \
 253     ))
 254 
 255     $(BUILD_LIBAWT_XAWT): $(call FindLib, java.base, java)
 256 
 257     $(BUILD_LIBAWT_XAWT): $(BUILD_LIBAWT)
 258 
 259     TARGETS += $(BUILD_LIBAWT_XAWT)
 260 
 261   endif
 262 endif
 263 
 264 ################################################################################
 265 
 266 # The fast floor code loses precision.
 267 LCMS_CFLAGS=-DCMS_DONT_USE_FAST_FLOOR
 268 
 269 ifeq ($(USE_EXTERNAL_LCMS), true)
 270   # If we're using an external library, we'll just need the wrapper part.
 271   # By including it explicitly, all other files will be excluded.
 272   BUILD_LIBLCMS_INCLUDE_FILES := LCMS.c
 273   # If we're using an external library, we can't include our own SRC path
 274   # as includes, instead the system headers should be used.
 275   LIBLCMS_HEADERS_FROM_SRC := false
 276 else
 277   BUILD_LIBLCMS_INCLUDE_FILES :=
 278 endif
 279 
 280 ifeq ($(TOOLCHAIN_TYPE), clang)
 281  ifeq ($(TOOLCHAIN_VERSION), 10.1)
 282    # Work around an optimizer bug seen with Xcode 10.1, but fixed by 10.3
 283    BUILD_LIBLCMS_cmsopt.c_CFLAGS := -O0
 284  endif
 285 endif
 286 
 287 $(eval $(call SetupJdkLibrary, BUILD_LIBLCMS, \
 288     NAME := lcms, \
 289     INCLUDE_FILES := $(BUILD_LIBLCMS_INCLUDE_FILES), \
 290     OPTIMIZATION := HIGHEST, \
 291     CFLAGS := $(CFLAGS_JDKLIB) \
 292         $(LCMS_CFLAGS), \
 293     CFLAGS_windows := -DCMS_IS_WINDOWS_, \
 294     EXTRA_HEADER_DIRS := \
 295         common/awt/debug \
 296         libawt/java2d, \
 297     HEADERS_FROM_SRC := $(LIBLCMS_HEADERS_FROM_SRC), \
 298     DISABLED_WARNINGS_gcc := format-nonliteral type-limits \
 299         misleading-indentation undef unused-function stringop-truncation, \
 300     DISABLED_WARNINGS_clang := tautological-compare format-nonliteral undef, \
 301     DISABLED_WARNINGS_microsoft := 4819, \
 302     LDFLAGS := $(LDFLAGS_JDKLIB) \
 303         $(call SET_SHARED_LIBRARY_ORIGIN), \
 304     LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
 305     LIBS_unix := -lawt -ljvm -ljava $(LCMS_LIBS) $(LIBM), \
 306     LIBS_windows := $(WIN_AWT_LIB) $(WIN_JAVA_LIB), \
 307 ))
 308 
 309 TARGETS += $(BUILD_LIBLCMS)
 310 
 311 $(BUILD_LIBLCMS): $(BUILD_LIBAWT)
 312 
 313 ################################################################################
 314 
 315 # "DISABLED_WARNINGS_gcc := clobbered" rationale:
 316 # Suppress gcc warnings like "variable might be clobbered by 'longjmp'
 317 # or 'vfork'": this warning indicates that some variable is placed to
 318 # a register by optimized compiler and it's value might be lost on longjmp().
 319 # Recommended way to avoid such warning is to declare the variable as
 320 # volatile to prevent the optimization. However, this approach does not
 321 # work because we have to declare all variables as volatile in result.
 322 
 323 ifeq ($(USE_EXTERNAL_LIBJPEG), true)
 324   LIBJPEG_LIBS := -ljpeg
 325   BUILD_LIBJAVAJPEG_INCLUDE_FILES := \
 326       imageioJPEG.c \
 327       jpegdecoder.c
 328   # If we're using an external library, we can't include our own SRC path
 329   # as includes, instead the system headers should be used.
 330   LIBJPEG_HEADERS_FROM_SRC := false
 331 else
 332   LIBJPEG_LIBS :=
 333   BUILD_LIBJAVAJPEG_INCLUDE_FILES :=
 334 endif
 335 
 336 $(eval $(call SetupJdkLibrary, BUILD_LIBJAVAJPEG, \
 337     NAME := javajpeg, \
 338     INCLUDE_FILES := $(BUILD_LIBJAVAJPEG_INCLUDE_FILES), \
 339     OPTIMIZATION := HIGHEST, \
 340     CFLAGS := $(CFLAGS_JDKLIB), \
 341     HEADERS_FROM_SRC := $(LIBJPEG_HEADERS_FROM_SRC), \
 342     DISABLED_WARNINGS_gcc := clobbered implicit-fallthrough shift-negative-value, \
 343     LDFLAGS := $(LDFLAGS_JDKLIB) \
 344         $(call SET_SHARED_LIBRARY_ORIGIN), \
 345     LIBS := $(LIBJPEG_LIBS) $(JDKLIB_LIBS), \
 346     LIBS_windows := $(WIN_JAVA_LIB) jvm.lib, \
 347 ))
 348 
 349 $(BUILD_LIBJAVAJPEG): $(call FindLib, java.base, java)
 350 
 351 TARGETS += $(BUILD_LIBJAVAJPEG)
 352 
 353 ################################################################################
 354 
 355 # Mac and Windows only use the native AWT lib, do not build libawt_headless
 356 ifeq ($(call isTargetOs, windows macosx), false)
 357 
 358   LIBAWT_HEADLESS_EXTRA_SRC := \
 359       common/font \
 360       common/java2d \
 361       $(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
 362       #
 363 
 364   LIBAWT_HEADLESS_EXCLUDES := medialib
 365 
 366   LIBAWT_HEADLESS_EXTRA_HEADER_DIRS := \
 367       $(LIBAWT_DEFAULT_HEADER_DIRS) \
 368       common/awt/debug \
 369       common/font \
 370       common/java2d/opengl \
 371       #
 372 
 373   LIBAWT_HEADLESS_CFLAGS := $(CUPS_CFLAGS) $(FONTCONFIG_CFLAGS) $(X_CFLAGS) \
 374       -DHEADLESS=true
 375 
 376   $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_HEADLESS, \
 377       NAME := awt_headless, \
 378       EXTRA_SRC := $(LIBAWT_HEADLESS_EXTRA_SRC), \
 379       EXCLUDES := $(LIBAWT_HEADLESS_EXCLUDES), \
 380       OPTIMIZATION := LOW, \
 381       CFLAGS := $(CFLAGS_JDKLIB) \
 382           $(LIBAWT_HEADLESS_CFLAGS), \
 383       EXTRA_HEADER_DIRS := $(LIBAWT_HEADLESS_EXTRA_HEADER_DIRS), \
 384       DISABLED_WARNINGS_gcc := unused-function, \
 385       LDFLAGS := $(LDFLAGS_JDKLIB) \
 386           $(call SET_SHARED_LIBRARY_ORIGIN), \
 387       LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
 388       LIBS_unix := -lawt -ljvm -ljava, \
 389       LIBS_linux := $(LIBM) $(LIBDL), \
 390   ))
 391 
 392   $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
 393 
 394   TARGETS += $(BUILD_LIBAWT_HEADLESS)
 395 
 396 endif
 397 
 398 ################################################################################
 399 
 400 ifeq ($(FREETYPE_TO_USE), system)
 401   # For use by libfontmanager:
 402   LIBFREETYPE_CFLAGS := $(FREETYPE_CFLAGS)
 403   LIBFREETYPE_LIBS := $(FREETYPE_LIBS)
 404 else
 405   BUILD_LIBFREETYPE_HEADER_DIRS := $(TOPDIR)/src/$(MODULE)/share/native/libfreetype/include
 406   BUILD_LIBFREETYPE_CFLAGS := -DFT2_BUILD_LIBRARY $(EXPORT_ALL_SYMBOLS)
 407 
 408   # For use by libfontmanager:
 409   LIBFREETYPE_CFLAGS := -I$(BUILD_LIBFREETYPE_HEADER_DIRS)
 410   ifeq ($(call isTargetOs, windows), true)
 411     LIBFREETYPE_LIBS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfreetype/freetype.lib
 412     # freetype now requires you to manually define this (see ftconfig.h)
 413     BUILD_LIBFREETYPE_CFLAGS += -DDLL_EXPORT
 414   else
 415     LIBFREETYPE_LIBS := -lfreetype
 416   endif
 417 
 418   $(eval $(call SetupJdkLibrary, BUILD_LIBFREETYPE, \
 419       NAME := freetype, \
 420       OPTIMIZATION := HIGHEST, \
 421       CFLAGS := $(CFLAGS_JDKLIB) \
 422           $(BUILD_LIBFREETYPE_CFLAGS), \
 423       EXTRA_HEADER_DIRS := $(BUILD_LIBFREETYPE_HEADER_DIRS), \
 424       DISABLED_WARNINGS_microsoft := 4018 4267 4244 4312 4819, \
 425       DISABLED_WARNINGS_gcc := implicit-fallthrough cast-function-type bad-function-cast, \
 426       LDFLAGS := $(LDFLAGS_JDKLIB) \
 427           $(call SET_SHARED_LIBRARY_ORIGIN), \
 428   ))
 429 
 430   TARGETS += $(BUILD_LIBFREETYPE)
 431 endif
 432 
 433 ###########################################################################
 434 
 435 HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND
 436 
 437 # This is better than adding EXPORT_ALL_SYMBOLS
 438 ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
 439   HARFBUZZ_CFLAGS += -DHB_EXTERN=__attribute__\(\(visibility\(\"default\"\)\)\)
 440 else ifeq ($(TOOLCHAIN_TYPE), microsoft)
 441   HARFBUZZ_CFLAGS += -DHB_EXTERN=__declspec\(dllexport\)
 442 endif
 443 
 444 ifeq ($(call isTargetOs, windows), false)
 445   HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \
 446                       -DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H \
 447                       -DHB_NO_PRAGMA_GCC_DIAGNOSTIC
 448 endif
 449 ifeq ($(call isTargetOs, linux macosx), true)
 450   HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
 451 endif
 452 ifeq ($(call isTargetOs, macosx), true)
 453   HARFBUZZ_CFLAGS += -DHAVE_CORETEXT
 454 endif
 455 ifeq ($(call isTargetOs, macosx), false)
 456   LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-coretext.cc
 457 endif
 458 # hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later.
 459 LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-ft.cc
 460 
 461 LIBHARFBUZZ_CFLAGS += $(HARFBUZZ_CFLAGS)
 462 
 463 # For use by libfontmanager:
 464 ifeq ($(call isTargetOs, windows), true)
 465   LIBHARFBUZZ_LIBS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libharfbuzz/harfbuzz.lib
 466 else
 467   LIBHARFBUZZ_LIBS := -lharfbuzz
 468 endif
 469 
 470 LIBHARFBUZZ_EXTRA_HEADER_DIRS := \
 471     libharfbuzz/hb-ucdn \
 472     #
 473 
 474 LIBHARFBUZZ_OPTIMIZATION := HIGH
 475 
 476 LIBHARFBUZZ_CFLAGS += $(X_CFLAGS) -DLE_STANDALONE -DHEADLESS
 477 
 478 $(eval $(call SetupJdkLibrary, BUILD_LIBHARFBUZZ, \
 479     NAME := harfbuzz, \
 480     EXCLUDE_FILES := $(LIBHARFBUZZ_EXCLUDE_FILES), \
 481     TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
 482     CFLAGS := $(CFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
 483     CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
 484     OPTIMIZATION := $(LIBHARFBUZZ_OPTIMIZATION), \
 485     CFLAGS_windows = -DCC_NOEX, \
 486     EXTRA_HEADER_DIRS := $(LIBHARFBUZZ_EXTRA_HEADER_DIRS), \
 487     WARNINGS_AS_ERRORS_xlc := false, \
 488     DISABLED_WARNINGS_gcc := type-limits missing-field-initializers strict-aliasing, \
 489     DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \
 490         maybe-uninitialized class-memaccess, \
 491     DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
 492         tautological-constant-out-of-range-compare int-to-pointer-cast \
 493         undef missing-field-initializers, \
 494     DISABLED_WARNINGS_microsoft := 4267 4244 4090 4146 4334 4819 4101 4068 4805 4138, \
 495     LDFLAGS := $(LDFLAGS_JDKLIB) \
 496         $(call SET_SHARED_LIBRARY_ORIGIN), \
 497     LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
 498     LDFLAGS_aix := -Wl$(COMMA)-berok, \
 499     LIBS := $(BUILD_LIBHARFBUZZ), \
 500     LIBS_unix := $(LIBM) $(LIBCXX), \
 501     LIBS_macosx := -framework CoreText -framework CoreFoundation -framework CoreGraphics, \
 502     LIBS_windows := user32.lib, \
 503 ))
 504 
 505 ifeq ($(FREETYPE_TO_USE), bundled)
 506   $(BUILD_LIBHARFBUZZ): $(BUILD_LIBFREETYPE)
 507 endif
 508 
 509 TARGETS += $(BUILD_LIBHARFBUZZ)
 510 
 511 ###########################################################################
 512 
 513 LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
 514     libharfbuzz \
 515     common/awt \
 516     common/font \
 517     libawt/java2d \
 518     libawt/java2d/pipe \
 519     libawt/java2d/loops \
 520     #
 521 
 522 LIBFONTMANAGER_CFLAGS += $(LIBFREETYPE_CFLAGS) $(HARFBUZZ_FLAGS)
 523 BUILD_LIBFONTMANAGER_FONTLIB += $(LIBHARFBUZZ_LIBS) $(LIBFREETYPE_LIBS)
 524 
 525 LIBFONTMANAGER_OPTIMIZATION := HIGH
 526 
 527 ifeq ($(call isTargetOs, windows), true)
 528   LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \
 529       X11TextRenderer.c
 530   LIBFONTMANAGER_OPTIMIZATION := HIGHEST
 531 else ifeq ($(call isTargetOs, macosx), true)
 532   LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \
 533       X11TextRenderer.c \
 534       fontpath.c \
 535       lcdglyph.c
 536 else
 537   LIBFONTMANAGER_EXCLUDE_FILES += fontpath.c \
 538       lcdglyph.c
 539 endif
 540 
 541 LIBFONTMANAGER_CFLAGS += $(X_CFLAGS) -DLE_STANDALONE -DHEADLESS
 542 
 543 ifeq ($(TOOLCHAIN_TYPE), gcc)
 544   # Turn off all warnings for sunFont.c. This is needed because the specific warning
 545   # about discarding 'const' qualifier cannot be turned off individually.
 546   BUILD_LIBFONTMANAGER_sunFont.c_CFLAGS := -w
 547 endif
 548 
 549 # LDFLAGS clarification:
 550 #   Filter relevant linker flags disallowing unresolved symbols as we cannot
 551 #   build-time decide to which library to link against (libawt_headless or
 552 #   libawt_xawt). See JDK-8196516 for details.
 553 $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \
 554     NAME := fontmanager, \
 555     EXCLUDE_FILES := $(LIBFONTMANAGER_EXCLUDE_FILES) \
 556         AccelGlyphCache.c, \
 557     TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
 558     CFLAGS := $(CFLAGS_JDKLIB) $(LIBFONTMANAGER_CFLAGS), \
 559     CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBFONTMANAGER_CFLAGS), \
 560     OPTIMIZATION := $(LIBFONTMANAGER_OPTIMIZATION), \
 561     CFLAGS_windows = -DCC_NOEX, \
 562     EXTRA_HEADER_DIRS := $(LIBFONTMANAGER_EXTRA_HEADER_DIRS), \
 563     WARNINGS_AS_ERRORS_xlc := false, \
 564     DISABLED_WARNINGS_gcc := sign-compare unused-function int-to-pointer-cast, \
 565     DISABLED_WARNINGS_clang := sign-compare, \
 566     DISABLED_WARNINGS_microsoft := 4018 4146 4244 4996, \
 567     LDFLAGS := $(subst -Xlinker -z -Xlinker defs,, \
 568         $(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB))) $(LDFLAGS_CXX_JDK) \
 569         $(call SET_SHARED_LIBRARY_ORIGIN), \
 570     LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
 571     LDFLAGS_aix := -Wl$(COMMA)-berok, \
 572     LIBS := $(BUILD_LIBFONTMANAGER_FONTLIB), \
 573     LIBS_unix := -lawt -ljava -ljvm $(LIBM) $(LIBCXX), \
 574     LIBS_macosx := -lawt_lwawt, \
 575     LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib gdi32.lib \
 576         $(WIN_AWT_LIB), \
 577 ))
 578 
 579 $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT) $(BUILD_LIBHARFBUZZ)
 580 
 581 ifeq ($(call isTargetOs, macosx), true)
 582   $(BUILD_LIBFONTMANAGER): $(call FindLib, $(MODULE), awt_lwawt)
 583 endif
 584 
 585 ifeq ($(FREETYPE_TO_USE), bundled)
 586   $(BUILD_LIBFONTMANAGER): $(BUILD_LIBFREETYPE)
 587 endif
 588 
 589 TARGETS += $(BUILD_LIBFONTMANAGER)
 590 
 591 ################################################################################
 592 
 593 ifeq ($(call isTargetOs, windows), true)
 594 
 595   LIBJAWT_CFLAGS := -EHsc -DUNICODE -D_UNICODE
 596 
 597   LIBJAWT_EXTRA_HEADER_DIRS := \
 598       include \
 599       common/awt/debug \
 600       libawt/awt/image/cvutils \
 601       libawt/java2d \
 602       libawt/java2d/windows \
 603       libawt/windows \
 604       java.base:include \
 605       java.base:libjava \
 606       #
 607 
 608   ifeq ($(call isTargetCpu, x86), true)
 609     KERNEL32_LIB := kernel32.lib
 610   endif
 611 
 612   $(eval $(call SetupJdkLibrary, BUILD_LIBJAWT, \
 613       NAME := jawt, \
 614       OPTIMIZATION := LOW, \
 615       CFLAGS := $(CXXFLAGS_JDKLIB) \
 616           $(LIBJAWT_CFLAGS), \
 617       EXTRA_HEADER_DIRS := $(LIBJAWT_EXTRA_HEADER_DIRS), \
 618       LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK), \
 619       LIBS := $(JDKLIB_LIBS) $(KERNEL32_LIB) advapi32.lib $(WIN_AWT_LIB), \
 620   ))
 621 
 622   $(BUILD_LIBJAWT): $(BUILD_LIBAWT)
 623 
 624   $(eval $(call SetupCopyFiles, COPY_JAWT_LIB, \
 625       FILES := $(BUILD_LIBJAWT_IMPORT_LIBRARY), \
 626       DEST := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
 627   ))
 628 
 629   $(COPY_JAWT_LIB): $(BUILD_LIBJAWT)
 630 
 631   TARGETS += $(COPY_JAWT_LIB)
 632 
 633 else # not windows
 634 
 635   ifeq ($(call isTargetOs, macosx), true)
 636     # libjawt on macosx do not use the unix code
 637     LIBJAWT_EXCLUDE_SRC_PATTERNS := /unix/
 638   endif
 639 
 640   ifeq ($(call isTargetOs, macosx), true)
 641     JAWT_LIBS := -lawt_lwawt
 642   else
 643     JAWT_LIBS := -lawt
 644     ifeq ($(ENABLE_HEADLESS_ONLY), false)
 645       JAWT_LIBS += -lawt_xawt
 646     else
 647       JAWT_LIBS += -lawt_headless
 648       ifeq ($(call isTargetOs, linux), true)
 649         JAWT_CFLAGS += -DHEADLESS
 650       endif
 651     endif
 652   endif
 653 
 654   $(eval $(call SetupJdkLibrary, BUILD_LIBJAWT, \
 655       NAME := jawt, \
 656       EXCLUDE_SRC_PATTERNS := $(LIBJAWT_EXCLUDE_SRC_PATTERNS), \
 657       INCLUDE_FILES := $(JAWT_FILES), \
 658       OPTIMIZATION := LOW, \
 659       CFLAGS := $(CFLAGS_JDKLIB) \
 660           $(JAWT_CFLAGS), \
 661       DISABLED_WARNINGS_clang := sign-compare, \
 662       EXTRA_HEADER_DIRS := \
 663           include \
 664           common/awt, \
 665       LDFLAGS := $(LDFLAGS_JDKLIB) \
 666           $(call SET_SHARED_LIBRARY_ORIGIN), \
 667       LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
 668       LDFLAGS_macosx := -Wl$(COMMA)-rpath$(COMMA)@loader_path, \
 669       LIBS_unix := $(JAWT_LIBS) $(JDKLIB_LIBS), \
 670       LIBS_macosx := -framework Cocoa, \
 671   ))
 672 
 673   ifeq ($(ENABLE_HEADLESS_ONLY), false)
 674     $(BUILD_LIBJAWT): $(BUILD_LIBAWT_XAWT)
 675   else
 676     $(BUILD_LIBJAWT): $(call FindLib, $(MODULE), awt_headless)
 677   endif
 678 
 679   ifeq ($(call isTargetOs, macosx), true)
 680    $(BUILD_LIBJAWT): $(call FindLib, $(MODULE), awt_lwawt)
 681   endif
 682 
 683 endif
 684 
 685 TARGETS += $(BUILD_LIBJAWT)
 686 
 687 ################################################################################
 688 
 689 ifeq ($(ENABLE_HEADLESS_ONLY), false)
 690 
 691   LIBSPLASHSCREEN_EXTRA_SRC := \
 692       common/awt/systemscale \
 693       #
 694 
 695   ifeq ($(USE_EXTERNAL_LIBGIF), false)
 696     LIBSPLASHSCREEN_HEADER_DIRS += libsplashscreen/giflib
 697   else
 698     LIBSPLASHSCREEN_EXCLUDES := giflib
 699     GIFLIB_LIBS := -lgif
 700   endif
 701 
 702   ifeq ($(USE_EXTERNAL_LIBJPEG), false)
 703     # While the following ought to work, it will currently pull in the closed
 704     # additions to this library, and this was not done previously in the build.
 705     # LIBSPLASHSCREEN_EXTRA_SRC += libjavajpeg
 706     LIBSPLASHSCREEN_EXTRA_SRC += $(TOPDIR)/src/java.desktop/share/native/libjavajpeg
 707   else
 708     LIBJPEG_LIBS := -ljpeg
 709   endif
 710 
 711   ifeq ($(USE_EXTERNAL_LIBPNG), false)
 712     LIBSPLASHSCREEN_HEADER_DIRS += libsplashscreen/libpng
 713   else
 714     LIBSPLASHSCREEN_EXCLUDES += libpng
 715   endif
 716 
 717   ifeq ($(USE_EXTERNAL_LIBZ), false)
 718     LIBSPLASHSCREEN_EXTRA_SRC += java.base:libzip/zlib
 719   endif
 720 
 721   ifeq ($(call isTargetOs, macosx), true)
 722     # libsplashscreen on macosx do not use the unix code
 723     LIBSPLASHSCREEN_EXCLUDE_SRC_PATTERNS := /unix/
 724   endif
 725 
 726   LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE \
 727                             -DPNG_ARM_NEON_OPT=0 -DPNG_ARM_NEON_IMPLEMENTATION=0
 728 
 729   ifeq ($(call isTargetOs, linux), true)
 730     ifeq ($(call isTargetCpuArch, ppc), true)
 731       LIBSPLASHSCREEN_CFLAGS += -DPNG_POWERPC_VSX_OPT=0
 732     endif
 733   endif
 734 
 735   ifeq ($(call isTargetOs, macosx), true)
 736     LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX
 737 
 738     BUILD_LIBSPLASHSCREEN_java_awt_SplashScreen.c_CFLAGS := -x objective-c -O0
 739     BUILD_LIBSPLASHSCREEN_splashscreen_gfx_impl.c_CFLAGS := -x objective-c -O0
 740     BUILD_LIBSPLASHSCREEN_splashscreen_gif.c_CFLAGS := -x objective-c -O0
 741     BUILD_LIBSPLASHSCREEN_splashscreen_impl.c_CFLAGS := -x objective-c -O0
 742     BUILD_LIBSPLASHSCREEN_splashscreen_jpeg.c_CFLAGS := -x objective-c -O0
 743     BUILD_LIBSPLASHSCREEN_splashscreen_png.c_CFLAGS := -x objective-c -O0
 744     BUILD_LIBSPLASHSCREEN_splashscreen_sys.m_CFLAGS := -O0
 745 
 746   else ifeq ($(call isTargetOs, windows), true)
 747     LIBSPLASHSCREEN_CFLAGS += -DWITH_WIN32
 748   else
 749     LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 $(X_CFLAGS)
 750   endif
 751 
 752   LIBSPLASHSCREEN_LIBS :=
 753 
 754   ifeq ($(call isTargetOs, macosx), true)
 755     LIBSPLASHSCREEN_LIBS += \
 756         $(LIBM) -lpthread -liconv -losxapp \
 757         -framework ApplicationServices \
 758         -framework Foundation \
 759         -framework Security \
 760         -framework Cocoa \
 761         -framework JavaNativeFoundation
 762   else ifeq ($(call isTargetOs, windows), true)
 763     LIBSPLASHSCREEN_LIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib
 764   else
 765     LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread -ldl
 766   endif
 767 
 768   LIBSPLASHSCREEN_HEADER_DIRS += \
 769       libosxapp \
 770       java.base:include \
 771       java.base:libjava \
 772       #
 773 
 774   $(eval $(call SetupJdkLibrary, BUILD_LIBSPLASHSCREEN, \
 775       NAME := splashscreen, \
 776       EXTRA_SRC := $(LIBSPLASHSCREEN_EXTRA_SRC), \
 777       EXCLUDE_SRC_PATTERNS := $(LIBSPLASHSCREEN_EXCLUDE_SRC_PATTERNS), \
 778       EXCLUDE_FILES := imageioJPEG.c jpegdecoder.c pngtest.c, \
 779       EXCLUDES := $(LIBSPLASHSCREEN_EXCLUDES), \
 780       OPTIMIZATION := LOW, \
 781       CFLAGS := $(CFLAGS_JDKLIB) $(LIBSPLASHSCREEN_CFLAGS) \
 782           $(GIFLIB_CFLAGS) $(LIBJPEG_CFLAGS) $(PNG_CFLAGS) $(LIBZ_CFLAGS), \
 783       EXTRA_HEADER_DIRS := $(LIBSPLASHSCREEN_HEADER_DIRS), \
 784       DISABLED_WARNINGS_gcc := sign-compare type-limits unused-result \
 785           maybe-uninitialized shift-negative-value implicit-fallthrough \
 786           unused-function, \
 787       DISABLED_WARNINGS_clang := incompatible-pointer-types sign-compare, \
 788       DISABLED_WARNINGS_microsoft := 4018 4244 4267, \
 789       LDFLAGS := $(LDFLAGS_JDKLIB) \
 790           $(call SET_SHARED_LIBRARY_ORIGIN), \
 791       LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \
 792       LDFLAGS_windows := -delayload:user32.dll, \
 793       LIBS := $(JDKLIB_LIBS) $(LIBSPLASHSCREEN_LIBS) $(LIBZ_LIBS) \
 794           $(GIFLIB_LIBS) $(LIBJPEG_LIBS) $(PNG_LIBS), \
 795       LIBS_aix := -liconv, \
 796   ))
 797 
 798   TARGETS += $(BUILD_LIBSPLASHSCREEN)
 799 
 800   ifeq ($(call isTargetOs, macosx), true)
 801     $(BUILD_LIBSPLASHSCREEN): $(call FindLib, $(MODULE), osxapp)
 802   endif
 803 
 804 endif
 805 
 806 ################################################################################
 807 
 808 ifeq ($(call isTargetOs, macosx), true)
 809 
 810   LIBAWT_LWAWT_EXTRA_SRC := \
 811       $(TOPDIR)/src/$(MODULE)/unix/native/common/awt \
 812       $(TOPDIR)/src/$(MODULE)/share/native/common/font \
 813       $(TOPDIR)/src/$(MODULE)/share/native/common/java2d \
 814       #
 815 
 816   LIBAWT_LWAWT_EXTRA_HEADER_DIRS := \
 817       $(LIBAWT_DEFAULT_HEADER_DIRS) \
 818       libawt_lwawt/awt \
 819       libawt_lwawt/font \
 820       libawt_lwawt/java2d/opengl \
 821       include \
 822       common/awt/debug \
 823       common/java2d/opengl \
 824       libosxapp \
 825       #
 826 
 827   LIBAWT_LWAWT_CFLAGS := $(X_CFLAGS) $(X_LIBS)
 828 
 829   LIBAWT_LWAWT_EXFILES := fontpath.c awt_Font.c X11Color.c
 830   LIBAWT_LWAWT_EXCLUDES := $(TOPDIR)/src/$(MODULE)/unix/native/common/awt/medialib
 831 
 832   $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_LWAWT, \
 833       NAME := awt_lwawt, \
 834       EXTRA_SRC := $(LIBAWT_LWAWT_EXTRA_SRC), \
 835       INCLUDE_FILES := $(LIBAWT_LWAWT_FILES), \
 836       EXCLUDE_FILES := $(LIBAWT_LWAWT_EXFILES), \
 837       EXCLUDES := $(LIBAWT_LWAWT_EXCLUDES), \
 838       OPTIMIZATION := LOW, \
 839       CFLAGS := $(CFLAGS_JDKLIB) \
 840           $(LIBAWT_LWAWT_CFLAGS), \
 841       EXTRA_HEADER_DIRS := $(LIBAWT_LWAWT_EXTRA_HEADER_DIRS), \
 842       DISABLED_WARNINGS_clang := incomplete-implementation enum-conversion \
 843           deprecated-declarations objc-method-access bitwise-op-parentheses \
 844           incompatible-pointer-types parentheses-equality extra-tokens \
 845           sign-compare semicolon-before-method-body format-nonliteral undef \
 846           pointer-arith, \
 847       LDFLAGS := $(LDFLAGS_JDKLIB) \
 848           $(call SET_SHARED_LIBRARY_ORIGIN) \
 849           -L$(INSTALL_LIBRARIES_HERE), \
 850       LIBS := -lawt -lmlib_image -losxapp -ljvm $(LIBM) \
 851           -framework Accelerate \
 852           -framework ApplicationServices \
 853           -framework AudioToolbox \
 854           -framework Carbon \
 855           -framework Cocoa \
 856           -framework Security \
 857           -framework ExceptionHandling \
 858           -framework JavaNativeFoundation \
 859           -framework JavaRuntimeSupport \
 860           -framework OpenGL \
 861           -framework QuartzCore -ljava, \
 862   ))
 863 
 864   TARGETS += $(BUILD_LIBAWT_LWAWT)
 865 
 866   $(BUILD_LIBAWT_LWAWT): $(BUILD_LIBAWT)
 867 
 868   $(BUILD_LIBAWT_LWAWT): $(BUILD_LIBMLIB_IMAGE)
 869 
 870   $(BUILD_LIBAWT_LWAWT): $(call FindLib, $(MODULE), osxapp)
 871 
 872   $(BUILD_LIBAWT_LWAWT): $(call FindLib, java.base, java)
 873 
 874 endif
 875 
 876 ################################################################################
 877 
 878 ifeq ($(call isTargetOs, macosx), true)
 879 
 880   $(eval $(call SetupJdkLibrary, BUILD_LIBOSXUI, \
 881       NAME := osxui, \
 882       OPTIMIZATION := LOW, \
 883       CFLAGS := $(CFLAGS_JDKLIB), \
 884       EXTRA_HEADER_DIRS := \
 885           libawt_lwawt/awt \
 886           libosxapp, \
 887       DISABLED_WARNINGS_clang := deprecated-declarations sign-compare, \
 888       LDFLAGS := $(LDFLAGS_JDKLIB) \
 889           $(call SET_SHARED_LIBRARY_ORIGIN) \
 890           -Wl$(COMMA)-rpath$(COMMA)@loader_path \
 891           -L$(INSTALL_LIBRARIES_HERE), \
 892       LIBS := -lawt -losxapp -lawt_lwawt \
 893           -framework Cocoa \
 894           -framework Carbon \
 895           -framework ApplicationServices \
 896           -framework JavaNativeFoundation \
 897           -framework JavaRuntimeSupport \
 898           -ljava -ljvm, \
 899   ))
 900 
 901   TARGETS += $(BUILD_LIBOSXUI)
 902 
 903   $(BUILD_LIBOSXUI): $(BUILD_LIBAWT)
 904 
 905   $(BUILD_LIBOSXUI): $(call FindLib, $(MODULE), osxapp)
 906 
 907   $(BUILD_LIBOSXUI): $(BUILD_LIBAWT_LWAWT)
 908 
 909 endif