# The program name. PROG = program # The class dictionary file. CDFILE = $(PROG).cd # The behavior files. BEHFILES = $(PROG).beh # This is the name of the class which has the "main" method. MAIN = Main # This is the directory into which .java files are generated. GENDIR = ./gen # This is the directory into which .class files are generated. CLASSDIR = ./gen # 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 = CLASSPATH=$(CLASSDIR):$$CLASSPATH javac -J-mx32m -d $(CLASSDIR) -depend -deprecation # Demeter compiler DEMJAVA = demjava -aspect -outputdir $(GENDIR) # parser generator PARSEGEN = javacc #### # 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 MKDIR = mkdir -m 755 -p MAIN_TARGET = $(PACKAGE_DIR)/$(MAIN).class SRC = $(GENDIR)/*.java GRAMMAR = grammar.jj PARSER = Parser.java all: $(MAIN_TARGET) $(MAIN_TARGET): $(GENDIR)/code $(GENDIR)/$(PARSER) @$(MAKE) --no-print-directory $(GENDIR)/compile @touch $(MAIN_TARGET) $(GENDIR)/code: $(CDFILE) $(BEHFILES) $(DEMJAVA) -code -grammar $(CDFILE) $(BEHFILES) @touch $@ $(GENDIR)/$(PARSER): $(GENDIR)/$(GRAMMAR) (cd $(GENDIR); $(PARSEGEN) $(GRAMMAR)) $(GENDIR)/compile: $(SRC) @$(MKDIR) $(CLASSDIR) $(JAVAC) $? @touch $@ $(SRC): test: all $(TEST_DEPS) CLASSPATH=$(CLASSDIR):$$CLASSPATH $(JAVA) $(PACKAGE_PREFIX)$(MAIN) $(TEST_ARGS) clean: $(RM) -r $(GENDIR) $(RM) *~ core new: clean all .PHONY: all test clean new