This commit is contained in:
ceriel 1991-10-25 18:23:32 +00:00
parent 035d9f7624
commit 45afd0804b
20 changed files with 2371 additions and 0 deletions

5
fast/.distr Normal file
View file

@ -0,0 +1,5 @@
Action
driver
f_c
f_m2
f_pc

12
fast/Action Normal file
View file

@ -0,0 +1,12 @@
name "Fast ANSI C compiler"
dir f_c
end
name "Fast Pascal compiler"
dir f_pc
end
name "Fast Modula-2 compiler"
dir f_m2
end
name "Driver for fast compilers"
dir driver
end

5
fast/driver/.distr Normal file
View file

@ -0,0 +1,5 @@
afcc.1
afm2.1
afpc.1
driver.c
proto.make

136
fast/driver/afcc.1 Normal file
View file

@ -0,0 +1,136 @@
.TH AFCC 1
.SH NAME
afcc \- fast ACK compatible ANSI C compiler
.SH SYNOPSIS
.B afcc
[
.B \-c
]
[
.B \-v
]
[
.B \-vn
]
[ \fB\-D\fIname\fR ]
[ \fB\-D\fIname\fB=\fIdef\fR ]
[
.BI \-I pathname
]
[
.B \-w
]
[
.B \-o
.I outfile
]
[
.BI \-U name
]
[
.BI -M compiler
]
.I sourcefile ...
.SH DESCRIPTION
.LP
.I Afcc
is a fast
.B C
compiler. It translates
.B C
programs
into ack(1)-compatible relocatable object modules, and does so in one pass.
Then, if the \fB\-c\fP flag is not given,
.I afcc
offers the object modules to a link-editor,
to create an executable binary.
.LP
.I Afcc
accepts several types of filename arguments. Files with
names ending in
.B .c
are taken to be
.B C
source programs.
They are compiled, and the resulting object module is placed in the current
directory.
The object module is named after its source file, the suffix
.B .o
replacing
.BR .c
in the name of the object.
.LP
Other arguments refer to loader options,
object modules, or object libraries.
Unless the
.B \-c
flag is given, these modules and libraries, together with the results of any
specified compilations, are passed (in the order given) to the
link-editor to produce
an output file named
.IR a.out .
You can specify a name for the executable by using the
.B \-o
option.
.SH OPTIONS
.LP
.IP \fB\-c\fP
.br
Suppress the loading phase of the compilation, and force an object module to
be produced, even if only one program is compiled.
A single object module can be named explicitly using the
.B \-o
option.
.IP \fB\-D\fIname\fR\fB=\fIdef\fR
Define a symbol
.I name
to the
preprocessor, as if by "#define".
.IP \fB\-D\fIname\fR
.br
same as \fB\-D\fIname\fB=1\fR.
.IP \fB\-I\fIpathname\fR
.br
Add
.I pathname
to the list of directories in which to search for
.B #include
files with filenames not beginning with slash.
The compiler first searches for
.B #include
files in the directory containing
.I sourcefile,
then in directories in
.B \-I
options, then in the ACK include directory,
and finally, in
.I /usr/include.
.IP "\fB\-o \fIoutput\fR"
Name the final output file
.I output.
.IP \fB\-U\fIname\fR
.br
Remove any initial definition of
.I name.
.IP \fB\-v\fP
.br
Verbose. Print the commands as they are executed.
.IP \fB\-vn\fP
.br
Verbose, no execute. Only print the commands, do not execute them.
.IP \fB\-w\fP
suppress warning messages.
.IP \fB\-M\fIcompiler\fR
.br
use \fIcompiler\fR as C compiler instead of the default.
.LP
Object modules produced by ack(1) and
.I afcc
can be freely mixed.
.SH "SEE ALSO"
.IP [1]
B.W. Kernighan, D. Ritchie, "\fIThe C programming Language\fP", Prentice-Hall Inc., 1978
.IP [2]
ack(1) manual page.
.SH DIAGNOSTICS
Diagnostics are intended to be self-explanatory.

201
fast/driver/afm2.1 Normal file
View file

@ -0,0 +1,201 @@
.TH FM2 1
.SH NAME
afm2 \- fast ACK compatible Modula-2 compiler
.SH SYNOPSIS
.B afm2
[
.B \-c
]
[
.B \-v
]
[
.B \-vn
]
[ \fB\-D\fIname\fR ]
[ \fB\-D\fIname\fB=\fIdef\fR ]
[
.BI \-I pathname
]
[
.BI \-w classes
]
[
.BI \-W classes
]
[
.B \-L
]
[
.B \-o
.I outfile
]
[
.B \-R
]
[
.B \-A
]
[
.B \-3
]
[
.B \-_
]
[
.BI \-U name
]
[
.BI -M compiler
]
.I sourcefile ...
.SH DESCRIPTION
.LP
.I afm2
is a fast
.B Modula-2
compiler. It translates
.B Modula-2
programs
into ack(1)-compatible relocatable object modules, and does so in one pass.
Then, if the \fB\-c\fP flag is not given,
.I afm2
offers the object modules to a link-editor,
to create an executable binary.
.LP
.I Afm2
accepts several types of filename arguments. Files with
names ending in
.B .mod
are taken to be
.B Modula-2
source programs.
They are compiled, and the resulting object module is placed in the current
directory.
The object module is named after its source file, the suffix
.B .o
replacing
.BR .mod
in the name of the object.
A file with suffix
.B .mod
is passed through the C preprocessor if it begins with a '#'.
.PP
Definition modules are not separately compiled. The compiler reads them when
it needs them.
Definition modules are expected to reside in files with names ending
in
.BR .def .
The name of the file in which a definition module is stored must be the same as
the module-name, apart from the extension.
Also, in most Unix systems filenames are only 14 characters long.
So, given an IMPORT declaration for a module called "LongModulName",
the compiler will try to open a file called "LongModulN.def".
The requirement does not hold for implementation or program modules,
but is certainly recommended.
.LP
Other arguments refer to loader options,
object modules, or object libraries.
Unless the
.B \-c
flag is given, these modules and libraries, together with the results of any
specified compilations, are passed (in the order given) to the
link-editor to produce
an output file named
.IR a.out .
You can specify a name for the executable by using the
.B \-o
option.
.SH OPTIONS
.LP
.IP \fB\-c\fP
.br
Suppress the loading phase of the compilation, and force an object module to
be produced, even if only one program is compiled.
A single object module can be named explicitly using the
.B \-o
option.
.IP \fB\-D\fIname\fR\fB=\fIdef\fR
Define a symbol
.I name
to the
preprocessor, as if by "#define".
.IP \fB\-D\fIname\fR
.br
same as \fB\-D\fIname\fB=1\fR.
.IP \fB\-I\fIpathname\fR
.br
Add
.I pathname
to the list of directories in which to search for
.B #include
files with filenames not beginning with slash.
The preprocessor first searches for
.B #include
files in the directory containing
.I sourcefile,
then in directories in
.B \-I
options, then in the ACK include directory,
and finally, in
.I /usr/include.
This flag is also passed to the compiler. When the compiler needs a definition
module, it is first searched for in the current directory, then in the
directories given to it by the \fB\-I\fP flag, and then in a default directory,
.I $TARGET_HOME/lib/m2.
.I afm2
This default directory contains all definition modules of
the runtime system.
.IP "\fB\-o \fIoutput\fR"
Name the final output file
.I output.
.IP \fB\-U\fIname\fR
.br
Remove any initial definition of
.I name.
.IP \fB\-v\fP
.br
Verbose. Print the commands as they are executed.
.IP \fB\-vn\fP
.br
Verbose, no execute. Only print the commands, do not execute them.
.IP \fB\-L\fR
do not generate code to keep track of
the current location in the source code.
.IP \fB\-w\fR\fIclasses\fR
suppress warning messages whose class is a member of \fIclasses\fR.
Currently, there are three classes: \fBO\fR, indicating old-flashioned use,
\fBW\fR, indicating "ordinary" warnings, and \fBR\fR, indicating
restricted Modula-2.
If no \fIclasses\fR are given, all warnings are suppressed.
By default, warnings in class \fBO\fR and \fBW\fR are given.
.IP \fB\-W\fR\fIclasses\fR
allow for warning messages whose class is a member of \fIclasses\fR.
.IP \fB\-R\fP
.br
disable all range-checks.
.IP \fB\-A\fP
.br
enable extra array bound checks. Unfortunately, the back-end used for this
compiler is a bit sloppy, so extra array bound checks are needed if you want
detection of array bound errors.
.IP \fB\-3\fP
.br
Only accept Modula-2 programs that strictly conform to the 3rd Edition of
[1].
.IP \fB\-_\fP
.br
allow for underscores within identifiers. Identifiers may not start or end
with an underscore, even if this flag is given.
.IP \fB\-M\fIcompiler\fR
.br
use \fIcompiler\fR as Modula-2 compiler instead of the default.
.SH "SEE ALSO"
.IP [1]
N. Wirth, \fIProgramming in Modula-2\fP, 3rd edition, Springer Verlag.
.IP [2]
C.J.H. Jacobs, \fIThe ACK Modula-2 Compiler\fP.
.IP [3]
ack(1) unix manual page.
.SH DIAGNOSTICS
Diagnostics are intended to be self-explanatory.

219
fast/driver/afpc.1 Normal file
View file

