Makefile requirements for .JAVAC

Makefile has some requirements when used with the .JAVAC special target.

The .JAVAC special target must be used with no dependencies and no build script:

.JAVAC:

clearmake issues a warning and ignores any dependencies or build script.

Other than that, makefiles must use implicit (suffix or pattern) rules. For example:

.SUFFIXES: .java .class
.java.class:
        rm -f $@
        $(JAVAC) $(JFLAGS) $<

Makefiles might also use pattern rules for compatibility modes that support them. For example:

%.class: %.java
        rm -f $@
        $(JAVAC) $(JFLAGS) ${@:.class=.java}

The makefiles must also use absolute paths for .class targets. For example:

all_classes: /vobs/proj/src/pkg1/foo.class

clearmake contains a built-in macro function you can use to specify absolute paths more easily:

$(javaclasses)

For more information about the javaclasses macro, see Using the javaclasses built-in macro.

The first time clearmake builds with .JAVAC enabled, clearmake is not making use of any inferred knowledge before it builds the first .class target.

After the first build session completes, the .class dependencies are known. As a result, some targets might be rebuilt in the second build session in that view, because clearmake is now using the .class.dep files, which might declare .class dependencies that require a different build order. After the second build session completes, the .class DOs are reusable in that view.