# Half-baked makefile, tuned for this project,
# since I can't make Garth Dickie's more elaborate one work.

#
# Variables:
#     PUBLICDIR
#         Target directory for `make public'.  This should be the directory
#         (accessible from your web server) which you use as your CODEBASE
#         when including applets in your pages.
#

PUBLICDIR = /u/www/root/java/idvi/wwwtestlib/classes/
PUBLICJAR = viewerclasses.zip

#
#     RELEASEDIR
#         Target directory for `make release'.  This can be any directory.
#         This is used for building a subset of your classes for release.
#

#RELEASEDIR = ${HOME}/idvi/release/v11/classes/
RELEASEDIR = ./release/v11/classes/

#
#     SOURCERELEASEDIR
#         Target directory for `make sourcerelease'.
#

SOURCERELEASEDIR = ./release/v11/idvisource_1.1/

#
#     JAVAC
#         The name of your Java compiler.
#

JAVAC = javac

#
#     JFLAGS
#         Options for the Java compiler.
#

JFLAGS = 

JAR = jar

#
#     APPLETVIEWER
#         The name of the application you use for viewing applets.
#

APPLETVIEWER = appletviewer

#MAKE = /usr/ccs/bin/make
MAKE = make


# make all: update all .class files
all:
	${JAVAC} ${JFLAGS} `find . -name '*.java'`

# make clean: clean up
clean:
	find . -name release -prune -o -name '*.class' -print | xargs rm -f

# make public: update all class files, then copy them to the public tree ${PUBLICDIR}
# and bundle them into a .jar/.zip file.

public: all
	find * -name release -prune -o '*.class' -print > /tmp/$$.files; \
	   cpio -pdm ${PUBLICDIR} < /tmp/$$.files; \
	   (cd ${PUBLICDIR}; ${JAR} cf ${PUBLICJAR} `cat /tmp/$$.files`); \
	   rm /tmp/$$.files

# make sourcerelease: copy *.java files to ${SOURCERELEASEDIR}
sourcerelease:
	mkdir -p ${SOURCERELEASEDIR}
	find * -name release -prune -o '*.java' -print | cpio -pdm ${SOURCERELEASEDIR}
	find ${SOURCERELEASEDIR} -type d | xargs chmod a+rx,u+w,g+s

# make release: don't update classes, but copy snapshot to ${RELEASEDIR}
release:
	mkdir -p ${RELEASEDIR}
	find * -name release -prune -o '*.class' -print | cpio -pdm ${RELEASEDIR}
	find ${RELEASEDIR} -type d | xargs chmod a+rx,u+w,g+s
