# Simple makefile to automate common tasks performed when modifying
# shotgun code.
#
# History:
#  2005-09-02	Art Munson created.
###################################################################

info:
	@echo "This makefile supports the following commands:"
	@echo " % make info - shows this message"
	@echo " % make shotgun - recompiles code as needed"
	@echo " % make jarfile - packages shotgun into a jar file"
	@echo " % make doc - generates javadoc files in doc/"
	@echo " % make clean - removes .class files"
	@echo " % make cleandoc - removes doc/"
	@echo
	@echo " (if you commit changes, update the VERSION)"
	@echo " (after committing, if you want to tag all the files with the "
	@echo "  symbolic version, use 'cvs tag shotgun_major_minor')"

##################################################################
# Rules for compiling shotgun.
##################################################################

# Keep this list of source code files up to date, and alphabetized.
# Place subdirectories at end of list.
SRC = \
	CMatrix.java \
	ExternalSampler.java \
	LibraryLoader.java \
	Model.java \
	ModelCounts.java \
	ModelFilter.java \
	ModelSampler.java \
	ModelSelection.java \
	MultiClassEnsemble.java \
	Predictions.java \
	RandomSampler.java \
	Targets.java \
	Threshold.java \
	TopSampler.java \
	metrics/BalancedLoss.java \
	metrics/FMeasure.java \
	metrics/Lift.java \
	metrics/MetricBundle.java \
	metrics/MultiMetric.java \
	metrics/PerfCache.java
CLASS = $(SRC:%.java=shotgun/%.class)

shotgun: $(CLASS)

%.class: %.java
	javac -source 1.4 $*.java

##################################################################
# Rules for packaging shotgun.
##################################################################

VERSION = `cat VERSION | sed 's/.*=//' | tr '\n' '.'`
JARFILE=shotgun.$(VERSION)jar

jarfile: shotgun
	jar cvfm $(JARFILE) \
	  META-INF/MANIFEST.MF \
	  VERSION \
	  shotgun/*.class \
	  shotgun/metrics/*.class

##################################################################
# Rules for generating javadoc API files.
##################################################################

doc:
	mkdir -p doc
	javadoc -d doc -version -author -source 1.4 \
	  -subpackages shotgun.metrics shotgun

##################################################################
# Rules for cleaning up.
##################################################################

clean:
	-rm shotgun/*.class shotgun/metrics/*.class shotgun/*~

cleandoc:
	-rm -r doc/
