# Makefile	(C) K. J. Turner, Y. P. Tay	04/08/03

# Build "ChordTutor" targets (e.g. "make" or "make clean"):
#   clean		clean up all temporary files
#   convert		build and run score-to-MIDI converter on PC
#   pda			build chord tutor for palm-held (*.lnk, *.pdb, *.prc)
#   pc			build and run chord tutor on PC (*.class - default)
#   spotless		clean up all generated files
#
# Assumes CLASSPATH set up for SuperWaba classes, e.g. on Windows:
#
#   C:\Program Files\SuperWaba\ext\xplat\wextras\classes;
#   C:\Program Files\SuperWaba\ext\xplat\wgl;
#   C:\Program Files\SuperWaba\bin;
#   C:\Program Files\SuperWaba\classes
#
# Assumes PATH set up for JDK binaries, e.g. on Windows:
#
#   C:\Program Files\JDK\bin

# Variable names:
#
#   BPP:	bits per pixel for PC display (can be set to 2, 4, 8)
#   CREATOR:	Palm database creator ID
#   MAIN:	main program name
#   OBJECTS:	object (class) files
#   SCALE:	scale factor for PC display (can be set to 1, 2, 3, 4)
#   SOURCES:	source (Java) files
#   UISTYLE:	user interface style for PC display (can be set to "PalmOS")
#   VERSION:	Palm program version ID

BPP = 8
CHORDS = ChordDB.pdb
CONVERT = MidiConverter
CREATE = CreateChords
CREATOR = ChTu
MAIN = ChordTutor
OBJECTS = $(MAIN).class ChordDB.class Score.class \
  $(CONVERT).class $(CREATE).class
SCALE = 2
SCORES = ChordTutorDB.pdb
SOURCES = $(MAIN).java ChordDB.java Score.java \
  $(CONVERT).java $(CREATE).java
TARGET = 1.1
UISTYLE =
VERSION = 1.0

# fixed names

APPLET = waba.applet.Applet
CE = $(MAIN).pdb $(MAIN).lnk
DB = $(CHORDS) $(SCORES)
PILOT = $(MAIN).pdb $(MAIN).prc
SHELL = sh

# build rules:

pc: $(OBJECTS) $(CHORDS)
	@echo Running chord tutor
	@java $(APPLET) /bpp $(BPP) /scale $(SCALE) /uiStyle $(UISTYLE) $(MAIN)

clean:
	@echo Cleaning up
	@rm -f core *~ *.bak $(OBJECTS)

convert: $(CONVERT).class
	@echo Running score-to-MIDI converter
	@java $(APPLET) /bpp $(BPP) /scale $(SCALE) /uiStyle $(UISTYLE) \
	  $(CONVERT)

$(CHORDS): $(CREATE).class
	@echo Running chord database creator
	@java $(APPLET) /bpp $(BPP) /scale $(SCALE) /uiStyle $(UISTYLE) \
	  $(CREATE)

pda:	$(OBJECTS) $(CHORDS)
	@echo Creating Pilot files $(PILOT)
	@echo Creating Windows CE files $(CE)
	@java Warp c /c $(CREATOR) /q $(MAIN)
	@java Exegen /c $(CREATOR) /q /v $(VERSION) /i $(MAIN).bmp \
	  /j $(MAIN)Small.bmp $(MAIN) $(MAIN) $(MAIN)

spotless: clean
	@rm -fr $(PILOT) $(CE) $(DB) *.mid

$(OBJECTS): $(SOURCES)
	@echo Compiling source
	@javac -target $(TARGET) -O $(SOURCES)
