1 #
   2 # Copyright (c) 2013, 2016, 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 ################################################################################
  27 # Create the libjsig.so shared library
  28 
  29 default: all
  30 
  31 include $(SPEC)
  32 include MakeBase.gmk
  33 include NativeCompilation.gmk
  34 
  35 ifneq ($(OPENJDK_TARGET_OS), windows)
  36   ifeq ($(STATIC_BUILD), false)
  37     ifeq ($(OPENJDK_TARGET_OS), linux)
  38       LIBJSIG_CFLAGS := -fPIC -D_GNU_SOURCE -D_REENTRANT $(EXTRA_CFLAGS)
  39       LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE) $(EXTRA_CFLAGS)
  40       LIBJSIG_LIBS := $(LIBDL)
  41 
  42       # NOTE: The old build compiled this library without -soname.
  43       # To emulate this, we need to clear out SET_SHARED_LIBRARY_NAME.
  44       SET_SHARED_LIBRARY_NAME :=
  45 
  46       # Flags for other CPUs can be provided in EXTRA_CFLAGS
  47       ifeq ($(OPENJDK_TARGET_CPU), x86_64)
  48         LIBJSIG_CPU_FLAGS := -m64
  49       else ifeq ($(OPENJDK_TARGET_CPU), x86)
  50         LIBJSIG_CPU_FLAGS := -m32 -march=i586
  51       else ifeq ($(OPENJDK_TARGET_CPU), ppc64)
  52         LIBJSIG_CPU_FLAGS := -mcpu=powerpc64 -mtune=power5
  53       else ifeq ($(OPENJDK_TARGET_CPU), ppc64le)
  54         LIBJSIG_CPU_FLAGS := -DABI_ELFv2 -mcpu=power8 -mtune=power8
  55       else ifeq ($(OPENJDK_TARGET_CPU), s390x)
  56         LIBJSIG_CPU_FLAGS := -mbackchain -march=z10
  57       endif
  58 
  59     else ifeq ($(OPENJDK_TARGET_OS), solaris)
  60       LIBJSIG_CFLAGS := -m64 -KPIC -mt
  61       LIBJSIG_LDFLAGS := -m64 -mt -xnolib
  62       LIBJSIG_LIBS := $(LIBDL)
  63 
  64       # NOTE: The old build compiled this library without -soname.
  65       # To emulate this, we need to clear out SET_SHARED_LIBRARY_NAME.
  66       SET_SHARED_LIBRARY_NAME :=
  67 
  68     else ifeq ($(OPENJDK_TARGET_OS), aix)
  69       LIBJSIG_CFLAGS := -q64 -D_GNU_SOURCE -D_REENTRANT -qpic=large
  70       LIBJSIG_LDFLAGS := -b64 -bexpall -G -bnoentry -qmkshrobj -brtl -bnolibpath -bernotok
  71       LIBJSIG_LIBS := $(LIBDL)
  72 
  73       # NOTE: The old build compiled this library without -soname.
  74       # To emulate this, we need to clear out SET_SHARED_LIBRARY_NAME.
  75       SET_SHARED_LIBRARY_NAME :=
  76 
  77     else ifeq ($(OPENJDK_TARGET_OS), macosx)
  78       LIBJSIG_CFLAGS := -m64 -D_GNU_SOURCE -pthread -mno-omit-leaf-frame-pointer -mstack-alignment=16 -fPIC
  79       LIBJSIG_LDFLAGS := $(LDFLAGS_HASH_STYLE)
  80     else
  81       $(error Unknown target OS $(OPENJDK_TARGET_OS) in CompileLibjsig.gmk)
  82     endif
  83 
  84     LIBJSIG_SRC_FILE := $(HOTSPOT_TOPDIR)/src/os/$(HOTSPOT_TARGET_OS)/vm/jsig.c
  85     LIBJSIG_MAPFILE := $(wildcard $(HOTSPOT_TOPDIR)/make/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS))
  86     LIBJSIG_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/libjsig
  87 
  88     LIBJSIG_LDFLAGS += $(SHARED_LIBRARY_FLAGS)
  89 
  90     LIB_OUTPUTDIR := $(call FindLibDirForModule, java.base)
  91 
  92     $(eval $(call SetupNativeCompilation, BUILD_LIBJSIG, \
  93         LIBRARY := jsig, \
  94         EXTRA_FILES := $(LIBJSIG_SRC_FILE), \
  95         OUTPUT_DIR := $(LIB_OUTPUTDIR), \
  96         LANG := C, \
  97         CFLAGS := $(LIBJSIG_CFLAGS) $(LIBJSIG_CPU_FLAGS), \
  98         LDFLAGS := $(LIBJSIG_LDFLAGS) $(LIBJSIG_CPU_FLAGS), \
  99         LIBS := $(LIBJSIG_LIBS), \
 100         MAPFILE := $(LIBJSIG_MAPFILE), \
 101         OBJECT_DIR := $(LIBJSIG_OUTPUTDIR)/objs, \
 102     ))
 103 
 104     TARGETS += $(BUILD_LIBJSIG)
 105 
 106     ############################################################################
 107     # Create symlinks in each variant sub dir
 108     ifeq ($(OPENJDK_TARGET_OS), macosx)
 109       DEBUG_INFO_SUFFIX := $(SHARED_LIBRARY_SUFFIX).dSYM
 110     else
 111       DEBUG_INFO_SUFFIX := .debuginfo
 112     endif
 113 
 114     # $1 variant subdir
 115     define CreateSymlinks
 116       # Always symlink from libdir/variant/libjsig.so -> ../libjsig.so and
 117       # the corresponding debuginfo.
 118       $(LIB_OUTPUTDIR)/$1/$(call SHARED_LIBRARY,jsig): \
 119           $(LIB_OUTPUTDIR)/$(call SHARED_LIBRARY,jsig)
 120                 $$(call MakeDir, $$(@D))
 121                 $(RM) $$@
 122                 $(LN) -s ../$$(@F) $$@
 123 
 124       TARGETS += $(LIB_OUTPUTDIR)/$1/$(call SHARED_LIBRARY,jsig)
 125 
 126       ifeq ($(COPY_DEBUG_SYMBOLS), true)
 127         $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX): \
 128             $(LIB_OUTPUTDIR)/$(call SHARED_LIBRARY,jsig)
 129                 $$(call MakeDir, $$(@D))
 130                 $(RM) $$@
 131                 $(LN) -s ../$$(@F) $$@
 132 
 133         TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)
 134 
 135         ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
 136           $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz: \
 137               $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)
 138                         $(CD) $$(@D) && $(ZIPEXE) -q -y $$@ $$(basename $$(@F))$(DEBUG_INFO_SUFFIX)
 139 
 140           TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz
 141         endif
 142       endif
 143     endef
 144 
 145     # The subdir is the same as the variant for client and minimal, for all
 146     # others it's server.
 147     VARIANT_SUBDIRS := $(filter client minimal, $(JVM_VARIANTS)) \
 148         $(if $(filter-out client minimal, $(JVM_VARIANTS)), server)
 149     $(foreach v, $(VARIANT_SUBDIRS), $(eval $(call CreateSymlinks,$v)))
 150 
 151     ############################################################################
 152 
 153     include CopyToExplodedJdk.gmk
 154 
 155   endif
 156 endif
 157 
 158 all: $(TARGETS)
 159 
 160 .PHONY: all