mmake(1) generate a Java Makefile

DESCRIPTION

This program will generate a Makefile for Java source files. Use the -d option to accept all defaults.

After running mmake, you will obtain a Makefile in the directory from where you started the program. The Makefile will handle java files in the current directory and in any sub-directories.

Use the generated Makefile with mmake as follows:

To compile Java files just type make. It's also possible to run make with one of the following targets: doc, clean, help, jar, srcjar, bundle, install, uninstall, tags and depend Where 'make doc' runs javadoc on the source files, it will only work for files in a package. The command 'make clean' removes class files and other temporary files. The command 'make jar' creates a jar file with all class files (and other files of your choice, see the JAR_OBJS variable in the Makefile). The command 'make srcjar' creates a jar file with all java files. The command 'make bundle' creates a Mac OS X Application Bundle with all the jar file. The command 'make install' will install a jar file, app bundle, class files and any shell wrappers you have made. (A shell script must have the extension .sh to be installed). Use 'make uninstall' to remove installed files. The command 'make help', shows a help text with available targets. The command 'make tags' will generate a tag file for Emacs. And finally the command 'make depend' creates a dependency graph for the class files. (The dependency graph will be put in a file called makefile.dep, which is included in the Makefile)

You don't have to run mmake each time you add a new java file to your project. You can add as many new java files as you like, the Makefile will find them. This is the case as long as you don't add a new package. In that case, you must either run mmake again or update the PACKAGE variable in the Makefile. This is because the Makefile uses this variable to find directories with java files.

The program mmake is able to create a dependency graph for your java files. To do this, it needs the jikes compiler from IBM. Get jikes from http://www.ibm.com/developerworks/oss/jikes/.You would probably be more content with jikes anyhow, since it is much faster than javac. To create a dependencies graph, do a make clean before running make depend.

A NOTE ON INSTALLATION

The Makefile created with mmake will do a fair job installing the different files that makes up your system. It uses the following Makefile variables when it conducts the install routine:
  • PREFIX
  • CLASS_DIR
  • JAR_DIR
  • BUNDLE_DIR
  • DOC_DIR
  • SCRIPT_DIR

PREFIX

This variable will be prepended to all other directory variables above. It is used for grouping the other directories into one root directory. If you don't want that, you may simply set the variable to an empty string in the Makefile. If the variable is empty you could still use it on the command line when you run make, for instance for a one-shoot installation like: make PREFIX=/local/myproject/ install

CLASS_DIR

This variable denotes the top directory from where all class files will be installed. Its default value is classes, which I believe is a good value. Note: If you don't want to install any class files (because you are, for example, only going to use a jar file), set this variable to an empty string and no class files will be installed.

Resource files will also be installed below this directory if such files are present in a package structure. This is useful if you are using e.g. ResourceBundles to Localize your application and have your property files in it's own directory in the package structure.

JAR_DIR

This variable tells the Makefile where to install the jar file. The default value is lib, which is also a good default value.

BUNDLE_DIR

This variable tells the Makefile where to install the app bundle. The default value is lib, which is also a good default value.

DOC_DIR

When you run javadoc, all the html files will be put into this directory. Its default value is doc/api-docs. You should probably keep that name, but then again, you may change it as you like.

SCRIPT_DIR

The Makefile uses this variable to install any shell wrapper-scripts that you have created. If you write an application, it is always nice for the user that you provide a wrapper script to start the application. Its default value is bin. (The Makefile will only install shell-scripts that has the extension .sh. The mmake script will tell the Makefile where to look for shell-scripts)

INSTALLATION SUMMARY

If you keep the default values you will get an installation tree that looks like this:

 `-- PREFIX
     |-- bin
     |-- classes
     |   `-- package <--- Example of a sub-directory
     |       |-- sub-package1
     |       |-- sub-package2
     |       `-- sub-package3
     |-- doc
     |   `-- api-docs
     `-- lib