2106N/A#
2362N/A# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2106N/A#
2106N/A# Redistribution and use in source and binary forms, with or without
2106N/A# modification, are permitted provided that the following conditions
2106N/A# are met:
2106N/A#
2106N/A# - Redistributions of source code must retain the above copyright
2106N/A# notice, this list of conditions and the following disclaimer.
2106N/A#
2106N/A# - Redistributions in binary form must reproduce the above copyright
2106N/A# notice, this list of conditions and the following disclaimer in the
2106N/A# documentation and/or other materials provided with the distribution.
2106N/A#
2362N/A# - Neither the name of Oracle nor the names of its
2106N/A# contributors may be used to endorse or promote products derived
2106N/A# from this software without specific prior written permission.
2106N/A#
2106N/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
2106N/A# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2106N/A# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2106N/A# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
2106N/A# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2106N/A# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2106N/A# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2106N/A# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2106N/A# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2106N/A# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2106N/A# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2106N/A#
2106N/A
2106N/A########################################################################
2106N/A#
2106N/A# Sample GNU Makefile for building JVMTI Demo compiledMethodLoad
2106N/A#
2106N/A# Example uses:
2106N/A# gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
2106N/A# gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
2106N/A# gnumake JDK=<java_home> OSNAME=linux [OPT=true]
2106N/A# gnumake JDK=<java_home> OSNAME=win32 [OPT=true]
2106N/A#
2106N/A########################################################################
2106N/A
2106N/A# Source lists
2106N/ALIBNAME=compiledMethodLoad
2106N/ASOURCES=compiledMethodLoad.c ../agent_util/agent_util.c
2106N/A
2106N/A# Solaris Sun C Compiler Version 5.5
2106N/Aifeq ($(OSNAME), solaris)
2106N/A # Sun Solaris Compiler options needed
2106N/A COMMON_FLAGS=-mt -KPIC
2106N/A # Options that help find errors
2106N/A COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none
2106N/A # Check LIBARCH for any special compiler options
2106N/A LIBARCH=$(shell uname -p)
2106N/A ifeq ($(LIBARCH), sparc)
2106N/A COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
2106N/A endif
2106N/A ifeq ($(LIBARCH), sparcv9)
2106N/A COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
2106N/A endif
2106N/A ifeq ($(OPT), true)
2106N/A CFLAGS=-xO2 $(COMMON_FLAGS)
2106N/A else
2106N/A CFLAGS=-g $(COMMON_FLAGS)
2106N/A endif
2106N/A # Object files needed to create library
2106N/A OBJECTS=$(SOURCES:%.c=%.o)
2106N/A # Library name and options needed to build it
2106N/A LIBRARY=lib$(LIBNAME).so
2106N/A LDFLAGS=-z defs -ztext
2106N/A # Libraries we are dependent on
2106N/A LIBRARIES= -lc
2106N/A # Building a shared library
2106N/A LINK_SHARED=$(LINK.c) -G -o $@
2106N/Aendif
2106N/A
2106N/A# Linux GNU C Compiler
2106N/Aifeq ($(OSNAME), linux)
2106N/A # GNU Compiler options needed to build it
2106N/A COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
2106N/A # Options that help find errors
2106N/A COMMON_FLAGS+= -W -Wall -Wno-unused -Wno-parentheses
2106N/A ifeq ($(OPT), true)
2106N/A CFLAGS=-O2 $(COMMON_FLAGS)
2106N/A else
2106N/A CFLAGS=-g $(COMMON_FLAGS)
2106N/A endif
2106N/A # Object files needed to create library
2106N/A OBJECTS=$(SOURCES:%.c=%.o)
2106N/A # Library name and options needed to build it
2106N/A LIBRARY=lib$(LIBNAME).so
5029N/A LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
2106N/A # Libraries we are dependent on
2106N/A LIBRARIES=-lc
2106N/A # Building a shared library
2106N/A LINK_SHARED=$(LINK.c) -shared -o $@
2106N/Aendif
2106N/A
2106N/A# Windows Microsoft C/C++ Optimizing Compiler Version 12
2106N/Aifeq ($(OSNAME), win32)
2106N/A CC=cl
2106N/A # Compiler options needed to build it
2106N/A COMMON_FLAGS=-Gy -DWIN32
2106N/A # Options that help find errors
2106N/A COMMON_FLAGS+=-W0 -WX
2106N/A ifeq ($(OPT), true)
2106N/A CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS)
2106N/A else
2106N/A CFLAGS= -Od -Zi $(COMMON_FLAGS)
2106N/A endif
2106N/A # Object files needed to create library
2106N/A OBJECTS=$(SOURCES:%.c=%.obj)
2106N/A # Library name and options needed to build it
2106N/A LIBRARY=$(LIBNAME).dll
2106N/A LDFLAGS=
2106N/A # Libraries we are dependent on
2106N/A LIBRARIES=
2106N/A # Building a shared library
2106N/A LINK_SHARED=link -dll -out:$@
2106N/Aendif
2106N/A
2106N/A# Common -I options
2106N/ACFLAGS += -I.
2106N/ACFLAGS += -I../agent_util
2106N/ACFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
2106N/A
2106N/A# Default rule
2106N/Aall: $(LIBRARY)
2106N/A
2106N/A# Build native library
2106N/A$(LIBRARY): $(OBJECTS)
2106N/A $(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
2106N/A
2106N/A# Cleanup the built bits
2106N/Aclean:
2106N/A rm -f $(LIBRARY) $(OBJECTS)
2106N/A
2106N/A# Simple tester
2106N/Atest: all
2106N/A LD_LIBRARY_PATH=`pwd` $(JDK)/bin/java -agentlib:$(LIBNAME) -version
2106N/A
2106N/A# Compilation rule only needed on Windows
2106N/Aifeq ($(OSNAME), win32)
2106N/A%.obj: %.c
2106N/A $(COMPILE.c) $<
2106N/Aendif
2106N/A