@ -0,0 +1,219 @@
.TH AFPC 1
.SH NAME
afpc \- fast ACK compatible Pascal compiler
.SH SYNOPSIS
.B afpc
[
.B \-c
]
[
.B \-v
]
[
.B \-vn
]
[ \fB\-D\fIname\fR ]
[ \fB\-D\fIname\fB=\fIdef\fR ]
[
.BI \-I pathname
]
[
.B \-w
]
[
.B \-L
]
[
.B \-o
.I outfile
]
[
.B \-R
]
[
.B \-A
]
[
.B \-a
]
[
.B \-d
]
[
.BI \-i num
]
[
.B \-t
]
[
.B \-C
]
[
.B \-U+
]
[
.B \-u+
]
[
.B \-s+
]
[
.B \-c+
]
[
.BI \-U name
]
[
.BI -M compiler
]
.I sourcefile ...
.SH DESCRIPTION
.LP
.I afpc
is a fast
.B Pascal
compiler. It translates
.B Pascal
programs
into ack(1)-compatible relocatable object modules, and does so in one pass.
Then, if the \fB\-c\fP flag is not given,
.I afpc
offers the object modules to a link-editor,
to create an executable binary.
.LP
.I Fpc
accepts several types of filename arguments. Files with
names ending in
.B .p
are taken to be
.B Pascal
source programs.
They are compiled, and the resulting object module is placed in the current
directory.
The object module is named after its source file, the suffix
.B .o
replacing
.BR .p
in the name of the object.
A file with suffix
.B .p
is passed through the C preprocessor if it begins with a '#'.
.LP
Other arguments refer to loader options,
object modules, or object libraries.
Unless the
.B \-c
flag is given, these modules and libraries, together with the results of any
specified compilations, are passed (in the order given) to the
link-editor to produce
an output file named
.IR a.out .
You can specify a name for the executable by using the
.B \-o
option.
.LP
If a single
.B Pascal
program is compiled and loaded all at once, the object module
file is deleted.
.SH OPTIONS
.LP
.IP \fB\-c\fP
.br
Suppress the loading phase of the compilation, and force an object module to
be produced, even if only one program is compiled.
A single object module can be named explicitly using the
.B \-o
option.
.IP \fB\-D\fIname\fR\fB=\fIdef\fR
Define a symbol
.I name
to the
preprocessor, as if by "#define".
.IP \fB\-D\fIname\fR
.br
same as \fB\-D\fIname\fB=1\fR.
.IP \fB\-I\fIpathname\fR
.br
Add
.I pathname
to the list of directories in which to search for
.B #include
files with filenames not beginning with slash.
The preprocessor first searches for
.B #include
files in the directory containing
.I sourcefile,
then in directories in
.B \-I
options, and finally, in
.I /usr/include.
.IP "\fB\-o \fIoutput\fR"
Name the final output file
.I output.
.IP \fB\-U\fIname\fR
.br
Remove any initial definition of
.I name.
.IP \fB\-v\fP
.br
Verbose. Print the commands as they are executed.
.IP \fB\-vn\fP
.br
Verbose, no execute. Only print the commands, do not execute them.
.IP \fB\-L\fP
.br
do not generate code to keep track of
the current location in the source code.
.IP \fB\-w\fP
.br
suppress warning messages.
.IP \fB\-d\fP
.br
allow for "long"s.
.IP \fB\-i\fInum\fR
.br
set size for integer sets. By default, the set size is the word size.
.IP \fB\-C\fP
.br
distinguish between lower case and upper case. Normally, upper case letters
are considered equal to their lower case counterpart.
.IP \fB\-t\fP
.br
trace calls and exits of procedures and functions.
.IP \fB\-R\fP
.br
disable all range-checks.
.IP \fB\-A\fP
.br
enable extra array bound checks. Unfortunately, the back-end used for this
compiler is a bit sloppy, so extra array bound checks are needed if you want
detection of array bound errors.
.IP \fB\-a\fP
.br
disable assertions. Assertions are skipped instead of evaluated.
.IP "\fB\-U+\fP, \fB\-u+\fP"
.br
allow for underscores within identifiers. Identifiers may not start
with an underscore, even if this flag is given.
.IP \fB-s+\fP
.br
allow only standard
.BR Pascal .
This disables the \fB\-c+\fP, \fB\-d\fR, \fB\-u+\fR,
\fB\-U+\fR and \fB\-C\fR options.
Furthermore, assertions are not recognized at all.
.IP \fB-c+\fP
.br
allow C-like strings. This option is mainly intended for usage with
C-functions. This option will cause the type 'string' to be known.
.IP \fB\-M\fIcompiler\fR
.br
use \fIcompiler\fR as Modula-2 compiler instead of the default.
.SH "SEE ALSO"
.IP [1]
J.W. Stevenson, H. v. Eck, \fIAmsterdam Compiler Kit-Pascal reference manual\fP.
.IP [2]
ack(1) unix manual page.
.SH DIAGNOSTICS
Diagnostics are intended to be self-explanatory.

654
fast/driver/driver.c Normal file
View file

