Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/demo/jvmti/mtrace/sample.makefile.txt
38829 views
#1# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.2#3# Redistribution and use in source and binary forms, with or without4# modification, are permitted provided that the following conditions5# are met:6#7# - Redistributions of source code must retain the above copyright8# notice, this list of conditions and the following disclaimer.9#10# - Redistributions in binary form must reproduce the above copyright11# notice, this list of conditions and the following disclaimer in the12# documentation and/or other materials provided with the distribution.13#14# - Neither the name of Oracle nor the names of its15# contributors may be used to endorse or promote products derived16# from this software without specific prior written permission.17#18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS19# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,20# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR22# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,23# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,24# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29#3031########################################################################32#33# Sample GNU Makefile for building JVMTI Demo mtrace34#35# Example uses:36# gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]37# gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]38# gnumake JDK=<java_home> OSNAME=linux [OPT=true]39# gnumake JDK=<java_home> OSNAME=win32 [OPT=true]40#41########################################################################4243# Source lists44LIBNAME=mtrace45SOURCES=mtrace.c ../agent_util/agent_util.c46JAVA_SOURCES=Mtrace.java4748# Name of jar file that needs to be created49JARFILE=mtrace.jar5051# Solaris Sun C Compiler Version 5.552ifeq ($(OSNAME), solaris)53# Sun Solaris Compiler options needed54COMMON_FLAGS=-mt -KPIC55# Options that help find errors56COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none57# Check LIBARCH for any special compiler options58LIBARCH=$(shell uname -p)59ifeq ($(LIBARCH), sparc)60COMMON_FLAGS+=-xarch=v8 -xregs=no%appl61endif62ifeq ($(LIBARCH), sparcv9)63COMMON_FLAGS+=-xarch=v9 -xregs=no%appl64endif65ifeq ($(OPT), true)66CFLAGS=-xO2 $(COMMON_FLAGS)67else68CFLAGS=-g $(COMMON_FLAGS)69endif70# Object files needed to create library71OBJECTS=$(SOURCES:%.c=%.o)72# Library name and options needed to build it73LIBRARY=lib$(LIBNAME).so74LDFLAGS=-z defs -ztext75# Libraries we are dependent on76LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc77# Building a shared library78LINK_SHARED=$(LINK.c) -G -o $@79endif8081# Linux GNU C Compiler82ifeq ($(OSNAME), linux)83# GNU Compiler options needed to build it84COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer85# Options that help find errors86COMMON_FLAGS+= -W -Wall -Wno-unused -Wno-parentheses87ifeq ($(OPT), true)88CFLAGS=-O2 $(COMMON_FLAGS)89else90CFLAGS=-g $(COMMON_FLAGS)91endif92# Object files needed to create library93OBJECTS=$(SOURCES:%.c=%.o)94# Library name and options needed to build it95LIBRARY=lib$(LIBNAME).so96LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc97# Libraries we are dependent on98LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc99# Building a shared library100LINK_SHARED=$(LINK.c) -shared -o $@101endif102103# Windows Microsoft C/C++ Optimizing Compiler Version 12104ifeq ($(OSNAME), win32)105CC=cl106# Compiler options needed to build it107COMMON_FLAGS=-Gy -DWIN32108# Options that help find errors109COMMON_FLAGS+=-W0 -WX110ifeq ($(OPT), true)111CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS)112else113CFLAGS= -Od -Zi $(COMMON_FLAGS)114endif115# Add in java_crw_demo obj file on windows (easier)116SOURCES+=../java_crw_demo/java_crw_demo.c117# Object files needed to create library118OBJECTS=$(SOURCES:%.c=%.obj)119# Library name and options needed to build it120LIBRARY=$(LIBNAME).dll121LDFLAGS=122# Libraries we are dependent on123LIBRARIES=$(JDK)/124# Building a shared library125LINK_SHARED=link -dll -out:$@126endif127128# Common -I options129CFLAGS += -I.130CFLAGS += -I../agent_util131CFLAGS += -I../java_crw_demo132CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)133134# Default rule (build both native library and jar file)135all: $(LIBRARY) $(JARFILE)136137# Build native library138$(LIBRARY): $(OBJECTS)139$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)140141# Build jar file142$(JARFILE): $(JAVA_SOURCES)143rm -f -r classes144mkdir -p classes145$(JDK)/bin/javac -d classes $(JAVA_SOURCES)146(cd classes; $(JDK)/bin/jar cf ../$@ *)147148# Cleanup the built bits149clean:150rm -f -r classes151rm -f $(LIBRARY) $(JARFILE) $(OBJECTS)152153# Simple tester154test: all155LD_LIBRARY_PATH=. $(JDK)/bin/java -agentlib:$(LIBNAME) -Xbootclasspath/a:./$(JARFILE) -version156157# Compilation rule only needed on Windows158ifeq ($(OSNAME), win32)159%.obj: %.c160$(COMPILE.c) $<161endif162163164165