jdk/src/demo/share/jvmti/heapViewer/sample.makefile.txt
changeset 44782 15f36f4cf2b7
parent 44703 755b714df450
parent 44781 5a43cca8fc10
child 44784 f2e3396a6a6b
equal deleted inserted replaced
44703:755b714df450 44782:15f36f4cf2b7
     1 #
       
     2 # Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
       
     3 #
       
     4 # Redistribution and use in source and binary forms, with or without
       
     5 # modification, are permitted provided that the following conditions
       
     6 # are met:
       
     7 #
       
     8 #   - Redistributions of source code must retain the above copyright
       
     9 #     notice, this list of conditions and the following disclaimer.
       
    10 #
       
    11 #   - Redistributions in binary form must reproduce the above copyright
       
    12 #     notice, this list of conditions and the following disclaimer in the
       
    13 #     documentation and/or other materials provided with the distribution.
       
    14 #
       
    15 #   - Neither the name of Oracle nor the names of its
       
    16 #     contributors may be used to endorse or promote products derived
       
    17 #     from this software without specific prior written permission.
       
    18 #
       
    19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
       
    20 # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
       
    21 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       
    22 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
       
    23 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       
    24 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       
    25 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       
    26 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
       
    27 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
       
    28 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       
    29 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    30 #
       
    31 
       
    32 ########################################################################
       
    33 #
       
    34 # Sample GNU Makefile for building JVMTI Demo heapViewer
       
    35 #
       
    36 #  Example uses:    
       
    37 #       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
       
    38 #       gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
       
    39 #       gnumake JDK=<java_home> OSNAME=linux   [OPT=true]
       
    40 #       gnumake JDK=<java_home> OSNAME=win32   [OPT=true]
       
    41 #
       
    42 ########################################################################
       
    43 
       
    44 # Source lists
       
    45 LIBNAME=heapViewer
       
    46 SOURCES=heapViewer.c ../agent_util/agent_util.c
       
    47 
       
    48 # Solaris Studio C Compiler Version 12.4
       
    49 ifeq ($(OSNAME), solaris)
       
    50     # Sun Solaris Compiler options needed
       
    51     COMMON_FLAGS=-mt -KPIC
       
    52     # Options that help find errors
       
    53     COMMON_FLAGS+= -Xa -v -xc99=%none
       
    54     # Check LIBARCH for any special compiler options
       
    55     LIBARCH=$(shell uname -p)
       
    56     ifeq ($(LIBARCH), sparc)
       
    57         COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
       
    58     endif
       
    59     ifeq ($(LIBARCH), sparcv9)
       
    60         COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
       
    61     endif
       
    62     ifeq ($(OPT), true)
       
    63         CFLAGS=-xO2 $(COMMON_FLAGS) 
       
    64     else
       
    65         CFLAGS=-g $(COMMON_FLAGS)
       
    66     endif
       
    67     # Object files needed to create library
       
    68     OBJECTS=$(SOURCES:%.c=%.o)
       
    69     # Library name and options needed to build it
       
    70     LIBRARY=lib$(LIBNAME).so
       
    71     LDFLAGS=-z defs -ztext
       
    72     # Libraries we are dependent on
       
    73     LIBRARIES= -lc
       
    74     # Building a shared library
       
    75     LINK_SHARED=$(LINK.c) -G -o $@
       
    76 endif
       
    77 
       
    78 # Linux GNU C Compiler
       
    79 ifeq ($(OSNAME), linux)
       
    80     # GNU Compiler options needed to build it
       
    81     COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
       
    82     # Options that help find errors
       
    83     COMMON_FLAGS+= -W -Wall  -Wno-unused -Wno-parentheses
       
    84     ifeq ($(OPT), true)
       
    85         CFLAGS=-O2 $(COMMON_FLAGS) 
       
    86     else
       
    87         CFLAGS=-g $(COMMON_FLAGS) 
       
    88     endif
       
    89     # Object files needed to create library
       
    90     OBJECTS=$(SOURCES:%.c=%.o)
       
    91     # Library name and options needed to build it
       
    92     LIBRARY=lib$(LIBNAME).so
       
    93     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
       
    94     # Libraries we are dependent on
       
    95     LIBRARIES=-lc
       
    96     # Building a shared library
       
    97     LINK_SHARED=$(LINK.c) -shared -o $@
       
    98 endif
       
    99 
       
   100 # Windows Microsoft C/C++ Optimizing Compiler Version 12
       
   101 ifeq ($(OSNAME), win32)
       
   102     CC=cl
       
   103     # Compiler options needed to build it
       
   104     COMMON_FLAGS=-Gy -DWIN32
       
   105     # Options that help find errors
       
   106     COMMON_FLAGS+=-W0 -WX
       
   107     ifeq ($(OPT), true)
       
   108         CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) 
       
   109     else
       
   110         CFLAGS= -Od -Zi $(COMMON_FLAGS) 
       
   111     endif
       
   112     # Object files needed to create library
       
   113     OBJECTS=$(SOURCES:%.c=%.obj)
       
   114     # Library name and options needed to build it
       
   115     LIBRARY=$(LIBNAME).dll
       
   116     LDFLAGS=
       
   117     # Libraries we are dependent on
       
   118     LIBRARIES=
       
   119     # Building a shared library
       
   120     LINK_SHARED=link -dll -out:$@
       
   121 endif
       
   122 
       
   123 # Common -I options
       
   124 CFLAGS += -I.
       
   125 CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
       
   126 
       
   127 # Default rule
       
   128 all: $(LIBRARY)
       
   129 
       
   130 # Build native library
       
   131 $(LIBRARY): $(OBJECTS)
       
   132 	$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
       
   133 
       
   134 # Cleanup the built bits
       
   135 clean:
       
   136 	rm -f $(LIBRARY) $(OBJECTS)
       
   137 
       
   138 # Simple tester
       
   139 test: all
       
   140 	LD_LIBRARY_PATH=`pwd` $(JDK)/bin/java -agentlib:$(LIBNAME) -version
       
   141 
       
   142 # Compilation rule only needed on Windows
       
   143 ifeq ($(OSNAME), win32)
       
   144 %.obj: %.c
       
   145 	$(COMPILE.c) $<
       
   146 endif
       
   147