CoreLibraries.gmk 20.5 KB
Newer Older
I
ihse 已提交
1
#
2
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
I
ihse 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

26 27 28
# Include custom extensions if available.
-include $(CUSTOM_MAKE_DIR)/lib/CoreLibraries.gmk

I
ihse 已提交
29 30 31 32
WIN_VERIFY_LIB := $(JDK_OUTPUTDIR)/objs/libverify/verify.lib

##########################################################################################

33
BUILD_LIBFDLIBM_OPTIMIZATION := NONE
I
ihse 已提交
34

35 36 37 38
ifeq ($(OPENJDK_TARGET_OS), solaris)
  BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
endif

39 40 41 42 43 44 45

# If FDLIBM_CFLAGS is non-empty we know that we can optimize
# fdlibm when adding those extra C flags. Currently GCC only.
LIBFDLIBM_CFLAGS :=
ifneq ($(FDLIBM_CFLAGS), )
  BUILD_LIBFDLIBM_OPTIMIZATION := HIGH
  LIBFDLIBM_CFLAGS := $(FDLIBM_CFLAGS)
I
ihse 已提交
46 47 48
endif

ifneq ($(OPENJDK_TARGET_OS), macosx)
49 50 51 52 53
  # Unfortunately, '-ffp-contract' is only available since gcc 4.6. For ppc64le
  # that's no problem since ppc64le support only appeared in gcc 4.8.3. But on
  # ppc64 (big endian) we traditionally compiled with gcc 4.3 which only knows
  # '-mno-fused-madd'. However, that's still not enough to get the float
  # computations right - we additionally have to supply '-fno-strict-aliasing'.
I
ihse 已提交
54 55 56 57 58 59 60 61 62
  $(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM, \
      STATIC_LIBRARY := fdlibm, \
      OUTPUT_DIR := $(JDK_OUTPUTDIR)/objs, \
      SRC := $(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/src, \
      LANG := C, \
      OPTIMIZATION := $(BUILD_LIBFDLIBM_OPTIMIZATION), \
      CFLAGS := $(CFLAGS_JDKLIB) \
          -I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include, \
      CFLAGS_windows_debug := -DLOGGING, \
K
Merge  
kvn 已提交
63
      CFLAGS_aix := -qfloat=nomaf, \
64
      CFLAGS_linux := $(LIBFDLIBM_CFLAGS), \
I
ihse 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
      ARFLAGS := $(ARFLAGS), \
      OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libfdlibm, \
      DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))

else

  # On macosx the old build does partial (incremental) linking of fdlibm instead of
  # a plain static library.
  $(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM_MAC, \
      LIBRARY := fdlibm, \
      OUTPUT_DIR := $(JDK_OUTPUTDIR)/objs/libfdlibm, \
      SRC := $(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/src, \
      LANG := C, \
      CFLAGS := $(CFLAGS_JDKLIB) \
          -I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include, \
      LDFLAGS := -nostdlib -r -arch x86_64, \
      OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libfdlibm, \
      DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))

  BUILD_LIBFDLIBM := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)
  $(BUILD_LIBFDLIBM): $(BUILD_LIBFDLIBM_MAC)
	$(call install-file)

endif

BUILD_LIBRARIES += $(BUILD_LIBFDLIBM)

##########################################################################################

BUILD_LIBVERIFY_SRC := check_code.c check_format.c

ifeq ($(OPENJDK_TARGET_OS), solaris)
  ifneq ($(OPENJDK_TARGET_CPU), x86_64)
I
ihse 已提交
98
    BUILD_LIBVERIFY_REORDER := $(JDK_TOPDIR)/make/mapfiles/libverify/reorder-$(OPENJDK_TARGET_CPU)
I
ihse 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
  endif
endif

LIBVERIFY_OPTIMIZATION := HIGH
ifneq ($(findstring $(OPENJDK_TARGET_OS), solaris linux), )
  ifeq ($(ENABLE_DEBUG_SYMBOLS), true)
    LIBVERIFY_OPTIMIZATION := LOW
  endif
endif

