jdk/src/share/demo/jvmti/hprof/sample.makefile.txt
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
# Copyright 2004-2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
# Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
# are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
#   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
#     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
#   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
#     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
#     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
#   - Neither the name of Sun Microsystems nor the names of its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
#     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
#     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
########################################################################
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
# Sample GNU Makefile for building 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#  Example uses:    
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
########################################################################
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
# Source lists
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
LIBNAME=hprof
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
SOURCES= \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    debug_malloc.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    hprof_blocks.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    hprof_class.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    hprof_cpu.c		\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    hprof_error.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    hprof_event.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    hprof_frame.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    hprof_init.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    hprof_io.c		\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    hprof_ioname.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    hprof_listener.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    hprof_loader.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    hprof_monitor.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    hprof_object.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    hprof_reference.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    hprof_site.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    hprof_stack.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    hprof_string.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    hprof_table.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    hprof_tag.c		\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    hprof_tls.c		\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    hprof_trace.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    hprof_tracker.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    hprof_util.c	\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    hprof_md.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
JAVA_SOURCES=Tracker.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
# Name of jar file that needs to be created
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#JARFILE=hprof.jar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
# Solaris Sun C Compiler Version 5.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
ifeq ($(OSNAME), solaris)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    # Sun Solaris Compiler options needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    COMMON_FLAGS=-mt -KPIC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    # Options that help find errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    # To make hprof logging code available
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    COMMON_FLAGS+= -DHPROF_LOGGING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    # Check LIBARCH for any special compiler options
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    LIBARCH=$(shell uname -p)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    ifeq ($(LIBARCH), sparc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    ifeq ($(LIBARCH), sparcv9)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    ifeq ($(OPT), true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        CFLAGS=-xO2 $(COMMON_FLAGS)  -DNDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        CFLAGS=-g $(COMMON_FLAGS) -DDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    # Object files needed to create library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    OBJECTS=$(SOURCES:%.c=%.o)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    # Library name and options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    LIBRARY=lib$(LIBNAME).so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    LDFLAGS=-z defs -ztext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    # Libraries we are dependent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    LIBRARIES=-lsocket -lnsl -ldl -lc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    # Building a shared library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    LINK_SHARED=$(LINK.c) -G -o $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
# Linux GNU C Compiler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
ifeq ($(OSNAME), linux)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    # GNU Compiler options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    # Options that help find errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    # To allow access to dladdr()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    COMMON_FLAGS+= -D_GNU_SOURCE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    # To prevent include of procfs.h
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    COMMON_FLAGS+= -DLINUX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    # To make sure code is reentrant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    COMMON_FLAGS+= -D_REENTRANT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    # To make hprof logging code available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    COMMON_FLAGS+= -DHPROF_LOGGING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    ifeq ($(OPT), true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        CFLAGS=-O2 $(COMMON_FLAGS)  -DNDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        CFLAGS=-g $(COMMON_FLAGS)  -DDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    # Object files needed to create library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    OBJECTS=$(SOURCES:%.c=%.o)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    # Library name and options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    LIBRARY=lib$(LIBNAME).so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    # Libraries we are dependent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    LIBRARIES= -lnsl -ldl -lc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    # Building a shared library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    LINK_SHARED=$(LINK.c) -shared -o $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
# Windows Microsoft C/C++ Optimizing Compiler Version 12
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
ifeq ($(OSNAME), win32)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    CC=cl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    # Compiler options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    COMMON_FLAGS=-Gy -DWIN32
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    # Options that help find errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    COMMON_FLAGS+=-W0 -WX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    # To make hprof logging code available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    COMMON_FLAGS+= -DHPROF_LOGGING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    ifeq ($(OPT), true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS)  -DNDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        CFLAGS= -Od -Zi $(COMMON_FLAGS)  -DDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    # Add java_crw_demo source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    SOURCES += ../java_crw_demo.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    # Object files needed to create library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    OBJECTS=$(SOURCES:%.c=%.obj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    # Library name and options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    LIBRARY=$(LIBNAME).dll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    LDFLAGS=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    # Libraries we are dependent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    LIBRARIES=wsock32.lib winmm.lib
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    # Building a shared library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    LINK_SHARED=link -dll -out:$@
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
# Common -I options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
CFLAGS += -I.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
CFLAGS += -I../java_crw_demo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
# Default rule (build both native library and jar file)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
all: hprof_md.c $(LIBRARY) $(JARFILE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
# Get platform specific hprof_md.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
hprof_md.c:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
	rm -f $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
	cp $(OSNAME)/hprof_md.c $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
# Build native library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
$(LIBRARY): $(OBJECTS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
# Build jar file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
$(JARFILE): $(JAVA_SOURCES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
	rm -f -r classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
	mkdir -p classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
	$(JDK)/bin/javac -d classes $(JAVA_SOURCES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
	(cd classes; $(JDK)/bin/jar cf ../$@ *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
# Cleanup the built bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
clean:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
	rm -f -r classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
	rm -f $(LIBRARY) $(JARFILE) $(OBJECTS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
# Simple tester
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
test: all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
	LD_LIBRARY_PATH=. $(JDK)/bin/java -agentlib:$(LIBNAME) -Xbootclasspath/a:./$(JARFILE) -version
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
# Compilation rule only needed on Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
ifeq ($(OSNAME), win32)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
%.obj: %.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
	$(COMPILE.c) $<
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205