@ -0,0 +1,654 @@
/* fcc/fm2/fpc
Driver for fast ACK compilers.
Derived from the C compiler driver from Minix.
Compile this file with
cc -O -I<ACK home directory>/config -DF?? driver.c
where F?? is either FCC, FPC, or FM2.
Install the resulting binaries in the EM bin directory.
Suggested names: afcc, afm2, and afpc.
*/
#if FM2+FPC+FCC > 1
Something wrong here! Only one of FM2, FPC, or FCC must be defined
#endif
#include <errno.h>
#include <signal.h>
#include <varargs.h>
#include <stdio.h>
#include <em_path.h>
#define M2DEF "/lib/m2"
#define FASTDIR EM_DIR
#define BINDIR "/lib.bin/"
#define CCINCL "/include/tail_ac"
char *ROOT_DIR = FASTDIR;
/*
Version producing ACK .o files in one pass.
*/
#define MAXARGC 256 /* maximum number of arguments allowed in a list */
#define USTR_SIZE 128 /* maximum length of string variable */
typedef char USTRING[USTR_SIZE];
USTRING INCLUDE = "-I";
struct arglist {
int al_argc;
char *al_argv[MAXARGC];
};
#define CPP "*cpp"
#define LD "*../bin/ack"
#define SHELL "/bin/sh"
int kids = -1;
int ecount = 0;
struct arglist CPP_FLAGS = {
7,
{
"-D__unix",
"-D_EM_WSIZE=4",
"-D_EM_PSIZE=4",
"-D_EM_SSIZE=2",
"-D_EM_LSIZE=4",
"-D_EM_FSIZE=4",
"-D_EM_DSIZE=8",
}
};
struct arglist COMP_FLAGS;
char *o_FILE = "a.out"; /* default name for executable file */
#define remove(str) ((noexec || unlink(str)), (str)[0] = '\0')
#define cleanup(str) (str && str[0] && remove(str))
#define init(al) ((al)->al_argc = 1)
char ProgCall[128];
struct arglist SRCFILES;
struct arglist LDFILES;
struct arglist GEN_LDFILES;
int RET_CODE = 0;
struct arglist LD_FLAGS;
struct arglist CALL_VEC;
int o_flag = 0;
int c_flag = 0;
int v_flag = 0;
int O_flag = 0;
char *mkstr();
char *malloc();
char *alloc();
char *extension();
USTRING ofile;
USTRING BASE;
USTRING tmp_file;
int noexec = 0;
extern char *strcat(), *strcpy(), *mktemp(), *strchr();
trapcc(sig)
int sig;
{
signal(sig, SIG_IGN);
if (kids != -1) kill(kids, sig);
cleanup(ofile);
cleanup(tmp_file);
exit(1);
}
#ifdef FCC
#define lang_suffix() "c"
#define comp_name() "*c_ce"
#endif FCC
#ifdef FM2
#define lang_suffix() "mod"
#define comp_name() "*m2_ce"
#endif FM2
#ifdef FPC
#define lang_suffix() "p"
#define comp_name() "*pc_ce"
#endif FPC
#ifdef FCC
int
lang_opt(str)
char *str;
{
switch(str[1]) {
case '-': /* debug options */
case 'w': /* disable warnings */
if (str[2]) {
char buf[3];
buf[2] = '\0';
buf[0] = '-';
buf[1] = str[2];
append(&COMP_FLAGS, buf);
}
else append(&COMP_FLAGS, "-a");
return 1;
}
return 0;
}
#endif FCC
#ifdef FM2
int
lang_opt(str)
char *str;
{
switch(str[1]) {
case '-': /* debug options */
case 'w': /* disable warnings */
case 'R': /* no runtime checks */
case 'W': /* add warnings */
case 'L': /* no line numbers */
case 'A': /* extra array bound checks */
case '3': /* only accept 3rd edition Modula-2 */
append(&COMP_FLAGS, str);
return 1;
case 'I':
append(&COMP_FLAGS, str);
break; /* !!! */
case 'U': /* underscores in identifiers allowed */
if (str[2] == '\0') {
append(&COMP_FLAGS, str);
return 1;
}
break;
case 'e': /* local extension for Modula-2 compiler:
procedure constants
*/
str[1] = 'l';
append(&COMP_FLAGS, str);
return 1;
}
return 0;
}
#endif FM2
#ifdef FPC
int
lang_opt(str)
char *str;
{
switch(str[1]) {
case '-': /* debug options */
case 'a': /* enable assertions */
case 'd': /* allow doubles (longs) */
case 'i': /* set size of integer sets */
case 't': /* tracing */
case 'w': /* disable warnings */
case 'A': /* extra array bound checks */
case 'C': /* distinguish between lower case and upper case */
case 'L': /* no FIL and LIN instructions */
case 'R': /* no runtime checks */
append(&COMP_FLAGS, str);
return 1;
case 'u':
case 'U':
/* underscores in identifiers */
case 's':
/* only compile standard pascal */
case 'c':
/* C type strings */
if (str[2] == '+' && str[3] == '\0') {
str[2] = 0;
append(&COMP_FLAGS, str);
return 1;
}
}
return 0;
}
#endif FPC
main(argc, argv)
char *argv[];
{
char *str;
char **argvec;
int count;
char *ext;
register struct arglist *call = &CALL_VEC;
char *file;
char *ldfile = 0;
USTRING COMP;
int compile_cnt = 0;
setbuf(stdout, (char *) 0);
basename(*argv++,ProgCall);
strcat(INCLUDE, ROOT_DIR);
#ifdef FM2
strcat(INCLUDE, M2DEF);
#endif FM2
#ifdef FCC
strcat(INCLUDE, CCINCL);
#endif FCC
#ifdef FPC
INCLUDE[0] = '\0';
#endif FPC
strcpy(COMP,comp_name());
#ifdef vax4
append(CPP_FLAGS, "-D__vax");
#endif
#ifdef sun3
append(CPP_FLAGS, "-D__sun");
#endif
#ifdef m68020
append(CPP_FLAGS, "-D__mc68020");
append(CPP_FLAGS, "-D__mc68000");
#endif
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
signal(SIGHUP, trapcc);
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
signal(SIGINT, trapcc);
if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
signal(SIGQUIT, trapcc);
while (--argc > 0) {
if (*(str = *argv++) != '-') {
append(&SRCFILES, str);
continue;
}
if (lang_opt(str)) {
}
else switch (str[1]) {
case 'c': /* stop after producing .o files */
c_flag = 1;
break;
case 'D': /* preprocessor #define */
case 'U': /* preprocessor #undef */
append(&CPP_FLAGS, str);
break;
case 'I': /* include directory */
append(&CPP_FLAGS, str);
break;
case 'o': /* target file */
if (argc-- >= 0) {
o_flag = 1;
o_FILE = *argv++;
ext = extension(o_FILE);
if (ext != o_FILE && ! strcmp(ext, lang_suffix())
) {
error("-o would overwrite %s", o_FILE);
}
append(&LD_FLAGS, "-o");
append(&LD_FLAGS, o_FILE);
}
break;
case 'O': /* use built in peephole optimizer */
O_flag = 1;
break;
case 'v': /* verbose */
v_flag++;
if (str[2] == 'n')
noexec = 1;
break;
case 'l': /* library file */
append(&SRCFILES, str);
break;
case 'M': /* use other compiler (for testing) */
strcpy(COMP, str+2);
break;
default:
append(&LD_FLAGS, str);
break;
}
}
if (ecount) exit(1);
count = SRCFILES.al_argc;
argvec = &(SRCFILES.al_argv[0]);
while (count-- > 0) {
ext = extension(*argvec);
if (*argvec[0] != '-' &&
ext != *argvec++ && (! strcmp(ext, lang_suffix())
)) {
compile_cnt++;
}
}
if (compile_cnt > 1 && c_flag && o_flag) {
warning("-o flag ignored");
o_flag = 0;
}
count = SRCFILES.al_argc;
argvec = &(SRCFILES.al_argv[0]);
while (count-- > 0) {
register char *f;
basename(file = *argvec++, BASE);
ext = extension(file);
if (file[0] != '-' &&
ext != file && (!strcmp(ext, lang_suffix())
)) {
if (compile_cnt > 1) printf("%s\n", file);
ldfile = c_flag ? ofile : alloc((unsigned)strlen(BASE)+3);
if (
#ifdef FCC
!strcmp(ext, "s") &&
#endif
needsprep(file)) {
strcpy(tmp_file, TMP_DIR);
strcat(tmp_file, "/F_XXXXXX");
mktemp(tmp_file);
init(call);
append(call, CPP);
concat(call, &CPP_FLAGS);
append(call, INCLUDE);
append(call, file);
if (runvec(call, tmp_file)) {
file = tmp_file;
}
else {
remove(tmp_file);
tmp_file[0] = '\0';
continue;
}
}
init(call);
if (o_flag && c_flag) {
f = o_FILE;
}
else f = mkstr(ldfile, BASE, ".o", (char *)0);
append(call, COMP);
#ifdef FCC
concat(call, &CPP_FLAGS);
#endif
concat(call, &COMP_FLAGS);
#if FM2 || FCC
append(call, INCLUDE);
#endif
append(call, file);
append(call, f);
if (runvec(call, (char *) 0)) {
file = f;
}
else {
remove(f);
continue;
}
cleanup(tmp_file);
tmp_file[0] = '\0';
}
else if (file[0] != '-' &&
strcmp(ext, "o") && strcmp(ext, "a")) {
warning("file with unknown suffix (%s) passed to the loader", ext);
}
if (c_flag)
continue;
append(&LDFILES, file);
if (ldfile) {
append(&GEN_LDFILES, ldfile);
ldfile = 0;
}
}
/* *.s to a.out */
if (RET_CODE == 0 && LDFILES.al_argc > 0) {
init(call);
append(call, LD);
#ifdef FCC
append(call, "-.c");
append(call, "-ansi");
#endif
#ifdef FM2
append(call, "-.mod");
#endif
#ifdef FPC
append(call, "-.p");
#endif
concat(call, &LD_FLAGS);
concat(call, &LDFILES);
if (runvec(call, (char *) 0) && GEN_LDFILES.al_argc == 1)
;
cleanup(tmp_file);
}
exit(RET_CODE);
}
needsprep(name)
char *name;
{
int file;
char fc;
file = open(name,0);
if (file < 0) return 0;
if (read(file, &fc, 1) != 1) fc = 0;
close(file);
return fc == '#';
}
char *
alloc(u)
unsigned u;
{
char *p = malloc(u);
if (p == 0)
panic("no space");
return p;
}
append(al, arg)
struct arglist *al;
char *arg;
{
if (!arg || !*arg) return;
if (al->al_argc >= MAXARGC)
panic("argument list overflow");
if (*arg == '*') {
char *p;
p = alloc((unsigned)strlen(ROOT_DIR)+strlen(BINDIR)+strlen(arg+1)+1);
strcpy(p, ROOT_DIR);
strcat(p, BINDIR);
strcat(p, arg+1);
arg = p;
}
al->al_argv[(al->al_argc)++] = arg;
}
concat(al1, al2)
struct arglist *al1, *al2;
{
register i = al2->al_argc;
register char **p = &(al1->al_argv[al1->al_argc]);
register char **q = &(al2->al_argv[0]);
if ((al1->al_argc += i) >= MAXARGC)
panic("argument list overflow");
while (i-- > 0) {
if (**q == '*') {
*p = alloc((unsigned)strlen(ROOT_DIR)+strlen(BINDIR)+strlen(*q+1)+2);
strcpy(*p, ROOT_DIR);
strcat(*p, BINDIR);
strcat(*p++, *q+1);
q++;
}
else *p++ = *q++;
}
}
/*VARARGS*/
char *
mkstr(va_alist)
va_dcl
{
va_list ap;
char *dst;
va_start(ap);
{
register char *p;
register char *q;
dst = q = va_arg(ap, char *);
p = va_arg(ap, char *);
while (p) {
while (*q++ = *p++);
q--;
p = va_arg(ap, char *);
}
}
va_end(ap);
return dst;
}
basename(str, dst)
char *str;
register char *dst;
{
register char *p1 = str;
register char *p2 = p1;
while (*p1)
if (*p1++ == '/')
p2 = p1;
p1--;
while (*p1 != '.' && p1 >= p2) p1--;
if (p1 >= p2) {
*p1 = '\0';
while (*dst++ = *p2++);
*p1 = '.';
}
else
while (*dst++ = *p2++);
}
char *
extension(fn)
char *fn;
{
register char *c = fn;
while (*c++) ;
while (*--c != '.' && c >= fn) { }
if (c++ < fn || !*c) return fn;
return c;
}
runvec(vec, outp)
struct arglist *vec;
char *outp;
{
int pid, status;
if (v_flag) {
pr_vec(vec);
putc('\n', stderr);
}
if ((pid = fork()) == 0) { /* start up the process */
if (outp) { /* redirect standard output */
close(1);
if (creat(outp, 0666) != 1)
panic("cannot create output file");
}
ex_vec(vec);
}
if (pid == -1)
panic("no more processes");
kids = pid;
wait(&status);
if (status) switch(status & 0177) {
case SIGHUP:
case SIGINT:
case SIGQUIT:
case SIGTERM:
case 0:
break;
default:
error("%s died with signal %d\n", vec->al_argv[1], status&0177);
}
kids = -1;
return status ? ((RET_CODE = 1), 0) : 1;
}
/*VARARGS1*/
error(str, s1, s2)
char *str, *s1, *s2;
{
fprintf(stderr, "%s: ", ProgCall);
fprintf(stderr, str, s1, s2);
putc('\n', stderr);
ecount++;
}
/*VARARGS1*/
warning(str, s1, s2)
char *str, *s1, *s2;
{
fprintf(stderr, "%s: (warning) ", ProgCall);
fprintf(stderr, str, s1, s2);
putc('\n', stderr);
}
panic(str)
char *str;
{
error(str);
trapcc(SIGINT);
}
pr_vec(vec)
register struct arglist *vec;
{
register char **ap = &vec->al_argv[1];
vec->al_argv[vec->al_argc] = 0;
fputs(*ap, stderr);
while (*++ap) {
putc(' ', stderr);
fputs(*ap, stderr);
}
}
extern int errno;
ex_vec(vec)
register struct arglist *vec;
{
if (noexec)
exit(0);
vec->al_argv[vec->al_argc] = 0;
execv(vec->al_argv[1], &(vec->al_argv[1]));
if (errno == ENOEXEC) { /* not an a.out, try it with the SHELL */
vec->al_argv[0] = SHELL;
execv(SHELL, &(vec->al_argv[0]));
}
if (access(vec->al_argv[1], 1) == 0) {
/* File is executable. */
error("cannot execute %s", vec->al_argv[1]);
} else {
error("%s is not executable", vec->al_argv[1]);
}
exit(1);
}

