1 #
   2 # Copyright (c) 2011, 2014, 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 include LibCommon.gmk
  27 
  28 ################################################################################
  29 
  30 LIBINSTRUMENT_SRC := $(JDK_TOPDIR)/src/java.instrument/share/native/libinstrument \
  31     $(JDK_TOPDIR)/src/java.instrument/$(OPENJDK_TARGET_OS_TYPE)/native/libinstrument \
  32     #
  33 LIBINSTRUMENT_CFLAGS := $(CFLAGS_JDKLIB) \
  34     $(addprefix -I, $(LIBINSTRUMENT_SRC)) \
  35     -I$(JDK_OUTPUTDIR)/gensrc_headers/java.instrument \
  36     -I$(JDK_TOPDIR)/src/java.base/share/native/libjli \
  37     -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \
  38     #
  39 
  40 LIBINSTRUMENT_LDFLAGS :=
  41 LIBINSTRUMENT_LDFLAGS_SUFFIX :=
  42 
  43 ifeq ($(OPENJDK_TARGET_OS), windows)
  44   LIBINSTRUMENT_LDFLAGS += $(JDK_OUTPUTDIR)/objs/jli_static.lib $(WIN_JAVA_LIB) \
  45       -export:Agent_OnAttach advapi32.lib
  46   # Statically link the C runtime so that there are not dependencies on modules
  47   # not on the search patch when invoked from the Windows system directory
  48   # (or elsewhere).
  49   LIBINSTRUMENT_CFLAGS := $(filter-out -MD, $(LIBINSTRUMENT_CFLAGS))
  50   # equivalent of strcasecmp is stricmp on Windows
  51   LIBINSTRUMENT_CFLAGS += -Dstrcasecmp=stricmp
  52 else
  53   LIBINSTRUMENT_LDFLAGS_SUFFIX := -ljava
  54 endif
  55 
  56 $(eval $(call SetupNativeCompilation,BUILD_LIBINSTRUMENT, \
  57     LIBRARY := instrument, \
  58     OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
  59     SRC := $(LIBINSTRUMENT_SRC), \
  60     LANG := C, \
  61     OPTIMIZATION := LOW, \
  62     CFLAGS := $(LIBINSTRUMENT_CFLAGS) $(CFLAGS_WARNINGS_ARE_ERRORS), \
  63     CFLAGS_debug := -DJPLIS_LOGGING, \
  64     CFLAGS_release := -DNO_JPLIS_LOGGING, \
  65     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libinstrument/mapfile-vers, \
  66     LDFLAGS := $(LDFLAGS_JDKLIB) \
  67         $(call SET_SHARED_LIBRARY_ORIGIN) \
  68         $(LIBINSTRUMENT_LDFLAGS), \
  69     LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/jli), \
  70     LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/jli), \
  71     LDFLAGS_macosx := -Xlinker -all_load $(JDK_OUTPUTDIR)/objs/libjli_static.a \
  72         -framework Cocoa -framework Security -framework ApplicationServices, \
  73     LDFLAGS_SUFFIX := $(LIBINSTRUMENT_LDFLAGS_SUFFIX), \
  74     LDFLAGS_SUFFIX_macosx := -liconv $(LIBZ), \
  75     LDFLAGS_SUFFIX_solaris := $(LIBZ) -L $(INSTALL_LIBRARIES_HERE)/jli -ljli $(LIBDL) -lc, \
  76     LDFLAGS_SUFFIX_linux := $(LIBZ) -L $(INSTALL_LIBRARIES_HERE)/jli -ljli $(LIBDL), \
  77     LDFLAGS_SUFFIX_aix := $(LIBZ) -L$(JDK_OUTPUTDIR)/objs -ljli_static $(LIBDL),\
  78     VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
  79     RC_FLAGS := $(RC_FLAGS) \
  80         -D "JDK_FNAME=instrument.dll" \
  81         -D "JDK_INTERNAL_NAME=instrument" \
  82         -D "JDK_FTYPE=0x2L", \
  83     OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libinstrument, \
  84     DEBUG_SYMBOLS := true))
  85 
  86 ifneq (, $(findstring $(OPENJDK_TARGET_OS), macosx windows aix))
  87   $(BUILD_LIBINSTRUMENT): $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)jli_static$(STATIC_LIBRARY_SUFFIX)
  88 else
  89   $(BUILD_LIBINSTRUMENT): $(INSTALL_LIBRARIES_HERE)/jli/$(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX)
  90 endif
  91 $(BUILD_LIBINSTRUMENT): $(BUILD_LIBJAVA)
  92 
  93 INSTRUMENT_LIBRARIES += $(BUILD_LIBINSTRUMENT)
  94 
  95 ################################################################################
  96 
  97 java.instrument: $(INSTRUMENT_LIBRARIES)
  98 
  99 all: java.instrument
 100 
 101 .PHONY: all java.instrument