$(eval $(call SetupNativeCompilation,BUILD_LIBVERIFY, \
    LIBRARY := verify, \
    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
    SRC := $(JDK_TOPDIR)/src/share/native/common, \
    INCLUDE_FILES := $(BUILD_LIBVERIFY_SRC), \
    LANG := C, \
    OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \
    CFLAGS := $(CFLAGS_JDKLIB), \
I
ihse 已提交
117
    MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libverify/mapfile-vers, \
I
ihse 已提交
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
    LDFLAGS := $(LDFLAGS_JDKLIB) \
        $(call SET_SHARED_LIBRARY_ORIGIN), \
    LDFLAGS_SUFFIX_posix := -ljvm -lc, \
    LDFLAGS_SUFFIX_windows := jvm.lib, \
    VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
    RC_FLAGS := $(RC_FLAGS) \
        -D "JDK_FNAME=verify.dll" \
        -D "JDK_INTERNAL_NAME=verify" \
        -D "JDK_FTYPE=0x2L", \
    REORDER := $(BUILD_LIBVERIFY_REORDER), \
    OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libverify, \
    DEBUG_SYMBOLS := true))

BUILD_LIBRARIES += $(BUILD_LIBVERIFY)

##########################################################################################

135 136
# Allow a custom makefile to add extra src dirs
LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/lang \
I
ihse 已提交
137 138 139 140 141 142 143
    $(JDK_TOPDIR)/src/share/native/java/lang \
    $(JDK_TOPDIR)/src/share/native/java/lang/reflect \
    $(JDK_TOPDIR)/src/share/native/java/io \
    $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/io \
    $(JDK_TOPDIR)/src/share/native/java/nio \
    $(JDK_TOPDIR)/src/share/native/java/security \
    $(JDK_TOPDIR)/src/share/native/common \
144
    $(JDK_TOPDIR)/src/share/native/com/alibaba/jwarmup \
145
    $(JDK_TOPDIR)/src/share/native/com/alibaba/jvm/gc \
I
ihse 已提交
146 147 148 149 150 151 152
    $(JDK_TOPDIR)/src/share/native/sun/misc \
    $(JDK_TOPDIR)/src/share/native/sun/reflect \
    $(JDK_TOPDIR)/src/share/native/java/util \
    $(JDK_TOPDIR)/src/share/native/java/util/concurrent/atomic \
    $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \
    $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/util

153
ifeq ($(OPENJDK_TARGET_OS), windows)
I
ihse 已提交
154
  LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/util/locale/provider
155
else ifeq ($(OPENJDK_TARGET_OS), macosx)
I
ihse 已提交
156 157 158 159 160 161 162 163
  LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/util/locale/provider
endif

ifeq ($(OPENJDK_TARGET_OS), windows)
  LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/provider \
      $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/io
endif

164 165 166
# Make it possible to override this variable
LIBJAVA_MAPFILE ?= $(JDK_TOPDIR)/make/mapfiles/libjava/mapfile-vers

I
ihse 已提交
167 168 169 170 171 172 173
LIBJAVA_CFLAGS := $(foreach dir, $(LIBJAVA_SRC_DIRS), -I$(dir)) \
    -I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include \
    -DARCHPROPNAME='"$(OPENJDK_TARGET_CPU_OSARCH)"'

LIBJAVA_CFLAGS += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
    -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' \
    -DJDK_MICRO_VERSION='"$(JDK_MICRO_VERSION)"' \
174 175
     -DJDK_BUILD_NUMBER='"$(JDK_BUILD_NUMBER)"'  \
     $(VERSION_CFLAGS)
I
ihse 已提交
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206

ifneq (, $(JDK_UPDATE_VERSION))
  LIBJAVA_CFLAGS += -DJDK_UPDATE_VERSION='"$(JDK_UPDATE_VERSION)"'
endif

LIBJAVA_EXCLUDE_FILES := check_code.c check_format.c jspawnhelper.c

ifneq ($(OPENJDK_TARGET_OS), macosx)
  LIBJAVA_EXCLUDE_FILES += java_props_macosx.c
else
  BUILD_LIBJAVA_java_props_md.c_CFLAGS := -x objective-c
  BUILD_LIBJAVA_java_props_macosx.c_CFLAGS := -x objective-c
endif

ifeq ($(OPENJDK_TARGET_OS), windows)
  LIBJAVA_EXCLUDE_FILES += \
      UNIXProcess_md.c \
      UnixFileSystem_md.c \
      FileSystemPreferences.c
else
  LIBJAVA_EXCLUDE_FILES += \
      ProcessImpl_md.c \
      WinNTFileSystem_md.c \
      dirent_md.c \
      WindowsPreferences.c \
      sun/security/provider/WinCAPISeedGenerator.c \
      sun/io/Win32ErrorMode.c
endif

