#
# @(#)nmakefile	1.2 98/03/22
#
# Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.
#
# See also the LICENSE file in this distribution.
#
# NMake makefile for the example demonstrating shared dispatchers with
# JNI.
#

#
# Where is everything installed?
#
JDKDIR		= c:\devel\jdk1.3
IMAQDIR		= "c:\Program Files\National Instruments\NI-IMAQ"
IMAGEJDIR	= "c:\Program Files\ImageJ"
DLLDIR		= "c:\winnt\system32"

#
# Convenience, so you can set SUFFIX from the make command line and
# to run this example under java_g, if you have java_g:
#	C:> nmake SUFFIX=_g
#
SUFFIX  = 

#
# Other variables.
#
TARGETDIR  = $(IMAGEJDIR)\plugins
CLASSPATH  = $(IMAGEJDIR)\ij.jar;.
CLASSES    = AcquireIMAQ_.class
TARGETLIB  = AcquireIMAQ_Native
CFLAGS     = -DWIN32 -I$(JDKDIR)\include -I$(JDKDIR)\include\win32 -I$(IMAQDIR)\include
CLIBS	   = $(IMAQDIR)\lib\MSVC\imaq.lib user32.lib gdi32.lib
JFLAGS     = -classpath $(CLASSPATH)
.SUFFIXES: .java .class

#
# Targets
#


build: checkjdk $(CLASSES) $(TARGETLIB)$(SUFFIX).dll FORCE

#
# Build .class files.
#
.java.class:
	$(JDKDIR)\bin\javac $(JFLAGS) $<

#
# Run javah.
#
.class.h:
	$(JDKDIR)\bin\javah $(JFLAGS) -jni -o $(<:.class=).h $(<:.class=)


#
# Build Native DLL file
#
$(TARGETLIB)$(SUFFIX).dll: $(TARGETLIB).cpp AcquireIMAQ_.h
	cl $(CFLAGS) -LD -Fe$(TARGETLIB)$(SUFFIX).dll $(TARGETLIB).cpp $(CLIBS)

#
# Build Test version of file
#
$(TARGETLIB).exe: $(TARGETLIB).cpp AcquireIMAQ_.h
	cl $(CFLAGS) -DTEST_ACQUISITION -Zi $(TARGETLIB).cpp $(CLIBS)


#
# Check that the user has a valid JDKDIR install.  This will cause a
# premature death if JDKDIR is not defined.
#
checkjdk: $(JDKDIR)\bin\java.exe

#
# Help deal with phony targets.
#
FORCE: ;

#
# Cleanliness.
#
clean:
	-del *.class *.dll *.obj *.pdb *.exp *.lib *.exp *.ilk
	-del CFunc.h CMalloc.h CPtr.h

#
# Install everything where it needs to go
#
install: $(TARGETLIB)$(SUFFIX).dll $(CLASSES)
        copy $(TARGETLIB)$(SUFFIX).dll $(DLLDIR)
        copy $(CLASSES) $(TARGETDIR)

#
# Make everything
#
all:    build install

#
# Test of the library functions
#
test: $(TARGETLIB).exe

