static char *rcsid
= "$Header: liszt.c 1.6 83/07/25 12:07:31 layer Exp $";
** -[Wed May 4 18:18:10 1983 by layer]-
** liszt :: interface to the lisp compiler
** There are two reasons for having a C interface to the compiler:
** 1) Fseek doesn't work properly from lisp, and there is no
** 2) To start up a process from a 1 Mb process, like when liszt forks
** a /usr/lib/lisp/as to assemble the output of the compiler, takes
** too long. (The compiler is 100 times larger than this program.)
#include "../../franz/h/aout.h"
#include "../../franz/h/config.h"
#define LISZT "/usr/ucb/xliszt"
#define AS "/usr/lib/lisp/as"
register char *argv
[], **envp
;
register int autorun
= 0;
register int no_assem
= 0;
register int oflag
= 0, cur
;
char temp
[20], tempfile
[20], srcfile
[20], outfile
[20];
** process arguments :: check for -r and -S switches
** -F is a special flag that means just to fix the offset in the
** object file, and then quit.
/* If no args, then give the user an interactive liszt */
execle(LISZT
, "liszt", 0, envp
);
for (cur
= 1; cur
< argc
; cur
++) {
strcpy(outfile
,argv
[++cur
]);
strcpy(outfile
,argv
[++cur
]);
strcpy(srcfile
, argv
[cur
]);
sprintf(command
, "%s %s", LISZT
, args_to_string(argv
));
sprintf(tempfile
, "/tmp/Lzt%d.s", getpid());
/* If output file not given, then we deduce it... */
if (outfile
[slen
- 2] == '.')
sprintf(outfile
, "%s.o", temp
);
sprintf(command
, "%s -S%s -o %s %s",
LISZT
, flags_to_string(argc
, argv
), tempfile
, srcfile
);
if (system(command
) != 0)
sprintf(command
, "%s -o %s %s", AS
, outfile
, tempfile
);
if (system(command
) != 0)
if ((objp
= open(outfile
,2)) == -1)
if (read(objp
,&header
,sizeof header
) != sizeof (struct exec
))
/* Change the offset to the correct value */
/* seek back to beginning */
if (lseek(objp
,0,0) != 0)
/* write the new a.out header... */
if (write(objp
,&header
,sizeof header
) != sizeof(struct exec
))
for (; pp
[jj
]; ii
++, jj
++)
xstrcpy(&result
[ii
],pp
[jj
]);
ii
= ii
+ strlen(pp
[jj
]);
flags_to_string(argc
, argv
)
register int chari
, word
, skipnext
= 0, out
= 0;
for (word
= 1; word
< argc
; word
++)
for (chari
= 1; argv
[word
][chari
]; chari
++)
if (argv
[word
][chari
] == 'o')
result
[out
++] = argv
[word
][chari
];