ifeq ($(OPENJDK_TARGET_OS), solaris)
  ifneq ($(OPENJDK_TARGET_CPU), x86_64)
I
ihse 已提交
207
    LIBJAVA_REORDER := $(JDK_TOPDIR)/make/mapfiles/libjava/reorder-$(OPENJDK_TARGET_CPU)
I
ihse 已提交
208 209 210 211 212 213 214 215 216 217 218 219 220
  endif
endif

$(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \
    LIBRARY := java, \
    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
    SRC := $(LIBJAVA_SRC_DIRS), \
    EXCLUDES := fdlibm/src zip, \
    EXCLUDE_FILES := $(LIBJAVA_EXCLUDE_FILES), \
    LANG := C, \
    OPTIMIZATION := HIGH, \
    CFLAGS := $(CFLAGS_JDKLIB) \
        $(LIBJAVA_CFLAGS), \
221
    MAPFILE := $(LIBJAVA_MAPFILE), \
I
ihse 已提交
222 223 224 225 226
    LDFLAGS := $(LDFLAGS_JDKLIB) \
        $(call SET_SHARED_LIBRARY_ORIGIN), \
    LDFLAGS_SUFFIX_posix := -ljvm -lverify, \
    LDFLAGS_SUFFIX_solaris := -lsocket -lnsl -lscf $(LIBDL) $(BUILD_LIBFDLIBM) -lc, \
    LDFLAGS_SUFFIX_linux := $(LIBDL) $(BUILD_LIBFDLIBM), \
K
Merge  
kvn 已提交
227
    LDFLAGS_SUFFIX_aix := $(LIBDL) $(BUILD_LIBFDLIBM) -lm,\
I
ihse 已提交
228 229 230 231 232
    LDFLAGS_SUFFIX_macosx := -L$(JDK_OUTPUTDIR)/objs/ -lfdlibm \
        -framework CoreFoundation \
        -framework Foundation \
        -framework Security -framework SystemConfiguration, \
    LDFLAGS_SUFFIX_windows := -export:winFileHandleOpen -export:handleLseek \
233
        -export:getErrorString \
I
ihse 已提交
234 235
        jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
        shell32.lib delayimp.lib -DELAYLOAD:shell32.dll \
236
        advapi32.lib version.lib, \
I
ihse 已提交
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
    VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
    RC_FLAGS := $(RC_FLAGS) \
        -D "JDK_FNAME=java.dll" \
        -D "JDK_INTERNAL_NAME=java" \
        -D "JDK_FTYPE=0x2L", \
    REORDER := $(LIBJAVA_REORDER), \
    OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjava, \
    DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))

BUILD_LIBRARIES += $(BUILD_LIBJAVA)

$(BUILD_LIBJAVA): $(LIBJLI_BINARY)

$(BUILD_LIBJAVA): $(BUILD_LIBVERIFY)

$(BUILD_LIBJAVA): $(BUILD_LIBFDLIBM)

##########################################################################################

BUILD_LIBZIP_EXCLUDES :=
ifeq ($(USE_EXTERNAL_LIBZ), true)
  LIBZ := -lz
C
coffeys 已提交
259
  LIBZIP_EXCLUDES += zlib
I
ihse 已提交
260
else
C
coffeys 已提交
261
  ZLIB_CPPFLAGS := -I$(JDK_TOPDIR)/src/share/native/java/util/zip/zlib
I
ihse 已提交
262 263 264 265 266
endif

BUILD_LIBZIP_REORDER :=
ifeq ($(OPENJDK_TARGET_OS), solaris)
  ifneq ($(OPENJDK_TARGET_CPU), x86_64)
I
ihse 已提交
267
    BUILD_LIBZIP_REORDER := $(JDK_TOPDIR)/make/mapfiles/libzip/reorder-$(OPENJDK_TARGET_CPU)
I
ihse 已提交
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
  endif
endif

ifeq ($(LIBZIP_CAN_USE_MMAP), true)
  BUILD_LIBZIP_MMAP := -DUSE_MMAP
endif

