# $Id: Makefile.ship,v 1.13 2014-01-17 16:36:46 drmiller Exp $

COPTS =

CFLAGS += -D__wang700__ -I../common -I.

FONTDIR = $(shell if [[ -d ~/.fonts ]]; then echo ~/.fonts; elif [[ -d ~/Library/Fonts ]]; then echo ~/Library/Fonts; fi)
FONTS = $(notdir $(wildcard ../common/fonts/*.ttf))
COMMON_ICONS = $(subst ../common/,,$(wildcard ../common/icons/*.png))

XTRA = 
ROM = wang720c.rom
SPCL = plotter_chrgen.dat

COMMON_CLASSES = \
		Wang_SplashScreen.class \
		SuffFileFilter.class \
		SuffFileChooser.class \
		Wang_Colors.class \
		Wang_Keys.class \
		Wang_Properties.class \
		Wang_PropertyEditor.class \
		Wang_CharConverter.class \
		Wang_Indicator.class \
		Wang_InputDevice.class \
		Wang_Core.class \
		Wang_UI.class \
		Wang_ErrorLight.class \
		Wang_FunctionLabelBar.class \
		Wang_TapeDevice.class \
		Wang_TapeDrive.class \
		Wang_OutputDevice.class \
		Wang_Paper.class \
		IBM_Selectric.class \
		ASR33_Teletype.class \
		Wang_Plotter.class \
		Wang_InputOutputWriter.class \
		Wang_PaperTapeReader.class \
		Wang_Teletype.class \
		Wang_MicroFace.class \
		Wang_PlottingOutputWriter.class \
		Wang_OutputWriter.class \
		Wang_CN36_Type2.class \
		Wang_Display.class \
		Wang_Help.class \
		Wang_Keyboards.class \
		Wang_Keyboard.class \
		Wang_Debugger.class \
		Wang_DebugConsole.class

W700_CLASSES = \
		Wang700.class \
		Wang700_Properties.class \
		Wang700_Simulator.class

COMMON_W714_CLASSES = \
		Wang_Properties.class \
		Wang_UI.class \
		SuffFileFilter.class \
		SuffFileChooser.class \
		Wang_InstructionDecoder.class \
		Wang700_InstrDecoder.class \
		Wang_MarkSenseCard.class

DASM = dw700.o loaducode_txt.o

all: w700_fe.class

CFLAGS += -g -O3 $(COPTS)

w700-dasm: wang-dasm.o $(DASM)
	$(CC) $(CFLAGS) -o $@ $< $(DASM)

w700_fe.class: w700_fe.java $(COMMON_CLASSES) $(W700_CLASSES)
	javac w700_fe.java

w700_edit.class: w700_edit.java $(COMMON_W714_CLASSES)
	javac w700_edit.java

w700initProps.class: w700initProps.java \
		Wang_UI.class Wang_Properties.class Wang700_Properties.class
	javac w700initProps.java

.PRECIOUS: %.class ../common/%.class

../common/%.class: ../common/%.java
	javac $?

%.class: %.java
	javac $?

%.class: ../common/%.class
	cp -v ../common/$**.class .

clean:
	rm -f *.o

jar: wang700.jar

SHIP_DOCS = $(filter-out docs/wang700arch.html,$(wildcard docs/*.html))

wang700.jar: w700_fe.class w700_edit.class w700initProps.class $(ROM)
	echo -e "Main-Class: w700_fe\nSplashScreen-Image: icons/wang700.gif" >Manifest.txt
	jar cfm $@ Manifest.txt *.class $(ROM) icons/*.{gif,png} $(SHIP_DOCS) \
		$(addprefix -C ../common ,$(SPCL)) \
		$(addprefix -C ../common/fonts ,$(FONTS)) \
		$(addprefix -C ../common ,$(COMMON_ICONS))

wang700setup.jar: w700initProps.class
	echo "Main-Class: w700initProps" >Manifest.txt
	jar cfm $@ Manifest.txt w700initProps.class \
		Wang_UI.class Wang_Properties.class Wang700_Properties.class \
		Wang_PropertyEditor.class icons/setup.icns
