sa.make revision 2799
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts# This code is free software; you can redistribute it and/or modify it
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# under the terms of the GNU General Public License version 2 only, as
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# published by the Free Software Foundation.
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# This code is distributed in the hope that it will be useful, but WITHOUT
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# version 2 for more details (a copy is included in the LICENSE file that
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# accompanied this code).
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# You should have received a copy of the GNU General Public License version
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# 2 along with this work; if not, write to the Free Software Foundation,
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# or visit www.oracle.com if you need additional information or have any
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# This makefile (sa.make) is included from the sa.make in the
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# build directories.
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# This makefile is used to build Serviceability Agent java code
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# and generate JNI header file for native methods.
e440587b940248554524993d31d3e3f22997e62bBrian Baileyinclude $(GAMMADIR)/make/linux/makefiles/rules.make
e440587b940248554524993d31d3e3f22997e62bBrian BaileyAGENT_DIR = $(GAMMADIR)/agent
e440587b940248554524993d31d3e3f22997e62bBrian Baileyinclude $(GAMMADIR)/make/sa.files
e440587b940248554524993d31d3e3f22997e62bBrian BaileyTOPDIR = $(shell echo `pwd`)
e440587b940248554524993d31d3e3f22997e62bBrian BaileyGENERATED = $(TOPDIR)/../generated
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# tools.jar is needed by the JDI - SA binding
e440587b940248554524993d31d3e3f22997e62bBrian BaileySA_CLASSPATH = $(BOOT_JAVA_HOME)/lib/tools.jar
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# TODO: if it's a modules image, check if SA module is installed.
e440587b940248554524993d31d3e3f22997e62bBrian BaileyMODULELIB_PATH= $(BOOT_JAVA_HOME)/lib/modules
e440587b940248554524993d31d3e3f22997e62bBrian BaileyAGENT_FILES_LIST := $(GENERATED)/agent.classes.list
e440587b940248554524993d31d3e3f22997e62bBrian BaileySA_CLASSDIR = $(GENERATED)/saclasses
e440587b940248554524993d31d3e3f22997e62bBrian BaileySA_BUILD_VERSION_PROP = "sun.jvm.hotspot.runtime.VM.saBuildVersion=$(SA_BUILD_VERSION)"
96dfab48fc446b6279cce9e0ad25cea14380d96eJames PhillpottsSA_PROPERTIES = $(SA_CLASSDIR)/sa.properties
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts# if $(AGENT_DIR) does not exist, we don't build SA
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts# also, we don't build SA on Itanium, PowerPC, ARM or zero.
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" \
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts -a "$(SRCARCH)" != "arm" \
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts -a "$(SRCARCH)" != "ppc" \
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts -a "$(SRCARCH)" != "zero" ] ; then \
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts $(MAKE) -f sa.make $(GENERATED)/sa-jdi.jar; \
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts$(GENERATED)/sa-jdi.jar: $(AGENT_FILES)
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts $(QUIETLY) echo "Making $@"
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts $(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
e440587b940248554524993d31d3e3f22997e62bBrian Bailey echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) if [ ! -f $(SA_CLASSPATH) -a ! -d $(MODULELIB_PATH) ] ; then \
e440587b940248554524993d31d3e3f22997e62bBrian Bailey echo "Missing $(SA_CLASSPATH) file. Use 1.6.0 or later version of JDK";\
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) if [ ! -d $(SA_CLASSDIR) ] ; then \
e440587b940248554524993d31d3e3f22997e62bBrian Bailey mkdir -p $(SA_CLASSDIR); \
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# Note: When indented, make tries to execute the '$(shell' comment.
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts# In some environments, cmd processors have limited line length.
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# To prevent the javac invocation in the next block from using
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# a very long cmd line, we use javac's @file-list option. We
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# generate the file lists using make's built-in 'foreach' control
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# flow which also avoids cmd processor line length issues. Since
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# the 'foreach' is done as part of make's macro expansion phase,
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# the initialization of the lists is also done in the same phase
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# using '$(shell rm ...' instead of using the more traditional
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# 'rm ...' rule.
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(shell rm -rf $(AGENT_FILES_LIST))
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# gnumake 3.78.1 does not accept the *'s that
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# are in AGENT_FILES, so use the shell to expand them.
e440587b940248554524993d31d3e3f22997e62bBrian Bailey# Be extra carefull to not produce too long command lines in the shell!
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(foreach file,$(AGENT_FILES),$(shell ls -1 $(file) >> $(AGENT_FILES_LIST)))
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -classpath $(SA_CLASSPATH) -sourcepath $(AGENT_SRC_DIR) -d $(SA_CLASSDIR) @$(AGENT_FILES_LIST)
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) $(REMOTE) $(COMPILE.RMIC) -classpath $(SA_CLASSDIR) -d $(SA_CLASSDIR) sun.jvm.hotspot.debugger.remote.RemoteDebuggerServer
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) echo "$(SA_BUILD_VERSION_PROP)" > $(SA_PROPERTIES)
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql/sa.js
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/utilities/soql/sa.js $(SA_CLASSDIR)/sun/jvm/hotspot/utilities/soql
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) mkdir -p $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) rm -f $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/*
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) cp $(AGENT_SRC_DIR)/sun/jvm/hotspot/ui/resources/*.png $(SA_CLASSDIR)/sun/jvm/hotspot/ui/resources/
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) cp -r $(AGENT_SRC_DIR)/images/* $(SA_CLASSDIR)/
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) $(REMOTE) $(RUN.JAR) cf $@ -C $(SA_CLASSDIR)/ .
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) $(REMOTE) $(RUN.JAR) uf $@ -C $(AGENT_SRC_DIR) META-INF/services/com.sun.jdi.connect.Connector
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.x86.X86ThreadContext
e440587b940248554524993d31d3e3f22997e62bBrian Bailey $(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.ia64.IA64ThreadContext
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts $(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts $(QUIETLY) $(REMOTE) $(RUN.JAVAH) -classpath $(SA_CLASSDIR) -d $(GENERATED) -jni sun.jvm.hotspot.debugger.sparc.SPARCThreadContext
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts rm -rf $(SA_CLASSDIR)
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts rm -rf $(GENERATED)/sa-jdi.jar
96dfab48fc446b6279cce9e0ad25cea14380d96eJames Phillpotts rm -rf $(AGENT_FILES_LIST)