To recap the behaviour of GEN_make is quite simple. It translates named
tokens in an input file to token values in an output file. The job of
the configuration files is to manipulate the GEN_make token translation
table. GEN_make is written in Tcl and the token translation table
is just an associative array called Subs
.
GEN_make loads configuration information by source
ing them, ie. a
configuration file is itself a Tcl script! This cunning trick is a
generally useful technique and I commend it to you. There are currently
two configuration file commands, called files
and const
.
These are there for historical reasons, in the current implemention
there effect is similar except for the fact that const
can have only
one argument, whereas files
can have many. The syntax is,
files TOKEN values const TOKEN [value]In the
const
case the value defaults to the null string. In
addition to simply listing file names there are some `specials'.
These have the following forms,
files NEW_TOKEN %remext OLD_TOKEN files NEW_TOKEN %reverse OLD_TOKEN files NEW_TOKEN %upper OLD_TOKEN files NEW_TOKE %lower OLD_TOKEN files NEW_TOKEN %prefix <prefix> OLD_TOKEN files NEW_TOKEN %suffix OLD_TOKEN <suffix> files NEW_TOKEN %presuf <prefix> OLD_TOKEN <suffix>The use of these is hopefully clear! They add or subtract bits from file name to create new tokens, or reorder the elements of a token. If the bit you are adding contains characters special to Tcl (eg dollars) then you should enclose the bit in braces, eg.
# The task names files TASKS hdir hcreate hretype # The Fortran files files FORTRAN %suffix .f TASKS # The executables files EXECS %prefix {$(BIN)/} TASKS
It is important to realise that all token translation is delayed until
the proto-make file is processed, ie. it is quite valid to use one of
the specials above before TOKEN2
is defined.
The ability to do this is extremely useful. We only have to name the tasks once -- all the rest is rule based. In Starlink make files task names often appear in 4 or 5 places.