GNU Java Training Wheels 1.1: Makefile for building *.jtw into *.java and running *.class files

Previous: Piping the output of javac and java, Up: Tutorial 18 Advanced J.T.W. [Contents][Index]

#### 4.18.3 Makefile for building *.jtw into *.java and running *.class files

Here is the GNU Makefile for building `*.java` files and `*.class` files and running them.

    .PRECIOUS:
    .PRECIOUS: %.java %.class

    JAVAC_FLAGS = -source 1.5 -Xlint:unchecked -Xlint:deprecation
    JAVA_FLAGS  = -enableassertions
    SHELL       = /bin/bash

    %.java: %.jtw
            @echo "* Stage 1 : Debugging $*.jtw and building $*.java file"
            emacs --batch --eval "(setq *stump* \"$*\")" --load jtw-build-jtw.el --funcall doit

    %.class: %.java
            @echo "* Stage 2 : Debugging *.java and building *.class file(s)"
            javac $(JAVAC_FLAGS) $$(find . -name "*.java") |& emacs --batch --eval "(setq *stump* \"$*\")" --load jtw-javac.el --funcall doit |& grep "input0-9:" - |& sed -e "s/input0-9:s//g" -

    %.run: %.class
            @echo "* Stage 3 : Running $*.class File"
            java $(JAVA_FLAGS) $* |& emacs --batch --load jtw-java.el --funcall doit |& grep "input0-9*:" - |& sed -e "s/input0-9*://g" -

    build: clean

The first line `.PRECIOUS` without any arguments clears the list of precious files, the list of files not to delete during the build process.