We assume you are using the supplied jdeps script in all examples below. Most of the options are not needed in the typical case. Usually the command you want is
jdeps *.java > .depsor
jdeps -d classes *.java > .deps
JavaDeps parses a set of java source files to determine their inter-dependencies. It does not include dependencies on classes not built from the source files specified on the command line. Hence, you must run it on all the sources in your project.
By default, build rules are emitted for every class file built from your sources, though this can be suppressed. The default build rule is to run $(JAVACOMPILE) on the java file for that class. This allows you to set the exact form of the command elsewhere in the main makefile, by setting the JAVACOMPILE variable. If you prefer, the build rule may be specified with the -b option when JavaDeps is run.
A makefile variable -- named CLASSES by default, but can be changed using the -C option -- will hold the names of all the class files that can be built from your sources. This list is sorted so that no class file depends on a class later in the list, so it is useful for a compilation target. The example makefile below shows this.
The resulting build and dependency rules are written to standard output, so you'd typically re-direct it to a file included by the main makefile.
The prototypical makefile would be something like the following:
JAVACOMPILE = javac default: all include .deps all: $(CLASSES) .deps: Makefile jdeps *.java > .deps
If you're wondering about the default/include/all sequence, here is the reason it is thus. The target to build all the classes, all, uses the variable CLASSES, defined in the .deps file. Hence, it must appear after the inclusion. However, the included file defines lots of targets of its own. Typing make (without specifying a target) will build the first target encountered. If you don't put some other target, say default in front of the inclusion, this target will be an arbitrary .class file (the one that appears first in the CLASSES list). This is unlikely to be what what you want :-)
Usage: jdeps [options] [java-file ... | -f FILE ]
The options and their meanings are: