0N/A#
2362N/A# Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A#
0N/A# Redistribution and use in source and binary forms, with or without
0N/A# modification, are permitted provided that the following conditions
0N/A# are met:
0N/A#
0N/A# - Redistributions of source code must retain the above copyright
0N/A# notice, this list of conditions and the following disclaimer.
0N/A#
0N/A# - Redistributions in binary form must reproduce the above copyright
0N/A# notice, this list of conditions and the following disclaimer in the
0N/A# documentation and/or other materials provided with the distribution.
0N/A#
2362N/A# - Neither the name of Oracle nor the names of its
0N/A# contributors may be used to endorse or promote products derived
0N/A# from this software without specific prior written permission.
0N/A#
0N/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
0N/A# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
0N/A# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0N/A# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
0N/A# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0N/A# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0N/A# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
0N/A# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
0N/A# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
0N/A# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0N/A# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0N/A#
0N/A
0N/A########################################################################
0N/A#
0N/A# Sample GNU Makefile for building
0N/A#
0N/A# Example uses:
0N/A# gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
0N/A# gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
0N/A# gnumake JDK=<java_home> OSNAME=linux [OPT=true]
0N/A# gnumake JDK=<java_home> OSNAME=win32 [OPT=true]
0N/A#
0N/A########################################################################
0N/A
0N/A# Source lists
0N/ALIBNAME=java_crw_demo
0N/ASOURCES=java_crw_demo.c
0N/A
0N/A# Solaris Sun C Compiler Version 5.5
0N/Aifeq ($(OSNAME), solaris)
0N/A # Sun Solaris Compiler options needed
0N/A COMMON_FLAGS=-mt -KPIC
0N/A # Options that help find errors
0N/A COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none
0N/A # Check LIBARCH for any special compiler options
0N/A LIBARCH=$(shell uname -p)
0N/A ifeq ($(LIBARCH), sparc)
0N/A COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
0N/A endif
0N/A ifeq ($(LIBARCH), sparcv9)
0N/A COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
0N/A endif
0N/A ifeq ($(OPT), true)
0N/A CFLAGS=-xO2 $(COMMON_FLAGS)
0N/A else
0N/A CFLAGS=-g $(COMMON_FLAGS)
0N/A endif
0N/A # Object files needed to create library
0N/A OBJECTS=$(SOURCES:%.c=%.o)
0N/A # Library name and options needed to build it
0N/A LIBRARY=lib$(LIBNAME).so
0N/A LDFLAGS=-z defs -ztext
0N/A # Libraries we are dependent on
0N/A LIBRARIES=-lc
0N/A # Building a shared library
0N/A LINK_SHARED=$(LINK.c) -G -o $@
0N/Aendif
0N/A
0N/A# Linux GNU C Compiler
0N/Aifeq ($(OSNAME), linux)
0N/A # GNU Compiler options needed to build it
0N/A COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
0N/A # Options that help find errors
0N/A COMMON_FLAGS+= -W -Wall -Wno-unused -Wno-parentheses
0N/A ifeq ($(OPT), true)
0N/A CFLAGS=-O2 $(COMMON_FLAGS)
0N/A else
0N/A CFLAGS=-g $(COMMON_FLAGS)
0N/A endif
0N/A # Object files needed to create library
0N/A OBJECTS=$(SOURCES:%.c=%.o)
0N/A # Library name and options needed to build it
0N/A LIBRARY=lib$(LIBNAME).so
5029N/A LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
0N/A # Libraries we are dependent on
0N/A LIBRARIES=-lc
0N/A # Building a shared library
0N/A LINK_SHARED=$(LINK.c) -shared -o $@
0N/Aendif
0N/A
0N/A# Windows Microsoft C/C++ Optimizing Compiler Version 12
0N/Aifeq ($(OSNAME), win32)
0N/A CC=cl
0N/A # Compiler options needed to build it
0N/A COMMON_FLAGS=-Gy -DWIN32
0N/A # Options that help find errors
0N/A COMMON_FLAGS+=-W0 -WX
0N/A ifeq ($(OPT), true)
0N/A CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS)
0N/A else
0N/A CFLAGS= -Od -Zi $(COMMON_FLAGS)
0N/A endif
0N/A # Object files needed to create library
0N/A OBJECTS=$(SOURCES:%.c=%.obj)
0N/A # Library name and options needed to build it
0N/A LIBRARY=$(LIBNAME).dll
0N/A LDFLAGS=
0N/A # Libraries we are dependent on
0N/A LIBRARIES=
0N/A # Building a shared library
0N/A LINK_SHARED=link -dll -out:$@
0N/Aendif
0N/A
0N/A# Common -I options
0N/ACFLAGS += -I.
0N/ACFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
0N/A
0N/A# Default rule (build both native library and jar file)
0N/Aall: $(LIBRARY)
0N/A
0N/A# Build native library
0N/A$(LIBRARY): $(OBJECTS)
0N/A $(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
0N/A
0N/A# Cleanup the built bits
0N/Aclean:
0N/A rm -f -r classes
0N/A rm -f $(LIBRARY) $(OBJECTS)
0N/A
0N/A# Compilation rule only needed on Windows
0N/Aifeq ($(OSNAME), win32)
0N/A%.obj: %.c
0N/A $(COMPILE.c) $<
0N/Aendif
0N/A