next up previous contents
Next: 15. Example: Dynamic linking Up: 14. Auxiliary scripts Previous: 14.1.1 Bootstrapping: How ml-build   Contents


14.2 Generating dependencies for make

When ML programs are used as parts of larger projects, it can become necessary to use CM (or, e.g., ml-build as described in Section 14.1) in a traditional makefile for Unix' make. To avoid repeated invocations, the dependency information that CM normally manages internally must be described externally so that make can process it.

For this purpose, it is possible to let CM's dependency analyzer generate a list of files that a given ML program depends on (see Section 4.1.11). The ml-makedepend scripts conveniently wraps this functionality in such a way that it resembles the familiar makedepend facility found on many Unix installations for the use by C projects.

An invocation of ml-makedepend takes two mandatory arguments: the root description file of the ML program in question and the name of the target that is to be used by the generated makefile entry. Thus, a typical command line has the form:


  ml-makedepend project.cm targetname

This will cause ml-makedepend to first look for a file named makefile and if that cannot be found for Makefile. (An error message is issued if neither of the two exists.) After deleting any previously generated entry for this description-target combination, the script will invoke CM and add up-to-date dependency information to the file.

Using the -f option it is possible to force an arbitrary programmer-specified file to be used in place of makefile or Makefile.

Some of the files a CM-managed program depends on are stable libraries. Since the file names for stable libraries vary according to current CPU architecture and operating system, writing them directly would require different entries for different systems. To avoid this problem (most of the time15), ml-makedepend will use make-variables $(ARCH) and $(OPSYS) as placeholders within the information it generates. It is the programmer's responsibility to make sure that these variables are set to meaningful values at the time make is eventually being invoked. This feature can be turned off (causing actual file names to be used) by specifying the -n option to ml-makedepend.

In cases where the programmer prefers other strings to be used in place of $(ARCH) or $(OPSYS) (or both) one can specify those strings using the -a and -o options, respectively.

Like ml-build (Section 14.1) and sml (Section 13.3), the ml-makedepend command also accepts -D and -U command line options.

Thus, the full command line syntax for ml-makedepend is:


  ml-makedepend [DU-options] [-n] [-f makefile] project.cm target
  ml-makedepend [DU-options] [-a arch] [-o os] [-f makefile] project.cm target

(If -n is given, then any additional -a or -o options--while not illegal--will be ignored.)


next up previous contents
Next: 15. Example: Dynamic linking Up: 14. Auxiliary scripts Previous: 14.1.1 Bootstrapping: How ml-build   Contents
Matthias Blume
2001-07-19