-project := VimCoder
-version := 0.3.1
+# Use this file with GNU make to compile and package VimCoder.
+# Supported targets: all clean distclean dist fetch jar
-mainclass = bin/com/dogcows/VimCoder.class
-library = lib/ContestApplet.jar
-jarfile = $(project)-$(version).jar
+project = VimCoder
+version = 0.3.6
-JAVAC := javac
-JAVACFLAGS := -d bin -sourcepath src -classpath bin:$(library)
+sources = $(wildcard src/com/dogcows/*.java)
+classes = $(sources:src/%.java=%.class)
+library = lib/ContestApplet.jar
+jarfile = $(project)-$(version).jar
+resource_path = com/dogcows/resources
+resources = $(wildcard src/$(resource_path)/*)
+JAVAC = javac
+JAVACFLAGS = -d . -sourcepath src -classpath $(library)
-.PHONY: all clean distclean dist fetch jar
+PROVE = prove
-all: $(library) $(mainclass)
+
+all: $(classes) $(resources:src/%=%)
clean:
- rm -rf bin build
+ rm -rf com
distclean: clean
rm -rf lib
fetch: $(library)
-jar: all $(jarfile)
+jar: $(jarfile)
+test: all
+ $(PROVE)
-$(library):
- sh make.sh fetch $@
-bin/com/dogcows/%.class: src/com/dogcows/%.java
- mkdir -p bin/com/dogcows/resources &&\
-$(JAVAC) $(JAVACFLAGS) $< &&\
-cp -R src/com/dogcows/resources bin/com/dogcows/
+$(classes): $(sources) | $(library)
+ $(JAVAC) $(JAVACFLAGS) $^
+
+$(resource_path):
+ mkdir -p "$@"
+
+$(resource_path)/%: src/$(resource_path)/% | $(resource_path)
+ cp "$<" "$@"
+
+
+$(library):
+ mkdir -p lib
+ curl -o $@ http://www.topcoder.com/contest/classes/ContestApplet.jar
-$(jarfile): $(mainclass)
- sh make.sh jar $@
+$(jarfile): all
+ rm -f $@
+ jar cvf $@ COPYING README.md com
-$(mainclass): src/com/dogcows/Util.java src/com/dogcows/Editor.java
+.PHONY: all clean distclean dist fetch jar test
+# vim:noet:ts=8