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 ($(OPENJDK_TARGET_OS), solaris)
  39   BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
  40 endif
  41 
  42 ifeq ($(OPENJDK_TARGET_OS), linux)
  43   ifeq ($(OPENJDK_TARGET_CPU), ppc64)
  44     BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
  45   else ifeq ($(OPENJDK_TARGET_CPU), ppc64le)
  46     BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
  47   else ifeq ($(OPENJDK_TARGET_CPU), s390x)
  48     BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
  49   else ifeq ($(OPENJDK_TARGET_CPU), aarch64)
  50     BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
  51   endif
  52 endif
  53 
  54 LIBFDLIBM_SRC := $(TOPDIR)/src/java.base/share/native/libfdlibm
  55 LIBFDLIBM_CFLAGS := -I$(LIBFDLIBM_SRC)
  56 
  57 ifneq ($(OPENJDK_TARGET_OS), macosx)
  58   $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM, \
  59       NAME := fdlibm, \
  60       TYPE := STATIC_LIBRARY, \
  61       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
  62       SRC := $(LIBFDLIBM_SRC), \
  63       OPTIMIZATION := $(BUILD_LIBFDLIBM_OPTIMIZATION), \
  64       CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \
  65       CFLAGS_windows_debug := -DLOGGING, \
  66       CFLAGS_aix := -qfloat=nomaf, \
  67       CFLAGS_linux_ppc64 := -ffp-contract=off, \
  68       CFLAGS_linux_ppc64le := -ffp-contract=off, \
  69       CFLAGS_linux_s390x := -ffp-contract=off, \
  70       CFLAGS_linux_aarch64 := -ffp-contract=off, \
  71       DISABLED_WARNINGS_gcc := sign-compare misleading-indentation, \
  72       DISABLED_WARNINGS_microsoft := 4146 4244 4018, \
  73       ARFLAGS := $(ARFLAGS), \
  74       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \
  75   ))
  76 
  77 else
  78 
  79   # On macosx the old build does partial (incremental) linking of fdlibm instead of
  80   # a plain static library.
  81   $(eval $(call SetupNativeCompilation, BUILD_LIBFDLIBM_MAC, \
  82       NAME := fdlibm, \
  83       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \
  84       SRC := $(LIBFDLIBM_SRC), \
  85       CFLAGS := $(CFLAGS_JDKLIB) $(LIBFDLIBM_CFLAGS), \
  86       LDFLAGS := -nostdlib $(ARFLAGS), \
  87       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfdlibm, \
  88   ))
  89 
  90   BUILD_LIBFDLIBM := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)
  91   $(BUILD_LIBFDLIBM): $(BUILD_LIBFDLIBM_MAC)
  92         $(call install-file)
  93 
  94 endif
  95 
  96 ##########################################################################################
  97 






  98 LIBVERIFY_OPTIMIZATION := HIGH
  99 ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), )
 100   ifeq ($(COMPILE_WITH_DEBUG_SYMBOLS), true)
 101     LIBVERIFY_OPTIMIZATION := LOW
 102   endif
 103 endif
 104 
 105 $(eval $(call SetupJdkLibrary, BUILD_LIBVERIFY, \
 106     NAME := verify, \
 107     SRC := $(TOPDIR)/src/java.base/share/native/libverify, \
 108     OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \
 109     CFLAGS := $(CFLAGS_JDKLIB), \
 110     DISABLED_WARNINGS_gcc := implicit-fallthrough, \
 111     DISABLED_WARNINGS_microsoft := 4244 4267, \

 112     LDFLAGS := $(LDFLAGS_JDKLIB) \
 113         $(call SET_SHARED_LIBRARY_ORIGIN), \
 114     LIBS_unix := -ljvm, \
 115     LIBS_windows := jvm.lib, \

 116 ))
 117 
 118 TARGETS += $(BUILD_LIBVERIFY)
 119 
 120 ##########################################################################################
 121 
 122 # Allow a custom makefile to add extra src dirs
 123 LIBJAVA_SRC_DIRS += $(call FindSrcDirsForLib, java.base, java)
 124 
 125 LIBJAVA_CFLAGS := $(addprefix -I, $(LIBJAVA_SRC_DIRS)) \
 126     -I$(TOPDIR)/src/java.base/share/native/libfdlibm \
 127     -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
 128     -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"'
 129 



 130 ifeq ($(OPENJDK_TARGET_OS), macosx)
 131   BUILD_LIBJAVA_java_props_md.c_CFLAGS := -x objective-c
 132   BUILD_LIBJAVA_java_props_macosx.c_CFLAGS := -x objective-c
 133 endif
 134 






 135 $(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \
 136     NAME := java, \
 137     SRC := $(LIBJAVA_SRC_DIRS), \
 138     OPTIMIZATION := HIGH, \
 139     CFLAGS := $(CFLAGS_JDKLIB) \
 140         $(LIBJAVA_CFLAGS), \
 141     System.c_CFLAGS := $(VERSION_CFLAGS), \
 142     jdk_util.c_CFLAGS := $(VERSION_CFLAGS), \
 143     WARNINGS_AS_ERRORS_xlc := false, \
 144     DISABLED_WARNINGS_gcc := unused-result, \
 145     DISABLED_WARNINGS_solstudio := E_STATEMENT_NOT_REACHED, \

 146     LDFLAGS := $(LDFLAGS_JDKLIB) \
 147         $(call SET_SHARED_LIBRARY_ORIGIN), \
 148     LDFLAGS_macosx := -L$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/, \
 149     LDFLAGS_windows := -delayload:shell32.dll, \


 150     LIBS_unix := -ljvm -lverify, \
 151     LIBS_linux := $(LIBDL) $(BUILD_LIBFDLIBM), \
 152     LIBS_solaris := -lsocket -lnsl -lscf $(LIBDL) $(BUILD_LIBFDLIBM), \
 153     LIBS_aix := $(LIBDL) $(BUILD_LIBFDLIBM) $(LIBM),\
 154     LIBS_macosx := -lfdlibm \
 155         -framework CoreFoundation \
 156         -framework Foundation \
 157         -framework Security -framework SystemConfiguration, \
 158     LIBS_windows := jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
 159         shell32.lib delayimp.lib \
 160         advapi32.lib version.lib, \

 161 ))
 162 
 163 TARGETS += $(BUILD_LIBJAVA)
 164 
 165 $(BUILD_LIBJAVA): $(BUILD_LIBVERIFY)
 166 
 167 $(BUILD_LIBJAVA): $(BUILD_LIBFDLIBM)
 168 
 169 ##########################################################################################
 170 
 171 BUILD_LIBZIP_EXCLUDES :=
 172 ifeq ($(USE_EXTERNAL_LIBZ), true)
 173   LIBZIP_EXCLUDES += zlib
 174 endif
 175 







 176 ifeq ($(LIBZIP_CAN_USE_MMAP), true)
 177   BUILD_LIBZIP_MMAP := -DUSE_MMAP
 178 endif
 179 
 180 $(eval $(call SetupJdkLibrary, BUILD_LIBZIP, \
 181     NAME := zip, \
 182     OPTIMIZATION := LOW, \
 183     SRC := $(TOPDIR)/src/java.base/share/native/libzip, \
 184     EXCLUDES := $(LIBZIP_EXCLUDES), \
 185     CFLAGS := $(CFLAGS_JDKLIB) \
 186         $(LIBZ_CFLAGS) \
 187         -I$(TOPDIR)/src/java.base/share/native/libjava \
 188         -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
 189         -I$(SUPPORT_OUTPUTDIR)/headers/java.base, \
 190     CFLAGS_unix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \
 191     DISABLED_WARNINGS_gcc := implicit-fallthrough, \


 192     LDFLAGS := $(LDFLAGS_JDKLIB) \
 193         $(call SET_SHARED_LIBRARY_ORIGIN), \



 194     LIBS_unix := -ljvm -ljava $(LIBZ_LIBS), \
 195     LIBS_windows := jvm.lib $(WIN_JAVA_LIB), \
 196 ))
 197 
 198 $(BUILD_LIBZIP): $(BUILD_LIBJAVA)
 199 
 200 TARGETS += $(BUILD_LIBZIP)
 201 
 202 ##########################################################################################
 203 
 204 JIMAGELIB_CPPFLAGS := \
 205     -I$(TOPDIR)/src/java.base/share/native/libjava \
 206     -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
 207     -I$(TOPDIR)/src/java.base/share/native/libjimage \
 208     -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
 209     #
 210 
 211 $(eval $(call SetupJdkLibrary, BUILD_LIBJIMAGE, \
 212     NAME := jimage, \
 213     TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
 214     OPTIMIZATION := LOW, \
 215     SRC := $(TOPDIR)/src/java.base/share/native/libjimage \
 216         $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjimage, \
 217     EXCLUDES := $(LIBJIMAGE_EXCLUDES), \
 218     CFLAGS := $(CFLAGS_JDKLIB) $(JIMAGELIB_CPPFLAGS), \
 219     CXXFLAGS := $(CXXFLAGS_JDKLIB) $(JIMAGELIB_CPPFLAGS), \
 220     DISABLED_WARNINGS_gcc := implicit-fallthrough, \
 221     CFLAGS_unix := -UDEBUG, \

 222     LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
 223         $(call SET_SHARED_LIBRARY_ORIGIN), \




 224     LIBS_unix := -ljvm -ldl $(LIBCXX), \
 225     LIBS_macosx := -lc++, \
 226     LIBS_windows := jvm.lib, \
 227 ))
 228 
 229 $(BUILD_LIBJIMAGE): $(BUILD_LIBJAVA)
 230 
 231 TARGETS += $(BUILD_LIBJIMAGE)
 232 
 233 ##########################################################################################
 234 
 235 LIBJLI_SRC_DIRS := $(call FindSrcDirsForLib, java.base, jli)
 236 
 237 LIBJLI_CFLAGS := $(CFLAGS_JDKLIB)
 238 
 239 ifeq ($(call check-jvm-variant, zero), true)
 240   ERGO_FAMILY := zero
 241 else
 242   ifeq ($(OPENJDK_TARGET_CPU_ARCH), x86)
 243     ERGO_FAMILY := i586
 244   else
 245     ERGO_FAMILY := $(OPENJDK_TARGET_CPU_ARCH)
 246   endif
 247 endif
 248 LIBJLI_ALL_ERGO := $(wildcard $(addsuffix /ergo_*.c, $(LIBJLI_SRC_DIRS)))
 249 LIBJLI_EXCLUDE_ERGO := $(filter-out %/ergo_$(ERGO_FAMILY).c, $(LIBJLI_ALL_ERGO))
 250 # If all specialized ergo files are excluded, use generic ergo
 251 ifeq ($(LIBJLI_ALL_ERGO), $(LIBJLI_EXCLUDE_ERGO))
 252   LIBJLI_CFLAGS += -DUSE_GENERIC_ERGO
 253 endif
 254 LIBJLI_EXCLUDE_FILES += $(notdir $(LIBJLI_EXCLUDE_ERGO))
 255 
 256 ifeq ($(OPENJDK_TARGET_OS), macosx)
 257   LIBJLI_EXCLUDE_FILES += java_md_solinux.c ergo.c ergo_i586.c
 258 
 259   BUILD_LIBJLI_java_md_macosx.c_CFLAGS := -x objective-c
 260   BUILD_LIBJLI_STATIC_java_md_macosx.c_CFLAGS := -x objective-c
 261 
 262   LIBJLI_CFLAGS += -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
 263 endif
 264 
 265 ifeq ($(OPENJDK_TARGET_OS), windows)
 266   # Staticically link with c runtime on windows.
 267   LIBJLI_CFLAGS := $(filter-out -MD, $(LIBJLI_CFLAGS))
 268   LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)
 269   # Supply the name of the C runtime lib.
 270   LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"'
 271   ifneq ($(MSVCP_DLL), )
 272     LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"'
 273   endif
 274 else
 275   LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)/jli
 276 endif
 277 
 278 LIBJLI_CFLAGS += $(addprefix -I, $(LIBJLI_SRC_DIRS))
 279 
 280 LIBJLI_CFLAGS += $(LIBZ_CFLAGS)
 281 
 282 ifneq ($(USE_EXTERNAL_LIBZ), true)
 283   LIBJLI_EXTRA_FILES += \
 284       $(addprefix $(TOPDIR)/src/java.base/share/native/libzip/zlib/, \
 285           inflate.c \
 286           inftrees.c \
 287           inffast.c \
 288           zadler32.c \
 289           zcrc32.c \
 290           zutil.c \
 291       )
 292 endif
 293 
 294 $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \
 295     NAME := jli, \
 296     OUTPUT_DIR := $(LIBJLI_OUTPUT_DIR), \
 297     SRC := $(LIBJLI_SRC_DIRS), \
 298     EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
 299     EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
 300     OPTIMIZATION := HIGH, \
 301     CFLAGS := $(LIBJLI_CFLAGS), \
 302     DISABLED_WARNINGS_gcc := maybe-uninitialized, \
 303     DISABLED_WARNINGS_solstudio := \
 304         E_ASM_DISABLES_OPTIMIZATION \
 305         E_STATEMENT_NOT_REACHED, \

 306     LDFLAGS := $(LDFLAGS_JDKLIB) \
 307         $(call SET_SHARED_LIBRARY_ORIGIN), \
 308     LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
 309     LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \




















 310     LIBS_unix := $(LIBZ_LIBS), \
 311     LIBS_linux := $(LIBDL) -lpthread, \
 312     LIBS_solaris := $(LIBDL), \
 313     LIBS_aix := $(LIBDL),\
 314     LIBS_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \
 315     LIBS_windows := advapi32.lib comctl32.lib user32.lib, \
 316 ))
 317 
 318 TARGETS += $(BUILD_LIBJLI)
 319 
 320 # On windows, the static library has the same suffix as the import library created by
 321 # with the shared library, so the static library is given a different name. No harm
 322 # in doing it for all platform to reduce complexity.
 323 ifeq ($(OPENJDK_TARGET_OS), windows)
 324   $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \
 325       NAME := jli_static, \
 326       TYPE := STATIC_LIBRARY, \
 327       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
 328       SRC := $(LIBJLI_SRC_DIRS), \
 329       EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
 330       EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
 331       OPTIMIZATION := HIGH, \
 332       CFLAGS := $(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS), \
 333       ARFLAGS := $(ARFLAGS), \
 334       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \
 335   ))
 336 
 337   TARGETS += $(BUILD_LIBJLI_STATIC)
 338 
 339 else ifeq ($(OPENJDK_TARGET_OS), macosx)
 340   #
 341   # On macosx they do partial (incremental) linking of libjli_static.a
 342   # code it here...rather than add support to NativeCompilation
 343   # as this is first time I see it
 344   $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \
 345       NAME := jli_static, \
 346       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
 347       SRC := $(LIBJLI_SRC_DIRS), \
 348       EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
 349       EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
 350       OPTIMIZATION := HIGH, \
 351       CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \
 352       LDFLAGS := -nostdlib $(ARFLAGS), \
 353       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \
 354   ))
 355 
 356   ifeq ($(STATIC_BUILD), true)
 357     TARGETS += $(BUILD_LIBJLI_STATIC)
 358   else
 359     $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static.a: $(BUILD_LIBJLI_STATIC)
 360         $(call install-file)
 361 
 362     TARGETS += $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static.a
 363   endif
 364 
 365 else ifeq ($(OPENJDK_TARGET_OS), aix)
 366   # AIX also requires a static libjli because the compiler doesn't support '-rpath'
 367   $(eval $(call SetupNativeCompilation, BUILD_LIBJLI_STATIC, \
 368       NAME := jli_static, \
 369       TYPE := STATIC_LIBRARY, \
 370       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE), \
 371       SRC := $(LIBJLI_SRC_DIRS), \
 372       EXCLUDE_FILES := $(LIBJLI_EXCLUDE_FILES), \
 373       EXTRA_FILES := $(LIBJLI_EXTRA_FILES), \
 374       OPTIMIZATION := HIGH, \
 375       CFLAGS := $(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS), \
 376       ARFLAGS := $(ARFLAGS), \
 377       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static))
 378 
 379   TARGETS += $(BUILD_LIBJLI_STATIC)
 380 
 381 endif
--- EOF ---