$(eval $(call SetupNativeCompilation,BUILD_LIBZIP, \
    LIBRARY := zip, \
    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
    LANG := C, \
    OPTIMIZATION := LOW, \
    SRC := $(JDK_TOPDIR)/src/share/native/java/util/zip, \
    EXCLUDES := $(LIBZIP_EXCLUDES), \
    CFLAGS := $(CFLAGS_JDKLIB) \
        $(ZLIB_CPPFLAGS) \
        -I$(JDK_TOPDIR)/src/share/native/java/io \
        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/io, \
    CFLAGS_posix := $(BUILD_LIBZIP_MMAP) -UDEBUG, \
I
ihse 已提交
287
    MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libzip/mapfile-vers, \
I
ihse 已提交
288 289 290 291 292
    REORDER := $(BUILD_LIBZIP_REORDER), \
    LDFLAGS := $(LDFLAGS_JDKLIB) \
        $(call SET_SHARED_LIBRARY_ORIGIN) \
        $(EXPORT_ZIP_FUNCS), \
    LDFLAGS_windows := -export:ZIP_Open -export:ZIP_Close -export:ZIP_FindEntry \
J
jiangli 已提交
293
        -export:ZIP_ReadEntry -export:ZIP_GetNextEntry -export:ZIP_CRC32 jvm.lib \
I
ihse 已提交
294 295 296
        $(WIN_JAVA_LIB), \
    LDFLAGS_SUFFIX_linux := -ljvm -ljava $(LIBZ), \
    LDFLAGS_SUFFIX_solaris := -ljvm -ljava $(LIBZ) -lc, \
297
    LDFLAGS_SUFFIX_aix := -ljvm -ljava $(LIBZ),\
I
ihse 已提交
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
    LDFLAGS_SUFFIX_macosx := $(LIBZ) -ljava -ljvm, \
    VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
    RC_FLAGS := $(RC_FLAGS) \
        -D "JDK_FNAME=zip.dll" \
        -D "JDK_INTERNAL_NAME=zip" \
        -D "JDK_FTYPE=0x2L", \
    OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libzip, \
    DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))


$(BUILD_LIBZIP): $(BUILD_LIBJAVA)

BUILD_LIBRARIES += $(BUILD_LIBZIP)

##########################################################################################

$(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK, \
    LIBRARY := unpack, \
    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
    SRC := $(JDK_TOPDIR)/src/share/native/com/sun/java/util/jar/pack, \
    EXCLUDE_FILES := main.cpp, \
    LANG := C++, \
    OPTIMIZATION := LOW, \
    CFLAGS := $(CXXFLAGS_JDKLIB) \
        -DNO_ZLIB -DUNPACK_JNI -DFULL, \
    CFLAGS_release := -DPRODUCT, \
I
ihse 已提交
324
    MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers, \
I
ihse 已提交
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
    LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
        $(call SET_SHARED_LIBRARY_ORIGIN), \
    LDFLAGS_windows := -map:$(JDK_OUTPUTDIR)/objs/unpack.map -debug \
        jvm.lib $(WIN_JAVA_LIB), \
    LDFLAGS_SUFFIX_posix := -ljvm $(LIBCXX) -ljava -lc, \
    OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libunpack, \
    VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
    RC_FLAGS := $(RC_FLAGS) \
        -D "JDK_FNAME=unpack.dll" \
        -D "JDK_INTERNAL_NAME=unpack" \
        -D "JDK_FTYPE=0x2L", \
    DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))

$(BUILD_LIBUNPACK): $(BUILD_LIBJAVA)

BUILD_LIBRARIES += $(BUILD_LIBUNPACK)

ifeq ($(OPENJDK_TARGET_OS), windows)
  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)unpack.map: $(BUILD_LIBUNPACK)
	$(ECHO) Copying $(@F)
	$(CP) $(patsubst %$(SHARED_LIBRARY_SUFFIX), %.map, $<) $@

  $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)unpack.pdb: $(BUILD_LIBUNPACK)
	$(ECHO) Copying $(@F)
	$(CP) $(patsubst %$(SHARED_LIBRARY_SUFFIX), %.pdb, $<) $@
endif

##########################################################################################

BUILD_LIBJLI_SRC_DIRS := $(JDK_TOPDIR)/src/share/bin $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin
LIBJLI_CFLAGS := $(CFLAGS_JDKLIB) $(foreach dir, $(BUILD_LIBJLI_SRC_DIRS), -I$(dir))

BUILD_LIBJLI_FILES := \
    java.c \
    splashscreen_stubs.c \
    parse_manifest.c \
    version_comp.c \
    wildcard.c \
    jli_util.c

ifeq ($(JVM_VARIANT_ZERO), true)
  ERGO_FAMILY := zero
else
  ifeq ($(OPENJDK_TARGET_CPU_ARCH), x86)
    ERGO_FAMILY := i586
  else
    ERGO_FAMILY := $(OPENJDK_TARGET_CPU_ARCH)
  endif
