Listing 5. Makefile


# Generate Position Independent Code for dynamic linking
# and create a shared object module for JCDdriver to load at run time.
#
# Select ARCHOS, CFLAGS, and LDFLAGS for your operating system.
#
# Linux
ARCHOS=ix86-Linux
CFLAGS= -O -fPIC -I/usr/local/java/include/solaris -I/usr/local/java/include
LDFLAGS= -shared -Wl,-soname,Jcd_Drive
#
# IRIX 
#ARCHOS=mips-Irix
#CFLAGS= -O -I/usr/java/include/irix -I/usr/java/include
#LDFLAGS= -shared -Wl,-soname,Jcd_Drive -lcdaudio -lmediad -lds
#


JAVAC= javac
#JAVAC= /usr/local/java/bin/javac
#JAVAC= espresso

NATIVE_SRC= Jcd_Drive_$(ARCHOS)

%.class : %.java
		$(JAVAC) $< 

Jcd.class:	Jcd.java Jcd_Drive.so
		$(JAVAC) Jcd.java
		chmod +x Jcd.class

Jcd_Drive.so:	$(NATIVE_SRC).o Jcd_Drive.o
		cc -o Jcd_Drive.so Jcd_Drive.o $(NATIVE_SRC).o $(LDFLAGS)
		mkdir -p native/$(ARCHOS)
		cp Jcd_Drive.so native/$(ARCHOS)/Jcd_Drive.so

Jcd_Drive.h:	Drive.class
		javah Jcd.Drive
		touch Jcd_Drive.h

Jcd_Drive.c:	Drive.java
		javah -stubs Jcd.Drive
		touch Jcd_Drive.c

$(NATIVE_SRC).c:	Jcd_Drive.h