8000 minix/man/man1/acd.1 at R3.1.2 · fyy3/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
860 lines (837 loc) · 22.5 KB

acd.1

File metadata and controls

860 lines (837 loc) · 22.5 KB
rule is tried one by one in the order they were posted against the front of
the argument list. If a match is made then the matched arguments are removed
from the argument list and the arg-body is executed. If no match can be made
then the first argument is moved to the list of files waiting to be
transformed and the scan is restarted.
.PP
The match is done as follows: Each of the strings after
.B arg
must match one argument at the front of the argument list. A character
in a string must match a character in an argument word, a subst in a string
may match 1 to all remaining characters in the argument, preferring the
shortest possible match. The hyphen in a argument starting with a hyphen
cannot be matched by a subst. Therefore:
.PP
.RS
.B arg \-i
.RE
.PP
matches only the argument
.BR \-i .
.PP
.RS
.B arg \-O$n
.RE
.PP
matches any argument that starts with
.B \-O
and is at least three characters long. Lastly,
.PP
.RS
.B arg \-o $out
.RE
.PP
matches
.B \-o
and the argument following it, unless that argument starts with a hyphen.
.PP
The variable
.B $\(**
is set to all the matched arguments before the arg-body is executed. All
the substs in the arg strings are set to the characters they match. The
variable
.B $>
is set to null. All the values of the variables are saved and the variables
marked local. All variables except
.B $>
are marked read-only. After the arg-body is executed is the value of
.B $>
concatenated to the file list. This allows one to stuff new files into the
transformation phase. These added names are not evaluated until the start
of the next phase.
.SS The Compilation Phase
The files gathered in the file list in the scanning phase are now transformed
one by one using the transformation rules. The shortest, or preferred route
is computed for each file all the way to the stop suffix. Each file is
transformed until it lands at the stop suffix, or at a combine rule. After
a while all files are either fully transformed or at a combine rule.
.PP
The driver chooses a combine rule that is not on a path from another combine
rule and executes it. The file that results is then transformed until it
again lands at a combine rule or the stop suffix. This continues until all
files are at the stop suffix and the program exits.
.PP
The paths through transform rules may be ambiguous and have cycles, they will
be resolved. But paths through combines must be unambiguous, because of
the many paths from the different files that meet there. A description file
will usually have only one combine rule for the loader. However if you do
have a combine conflict then put a no-op transform rule in front of one to
resolve the problem.
.PP
If a file matches a long and a short suffix then the long suffix is preferred.
By putting a null input suffix (\fB""\fP) in a rule one can match any file
that no other rule matches. You can send unknown files to the loader this
way.
.PP
The variable
.B $\(**
is set to the file to be transformed or the files to be combined before the
transform or combine-body is executed.
.B $>
is set to the output file name, it may again be modified.
.B $<
is set to the original name of the first file of
.B $\(**
with the leading directories and the suffix removed.
.B $\(**
will be made up of temporary files after the first rule.
.B $>
will be another temporary file or the name of the target file
.RB ( $<
plus the stop suffix), if the stop suffix is reached.
.PP
.B $>
is passed to the next rule; it is imploded and checked to be a single word.
This driver does not store intermediate object files in the current directory
like most other compilers, but keeps them in
.B /tmp
too. (Who knows if the current directory can have files created in?) As an
example, here is how you can express the "normal" method:
.PP
.RS
.nf
.ft B
transform .s .o
if $> = $<.o
# Stop suffix is .o
else
$> = $<.o
temporary $>
$AS \-o $> $\(**
.ft P
.fi
.RE
.PP
Note that
.B temporary
is not called if the target is already the object file, or you would lose
the intended result!
.B $>
is known to be a word, because
.B $<
is local. (Any string whose substs are all expanded changes to a word.)
.SS "Predefined Variables"
The driver has three variables predefined:
.BR PROGRAM ,
set to the call name of the driver,
.BR VERSION ,
the driver's version number, and
.BR ARCH ,
set to the name of the default output architecture. The latter is optional,
and only defined if
.B acd
was compiled with \fB\-DARCH=\e"\fP\fIarch-name\fP\fB\e"\fP.
.SH EXAMPLE
As an example a description file for a C compiler is given. It has a
front end (ccom), an intermediate code optimizer (opt), a code generator (cg),
an assembler (as), and a loader (ld). The compiler can pre-process, but
there is also a separate cpp. If the
.B \-D
and options like it are changed to look like
.B \-o
then this example is even as required by \s-2POSIX\s+2.
.RS
.nf
# The compiler support search path.
C = /lib /usr/lib /usr/local/lib
# Compiler passes.
CPP = $C/cpp $CPP_F
CCOM = $C/ccom $CPP_F
OPT = $C/opt
CG = $C/cg
AS = $C/as
LD = $C/ld
# Predefined symbols.
CPP_F = \-D__EXAMPLE_CC__
# Library path.
LIBPATH = $USERLIBPATH $C
# Default transformation target.
stop .out
# Preprocessor directives.
arg \-D$name
arg \-U$name
arg \-I$dir
CPP_F = $CPP_F $\(**
# Stop suffix.
arg \-c
stop .o
arg \-E
stop .E
# Optimization.
arg \-O
prefer .m .m
OPT = $OPT -O1
arg \-O$n
numeric $n
prefer .m .m
OPT = $OPT $\(**
# Add debug info to the executable.
arg \-g
CCOM = $CCOM -g
# Add directories to the library path.
arg \-L$dir
USERLIBPATH = $USERLIBPATH $dir
# \-llib must be searched in $LIBPATH later.
arg \-l$lib
$> = $LIBPATH/lib$lib.a
# Change output file.
arg \-o$out
arg \-o $out
OUT = $out
# Complain about a missing argument.
arg \-o
error "argument expected after '$\(**'"
# Any other option (like \-s) are for the loader.
arg \-$any
LD = $LD $\(**
# Preprocess C-source.
transform .c .i
$CPP $\(** > $>
# Preprocess C-source and send it to standard output or $OUT.
transform .c .E
ifndef OUT
$CPP $\(**
else
$CPP $\(** > $OUT
# Compile C-source to intermediate code.
transform .c .m
transform .i .m
$CCOM $\(** $>
# Intermediate code optimizer.
transform .m .m
$OPT $\(** > $>
# Intermediate to assembly.
transform .m .s
$CG $\(** > $>
# Assembler to object code.
transform .s .o
if $> = $<.o
ifdef OUT
$> = $OUT
$AS \-o $> $\(**
# Combine object files and libraries to an executable.
combine (.o .a) .out
ifndef OUT
OUT = a.out
$LD \-o $OUT $C/crtso.o $\(** $C/libc.a
.fi
.RE
.SH FILES
.TP 25n
.RI /usr/lib/ descr /descr
\- compiler driver description file.
.SH "SEE ALSO"
.BR cc (1).
.SH ACKNOWLEDGEMENTS
Even though the end result doesn't look much like it, many ideas were
nevertheless derived from the ACK compiler driver by Ed Keizer.
.SH BUGS
\s-2POSIX\s+2 requires that if compiling one source file to an object file
fails then the compiler should continue with the next source file. There is
no way
.B acd
can do this, it always stops after error. It doesn't even know what an
object file is! (The requirement is stupid anyhow.)
.PP
If you don't think that tabs are 8 spaces wide, then don't mix them with
spaces for indentation.
.SH AUTHOR
Kees J. Bot (kjb@cs.vu.nl)
0