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