55
fast/driver/proto.make Normal file
View file

@ -0,0 +1,55 @@
# $Header$
#PARAMS do not remove this line!
SRC_DIR = $(SRC_HOME)/fast/driver
INCLUDES = -I$(TARGET_HOME)/config
CFLAGS = $(COPTIONS) $(INCLUDES)
LINTFLAGS = $(LINTOPTIONS) $(INCLUDES)
LDFLAGS = $(LDOPTIONS)
all: afcc afm2 afpc
install: all
cp afcc afm2 afpc $(TARGET_HOME)/bin
if [ $(DO_MACHINE_INDEP) = y ] ; \
then cp $(SRC_DIR)/afcc.1 $(SRC_DIR)/afm2.1 $(SRC_DIR)/afpc.1 $(TARGET_HOME)/man ; \
fi
cmp: all
-cmp afcc $(TARGET_HOME)/bin/afcc
-cmp afm2 $(TARGET_HOME)/bin/afm2
-cmp afpc $(TARGET_HOME)/bin/afpc
-cmp afcc.1 $(TARGET_HOME)/man/afcc.1
-cmp afm2.1 $(TARGET_HOME)/man/afm2.1
-cmp afpc.1 $(TARGET_HOME)/man/afpc.1
pr:
@pr $(SRC_DIR)/proto.make $(SRC_DIR)/driver.c
opr:
make pr | opr
clean:
rm -f *,$(SUF) afcc afm2 afpc Out
afcc.$(SUF): $(SRC_DIR)/driver.c $(TARGET_HOME)/config/em_path.h
$(CC) $(CFLAGS) -c -DFCC -D$(MACH) -D`ack_sys` $(SRC_DIR)/driver.c
mv driver.$(SUF) afcc.$(SUF)
afpc.$(SUF): $(SRC_DIR)/driver.c $(TARGET_HOME)/config/em_path.h
$(CC) $(CFLAGS) -c -DFPC -D$(MACH) -D`ack_sys` $(SRC_DIR)/driver.c
mv driver.$(SUF) afpc.$(SUF)
afm2.$(SUF): $(SRC_DIR)/driver.c $(TARGET_HOME)/config/em_path.h
$(CC) $(CFLAGS) -c -DFM2 -D$(MACH) -D`ack_sys` $(SRC_DIR)/driver.c
mv driver.$(SUF) afm2.$(SUF)
afcc: afcc.$(SUF)
$(CC) $(LDFLAGS) -o afcc afcc.$(SUF)
afm2: afm2.$(SUF)
$(CC) $(LDFLAGS) -o afm2 afm2.$(SUF)
afpc: afpc.$(SUF)
$(CC) $(LDFLAGS) -o afpc afpc.$(SUF)

3
fast/f_c.ansi/.distr Normal file
View file

@ -0,0 +1,3 @@
Parameters
proto.main
proto.make

142
fast/f_c.ansi/Parameters Normal file
View file

@ -0,0 +1,142 @@
!File: lint.h
#undef LINT 1 /* if defined, 'lint' is produced */
!File: pathlength.h
#define PATHLENGTH 1024 /* max. length of path to file */
!File: errout.h
#define ERROUT STDERR /* file pointer for writing messages */
#define ERR_SHADOW 5 /* a syntax error overshadows error messages
until ERR_SHADOW symbols have been
accepted without syntax error */
!File: idfsize.h
#define IDFSIZE 64 /* maximum significant length of an identifier */
!File: numsize.h
#define NUMSIZE 256 /* maximum length of a numeric constant */
!File: nparams.h
#define NPARAMS 32 /* maximum number of parameters */
#define STDC_NPARAMS 31 /* ANSI limit on number of parameters */
!File: ifdepth.h
#define IFDEPTH 256 /* maximum number of nested if-constructions */
!File: density.h
#define DENSITY 3 /* see switch.[ch] for an explanation */
!File: macbuf.h
#define LAPBUF 128 /* initial size of macro replacement buffer */
#define ARGBUF 128 /* initial size of macro parameter buffer(s) */
!File: strsize.h
#define ISTRSIZE 32 /* minimum number of bytes allocated for
storing a string */
#define RSTRSIZE 16 /* step size in enlarging the memory for
the storage of a string */
!File: trgt_sizes.h
#define MAXSIZE 8 /* the maximum of the SZ_* constants */
/* target machine sizes */
#define SZ_CHAR 1
#define SZ_SHORT 2
#define SZ_WORD 4
#define SZ_INT 4
#define SZ_LONG 4
#define SZ_FLOAT 4
#define SZ_DOUBLE 8
#define SZ_LNGDBL 8 /* for now */
#define SZ_POINTER 4
/* target machine alignment requirements */
#define AL_CHAR 1
#define AL_SHORT SZ_SHORT
#define AL_WORD SZ_WORD
#define AL_INT SZ_WORD
#define AL_LONG SZ_WORD
#define AL_FLOAT SZ_WORD
#define AL_DOUBLE SZ_WORD
#define AL_LNGDBL SZ_WORD
#define AL_POINTER SZ_WORD
#define AL_STRUCT 1
#define AL_UNION 1
!File: botch_free.h
#undef BOTCH_FREE 1 /* when defined, botch freed memory, as a check */
!File: dataflow.h
#undef DATAFLOW 1 /* produce some compile-time xref */
!File: debug.h
#undef DEBUG 1 /* perform various self-tests */
!File: use_tmp.h
#define PREPEND_SCOPES 1 /* collect exa, exp, ina and inp commands
and if USE_TMP is defined let them
precede the rest of the generated
compact code */
#undef USE_TMP 1 /* use C_insertpart, C_endpart mechanism
to generate EM-code in the order needed
for the code-generators. If not defined,
the old-style peephole optimizer is
needed. */
!File: parbufsize.h
#define PARBUFSIZE 1024
!File: textsize.h
#define ITEXTSIZE 32 /* 1st piece of memory for repl. text */
!File: inputtype.h
#define INP_READ_IN_ONE 1 /* read input file in one */
!File: nopp.h
#undef NOPP 1 /* if NOT defined, use built-int preprocessor */
!File: nobitfield.h
#undef NOBITFIELD 1 /* if NOT defined, implement bitfields */
!File: spec_arith.h
/* describes internal compiler arithmetics */
#undef SPECIAL_ARITHMETICS /* something different from native long */
#undef UNSIGNED_ARITH unsigned arith
!File: static.h
#define GSTATIC /* for large global "static" arrays */
!File: nocross.h
#define NOCROSS 1 /* if NOT defined, cross compiler */
!File: regcount.h
#undef REGCOUNT 1 /* count occurrences for register messages */
!File: dbsymtab.h
#undef DBSYMTAB 1 /* ability to produce symbol table for debugger */

65
fast/f_c.ansi/proto.main Normal file
View file