endif

ifeq ($(OPENJDK_TARGET_OS), macosx)
  LIBJLI_CFLAGS += -I$(JDK_TOPDIR)/src/macosx/bin
  BUILD_LIBJLI_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/bin
  BUILD_LIBJLI_FILES += java_md_common.c java_md_macosx.c

  BUILD_LIBJLI_java_md_macosx.c_CFLAGS := -x objective-c
  BUILD_LIBJLI_STATIC_java_md_macosx.c_CFLAGS := -x objective-c
endif

ifeq ($(OPENJDK_TARGET_OS), windows)
  BUILD_LIBJLI_FILES += java_md.c \
      cmdtoargs.c
  # Staticically link with c runtime on windows.
  LIBJLI_CFLAGS := $(filter-out -MD, $(LIBJLI_CFLAGS))
389 390 391 392 393
  # Supply the name of the C runtime lib.
  LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"'
  ifneq ($(MSVCP_DLL), )
    LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"'
  endif
I
ihse 已提交
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
else ifneq ($(OPENJDK_TARGET_OS), macosx)

  BUILD_LIBJLI_FILES += java_md_common.c
  BUILD_LIBJLI_FILES += java_md_solinux.c ergo.c

  ERGO_ARCH_FILE = ergo_$(ERGO_FAMILY).c

  # if the architecture specific ergo file exists then
  # use it, else use the generic definitions from ergo.c
  ifneq ($(wildcard $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin/$(ERGO_ARCH_FILE)), )
    BUILD_LIBJLI_FILES += $(ERGO_ARCH_FILE)
  else # !ERGO_ARCH_FILE
    LIBJLI_CFLAGS += -DUSE_GENERIC_ERGO
  endif # ERGO_ARCH_FILE
endif #WINDOWS

# Append defines depending on target platform
LIBJLI_CFLAGS += $(OPENJDK_TARGET_CPU_JLI_CFLAGS)

ifeq ($(OPENJDK_TARGET_OS), macosx)
  LIBJLI_CFLAGS += -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
endif

ifneq ($(USE_EXTERNAL_LIBZ), true)
C
coffeys 已提交
418
  BUILD_LIBJLI_SRC_DIRS += $(JDK_TOPDIR)/src/share/native/java/util/zip/zlib
I
ihse 已提交
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
  LIBJLI_CFLAGS += $(ZLIB_CPPFLAGS)
  BUILD_LIBJLI_FILES += \
      inflate.c \
      inftrees.c \
      inffast.c \
      zadler32.c \
      zcrc32.c \
      zutil.c
endif

ifeq ($(OPENJDK_TARGET_OS), windows)
  LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)
else
  LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)/jli
endif

$(eval $(call SetupNativeCompilation,BUILD_LIBJLI, \
    LIBRARY := jli, \
    OUTPUT_DIR := $(LIBJLI_OUTPUT_DIR), \
    SRC := $(BUILD_LIBJLI_SRC_DIRS), \
    INCLUDE_FILES := $(BUILD_LIBJLI_FILES), \
    LANG := C, \
    OPTIMIZATION := HIGH, \
    CFLAGS := $(LIBJLI_CFLAGS), \
I
ihse 已提交
443
    MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjli/mapfile-vers, \
I
ihse 已提交
444 445 446 447 448 449 450
    LDFLAGS := $(LDFLAGS_JDKLIB) \
        $(call SET_SHARED_LIBRARY_ORIGIN), \
    LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
    LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
    LDFLAGS_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \
    LDFLAGS_SUFFIX_solaris := $(LIBZ) $(LIBDL) -lc, \
    LDFLAGS_SUFFIX_linux := $(LIBZ) $(LIBDL) -lc -lpthread, \
451
    LDFLAGS_SUFFIX_aix := $(LIBZ) $(LIBDL),\
I
ihse 已提交
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
    LDFLAGS_SUFFIX_macosx := $(LIBZ), \
    LDFLAGS_SUFFIX_windows := \
        -export:JLI_Launch \
        -export:JLI_ManifestIterate \
        -export:JLI_SetTraceLauncher \
        -export:JLI_ReportErrorMessage \
        -export:JLI_ReportErrorMessageSys \
        -export:JLI_ReportMessage \
        -export:JLI_ReportExceptionDescription \
        -export:JLI_MemAlloc \
        -export:JLI_CmdToArgs \
        -export:JLI_GetStdArgc \
        -export:JLI_GetStdArgs \
        advapi32.lib \
        comctl32.lib \
        user32.lib, \
    VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
    RC_FLAGS := $(RC_FLAGS) \
        -D "JDK_FNAME=jli.dll" \
        -D "JDK_INTERNAL_NAME=jli" \
        -D "JDK_FTYPE=0x2L", \
    OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjli, \
    DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))

