diff options
Diffstat (limited to 'src/cmd/6a/lex.c')
-rw-r--r-- | src/cmd/6a/lex.c | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/src/cmd/6a/lex.c b/src/cmd/6a/lex.c index b4c7d0c2c..37144c888 100644 --- a/src/cmd/6a/lex.c +++ b/src/cmd/6a/lex.c @@ -56,7 +56,7 @@ void main(int argc, char *argv[]) { char *p; - int c; + int nout, nproc, i, c; thechar = '6'; thestring = "amd64"; @@ -96,10 +96,46 @@ main(int argc, char *argv[]) print("usage: %ca [-options] file.s\n", thechar); errorexit(); } - if(argc > 1){ - print("can't assemble multiple files\n"); + if(argc > 1 && systemtype(Windows)){ + print("can't assemble multiple files on windows\n"); errorexit(); } + if(argc > 1 && !systemtype(Windows)) { + nproc = 1; + if(p = getenv("NPROC")) + nproc = atol(p); /* */ + c = 0; + nout = 0; + for(;;) { + Waitmsg *w; + + while(nout < nproc && argc > 0) { + i = fork(); + if(i < 0) { + fprint(2, "fork: %r\n"); + errorexit(); + } + if(i == 0) { + print("%s:\n", *argv); + if(assemble(*argv)) + errorexit(); + exits(0); + } + nout++; + argc--; + argv++; + } + w = wait(); + if(w == nil) { + if(c) + errorexit(); + exits(0); + } + if(w->msg[0]) + c++; + nout--; + } + } if(assemble(argv[0])) errorexit(); exits(0); @@ -108,7 +144,7 @@ main(int argc, char *argv[]) int assemble(char *file) { - char *ofile, *p; + char *ofile, incfile[20], *p; int i, of; ofile = alloc(strlen(file)+3); // +3 for .x\0 (x=thechar) @@ -133,6 +169,15 @@ assemble(char *file) } else outfile = "/dev/null"; } + p = getenv("INCLUDE"); + if(p) { + setinclude(p); + } else { + if(systemtype(Plan9)) { + sprint(incfile,"/%s/include", thestring); + setinclude(strdup(incfile)); + } + } of = create(outfile, OWRITE, 0664); if(of < 0) { |