view make/lib/Lib-java.base.gmk @ 49568:a0f22265e29c

8200298: Unify all unix versions of libjsig/jsig.c Reviewed-by: dholmes, stuefe
author ihse
date Tue, 10 Apr 2018 19:46:02 +0200
parents b85603908ae4
children f0aeede1b855
line wrap: on
line source
#
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
# 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.
#

include LibCommon.gmk

# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, lib/Lib-java.base.gmk))

# Prepare the find cache.
LIB_java.base_SRC_DIRS += $(TOPDIR)/src/java.base/*/native

$(eval $(call FillCacheFind, $(wildcard $(LIB_java.base_SRC_DIRS))))

################################################################################
# Create all the core libraries

include CoreLibraries.gmk

################################################################################
# Create the network library

LIBNET_SRC_DIRS := $(call FindSrcDirsForLib, java.base, net)

$(eval $(call SetupJdkLibrary, BUILD_LIBNET, \
    NAME := net, \
    SRC := $(LIBNET_SRC_DIRS), \
    OPTIMIZATION := LOW, \
    CFLAGS := $(CFLAGS_JDKLIB) -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
        $(LIBJAVA_HEADER_FLAGS) $(addprefix -I, $(LIBNET_SRC_DIRS)), \
    DISABLED_WARNINGS_gcc := format-nonliteral, \
    DISABLED_WARNINGS_clang := parentheses-equality constant-logical-operand, \
    DISABLED_WARNINGS_microsoft := 4244 4047 4133 4996, \
    DISABLED_WARNINGS_solstudio := E_ARG_INCOMPATIBLE_WITH_ARG_L, \
    LDFLAGS := $(LDFLAGS_JDKLIB) \
        $(call SET_SHARED_LIBRARY_ORIGIN), \
    LDFLAGS_windows := -delayload:secur32.dll -delayload:iphlpapi.dll, \
    LIBS_unix := -ljvm -ljava, \
    LIBS_linux := $(LIBDL) -lpthread, \
    LIBS_solaris := -lnsl -lsocket $(LIBDL), \
    LIBS_aix := $(LIBDL),\
    LIBS_windows := ws2_32.lib jvm.lib secur32.lib iphlpapi.lib winhttp.lib \
        delayimp.lib $(WIN_JAVA_LIB) advapi32.lib, \
    LIBS_macosx := -framework CoreFoundation -framework CoreServices, \
))

$(BUILD_LIBNET): $(BUILD_LIBJAVA)

TARGETS += $(BUILD_LIBNET)

################################################################################
# Create the nio library

BUILD_LIBNIO_SRC := \
    $(TOPDIR)/src/java.base/share/native/libnio \
    $(TOPDIR)/src/java.base/share/native/libnio/ch \
    $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio \
    $(sort $(wildcard \
      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio/ch \
      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio/fs \
      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnio/ch \
      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnio/fs)) \
    #

BUILD_LIBNIO_CFLAGS := \
    $(addprefix -I, $(BUILD_LIBNIO_SRC)) \
    -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
    $(LIBJAVA_HEADER_FLAGS) \
    $(addprefix -I, $(BUILD_LIBNET_SRC))

$(eval $(call SetupJdkLibrary, BUILD_LIBNIO, \
    NAME := nio, \
    SRC := $(BUILD_LIBNIO_SRC), \
    EXCLUDE_FILES := $(BUILD_LIBNIO_EXFILES), \
    OPTIMIZATION := HIGH, \
    WARNINGS_AS_ERRORS_xlc := false, \
    CFLAGS := $(CFLAGS_JDKLIB) \
        $(BUILD_LIBNIO_CFLAGS), \
    LDFLAGS := $(LDFLAGS_JDKLIB) \
        $(call SET_SHARED_LIBRARY_ORIGIN), \
    LIBS_unix := -ljava -lnet, \
    LIBS_linux := -lpthread $(LIBDL), \
    LIBS_solaris := -ljvm -lsocket -lposix4 $(LIBDL) \
        -lsendfile, \
    LIBS_aix := $(LIBDL), \
    LIBS_macosx := \
        -framework CoreFoundation -framework CoreServices, \
    LIBS_windows := jvm.lib ws2_32.lib $(WIN_JAVA_LIB) \
        $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libnet/net.lib \
        advapi32.lib, \
))

TARGETS += $(BUILD_LIBNIO)

$(BUILD_LIBNIO): $(BUILD_LIBNET)

################################################################################
# Create the macosx security library

ifeq ($(OPENJDK_TARGET_OS), macosx)
  # JavaNativeFoundation framework not supported in static builds
  ifneq ($(STATIC_BUILD), true)

    LIBOSXSECURITY_DIRS := $(TOPDIR)/src/java.base/macosx/native/libosxsecurity
    LIBOSXSECURITY_CFLAGS := -I$(LIBOSXSECURITY_DIRS) \
        $(LIBJAVA_HEADER_FLAGS) \
        -I$(SUPPORT_OUTPUTDIR)/headers/java.base \

    $(eval $(call SetupJdkLibrary, BUILD_LIBOSXSECURITY, \
        NAME := osxsecurity, \
        SRC := $(LIBOSXSECURITY_DIRS), \
        OPTIMIZATION := LOW, \
        CFLAGS := $(CFLAGS_JDKLIB) \
            $(LIBOSXSECURITY_CFLAGS), \
        DISABLED_WARNINGS_clang := deprecated-declarations, \
        LDFLAGS := $(LDFLAGS_JDKLIB) \
            -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base \
            $(call SET_SHARED_LIBRARY_ORIGIN) \
            -fobjc-link-runtime, \
        LIBS := \
            -framework JavaNativeFoundation \
            -framework CoreServices \
            -framework Security \
            $(JDKLIB_LIBS), \
    ))

    $(BUILD_LIBOSXSECURITY): $(BUILD_LIBJAVA)

    TARGETS += $(BUILD_LIBOSXSECURITY)

  endif
endif

################################################################################
# Create the jsig library

ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
  ifeq ($(STATIC_BUILD), false)

    LIBJSIG_SRC_DIR := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjsig
    LIBJSIG_MAPFILE := $(wildcard $(TOPDIR)/make/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS))

    ifeq ($(OPENJDK_TARGET_OS), linux)
      # FIXME: This is probably not what we want to do, but keep it now for compatibility.
      LIBJSIG_CFLAGS := $(EXPORT_ALL_SYMBOLS)
    endif

    $(eval $(call SetupJdkLibrary, BUILD_LIBJSIG, \
        NAME := jsig, \
        SRC := $(LIBJSIG_SRC_DIR), \
        CFLAGS := $(CFLAGS_JDKLIB) $(LIBJSIG_CFLAGS), \
        LDFLAGS := $(LDFLAGS_JDKLIB) \
            $(call SET_SHARED_LIBRARY_ORIGIN), \
        LIBS_linux := $(LIBDL), \
        LIBS_solaris := $(LIBDL), \
        LIBS_aix := $(LIBDL), \
        MAPFILE := $(LIBJSIG_MAPFILE), \
    ))

    TARGETS += $(BUILD_LIBJSIG)

    ############################################################################
    # Create symlinks to libjsig in each JVM variant sub dir
    LIB_OUTPUTDIR := $(call FindLibDirForModule, java.base)

    # $1 variant subdir
    define CreateSymlinks
      # Always symlink from libdir/variant/libjsig.so -> ../libjsig.so.
      $(LIB_OUTPUTDIR)/$1/$(call SHARED_LIBRARY,jsig): \
          $(LIB_OUTPUTDIR)/$(call SHARED_LIBRARY,jsig)
		$$(call MakeDir, $$(@D))
		$(RM) $$@
		$(LN) -s ../$$(@F) $$@

      TARGETS += $(LIB_OUTPUTDIR)/$1/$(call SHARED_LIBRARY,jsig)
    endef

    # The subdir is the same as the variant for client and minimal, for all
    # others it's server.
    VARIANT_SUBDIRS := $(filter client minimal, $(JVM_VARIANTS)) \
        $(if $(filter-out client minimal, $(JVM_VARIANTS)), server)
    $(foreach v, $(VARIANT_SUBDIRS), $(eval $(call CreateSymlinks,$v)))

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

  endif
endif

################################################################################
# Create the symbols file for static builds.

ifeq ($(STATIC_BUILD), true)
  JAVA_BASE_EXPORT_SYMBOLS_SRC := \
      $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/jli/$(LIBRARY_PREFIX)jli.symbols \
      $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/$(LIBRARY_PREFIX)java.symbols \
      $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/$(LIBRARY_PREFIX)net.symbols \
      $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/$(LIBRARY_PREFIX)nio.symbols \
      $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/$(LIBRARY_PREFIX)verify.symbols \
      $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/$(LIBRARY_PREFIX)zip.symbols \
      $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/$(LIBRARY_PREFIX)jimage.symbols \
      $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/server/$(LIBRARY_PREFIX)jvm.symbols \
      #

  JAVA_BASE_EXPORT_SYMBOL_FILE := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/java.base.symbols

  $(JAVA_BASE_EXPORT_SYMBOL_FILE): $(JAVA_BASE_EXPORT_SYMBOLS_SRC)
	$(call LogInfo, Generating java.base.symbols file)
	$(CAT) $^ > $@

  # The individual symbol files is generated when the respective lib is built
  $(JAVA_BASE_EXPORT_SYMBOLS_SRC): $(BUILD_LIBJLI) $(BUILD_LIBJAVA) \
      $(BUILD_LIBNET) $(BUILD_LIBNIO) $(BUILD_LIBVERIFY) $(BUILD_LIBZIP) \
      $(BUILD_LIBJIMAGE)

  TARGETS += $(JAVA_BASE_EXPORT_SYMBOL_FILE)
endif