SRCS:=$(shell find . -name "*.java")

OBJS:=${SRCS:.java=.class}

CXX=javac
CURDIR:=$(shell pwd | sed 's/.*\///')

# SEP is to use ';' on windows and ':' on unix because windows is mentally deficient
SEP:=$(shell if [ "`uname`" = "CYGWIN" -o "`uname`" \> "CYGWIN" -a "`uname`" \< "CYGWIO" ] ; then echo ";" ; else echo ":" ; fi )
CXXFLAGS=-deprecation -classpath ".$(SEP)./ftp.jar"

.PHONY: all clean msg build clearbuildlist

all: msg clearbuildlist build

msg:
	@echo " **     These tools require the JDK 1.4 or higher.  These files         **"
	@echo " **     are _not_ necessary for development.  If errors occur, you      **"
	@echo " **     can remove the tools/mon/Makefile and continue without it.      **"

%.class: %.java
	@printf " $<" >> tmp_buildList.txt;

clearbuildlist:
	@rm -f tmp_buildList.txt;

tmp_buildList.txt: ${OBJS}
#	@echo "Build list constructed...";

build: tmp_buildList.txt
	@if [ -r tmp_buildList.txt ] ; then \
	$(if $(shell which $(CXX)), \
		echo "Compiling`cat tmp_buildList.txt`..."; $(CXX) $(CXXFLAGS) `cat tmp_buildList.txt`; , \
		printf "  ***** WARNING: You don't have java... skipping TekkotsuMon *****\n"; \
	) \
	fi;

clean:
	rm -f $(OBJS) *~ 
