# This is the name of your program. The class dictionary file should # be $(PROG).cd, and the behavior file should be $(PROG).beh. PROG = program # This is the name of the class which has the "main" method. MAIN = Main # This is the directory into which .class files are generated. CLASSDIR = . # This is the package your generated code belongs to. It should match # the package specified at the beginning of your .cd file. PACKAGE = # Arguments for testing the program. TEST_ARGS = < $(PROG).input # Files the program test depends on. Probably some subset of $(TEST_ARGS). TEST_DEPS = $(PROG).input # Make sure these are all in your $PATH: # interpreter JAVA = java # compiler JAVAC = javac -d $(CLASSDIR) # Demeter compiler DEMJAVA = demjava # parser generator PARSEGEN = jack #### # You shouldn't have to change anything below here. #### ifeq (,$(PACKAGE)) PACKAGE_PREFIX = PACKAGE_DIR = $(CLASSDIR) else PACKAGE_PREFIX = $(PACKAGE). PACKAGE_DIR = $(CLASSDIR)/$(subst .,/,$(PACKAGE)) endif MAIN_TARGET = $(PACKAGE_DIR)/$(MAIN).class GRAMMAR = $(PROG).jack PARSER = Parser.java PARSER_AUX = ParseError.java ParserConstants.java ParserTokenManager.java \ Token.java ASCII_UCodeESC_CharStream.java all: $(MAIN_TARGET) $(MAIN_TARGET): $(PROG).java $(PARSER) $(PARSER_AUX) @mkdir -p $(CLASSDIR) $(JAVAC) $? @touch $(MAIN_TARGET) $(PROG).java: $(PROG).cd $(PROG).beh $(DEMJAVA) -code $(PROG) $(PARSER): $(GRAMMAR) $(PARSEGEN) $^ $(GRAMMAR): $(PROG).cd $(DEMJAVA) -grammar $(PROG) $(PARSER_AUX): test: all $(TEST_DEPS) $(JAVA) $(PACKAGE_PREFIX)$(MAIN) $(TEST_ARGS) clean: $(RM) $(PACKAGE_DIR)/*.class $(PROG).java $(RM) $(GRAMMAR) $(PARSER) $(PARSER_AUX) $(RM) *~ core new: clean all .PHONY: all test clean new