1 #
   2 # Copyright (c) 2003, 2011, 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 # Makefile for building the Java Programming Language Instrumentation Services
  27 # agent, supporting java.lang.instrument
  28 
  29 BUILDDIR = ../..
  30 PACKAGE = sun.instrument
  31 LIBRARY = instrument
  32 PRODUCT = sun
  33 
  34 # Configure the CFLAGS for this library.  Use static binding so that there
  35 # are not dependencies on modules not on the search patch when invoked from
  36 # the Windows system directory (or elsewhere).
  37 MS_RUNTIME_STATIC=true
  38 
  39 FILES_m = mapfile-vers
  40 
  41 JAVAC_MAX_WARNINGS = true
  42 JAVAC_WARNINGS_FATAL = true
  43 
  44 include $(BUILDDIR)/common/Defs.gmk
  45 
  46 # Use the mapfile-vers (See the mapfile located with this Makefile)
  47 ifdef FILES_m
  48 include $(BUILDDIR)/common/Mapfile-vers.gmk
  49 endif
  50 
  51 #
  52 # Files to compile.
  53 #
  54 FILES_c = \
  55         EncodingSupport.c \
  56         EncodingSupport_md.c \
  57         FileSystemSupport_md.c \
  58         InstrumentationImplNativeMethods.c \
  59         InvocationAdapter.c \
  60         JarFacade.c \
  61         JPLISAgent.c \
  62         JPLISAssert.c \
  63         JavaExceptions.c \
  64         PathCharsValidator.c \
  65         Reentrancy.c \
  66         Utilities.c
  67 
  68 #
  69 # -jaragent support requires zip and jar manfiest parser to be compiled
  70 # into the instrument library.
  71 #
  72 IO_PLATFORM_SRC = $(PLATFORM_SRC)/native/java/io
  73 LAUNCHER_SHARE_SRC = $(SHARE_SRC)/bin
  74 LAUNCHER_PLATFORM_SRC = $(PLATFORM_SRC)/bin
  75 
  76 FILES_c += \
  77         canonicalize_md.c
  78 
  79 FILES_export = \
  80         sun/instrument/InstrumentationImpl.java
  81 
  82 #
  83 # This controls the ability to do logging in the library.
  84 #
  85 CPPFLAGS_DBG += -DJPLIS_LOGGING
  86 CPPFLAGS_OPT += -DNO_JPLIS_LOGGING
  87 
  88 OTHER_INCLUDES = -I$(SHARE_SRC)/instrument
  89 OTHER_INCLUDES += -I$(PLATFORM_SRC)/instrument
  90 OTHER_INCLUDES += -I$(IO_PLATFORM_SRC)
  91 OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC) -I$(LAUNCHER_PLATFORM_SRC)
  92 
  93 #
  94 # Create a dependency on libjli (Java Launcher Infrastructure)
  95 #
  96 # On UNIX, this is a relative dependency using $ORIGIN. Unfortunately, to
  97 # do this reliably on Linux takes a different syntax than Solaris.
  98 #
  99 # On Windows, this is done by using the same directory as the executable
 100 # itself, as with all the Windows libraries.
 101 #
 102 ifeq ($(PLATFORM), windows)
 103   OTHER_LDLIBS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/jli.lib
 104   OTHER_LCF += -export:Agent_OnAttach
 105   # equivalent of strcasecmp is stricmp on Windows
 106   CPPFLAGS_COMMON += -Dstrcasecmp=stricmp
 107 else
 108 ifneq (,$(findstring $(PLATFORM), macosx))
 109   ifneq ($(ARCH), universal)
 110     LDFLAGS += -Wl,-all_load
 111   endif
 112   LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a
 113   OTHER_LDLIBS += -liconv
 114   ifeq ($(SYSTEM_ZLIB), true)
 115     OTHER_LDLIBS += -lz
 116   endif
 117 else
 118   LDFLAGS += -L $(LIBDIR)/$(LIBARCH)/jli
 119   OTHER_LDLIBS += -ljli
 120   OTHER_LDLIBS += -ldl 
 121   ifeq ($(PLATFORM), solaris)
 122     LDFLAGS += -R \$$ORIGIN/jli
 123   endif
 124   ifeq ($(PLATFORM), linux)
 125     LDFLAGS += $(LDFLAG_Z_ORIGIN)
 126     LDFLAGS += -Wl,--allow-shlib-undefined
 127     LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/jli
 128   endif
 129 endif
 130 endif
 131 
 132 ifeq ($(PLATFORM), macosx)
 133   LDFLAGS += -framework Cocoa -framework Security -framework ApplicationServices
 134 endif
 135 
 136 #
 137 # Library to compile.
 138 #
 139 include $(BUILDDIR)/common/Library.gmk
 140 
 141 # We don't want to link against -ljava
 142 JAVALIB=
 143 
 144 #
 145 # Add to ambient vpath so we pick up the library files
 146 #
 147 vpath %.c $(SHARE_SRC)/instrument $(PLATFORM_SRC)/instrument
 148 vpath %.c $(IO_PLATFORM_SRC)
 149