@ -0,0 +1,65 @@
# $Header$
# C compilation part. Not to be called directly.
# Instead, it is to be called by the Makefile.
# SRC_DIR, UTIL_HOME, TARGET_HOME, CC, COPTIONS, LINT, LINTOPTIONS, LDOPTIONS,
# CC_AND_MKDEP, SUF, LIBSUF, MACH should be set here.
#PARAMS do not remove this line!
MDIR = $(TARGET_HOME)/modules
LIBDIR = $(MDIR)/lib
LINTLIBDIR = $(UTIL_HOME)/modules/lib
MALLOC = $(LIBDIR)/malloc.$(SUF)
EMLIB = $(LIBDIR)/libem_mesO.$(LIBSUF) \
$(LIBDIR)/libCEopt.$(LIBSUF) \
$(TARGET_HOME)/lib.bin/$(MACH)/ce.$(LIBSUF) \
$(TARGET_HOME)/lib.bin/$(MACH)/back.$(LIBSUF) \
$(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) \
$(LIBDIR)/libobject.$(LIBSUF)
MODLIB = $(LIBDIR)/libinput.$(LIBSUF) \
$(LIBDIR)/libassert.$(LIBSUF) \
$(LIBDIR)/liballoc.$(LIBSUF) \
$(MALLOC) \
$(LIBDIR)/libflt.$(LIBSUF) \
$(LIBDIR)/libprint.$(LIBSUF) \
$(LIBDIR)/libstring.$(LIBSUF) \
$(LIBDIR)/libsystem.$(LIBSUF)
LIBS = $(EMLIB) $(MODLIB)
LINTLIBS = $(LINTLIBDIR)/$(LINTPREF)em_mes.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)emk.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)input.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)assert.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)alloc.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)flt.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)print.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)string.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)system.$(LINTSUF)
PROFILE =
INCLUDES = -I. -I$(SRC_DIR) -I$(TARGET_HOME)/modules/h -I$(TARGET_HOME)/h -I$(TARGET_HOME)/modules/pkg
CFLAGS = $(PROFILE) $(INCLUDES) $(COPTIONS)
LINTFLAGS = $(INCLUDES) $(LINTOPTIONS)
LDFLAGS = $(PROFILE) $(LDOPTIONS)
# C_SRC and OBJ should be set here.
#LISTS do not remove this line!
all: main
clean:
rm -f *.$(SUF) main
lint:
$(LINT) $(LINTFLAGS) $(C_SRC) $(LINTLIBS)
main: $(OBJ)
$(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o main
# do not remove the next line; it is used for generating dependencies
#DEPENDENCIES

267
fast/f_c.ansi/proto.make Normal file
View file

@ -0,0 +1,267 @@
# $Header$
# make ANSI C compiler
#PARAMS do not remove this line!
UTIL_BIN = \
$(UTIL_HOME)/bin
SRC_DIR = \
$(SRC_HOME)/lang/cem/cemcom.ansi
FSRC_DIR = \
$(SRC_HOME)/fast/f_cem
TABGEN= $(UTIL_BIN)/tabgen
LLGEN = $(UTIL_BIN)/LLgen
LLGENOPTIONS = \
-v
SRC_G = $(SRC_DIR)/program.g $(SRC_DIR)/declar.g \
$(SRC_DIR)/expression.g $(SRC_DIR)/statement.g $(SRC_DIR)/ival.g
GEN_G = tokenfile.g
GFILES= $(GEN_G) $(SRC_G)
SRC_C = \
$(SRC_DIR)/Version.c \
$(SRC_DIR)/LLlex.c \
$(SRC_DIR)/LLmessage.c \
$(SRC_DIR)/arith.c \
$(SRC_DIR)/blocks.c \
$(SRC_DIR)/ch3.c \
$(SRC_DIR)/ch3bin.c \
$(SRC_DIR)/ch3mon.c \
$(SRC_DIR)/code.c \
$(SRC_DIR)/conversion.c \
$(SRC_DIR)/cstoper.c \
$(SRC_DIR)/dataflow.c \
$(SRC_DIR)/declarator.c \
$(SRC_DIR)/decspecs.c \
$(SRC_DIR)/domacro.c \
$(SRC_DIR)/dumpidf.c \
$(SRC_DIR)/error.c \
$(SRC_DIR)/eval.c \
$(SRC_DIR)/expr.c \
$(SRC_DIR)/field.c \
$(SRC_DIR)/fltcstoper.c \
$(SRC_DIR)/idf.c \
$(SRC_DIR)/init.c \
$(SRC_DIR)/input.c \
$(SRC_DIR)/l_comment.c \
$(SRC_DIR)/l_ev_ord.c \
$(SRC_DIR)/l_lint.c \
$(SRC_DIR)/l_misc.c \
$(SRC_DIR)/l_outdef.c \
$(SRC_DIR)/l_states.c \
$(SRC_DIR)/label.c \
$(SRC_DIR)/main.c \
$(SRC_DIR)/options.c \
$(SRC_DIR)/pragma.c \
$(SRC_DIR)/proto.c \
$(SRC_DIR)/replace.c \
$(SRC_DIR)/skip.c \
$(SRC_DIR)/stab.c \
$(SRC_DIR)/stack.c \
$(SRC_DIR)/struct.c \
$(SRC_DIR)/switch.c \
$(SRC_DIR)/tokenname.c \
$(SRC_DIR)/type.c \
$(SRC_DIR)/util.c
GEN_C = tokenfile.c program.c declar.c expression.c statement.c ival.c \
symbol2str.c char.c Lpars.c next.c
CFILES= $(SRC_C) $(GEN_C)
SRC_H = \
$(SRC_DIR)/LLlex.h \
$(SRC_DIR)/align.h \
$(SRC_DIR)/arith.h \
$(SRC_DIR)/assert.h \
$(SRC_DIR)/atw.h \
$(SRC_DIR)/class.h \
$(SRC_DIR)/decspecs.h \
$(SRC_DIR)/file_info.h \
$(SRC_DIR)/input.h \
$(SRC_DIR)/interface.h \
$(SRC_DIR)/l_class.h \
$(SRC_DIR)/l_comment.h \
$(SRC_DIR)/l_em.h \
$(SRC_DIR)/l_lint.h \
$(SRC_DIR)/label.h \
$(SRC_DIR)/level.h \
$(SRC_DIR)/mes.h \
$(SRC_DIR)/sizes.h \
$(SRC_DIR)/specials.h \
$(SRC_DIR)/tokenname.h
GEN_H = botch_free.h dataflow.h debug.h density.h errout.h \
idfsize.h ifdepth.h inputtype.h macbuf.h lint.h \
nobitfield.h nopp.h nocross.h \
nparams.h numsize.h parbufsize.h pathlength.h Lpars.h \
strsize.h trgt_sizes.h textsize.h use_tmp.h spec_arith.h static.h \
regcount.h dbsymtab.h \
code.h declar.h def.h expr.h field.h estack.h util.h proto.h replace.h \
idf.h macro.h stmt.h struct.h switch.h type.h l_brace.h l_state.h \
l_outdef.h stack.h
HFILES= $(GEN_H) $(SRC_H)
NEXTFILES = \
$(SRC_DIR)/code.str \
$(SRC_DIR)/declar.str \
$(SRC_DIR)/def.str \
$(SRC_DIR)/expr.str \
$(SRC_DIR)/field.str \
$(SRC_DIR)/estack.str \
$(SRC_DIR)/util.str \
$(SRC_DIR)/proto.str \
$(SRC_DIR)/replace.str \
$(SRC_DIR)/idf.str \
$(SRC_DIR)/macro.str \
$(SRC_DIR)/stack.str \
$(SRC_DIR)/stmt.str \
$(SRC_DIR)/struct.str \
$(SRC_DIR)/switch.str \
$(SRC_DIR)/type.str \
$(SRC_DIR)/l_brace.str \
$(SRC_DIR)/l_state.str \
$(SRC_DIR)/l_outdef.str
all: make.main
make -f make.main main
install: all
cp main $(TARGET_HOME)/lib.bin/c_ce
cmp: all
-cmp main $(TARGET_HOME)/lib.bin/c_ce
opr:
make pr | opr
pr:
@pr $(FSRC_DIR)/proto.make $(FSRC_DIR)/proto.main \
$(FSRC_DIR)/Parameters
lint: make.main
make -f make.main lint
Cfiles: hfiles LLfiles $(GEN_C) $(GEN_H) Makefile
echo $(CFILES) | tr ' ' '\012' > Cfiles
echo $(HFILES) | tr ' ' '\012' >> Cfiles
resolved: Cfiles
CC="$(CC)" UTIL_HOME="$(UTIL_HOME)" do_resolve `cat Cfiles` > Cfiles.new
-if cmp -s Cfiles Cfiles.new ; then rm -f Cfiles.new ; else mv Cfiles.new Cfiles ; fi
touch resolved
# there is no file called "dependencies"; we want dependencies checked
# every time. This means that make.main is made every time. Oh well ...
# it does not take much time.
dependencies: resolved
do_deps `grep '.c$$' Cfiles`
make.main: dependencies make_macros lists $(FSRC_DIR)/proto.main
sed -e '/^#DEPENDENCIES/,$$d' -e '/^#PARAMS/r make_macros' -e '/^#LISTS/r lists' $(FSRC_DIR)/proto.main > make.main
echo '#DEPENDENCIES' >> make.main
cat *.dep >> make.main
make_macros: Makefile
echo 'SRC_DIR=$(SRC_DIR)' > make_macros
echo 'UTIL_HOME=$(UTIL_HOME)' >> make_macros
echo 'TARGET_HOME=$(TARGET_HOME)' >> make_macros
echo 'CC=$(CC)' >> make_macros
echo 'COPTIONS=$(COPTIONS) -DPEEPHOLE' >> make_macros
echo 'LDOPTIONS=$(LDOPTIONS)' >> make_macros
echo 'LINT=$(LINT)' >> make_macros
echo 'LINTOPTIONS=$(LINTOPTIONS)' >> make_macros
echo 'SUF=$(SUF)' >> make_macros
echo 'LIBSUF=$(LIBSUF)' >> make_macros
echo 'CC_AND_MKDEP=$(CC_AND_MKDEP)' >> make_macros
echo 'MACH=$(MACH)' >> make_macros
lists: Cfiles
echo "C_SRC = \\" > lists
echo $(CFILES) >> lists
echo "OBJ = \\" >> lists
echo $(CFILES) | sed -e 's#[^ ]*/##g' -e 's/\.c/.$$(SUF)/g' >> lists
clean:
-make -f make.main clean
rm -f $(GEN_C) $(GEN_G) $(GEN_H) hfiles LLfiles Cfiles LL.output
rm -f resolved *.dep lists make.main make_macros
LLfiles: $(GFILES)
$(LLGEN) $(LLGENOPTIONS) $(GFILES)
@touch LLfiles
hfiles: $(FSRC_DIR)/Parameters $(SRC_DIR)/make.hfiles
$(SRC_DIR)/make.hfiles $(FSRC_DIR)/Parameters
touch hfiles
tokenfile.g: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokfile
$(SRC_DIR)/make.tokfile <$(SRC_DIR)/tokenname.c >tokenfile.g
symbol2str.c: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokcase
$(SRC_DIR)/make.tokcase <$(SRC_DIR)/tokenname.c >symbol2str.c
code.h: $(SRC_DIR)/code.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/code.str > code.h
declar.h: $(SRC_DIR)/declar.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/declar.str > declar.h
def.h: $(SRC_DIR)/def.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/def.str > def.h
expr.h: $(SRC_DIR)/expr.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/expr.str > expr.h
field.h: $(SRC_DIR)/field.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/field.str > field.h
estack.h: $(SRC_DIR)/estack.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/estack.str > estack.h
util.h: $(SRC_DIR)/util.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/util.str > util.h
proto.h: $(SRC_DIR)/proto.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/proto.str > proto.h
replace.h: $(SRC_DIR)/replace.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/replace.str > replace.h
idf.h: $(SRC_DIR)/idf.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/idf.str > idf.h
macro.h: $(SRC_DIR)/macro.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/macro.str > macro.h
stack.h: $(SRC_DIR)/stack.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/stack.str > stack.h
stmt.h: $(SRC_DIR)/stmt.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/stmt.str > stmt.h
struct.h: $(SRC_DIR)/struct.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/struct.str > struct.h
switch.h: $(SRC_DIR)/switch.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/switch.str > switch.h
type.h: $(SRC_DIR)/type.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/type.str > type.h
l_brace.h: $(SRC_DIR)/l_brace.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/l_brace.str > l_brace.h
l_state.h: $(SRC_DIR)/l_state.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/l_state.str > l_state.h
l_outdef.h: $(SRC_DIR)/l_outdef.str $(SRC_DIR)/make.allocd
$(SRC_DIR)/make.allocd < $(SRC_DIR)/l_outdef.str > l_outdef.h
next.c: $(NEXTFILES) $(SRC_DIR)/make.next
$(SRC_DIR)/make.next $(NEXTFILES) > next.c
char.c: $(SRC_DIR)/char.tab
$(TABGEN) -f$(SRC_DIR)/char.tab >char.c

3
fast/f_m2/.distr Normal file
View file

@ -0,0 +1,3 @@
Parameters
proto.main
proto.make

99
fast/f_m2/Parameters Normal file
View file

@ -0,0 +1,99 @@
!File: errout.h
#define ERROUT STDERR /* file pointer for writing messages */
#define MAXERR_LINE 100 /* maximum number of error messages given
on the same input line. */
!File: idfsize.h
#define IDFSIZE 128 /* maximum significant length of an identifier */
!File: numsize.h
#define NUMSIZE 256 /* maximum length of a numeric constant */
!File: strsize.h
#define ISTRSIZE 32 /* minimum number of bytes allocated for
storing a string */
#define RSTRSIZE 8 /* step size in enlarging the memory for
the storage of a string */
!File: target_sizes.h
#define MAXSIZE 8 /* the maximum of the SZ_* constants */
/* target machine sizes */
#define SZ_CHAR ((arith)1)
#define SZ_SHORT ((arith)2)
#define SZ_WORD ((arith)4)
#define SZ_INT ((arith)4)
#define SZ_LONG ((arith)4)
#define SZ_FLOAT ((arith)4)
#define SZ_DOUBLE ((arith)8)
#define SZ_POINTER ((arith)4)
/* target machine alignment requirements */
#define AL_CHAR 1
#define AL_SHORT ((int)SZ_SHORT)
#define AL_WORD ((int)SZ_WORD)
#define AL_INT ((int)SZ_WORD)
#define AL_LONG ((int)SZ_WORD)
#define AL_FLOAT ((int)SZ_WORD)
#define AL_DOUBLE ((int)SZ_WORD)
#define AL_POINTER ((int)SZ_WORD)
#define AL_STRUCT ((int)SZ_WORD)
!File: debugcst.h
#undef DEBUG 1 /* perform various self-tests */
!File: inputtype.h
#define INP_READ_IN_ONE 1 /* read input file in one */
!File: density.h
#define DENSITY 3 /* see casestat.C for an explanation */
!File: squeeze.h
#undef SQUEEZE 1 /* define on "small" machines */
!File: strict3rd.h
#undef STRICT_3RD_ED 1 /* define on "small" machines, and if you want
a compiler that only implements "3rd edition"
Modula-2
*/
!File: nocross.h
#define NOCROSS 1 /* define when cross-compiler not needed */
!File: nostrict.h
#undef NOSTRICT 1 /* define when STRICT warnings disabled
(yet another squeezing method)
*/
!File: bigresult.h
#define BIG_RESULT_ON_STACK 1 /* define when function results must be
put on the stack; in this case, caller
reserves space for it. When not defined,
callee puts result in global data area and
returns a pointer to it
*/
!File: dbsymtab.h
#undef DBSYMTAB 1 /* ability to produce symbol table for debugger */
!File: use_insert.h
#undef USE_INSERT 1 /* use C_insertpart mechanism */
!File: uns_arith.h
#define UNSIGNED_ARITH unsigned arith

65
fast/f_m2/proto.main Normal file
View file

@ -0,0 +1,65 @@
# $Header$
# C compilation part. Not to be called directly.
# Instead, it is to be called by the Makefile.
# SRC_DIR, UTIL_HOME, TARGET_HOME, CC, COPTIONS, LINT, LINTOPTIONS, LDOPTIONS,
# CC_AND_MKDEP, SUF, LIBSUF, MACH should be set here.
#PARAMS do not remove this line!
MDIR = $(TARGET_HOME)/modules
LIBDIR = $(MDIR)/lib
LINTLIBDIR = $(UTIL_HOME)/modules/lib
MALLOC = $(LIBDIR)/malloc.$(SUF)
EMLIB = $(LIBDIR)/libem_mesO.$(LIBSUF) \
$(LIBDIR)/libCEopt.$(LIBSUF) \
$(TARGET_HOME)/lib.bin/$(MACH)/ce.$(LIBSUF) \
$(TARGET_HOME)/lib.bin/$(MACH)/back.$(LIBSUF) \
$(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) \
$(LIBDIR)/libobject.$(LIBSUF)
MODLIB = $(LIBDIR)/libinput.$(LIBSUF) \
$(LIBDIR)/libassert.$(LIBSUF) \
$(LIBDIR)/liballoc.$(LIBSUF) \
$(MALLOC) \
$(LIBDIR)/libflt.$(LIBSUF) \
$(LIBDIR)/libprint.$(LIBSUF) \
$(LIBDIR)/libstring.$(LIBSUF) \
$(LIBDIR)/libsystem.$(LIBSUF)
LIBS = $(EMLIB) $(MODLIB)
LINTLIBS = $(LINTLIBDIR)/$(LINTPREF)em_mes.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)emk.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)input.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)assert.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)alloc.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)flt.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)print.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)string.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)system.$(LINTSUF)
PROFILE =
INCLUDES = -I. -I$(SRC_DIR) -I$(TARGET_HOME)/modules/h -I$(TARGET_HOME)/h -I$(TARGET_HOME)/modules/pkg
CFLAGS = $(PROFILE) $(INCLUDES) $(COPTIONS)
LINTFLAGS = $(INCLUDES) $(LINTOPTIONS)
LDFLAGS = $(PROFILE) $(LDOPTIONS)
# C_SRC and OBJ should be set here.
#LISTS do not remove this line!
all: main
clean:
rm -f *.$(SUF) main
lint:
$(LINT) $(LINTFLAGS) $(C_SRC) $(LINTLIBS)
main: $(OBJ)
$(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o main
# do not remove the next line; it is used for generating dependencies
#DEPENDENCIES

155
fast/f_m2/proto.make Normal file
View file

@ -0,0 +1,155 @@
# $Header$
# make Modula-2 compiler
#PARAMS do not remove this line!
UTIL_BIN = \
$(UTIL_HOME)/bin
SRC_DIR = \
$(SRC_HOME)/lang/m2/comp
FSRC_DIR = \
$(SRC_HOME)/fast/f_m2
TABGEN= $(UTIL_BIN)/tabgen
LLGEN = $(UTIL_BIN)/LLgen
LLGENOPTIONS = \
-v
SRC_G = $(SRC_DIR)/program.g $(SRC_DIR)/declar.g \
$(SRC_DIR)/expression.g $(SRC_DIR)/statement.g
GEN_G = tokenfile.g
GFILES= $(GEN_G) $(SRC_G)
SRC_C = $(SRC_DIR)/LLlex.c $(SRC_DIR)/LLmessage.c $(SRC_DIR)/error.c \
$(SRC_DIR)/main.c $(SRC_DIR)/tokenname.c $(SRC_DIR)/idf.c \
$(SRC_DIR)/input.c $(SRC_DIR)/type.c $(SRC_DIR)/def.c \
$(SRC_DIR)/misc.c $(SRC_DIR)/enter.c $(SRC_DIR)/defmodule.c \
$(SRC_DIR)/typequiv.c $(SRC_DIR)/node.c $(SRC_DIR)/cstoper.c \
$(SRC_DIR)/chk_expr.c $(SRC_DIR)/options.c $(SRC_DIR)/walk.c \
$(SRC_DIR)/desig.c $(SRC_DIR)/code.c $(SRC_DIR)/lookup.c \
$(SRC_DIR)/Version.c $(SRC_DIR)/stab.c
GEN_C = tokenfile.c program.c declar.c expression.c statement.c \
symbol2str.c char.c Lpars.c casestat.c tmpvar.c scope.c next.c
CFILES= $(SRC_C) $(GEN_C)
SRC_H = $(SRC_DIR)/LLlex.h $(SRC_DIR)/chk_expr.h $(SRC_DIR)/class.h \
$(SRC_DIR)/debug.h $(SRC_DIR)/desig.h $(SRC_DIR)/f_info.h \
$(SRC_DIR)/idf.h $(SRC_DIR)/input.h $(SRC_DIR)/main.h \
$(SRC_DIR)/misc.h $(SRC_DIR)/scope.h $(SRC_DIR)/standards.h \
$(SRC_DIR)/tokenname.h $(SRC_DIR)/walk.h $(SRC_DIR)/warning.h \
$(SRC_DIR)/SYSTEM.h
GEN_H = errout.h idfsize.h numsize.h strsize.h target_sizes.h bigresult.h \
inputtype.h density.h squeeze.h nocross.h nostrict.h def.h debugcst.h \
type.h Lpars.h node.h strict3rd.h real.h use_insert.h dbsymtab.h \
uns_arith.h def.h type.h node.h real.h
HFILES= $(GEN_H) $(SRC_H)
NEXTFILES = \
$(SRC_DIR)/def.H $(SRC_DIR)/type.H $(SRC_DIR)/node.H $(SRC_DIR)/real.H \
$(SRC_DIR)/scope.C $(SRC_DIR)/tmpvar.C $(SRC_DIR)/casestat.C
all: make.main
make -f make.main main
install: all
cp main $(TARGET_HOME)/lib.bin/m2_ce
cmp: all
-cmp main $(TARGET_HOME)/lib.bin/m2_ce
opr:
make pr | opr
pr:
@pr $(FSRC_DIR)/proto.make $(FSRC_DIR)/proto.main \
$(FSRC_DIR)/Parameters
lint: make.main
make -f make.main lint
Cfiles: hfiles LLfiles $(GEN_C) $(GEN_H) Makefile
echo $(CFILES) | tr ' ' '\012' > Cfiles
echo $(HFILES) | tr ' ' '\012' >> Cfiles
resolved: Cfiles
CC="$(CC)" UTIL_HOME="$(UTIL_HOME)" do_resolve `cat Cfiles` > Cfiles.new
-if cmp -s Cfiles Cfiles.new ; then rm -f Cfiles.new ; else mv Cfiles.new Cfiles ; fi
touch resolved
# there is no file called "dependencies"; we want dependencies checked
# every time. This means that make.main is made every time. Oh well ...
# it does not take much time.
dependencies: resolved
do_deps `grep '.c$$' Cfiles`
make.main: dependencies make_macros lists $(FSRC_DIR)/proto.main
sed -e '/^#DEPENDENCIES/,$$d' -e '/^#PARAMS/r make_macros' -e '/^#LISTS/r lists' $(FSRC_DIR)/proto.main > make.main
echo '#DEPENDENCIES' >> make.main
cat *.dep >> make.main
make_macros: Makefile
echo 'SRC_DIR=$(SRC_DIR)' > make_macros
echo 'UTIL_HOME=$(UTIL_HOME)' >> make_macros
echo 'TARGET_HOME=$(TARGET_HOME)' >> make_macros
echo 'CC=$(CC)' >> make_macros
echo 'COPTIONS=$(COPTIONS) -DPEEPHOLE' >> make_macros
echo 'LDOPTIONS=$(LDOPTIONS)' >> make_macros
echo 'LINT=$(LINT)' >> make_macros
echo 'LINTOPTIONS=$(LINTOPTIONS)' >> make_macros
echo 'SUF=$(SUF)' >> make_macros
echo 'LIBSUF=$(LIBSUF)' >> make_macros
echo 'CC_AND_MKDEP=$(CC_AND_MKDEP)' >> make_macros
echo 'MACH=$(MACH)' >> make_macros
lists: Cfiles
echo "C_SRC = \\" > lists
echo $(CFILES) >> lists
echo "OBJ = \\" >> lists
echo $(CFILES) | sed -e 's#[^ ]*/##g' -e 's/\.c/.$$(SUF)/g' >> lists
clean:
-make -f make.main clean
rm -f $(GEN_C) $(GEN_G) $(GEN_H) hfiles LLfiles Cfiles LL.output
rm -f resolved *.dep lists make.main make_macros
LLfiles: $(GFILES)
$(LLGEN) $(LLGENOPTIONS) $(GFILES)
@touch LLfiles
hfiles: $(FSRC_DIR)/Parameters $(SRC_DIR)/make.hfiles
$(SRC_DIR)/make.hfiles $(FSRC_DIR)/Parameters
touch hfiles
tokenfile.g: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokfile
$(SRC_DIR)/make.tokfile <$(SRC_DIR)/tokenname.c >tokenfile.g
symbol2str.c: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokcase
$(SRC_DIR)/make.tokcase <$(SRC_DIR)/tokenname.c >symbol2str.c
def.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/def.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/def.H > def.h
type.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/type.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/type.H > type.h
real.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/real.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/real.H > real.h
node.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/node.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/node.H > node.h
scope.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/scope.C
$(SRC_DIR)/make.allocd < $(SRC_DIR)/scope.C > scope.c
tmpvar.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/tmpvar.C
$(SRC_DIR)/make.allocd < $(SRC_DIR)/tmpvar.C > tmpvar.c
casestat.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/casestat.C
$(SRC_DIR)/make.allocd < $(SRC_DIR)/casestat.C > casestat.c
next.c: $(NEXTFILES) $(SRC_DIR)/make.next
$(SRC_DIR)/make.next $(NEXTFILES) > next.c
char.c: $(SRC_DIR)/char.tab
$(TABGEN) -f$(SRC_DIR)/char.tab >char.c

3
fast/f_pc/.distr Normal file
View file

@ -0,0 +1,3 @@
Parameters
proto.main
proto.make

61
fast/f_pc/Parameters Normal file
View file

@ -0,0 +1,61 @@
!File: debugcst.h
#undef DEBUG 1 /* perform various self-tests */
!File: density.h
#define DENSITY 3 /* to determine, if a csa or csb
instruction must be generated */
!File: errout.h
#define ERROUT STDERR /* file pointer for writing messages */
#define MAXERR_LINE 5 /* maximum number of error messages given
on the same input line. */
!File: idfsize.h
#define IDFSIZE 128 /* max. significant length of an identifier */
!File: inputtype.h
#define INP_READ_IN_ONE 1 /* read input file in one */
!File: numsize.h
#define NUMSIZE 256 /* maximum length of a numeric constant */
!File: strsize.h
#define ISTRSIZE 32 /* minimum number of bytes allocated for
storing a string */
#define RSTRSIZE 8 /* step size in enlarging the memory for
the storage of a string */
!File: target_sizes.h
#define MAXSIZE 8 /* the maximum of the SZ_* constants */
/* target machine sizes */
#define SZ_CHAR (arith)1
#define SZ_WORD (arith)4
#define SZ_INT (arith)4
#define SZ_LONG (arith)4
#define SZ_POINTER (arith)4
#define SZ_REAL (arith)8
/* target machine alignment requirements */
#define AL_CHAR 1
#define AL_WORD ((int)SZ_WORD)
#define AL_INT ((int)SZ_WORD)
#define AL_LONG ((int)SZ_WORD)
#define AL_POINTER ((int)SZ_WORD)
#define AL_REAL ((int)SZ_WORD)
#define AL_STRUCT ((int)SZ_WORD)
!File: nocross.h
#define NOCROSS 1 /* define when cross compiler not needed */
!File: dbsymtab.h
#undef DBSYMTAB 1 /* ability to produce symbol table for debugger */

65
fast/f_pc/proto.main Normal file
View file

@ -0,0 +1,65 @@
# $Header$
# C compilation part. Not to be called directly.
# Instead, it is to be called by the Makefile.
# SRC_DIR, UTIL_HOME, TARGET_HOME, CC, COPTIONS, LINT, LINTOPTIONS, LDOPTIONS,
# CC_AND_MKDEP, SUF, LIBSUF, MACH should be set here.
#PARAMS do not remove this line!
MDIR = $(TARGET_HOME)/modules
LIBDIR = $(MDIR)/lib
LINTLIBDIR = $(UTIL_HOME)/modules/lib
MALLOC = $(LIBDIR)/malloc.$(SUF)
EMLIB = $(LIBDIR)/libem_mesO.$(LIBSUF) \
$(LIBDIR)/libCEopt.$(LIBSUF) \
$(TARGET_HOME)/lib.bin/$(MACH)/ce.$(LIBSUF) \
$(TARGET_HOME)/lib.bin/$(MACH)/back.$(LIBSUF) \
$(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) \
$(LIBDIR)/libobject.$(LIBSUF)
MODLIB = $(LIBDIR)/libinput.$(LIBSUF) \
$(LIBDIR)/libassert.$(LIBSUF) \
$(LIBDIR)/liballoc.$(LIBSUF) \
$(MALLOC) \
$(LIBDIR)/libflt.$(LIBSUF) \
$(LIBDIR)/libprint.$(LIBSUF) \
$(LIBDIR)/libstring.$(LIBSUF) \
$(LIBDIR)/libsystem.$(LIBSUF)
LIBS = $(EMLIB) $(MODLIB)
LINTLIBS = $(LINTLIBDIR)/$(LINTPREF)em_mes.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)emk.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)input.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)assert.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)alloc.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)flt.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)print.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)string.$(LINTSUF) \
$(LINTLIBDIR)/$(LINTPREF)system.$(LINTSUF)
PROFILE =
INCLUDES = -I. -I$(SRC_DIR) -I$(TARGET_HOME)/modules/h -I$(TARGET_HOME)/h -I$(TARGET_HOME)/modules/pkg
CFLAGS = $(PROFILE) $(INCLUDES) $(COPTIONS) -DSTATIC=static
LINTFLAGS = $(INCLUDES) $(LINTOPTIONS) -DNORCSID -DSTATIC=static
LDFLAGS = $(PROFILE) $(LDOPTIONS)
# C_SRC and OBJ should be set here.
#LISTS do not remove this line!
all: main
clean:
rm -f *.$(SUF) main
lint:
$(LINT) $(LINTFLAGS) $(C_SRC) $(LINTLIBS)
main: $(OBJ)
$(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o main
# do not remove the next line; it is used for generating dependencies
#DEPENDENCIES

156
fast/f_pc/proto.make Normal file
View file

@ -0,0 +1,156 @@
# $Header$
# make Pascal compiler
#PARAMS do not remove this line!
UTIL_BIN = \
$(UTIL_HOME)/bin
SRC_DIR = \
$(SRC_HOME)/lang/pc/comp
FSRC_DIR = \
$(SRC_HOME)/fast/f_pc
TABGEN= $(UTIL_BIN)/tabgen
LLGEN = $(UTIL_BIN)/LLgen
LLGENOPTIONS = \
-v
SRC_G = $(SRC_DIR)/program.g $(SRC_DIR)/declar.g \
$(SRC_DIR)/expression.g $(SRC_DIR)/statement.g
GEN_G = tokenfile.g
GFILES= $(GEN_G) $(SRC_G)
SRC_C = $(SRC_DIR)/LLlex.c $(SRC_DIR)/LLmessage.c $(SRC_DIR)/body.c \
$(SRC_DIR)/error.c $(SRC_DIR)/label.c $(SRC_DIR)/readwrite.c \
$(SRC_DIR)/main.c $(SRC_DIR)/tokenname.c $(SRC_DIR)/idf.c \
$(SRC_DIR)/input.c $(SRC_DIR)/type.c $(SRC_DIR)/def.c \
$(SRC_DIR)/misc.c $(SRC_DIR)/enter.c $(SRC_DIR)/progs.c \
$(SRC_DIR)/typequiv.c $(SRC_DIR)/node.c $(SRC_DIR)/cstoper.c \
$(SRC_DIR)/chk_expr.c $(SRC_DIR)/options.c $(SRC_DIR)/scope.c \
$(SRC_DIR)/desig.c $(SRC_DIR)/code.c $(SRC_DIR)/lookup.c \
$(SRC_DIR)/stab.c
GEN_C = tokenfile.c program.c declar.c expression.c statement.c \
symbol2str.c char.c Lpars.c casestat.c tmpvar.c next.c
CFILES= $(SRC_C) $(GEN_C)
SRC_H = $(SRC_DIR)/LLlex.h $(SRC_DIR)/chk_expr.h $(SRC_DIR)/class.h \
$(SRC_DIR)/const.h $(SRC_DIR)/debug.h $(SRC_DIR)/f_info.h \
$(SRC_DIR)/idf.h $(SRC_DIR)/input.h $(SRC_DIR)/main.h \
$(SRC_DIR)/misc.h $(SRC_DIR)/required.h $(SRC_DIR)/tokenname.h
GEN_H = errout.h idfsize.h numsize.h strsize.h target_sizes.h \
inputtype.h density.h nocross.h def.h debugcst.h \
type.h Lpars.h node.h dbsymtab.h scope.h desig.h
HFILES= $(GEN_H) $(SRC_H)
NEXTFILES = \
$(SRC_DIR)/def.H $(SRC_DIR)/type.H $(SRC_DIR)/node.H \
$(SRC_DIR)/scope.H $(SRC_DIR)/desig.H \
$(SRC_DIR)/tmpvar.C $(SRC_DIR)/casestat.C
all: make.main
make -f make.main main
install: all
cp main $(TARGET_HOME)/lib.bin/pc_ce
cmp: all
-cmp main $(TARGET_HOME)/lib.bin/pc_ce
opr:
make pr | opr
pr:
@pr $(FSRC_DIR)/proto.make $(FSRC_DIR)/proto.main \
$(FSRC_DIR)/Parameters
lint: make.main
make -f make.main lint
Cfiles: hfiles LLfiles $(GEN_C) $(GEN_H) Makefile
echo $(CFILES) | tr ' ' '\012' > Cfiles
echo $(HFILES) | tr ' ' '\012' >> Cfiles
resolved: Cfiles
CC="$(CC)" UTIL_HOME="$(UTIL_HOME)" do_resolve `cat Cfiles` > Cfiles.new
-if cmp -s Cfiles Cfiles.new ; then rm -f Cfiles.new ; else mv Cfiles.new Cfiles ; fi
touch resolved
# there is no file called "dependencies"; we want dependencies checked
# every time. This means that make.main is made every time. Oh well ...
# it does not take much time.
dependencies: resolved
do_deps `grep '.c$$' Cfiles`
make.main: dependencies make_macros lists $(FSRC_DIR)/proto.main
sed -e '/^#DEPENDENCIES/,$$d' -e '/^#PARAMS/r make_macros' -e '/^#LISTS/r lists' $(FSRC_DIR)/proto.main > make.main
echo '#DEPENDENCIES' >> make.main
cat *.dep >> make.main
make_macros: Makefile
echo 'SRC_DIR=$(SRC_DIR)' > make_macros
echo 'UTIL_HOME=$(UTIL_HOME)' >> make_macros
echo 'TARGET_HOME=$(TARGET_HOME)' >> make_macros
echo 'CC=$(CC)' >> make_macros
echo 'COPTIONS=$(COPTIONS) -DPEEPHOLE' >> make_macros
echo 'LDOPTIONS=$(LDOPTIONS)' >> make_macros
echo 'LINT=$(LINT)' >> make_macros
echo 'LINTOPTIONS=$(LINTOPTIONS)' >> make_macros
echo 'SUF=$(SUF)' >> make_macros
echo 'LIBSUF=$(LIBSUF)' >> make_macros
echo 'CC_AND_MKDEP=$(CC_AND_MKDEP)' >> make_macros
echo 'MACH=$(MACH)' >> make_macros
lists: Cfiles
echo "C_SRC = \\" > lists
echo $(CFILES) >> lists
echo "OBJ = \\" >> lists
echo $(CFILES) | sed -e 's#[^ ]*/##g' -e 's/\.c/.$$(SUF)/g' >> lists
clean:
-make -f make.main clean
rm -f $(GEN_C) $(GEN_G) $(GEN_H) hfiles LLfiles Cfiles LL.output
rm -f resolved *.dep lists make.main make_macros
LLfiles: $(GFILES)
$(LLGEN) $(LLGENOPTIONS) $(GFILES)
@touch LLfiles
hfiles: $(FSRC_DIR)/Parameters $(SRC_DIR)/make.hfiles
$(SRC_DIR)/make.hfiles $(FSRC_DIR)/Parameters
touch hfiles
tokenfile.g: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokfile
$(SRC_DIR)/make.tokfile <$(SRC_DIR)/tokenname.c >tokenfile.g
symbol2str.c: $(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokcase
$(SRC_DIR)/make.tokcase <$(SRC_DIR)/tokenname.c >symbol2str.c
def.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/def.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/def.H > def.h
type.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/type.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/type.H > type.h
scope.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/scope.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/scope.H > scope.h
node.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/node.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/node.H > node.h
desig.h: $(SRC_DIR)/make.allocd $(SRC_DIR)/desig.H
$(SRC_DIR)/make.allocd < $(SRC_DIR)/desig.H > desig.h
tmpvar.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/tmpvar.C
$(SRC_DIR)/make.allocd < $(SRC_DIR)/tmpvar.C > tmpvar.c
casestat.c: $(SRC_DIR)/make.allocd $(SRC_DIR)/casestat.C
$(SRC_DIR)/make.allocd < $(SRC_DIR)/casestat.C > casestat.c
next.c: $(NEXTFILES) $(SRC_DIR)/make.next
$(SRC_DIR)/make.next $(NEXTFILES) > next.c
char.c: $(SRC_DIR)/char.tab
$(TABGEN) -f$(SRC_DIR)/char.tab >char.c