# ################################################################### # Makefile - identical for each directory # include $(PRJ)/common/Makefile.common # ################################################################### # filelist.mk - unique for each directory include $(PRJ)/OtherStuff1/src/filelist.mk include $(PRJ)/OtherStuff2/src/filelist.mk filelist += \ $(PRJ)/example/src/File1.java \ $(PRJ)/example/src/File2Ram.java # ################################################################### # Makefile.common - called by all Makefiles PRJ ?= PRJ_NOT_DEFINED TESTNAME ?= TESTNAME_NOT_DEFINED MK_CLASSPATH ?= ./class MK_LOGPATH ?= ./log COMPILER := javac COMPILE_OPTIONS := -d $(MK_CLASSPATH) -classpath $(MK_CLASSPATH) include ./filelist.mk .PHONY: compile run clean compile: $(MK_LOGPATH)/filelist.log @echo "Compile complete. Filelist is '$(MK_LOGPATH)/filelist.log'. To run test: make run TESTNAME=Testx" $(MK_LOGPATH)/filelist.log: $(filelist) @mkdir -p $(MK_CLASSPATH) $(MK_LOGPATH) $(COMPILER) $(COMPILE_OPTIONS) $? @echo $^ |sed 's# #\n#g' > $(MK_LOGPATH)/filelist.log $(MK_LOGPATH)/$(TESTNAME).log: $(MK_LOGPATH)/filelist.log java -classpath $(MK_CLASSPATH) $(TESTNAME) |tee $(MK_LOGPATH)/$(TESTNAME).log run: $(MK_LOGPATH)/$(TESTNAME).log @echo "Results are in '$(MK_LOGPATH)/$(TESTNAME).log'. Before re-running 'rm $(MK_LOGPATH)/$(TESTNAME).log' or 'make clean'" clean: rm -f $(MK_LOGPATH)/*.log $(MK_CLASSPATH)/*.class