BUILD_LIBRARIES += $(BUILD_LIBJLI)

# On windows, the static library has the same suffix as the import library created by
# with the shared library, so the static library is given a different name. No harm
# in doing it for all platform to reduce complexity.
ifeq ($(OPENJDK_TARGET_OS), windows)
  $(eval $(call SetupNativeCompilation,BUILD_LIBJLI_STATIC, \
      STATIC_LIBRARY := jli_static, \
      OUTPUT_DIR := $(JDK_OUTPUTDIR)/objs, \
      SRC := $(BUILD_LIBJLI_SRC_DIRS), \
      INCLUDE_FILES := $(BUILD_LIBJLI_FILES), \
      LANG := C, \
      OPTIMIZATION := HIGH, \
      CFLAGS := $(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS), \
      ARFLAGS := $(ARFLAGS), \
      OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjli_static, \
      DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))

  BUILD_LIBRARIES += $(BUILD_LIBJLI_STATIC)

else ifeq ($(OPENJDK_TARGET_OS), macosx)
  #
  # On macosx they do partial (incremental) linking of libjli_static.a
  # code it here...rather than add support to NativeCompilation
  # as this is first time I see it
  $(eval $(call SetupNativeCompilation,BUILD_LIBJLI_STATIC, \
      LIBRARY := jli_static, \
      OUTPUT_DIR := $(JDK_OUTPUTDIR)/objs, \
      SRC := $(BUILD_LIBJLI_SRC_DIRS), \
      INCLUDE_FILES := $(BUILD_LIBJLI_FILES), \
      LANG := C, \
      OPTIMIZATION := HIGH, \
      CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \
      LDFLAGS := -nostdlib -r, \
      OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjli_static, \
      DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))

  $(JDK_OUTPUTDIR)/objs/libjli_static.a: $(BUILD_LIBJLI_STATIC)
	$(call install-file)

  BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/libjli_static.a
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532

else ifeq ($(OPENJDK_TARGET_OS), aix)
  # AIX also requires a static libjli because the compiler doesn't support '-rpath'
  $(eval $(call SetupNativeCompilation,BUILD_LIBJLI_STATIC,\
      STATIC_LIBRARY:=jli_static,\
      OUTPUT_DIR:=$(JDK_OUTPUTDIR)/objs,\
      SRC:=$(BUILD_LIBJLI_SRC_DIRS),\
      INCLUDE_FILES:=$(BUILD_LIBJLI_FILES),\
      LANG:=C,\
      OPTIMIZATION:=HIGH, \
      CFLAGS:=$(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS),\
      ARFLAGS:=$(ARFLAGS),\
      OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))

  BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/libjli_static.a

I
ihse 已提交
533 534 535 536 537 538 539 540 541 542 543 544 545
endif

##########################################################################################

$(eval $(call SetupNativeCompilation,BUILD_LIBNPT, \
    LIBRARY := npt, \
    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
    SRC := $(JDK_TOPDIR)/src/share/npt $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt, \
    LANG := C, \
    OPTIMIZATION := LOW, \
    CFLAGS := $(CFLAGS_JDKLIB) \
        -I$(JDK_TOPDIR)/src/share/npt \
        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/npt, \
I
ihse 已提交
546
    MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libnpt/mapfile-vers, \
I
ihse 已提交
547 548 549 550 551 552 553 554 555 556 557 558 559 560
    LDFLAGS := $(LDFLAGS_JDKLIB) \
        $(call SET_SHARED_LIBRARY_ORIGIN), \
    LDFLAGS_macosx := -liconv, \
    LDFLAGS_SUFFIX_windows := -export:nptInitialize -export:nptTerminate, \
    LDFLAGS_SUFFIX_solaris := -lc, \
    VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
    RC_FLAGS := $(RC_FLAGS) \
        -D "JDK_FNAME=npt.dll" \
        -D "JDK_INTERNAL_NAME=npt" \
        -D "JDK_FTYPE=0x2L", \
    OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libnpt, \
    DEBUG_SYMBOLS := true))

BUILD_LIBRARIES += $(BUILD_LIBNPT)