hotspot/make/lib/CompileLibjsig.gmk
author lana
Tue, 08 Aug 2017 22:52:18 +0000
changeset 46168 a586a1c1a9e3
parent 42646 591ef3658bb0
permissions -rw-r--r--
Merge

#
# Copyright (c) 2013, 2016, 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.
#

################################################################################
# Create the libjsig.so shared library

default: all

include $(SPEC)
include MakeBase.gmk
include NativeCompilation.gmk

ifneq ($(OPENJDK_TARGET_OS), windows)
  ifeq ($(STATIC_BUILD), false)
    ifeq ($(OPENJDK_TARGET_OS), linux)
      LIBJSIG_CFLAGS := -fPIC -D_GNU_SOURCE -D_REENTRANT $(EXTRA_CFLAGS)
      LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE) $(EXTRA_CFLAGS)
      LIBJSIG_LIBS := $(LIBDL)

      # NOTE: The old build compiled this library without -soname.
      # To emulate this, we need to clear out SET_SHARED_LIBRARY_NAME.
      SET_SHARED_LIBRARY_NAME :=

      # Flags for other CPUs can be provided in EXTRA_CFLAGS
      ifeq ($(OPENJDK_TARGET_CPU), x86_64)
        LIBJSIG_CPU_FLAGS := -m64
      else ifeq ($(OPENJDK_TARGET_CPU), x86)
        LIBJSIG_CPU_FLAGS := -m32 -march=i586
      else ifeq ($(OPENJDK_TARGET_CPU), ppc64)
        LIBJSIG_CPU_FLAGS := -mcpu=powerpc64 -mtune=power5
      else ifeq ($(OPENJDK_TARGET_CPU), ppc64le)
        LIBJSIG_CPU_FLAGS := -DABI_ELFv2 -mcpu=power8 -mtune=power8
      else ifeq ($(OPENJDK_TARGET_CPU), s390x)
        LIBJSIG_CPU_FLAGS := -mbackchain -march=z10
      endif

    else ifeq ($(OPENJDK_TARGET_OS), solaris)
      LIBJSIG_CFLAGS := -m64 -KPIC -mt
      LIBJSIG_LDFLAGS := -m64 -mt -xnolib
      LIBJSIG_LIBS := $(LIBDL)

      # NOTE: The old build compiled this library without -soname.
      # To emulate this, we need to clear out SET_SHARED_LIBRARY_NAME.
      SET_SHARED_LIBRARY_NAME :=

    else ifeq ($(OPENJDK_TARGET_OS), aix)
      LIBJSIG_CFLAGS := -q64 -D_GNU_SOURCE -D_REENTRANT -qpic=large
      LIBJSIG_LDFLAGS := -b64 -bexpall -G -bnoentry -qmkshrobj -brtl -bnolibpath -bernotok
      LIBJSIG_LIBS := $(LIBDL)

      # NOTE: The old build compiled this library without -soname.
      # To emulate this, we need to clear out SET_SHARED_LIBRARY_NAME.
      SET_SHARED_LIBRARY_NAME :=

    else ifeq ($(OPENJDK_TARGET_OS), macosx)
      LIBJSIG_CFLAGS := -m64 -D_GNU_SOURCE -pthread -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fPIC
      LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE)
    else
      $(error Unknown target OS $(OPENJDK_TARGET_OS) in CompileLibjsig.gmk)
    endif

    LIBJSIG_SRC_FILE := $(HOTSPOT_TOPDIR)/src/os/$(HOTSPOT_TARGET_OS)/vm/jsig.c
    LIBJSIG_MAPFILE := $(wildcard $(HOTSPOT_TOPDIR)/make/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS))
    LIBJSIG_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/libjsig

    LIBJSIG_LDFLAGS += $(SHARED_LIBRARY_FLAGS)

    LIB_OUTPUTDIR := $(call FindLibDirForModule, java.base)

    $(eval $(call SetupNativeCompilation, BUILD_LIBJSIG, \
        LIBRARY := jsig, \
        EXTRA_FILES := $(LIBJSIG_SRC_FILE), \
        OUTPUT_DIR := $(LIB_OUTPUTDIR), \
        LANG := C, \
        CFLAGS := $(LIBJSIG_CFLAGS) $(LIBJSIG_CPU_FLAGS), \
        LDFLAGS := $(LIBJSIG_LDFLAGS) $(LIBJSIG_CPU_FLAGS), \
        LIBS := $(LIBJSIG_LIBS), \
        MAPFILE := $(LIBJSIG_MAPFILE), \
        OBJECT_DIR := $(LIBJSIG_OUTPUTDIR)/objs, \
    ))

    TARGETS += $(BUILD_LIBJSIG)

    ############################################################################
    # Create symlinks in each variant sub dir
    ifeq ($(OPENJDK_TARGET_OS), macosx)
      DEBUG_INFO_SUFFIX := $(SHARED_LIBRARY_SUFFIX).dSYM
    else
      DEBUG_INFO_SUFFIX := .debuginfo
    endif

    # $1 variant subdir
    define CreateSymlinks
      # Always symlink from libdir/variant/libjsig.so -> ../libjsig.so and
      # the corresponding debuginfo.
      $(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)

      ifeq ($(COPY_DEBUG_SYMBOLS), true)
        $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX): \
            $(LIB_OUTPUTDIR)/$(call SHARED_LIBRARY,jsig)
		$$(call MakeDir, $$(@D))
		$(RM) $$@
		$(LN) -s ../$$(@F) $$@

        TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)

        ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
          $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz: \
              $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)
			$(CD) $$(@D) && $(ZIPEXE) -q -y $$@ $$(basename $$(@F))$(DEBUG_INFO_SUFFIX)

          TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz
        endif
      endif
    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)))

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

    include CopyToExplodedJdk.gmk

  endif
endif

all: $(TARGETS)

.PHONY: all