jdk/src/demo/share/jvmti/heapTracker/sample.makefile.txt
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 14342 jdk/src/share/demo/jvmti/heapTracker/sample.makefile.txt@8435a30053c1
child 40187 cc7fb0b2445a
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 12056
diff changeset
     2
# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
2
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
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    15
#   - Neither the name of Oracle nor the names of its
2
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 JVMTI Demo heapTracker
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=heapTracker
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
SOURCES=heapTracker.c ../agent_util/agent_util.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
JAVA_SOURCES=HeapTracker.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
# Name of jar file that needs to be created
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
JARFILE=heapTracker.jar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
# Solaris Sun C Compiler Version 5.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
ifeq ($(OSNAME), solaris)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    # Sun Solaris Compiler options needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    COMMON_FLAGS=-mt -KPIC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    # Options that help find errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    # Check LIBARCH for any special compiler options
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    LIBARCH=$(shell uname -p)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    ifeq ($(LIBARCH), sparc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    ifeq ($(LIBARCH), sparcv9)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    ifeq ($(OPT), true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        CFLAGS=-xO2 $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        CFLAGS=-g $(COMMON_FLAGS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    # Object files needed to create library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    OBJECTS=$(SOURCES:%.c=%.o)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    # Library name and options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    LIBRARY=lib$(LIBNAME).so
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    LDFLAGS=-z defs -ztext
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    # Libraries we are dependent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    # Building a shared library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    LINK_SHARED=$(LINK.c) -G -o $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
# Linux GNU C Compiler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
ifeq ($(OSNAME), linux)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    # GNU Compiler options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    # Options that help find errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    ifeq ($(OPT), true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        CFLAGS=-O2 $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        CFLAGS=-g $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    # Object files needed to create library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    OBJECTS=$(SOURCES:%.c=%.o)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    # Library name and options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    LIBRARY=lib$(LIBNAME).so
12056
1f93da3840f7 7150392: Linux build breaks with GCC 4.7 due to unrecognized option
andrew
parents: 5506
diff changeset
    97
    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    # Libraries we are dependent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    # Building a shared library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    LINK_SHARED=$(LINK.c) -shared -o $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
# Windows Microsoft C/C++ Optimizing Compiler Version 12
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
ifeq ($(OSNAME), win32)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    CC=cl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    # Compiler options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    COMMON_FLAGS=-Gy -DWIN32
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    # Options that help find errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    COMMON_FLAGS+=-W0 -WX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    ifeq ($(OPT), true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    # Sources need java_crw_demo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    SOURCES += ../java_crw_demo/java_crw_demo.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    # Object files needed to create library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    OBJECTS=$(SOURCES:%.c=%.obj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    # Library name and options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    LIBRARY=$(LIBNAME).dll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    LDFLAGS=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    # Libraries we are dependent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    LIBRARIES=$(JDK)/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    # Building a shared library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    LINK_SHARED=link -dll -out:$@
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
# Common -I options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
CFLAGS += -I.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
CFLAGS += -I../agent_util
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
CFLAGS += -I../java_crw_demo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
# Default rule (build both native library and jar file)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
all: $(LIBRARY) $(JARFILE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
# Build native library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
$(LIBRARY): $(OBJECTS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
# Build jar file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
$(JARFILE): $(JAVA_SOURCES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
	rm -f -r classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
	mkdir -p classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
	$(JDK)/bin/javac -d classes $(JAVA_SOURCES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
	(cd classes; $(JDK)/bin/jar cf ../$@ *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
# Cleanup the built bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
clean:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
	rm -f -r classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
	rm -f $(LIBRARY) $(JARFILE) $(OBJECTS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
# Simple tester
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
test: all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
	LD_LIBRARY_PATH=. $(JDK)/bin/java -agentlib:$(LIBNAME) -Xbootclasspath/a:./$(JARFILE) -version
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
# Compilation rule only needed on Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
ifeq ($(OSNAME), win32)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
%.obj: %.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
	$(COMPILE.c) $<
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163