# Using JavaDeps with Win95

The following assumes you are using the Cygnus port of GNU tools to the win32 platform: Windows 95 and Windows NT. I suppose the following also works with winNT, but I don't have that platform to test on.

The major problem will be with the path separator: the great forward-slash `/' versus backslash `\' debate. The problem is that using the GNU tools on win95 along with javac unavoidably mixes the two kinds of slashes.

## Make calls BASH

For example, when make executes a makefile rule like `$(CC) file.c -o file`, it actually spawns a shell; something like `sh -c $(CC) file.c ...`.

This has the side effect that filenames in makefiles must conform to BASH (i.e. unix) standards. In particular, one cannot use a single backslash, because the shell interprets \x as an escape sequence.

There are two ways out of this: either use a forward slash, or quote the backslash, with another. So a pathname should appear in the Makefile as either `a/b.java` or `a\\b.java`

## Using / confuses javac

Java on win95 is of two minds with respect to slashes on win95. On one hand, it will find and open the file a/b/c.java. On the other hand, it does not recognize that a/b is the directory name and c.java is the file name.

One consequence of that is that if c.java contains a public class c, `javac` will fail, complaining that it is not in file c.java.

JavaDeps will fail, for much the same reason. The output makefile will not have the directory names prepended to class file names.

Rule 1: the path separator in makefiles must be \\.

## For wildcarding, / must be used

The command shell for MSDOS does not do wildcard expansion. When you issue a command like `DIR *.EXE`, the DOS command "shell" passes `*.EXE` to the `DIR` executable, and it is up to `DIR.EXE` to expand the wildcard. This is stupid; it forces every utility to know how to expand wildcards. In a sane (read UNIX) environment, the shell itself does the expansion, and passes the expanded list to the program as its set of parameters. Thus, exactly one program (the shell) needs to know how to do wildcarding. This has two benefits:

- Smaller utility executables, since they don't need the wildcarding code in them.
- Uniform wildcard expansion; in DOS, If you look closely you'll see that `COPY`, `MOVE` and `DIR` each interpret wildcards differently!

For the two reasons mentioned above, JavaDeps does not expand wildcards passed on the command line. This is easily solved, however: use the BASH shell that comes with the cygnus tools. It will happily expand wildcards, but this means that you must use the unix forward-slash path separator.

Rule 2: the path separator on the command line must be /.

Now you can do, for example, `java JavaDeps */*.java`, and JavaDeps will see the correct list of source files. However, the arguments passed to JavaDeps will use forward slashes as a path separator. These will end up this way in the makefile, and immediately, you see the conflict with rule 1.

Here the shell and `sed` come to the rescue. The jdeps script will take a list of files with forward slashes on the commandline, and turn them into backslashes before passing them on to JavaDeps. Then you can issue commands like `jdeps *.java lib/widget.java`. Be sure that only forward slashes are used!

Rule 3: use the supplied `jdeps` script with forward slashes