# # Sample makefile to create Java JNI with Cygwin b20.1 tools. This *will not* # work with Cygwin versions earlier than b20.1. # # The only difference from creating a regular DLL is to supply a different # entry point, __cygwin_noncygwin_dll_entry@12, since Java is an MSVC app. # # See Makefile.nocyg if you want to use -mno-cygwin and build a Mingw JNI. # CC = gcc CXX = c++ DEBUG = -g -Wall -O2 CXXFLAGS = $(DEBUG) CFLAGS = $(DEBUG) CPPFLAGS = -I /usr/include -I. -I$(JDK_ROOT)/include -I$(JDK_ROOT)/include/win32 #JDK_ROOT = c:/jdk1.1.7A JDK_ROOT = d:/work/oware3rd/native/jdk1.2 AS = as DLLTOOL = dlltool DLLWRAP = dllwrap # # Various targets to build. # DLL_NAME = hello.dll DLL_EXP_DEF = hello.def all: $(DLL_NAME) # # DLL related variables. These are used when building the DLL. See later. # # Some tools require special CPP macros when building a DLL (eg., _DLL etc). # Here we don't need anything. DLL_CFLAGS = -DBUILDING_DLL=1 -D_DLL=1 # The default entry point defined by dllwrap is __cygwin_dll_entry@12 # defined in libcygwin.a, but that's only appropriate for Cygwin apps, # but since Java is a MSVC app, we need to provide a different entry # point. Note the leading underscore and the trailing @12. # The -s flag strips the DLL to shrink the size. #DLL_LDFLAGS = -Wl,-e,__cygwin_noncygwin_dll_entry@12 -s DLL_LDFLAGS = -Wl # any extra libraries that your DLL may depend on. DLL_LDLIBS = /usr/lib/libexpect526.a /usr/lib/libtcl80.a DLL_SRCS = HelloWorldImp.cc DLL_OBJS = $(DLL_SRCS:.cc=.o) DLL_OBJS := $(DLL_OBJS:.c=.o) ### # # Making DLL # ### DLLWRAP_FLAGS = --output-def $(DLL_EXP_DEF) \ --add-stdcall-alias \ --driver-name $(CC) \ $(IMAGE_BASE) $(DLL_NAME): $(DLL_OBJS) $(DLLWRAP) $(DLLWRAP_FLAGS) -shared -o $(DLL_NAME) \ $(DLL_OBJS) $(DLL_LDFLAGS) $(DLL_LDLIBS) # # dependencies. # # # default rules for building DLL objects. Note that client programs (ie., # the ones that *use* the DLL) have to be compiled without the DLL_CFLAGS # flags. # .cc.o: $(CXX) -c $(DLL_CFLAGS) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< .c.o: $(CC) -c $(DLL_CFLAGS) $(CPPFLAGS) $(CFLAGS) -o $@ $< # Note that we omit the $(DLL_CFLAGS) for client programs. usedll.o: %o: %c $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< clean: -rm -f $(OBJS) $(DLL_OBJS) $(DLL_NAME) $(DLL_EXP_LIB) $(DLL_EXP_DEF) $(TESTPROGS)