| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If your project gets big, it becomes increasingly difficult to navigate a directory filled with `.sml', `.sig', `.uo', `.ui' files for all of your units, in addition to executables and build infrastructure. Mosmake supports distributing the source code for the units that make up your program into several subdirectories according to logical principles. (This is not as simple as it sounds, either -- but I've promised not to preach, so I won't go into specifics).
Mosmake's cross-directory support is based on three design principles:
Later versions of Mosmake may include some support for inferring locations from last names, if enough people pester me about it.
The most primitive way to use the cross-directory support is to simply add directory parts to the unit names in the `Dependencies' file:
foo/data: foo/read: foo/data bar/write: foo/data bar/stuff: foo/read bar/write %PROGRAM |
Then Mosmake will generate rules that switch to the `foo' and
`bar' directories as appropriate for compiling each of the four
units. The references to units in `foo' will get rewritten to
`../foo' when compiling in `bar', and directory-change
messages will get emitted to make the output of the entire
make process parseable by Emacs's compile-mode.
However, adding a lot of directory prefixes to the unit names will do nothing to keep the `Dependencies' file itself readable, even if brace expansion can keep the explosion somewhat under control. Therefore Mosmake supports having one `Dependencies' file in each directory, even if they are combined to form one top-level `mosmake.dep'. With per-directory `Dependencies' we could instead have:
# This is foo/Dependencies data: read: data |
# This is bar/Dependencies write: ../foo/data stuff: /foo/read write %PROGRAM |
Then, in order to tell Mosmake where to look for Dependencies files, put
MOSMAKEDIRS = foo bar |
in the `Makefile' in the superdirectory. $(MOSMAKEDIRS) is a
whitespace-separated list of directories where Mosmake will expect to
find a `Dependencies' file. Note that if `.' is not part of
the list, Mosmake will not try to read a `Dependencies' file
in the main directory itself.
Here are the properties of subdirectory `Dependencies' files, some of which are shown in the preceding example:
One disadvantage of only having one master makefile is that just typing
make `target' won't work unless your current directory is
the project root. Mosmake comes with a stub file `Makefile.chain'
that you can use to make make commands work even when started
from a subdirectory. Copy `Makefile.chain' to the main directory
and then place in each subdirectory a `Makefile' containing
DOWN = foo/bar # where are we, relative to the root? UP = ../.. # where is the root, relative to us? include $(UP)/Makefile.chain |
Then `Makefile.chain' will take care of starting a suitable
make command from the top level directory. When you type
make FILENAME, `Makefile.chain' will even try to
guess intelligently whether FILENAME is a local object file,
such that the top-level command should be make
foo/bar/FILENAME, or binary or meta-target, such that the
top-level command should be make FILENAME.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |