jdk/src/share/demo/jvmti/versionCheck/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 JVMTI Demo versionCheck
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=versionCheck
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
SOURCES=versionCheck.c ../agent_util/agent_util.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
# Solaris Sun C Compiler Version 5.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
ifeq ($(OSNAME), solaris)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    # Sun Solaris Compiler options needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    COMMON_FLAGS=-mt -KPIC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    # Options that help find errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    # Check LIBARCH for any special compiler options
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    LIBARCH=$(shell uname -p)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    ifeq ($(LIBARCH), sparc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    ifeq ($(LIBARCH), sparcv9)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    ifeq ($(OPT), true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        CFLAGS=-xO2 $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        CFLAGS=-g $(COMMON_FLAGS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    # Object files needed to create library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    OBJECTS=$(SOURCES:%.c=%.o)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    # Library name and options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    LIBRARY=lib$(LIBNAME).so
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    LDFLAGS=-z defs -ztext
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    # Libraries we are dependent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    LIBRARIES= -lc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    # Building a shared library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    LINK_SHARED=$(LINK.c) -G -o $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
# Linux GNU C Compiler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
ifeq ($(OSNAME), linux)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    # GNU Compiler options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    # Options that help find errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    ifeq ($(OPT), true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        CFLAGS=-O2 $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        CFLAGS=-g $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    # Object files needed to create library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    OBJECTS=$(SOURCES:%.c=%.o)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    # Library name and options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    LIBRARY=lib$(LIBNAME).so
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    # Libraries we are dependent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    LIBRARIES=-lc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    # Building a shared library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    LINK_SHARED=$(LINK.c) -shared -o $@
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
# Windows Microsoft C/C++ Optimizing Compiler Version 12
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
ifeq ($(OSNAME), win32)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    CC=cl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    # Compiler options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    COMMON_FLAGS=-Gy -DWIN32
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    # Options that help find errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    COMMON_FLAGS+=-W0 -WX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    ifeq ($(OPT), true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        CFLAGS= -Od -Zi $(COMMON_FLAGS) 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    # Object files needed to create library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    OBJECTS=$(SOURCES:%.c=%.obj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    # Library name and options needed to build it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    LIBRARY=$(LIBNAME).dll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    LDFLAGS=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    # Libraries we are dependent on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    LIBRARIES=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    # Building a shared library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    LINK_SHARED=link -dll -out:$@
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
# Common -I options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
CFLAGS += -I.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
CFLAGS += -I../agent_util
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
# Default rule
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
all: $(LIBRARY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
# Build native library
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
$(LIBRARY): $(OBJECTS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
# Cleanup the built bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
clean:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
	rm -f $(LIBRARY) $(OBJECTS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
# Simple tester
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
test: all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
	LD_LIBRARY_PATH=`pwd` $(JDK)/bin/java -agentlib:$(LIBNAME) -version
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
# Compilation rule only needed on Windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
ifeq ($(OSNAME), win32)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
%.obj: %.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
	$(COMPILE.c) $<
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148