1 #
   2 # Copyright (c) 2011, 2018, 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_VERIFY_LIB := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libverify/verify.lib
  27 
  28 # Hook to include the corresponding custom file, if present.
  29 $(eval $(call IncludeCustomExtension, lib/CoreLibraries.gmk))
  30 
  31 
  32 ##########################################################################################
  33 # libfdlibm is statically linked with libjava below and not delivered into the
  34 # product on its own.
  35 
  36 BUILD_LIBFDLIBM_OPTIMIZATION := NONE
  37 
  38 ifeq ($(call isTargetOs, solaris), true)
  39   BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
  40 endif
  41 
  42 # If FDLIBM_CFLAGS is non-empty we know that we can optimize
  43 # fdlibm when adding those extra C flags. Currently GCC,
  44 # and clang only.
  45 ifneq ($(FDLIBM_CFLAGS), )
  46   BUILD_LIBFDLIBM_OPTIMIZATION := LOW
  47 endif
  48 
  49 LIBFDLIBM_SRC := $(TOPDIR)/src/java.base/share/native/libfdlibm
  50 LIBFDLIBM_CFLAGS := -I$(LIBFDLIBM_SRC) $(FDLIBM_CFLAGS)
  51 
  52 $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \
  53     NAME := fdlibm, \
  54     TYPE := STATIC_LIBRARY, \
  55     OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
  56     SRC := $(LIBFDLIBM_SRC), \
  57     OPTIMIZATION := $(BUILD_LIBFDLIBM_OPTIMIZATION), \
  58     CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \
  59     CFLAGS_windows_debug := -DLOGGING, \
  60     CFLAGS_aix := -qfloat=nomaf, \
  61     DISABLED_WARNINGS_gcc := sign-compare misleading-indentation array-bounds, \
  62     DISABLED_WARNINGS_clang := sign-compare, \
  63     DISABLED_WARNINGS_microsoft := 4146 4244 4018, \
  64     ARFLAGS := $(ARFLAGS), \
  65     OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \
  66 ))
  67 
  68 ##########################################################################################
  69 
  70 LIBVERIFY_OPTIMIZATION := HIGH
  71 ifeq ($(call isTargetOs, solaris linux), true)
  72   ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true)
  73     LIBVERIFY_OPTIMIZATION := LOW
  74   endif
  75 endif
  76 
  77 $(eval $(call SetupJdkLibrary, BUILD_LIBVERIFY, \
  78     NAME := verify, \
  79     OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \
  80     CFLAGS := $(CFLAGS_JDKLIB), \
  81     LDFLAGS := $(LDFLAGS_JDKLIB) \
  82         $(call SET_SHARED_LIBRARY_ORIGIN), \
  83     LIBS_unix := -ljvm, \
  84     LIBS_windows := jvm.lib, \
  85 ))
  86 
  87 TARGETS += $(BUILD_LIBVERIFY)
  88 
  89 ##########################################################################################
  90 
  91 LIBJAVA_CFLAGS := -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"'
  92 
  93 ifeq ($(call isTargetOs, macosx), true)
  94   BUILD_LIBJAVA_java_props_md.c_CFLAGS := -x objective-c
  95   BUILD_LIBJAVA_java_props_macosx.c_CFLAGS := -x objective-c
  96 endif
  97 
  98 $(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \
  99     NAME := java, \
 100     OPTIMIZATION := HIGH, \
 101     CFLAGS := $(CFLAGS_JDKLIB) \
 102         $(LIBJAVA_CFLAGS), \
 103     jdk_util.c_CFLAGS := $(VERSION_CFLAGS), \
 104     EXTRA_HEADER_DIRS := libfdlibm, \
 105     WARNINGS_AS_ERRORS_xlc := false, \
 106     DISABLED_WARNINGS_gcc := unused-result unused-function, \
 107     DISABLED_WARNINGS_solstudio := E_STATEMENT_NOT_REACHED, \
 108     LDFLAGS := $(LDFLAGS_JDKLIB) \
 109         $(call SET_SHARED_LIBRARY_ORIGIN), \
 110     LDFLAGS_macosx := -L$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/, \
 111     LDFLAGS_windows := -delayload:shell32.dll, \
 112     LIBS := $(BUILD_LIBFDLIBM_TARGET), \
 113     LIBS_unix := -ljvm -lverify, \
 114     LIBS_linux := $(LIBDL), \
 115     LIBS_solaris := -lsocket -lnsl -lscf $(LIBDL), \
 116     LIBS_aix := $(LIBDL) $(LIBM),\
 117     LIBS_macosx := -framework CoreFoundation \
 118         -framework Foundation \
 119         -framework Security -framework SystemConfiguration, \
 120     LIBS_windows := jvm.lib $(WIN_VERIFY_LIB) \
 121         shell32.lib delayimp.lib \
 122         advapi32.lib version.lib, \
 123 ))
 124 
 125 TARGETS += $(BUILD_LIBJAVA)
 126 
 127 $(BUILD_LIBJAVA): $(BUILD_LIBVERIFY)
 128 
 129 $(BUILD_LIBJAVA): $(BUILD_LIBFDLIBM)
 130 
 131 ##########################################################################################
 132 
 133 BUILD_LIBZIP_EXCLUDES :=
 134 ifeq ($(USE_EXTERNAL_LIBZ), true)
 135   LIBZIP_EXCLUDES += zlib
 136 endif
 137 
 138 ifeq ($(LIBZIP_CAN_USE_MMAP), true)
 139   BUILD_LIBZIP_MMAP := -DUSE_MMAP
 140 endif
 141 
 142 $(eval $(call SetupJdkLibrary, BUILD_LIBZIP, \
 143     NAME := zip, \
 144     OPTIMIZATION := LOW, \
 145     EXCLUDES := $(LIBZIP_EXCLUDES), \
 146     CFLAGS := $(CFLAGS_JDKLIB) \
 147         $(LIBZ_CFLAGS), \
 148     CFLAGS_unix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \
 149     DISABLED_WARNINGS_gcc := unused-function, \
 150     LDFLAGS := $(LDFLAGS_JDKLIB) \
 151         $(call SET_SHARED_LIBRARY_ORIGIN), \
 152     LIBS_unix := -ljvm -ljava $(LIBZ_LIBS), \
 153     LIBS_windows := jvm.lib $(WIN_JAVA_LIB), \
 154 ))
 155 
 156 $(BUILD_LIBZIP): $(BUILD_LIBJAVA)
 157 
 158 TARGETS += $(BUILD_LIBZIP)
 159 
 160 ##########################################################################################
 161 
 162 $(eval $(call SetupJdkLibrary, BUILD_LIBJIMAGE, \
 163     NAME := jimage, \
 164     TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
 165     OPTIMIZATION := LOW, \
 166     CFLAGS := $(CFLAGS_JDKLIB), \
 167     CXXFLAGS := $(CXXFLAGS_JDKLIB), \
 168     CFLAGS_unix := -UDEBUG, \
 169     LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
 170         $(call SET_SHARED_LIBRARY_ORIGIN), \
 171     LIBS_unix := -ljvm -ldl $(LIBCXX), \
 172     LIBS_macosx := -lc++, \
 173     LIBS_windows := jvm.lib, \
 174 ))
 175 
 176 $(BUILD_LIBJIMAGE): $(BUILD_LIBJAVA)
 177 
 178 TARGETS += $(BUILD_LIBJIMAGE)
 179 
 180 ##########################################################################################
 181 
 182 ifeq ($(call isTargetOs, macosx), true)
 183   LIBJLI_EXCLUDE_FILES += java_md_solinux.c
 184 endif
 185 
 186 ifeq ($(call isTargetOs, windows), true)
 187   # Supply the name of the C runtime lib.
 188   LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"'
 189   ifneq ($(MSVCP_DLL), )
 190     LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"'
 191   endif
 192 endif
 193 
 194 LIBJLI_CFLAGS += -DLIBC=\"$(OPENJDK_TARGET_LIBC)\"
 195 
 196 LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
 197 
 198 ifneq ($(USE_EXTERNAL_LIBZ), true)
 199   LIBJLI_EXTRA_FILES += \
 200       $(addprefix $(TOPDIR)/src/java.base/share/native/libzip/zlib/, \
 201           inflate.c \
 202           inftrees.c \
 203           inffast.c \
 204           zadler32.c \
 205           zcrc32.c \
 206           zutil.c \
 207       )
 208 endif
 209 
 210 $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \
 211     NAME := jli, \
 212     OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
 213     EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
 214     EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
 215     OPTIMIZATION := HIGH, \
 216     CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \
 217     DISABLED_WARNINGS_gcc := unused-function, \
 218     DISABLED_WARNINGS_clang := sometimes-uninitialized format-nonliteral, \
 219     DISABLED_WARNINGS_solstudio := \
 220         E_ASM_DISABLES_OPTIMIZATION \
 221         E_STATEMENT_NOT_REACHED, \
 222     LDFLAGS := $(LDFLAGS_JDKLIB) \
 223         $(call SET_SHARED_LIBRARY_ORIGIN), \
 224     LIBS_unix := $(LIBZ_LIBS), \
 225     LIBS_linux := $(LIBDL) -lpthread, \
 226     LIBS_solaris := $(LIBDL), \
 227     LIBS_aix := $(LIBDL),\
 228     LIBS_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \
 229     LIBS_windows := advapi32.lib comctl32.lib user32.lib, \
 230 ))
 231 
 232 TARGETS += $(BUILD_LIBJLI)
 233 
 234 LIBJLI_SRC_DIRS := $(call FindSrcDirsForComponent, java.base, libjli)
 235 
 236 ifeq ($(call isTargetOs, aix), true)
 237   # AIX also requires a static libjli because the compiler doesn't support '-rpath'
 238   $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \
 239       NAME := jli_static, \
 240       TYPE := STATIC_LIBRARY, \
 241       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
 242       SRC := $(LIBJLI_SRC_DIRS), \
 243       EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
 244       EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
 245       OPTIMIZATION := HIGH, \
 246       CFLAGS := $(STATIC_LIBRARY_FLAGS) $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS) \
 247           $(addprefix -I, $(LIBJLI_SRC_DIRS)), \
 248       ARFLAGS := $(ARFLAGS), \
 249       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static))
 250 
 251   TARGETS += $(BUILD_LIBJLI_STATIC)
 252 
 253 endif