home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / forum16.lzh / SOFTWARE / C / CC / fastcc.c < prev    next >
C/C++ Source or Header  |  1990-11-15  |  22KB  |  738 lines

  1. /*
  2.  * NewCC: a skeleton cc-front-end with piping
  3.  *        This software is copyright (C) 1989 by Reimer Mellin        *
  4.  *                                                                    *
  5.  *        Permission is granted to reproduce and distribute           *
  6.  *        this package by any means so long as no fee is charged      *
  7.  *        above a nominal handling fee and so long as this            *
  8.  *        notice is always included in the copies.                    *
  9.  *        Commerical use or incorporation into commercial software    *
  10.  *        is prohibited without the written permission of the         *
  11.  *        author.                                                     *
  12.  *                                                                    *
  13.  *        Other rights are reserved except as explicitly granted      *
  14.  *        by written permission of the author.                        *
  15.  *                Reimer Mellin                                       *
  16.  *                Sulenstr.8                                          *
  17.  *                D-8000 Muenchen 71 (Federal Republic of Germany)    *
  18.  *                                                                    *
  19.  *           EMAIL:                                                   *
  20.  *                ram@altger.sub.org.UUCP                             *
  21.  *                ram%ramsys@chiuur.sub.org (home)                    *
  22.  *                                                                    *
  23.  */
  24.  
  25. #include <stdio.h>
  26. #include <errno.h>
  27.  
  28. extern  int     os9exec(), os9forkc(),errno;
  29.  
  30. /*
  31.  * structure for our lists
  32.  */
  33. struct  optlist {
  34.     short   numel;      /* number of elements in list */
  35.     char    **list;
  36. } cppopt,ccopt,optopt,asopt,lnopt,ccdo,asdo;
  37.  
  38. char    *rdir;          /* Rels-dir */
  39. char    *tmpdir;        /* temp-dir */
  40. short   compiler, assembler, linker;    /* what to do */
  41. short   quietflag, showflag, pipeflag, noopt, sig_rec;
  42.  
  43. static  char    *emptylist[] = {
  44.     0
  45. };
  46.  
  47. /*
  48.  * Default arg-vector for cpp
  49.  */
  50. static  char    *cpplist[] = {
  51.     "cpp", 0
  52. };
  53.  
  54. /*
  55.  * Default arg-vector for compiler
  56.  */
  57. static  char    *cclist[] = {
  58.     "c68", 0
  59. };
  60.  
  61. /*
  62.  * Default arg-vector for so-called 'optimizer'
  63.  */
  64. static  char    *optlist[] = {
  65.     "o68", 0
  66. };
  67.  
  68. /*
  69.  * Default arg-vector for assembler
  70.  */
  71. static  char    *asslist[] = {
  72.     "r68", "-q", 0
  73. };
  74.  
  75. /*
  76.  * Default arg-vector for linker, see iflag,xflag and jflag in main()
  77.  */
  78. static  char    *lnlist[] = {
  79.     "l68", 0
  80. };
  81.  
  82. void
  83. mputs( str )
  84. char    *str;
  85. {
  86.     fprintf(stderr,str);
  87. }
  88.  
  89. void
  90. usagehelp()
  91. {
  92.     fprintf(stderr,"%s: <opts> <files> <opts>\n", _prgname());
  93.     mputs("Options:\n");
  94.     mputs("\t-a\t\tCompile to assembler files\n");
  95.     mputs("\t-bp\t\tshow commands before executing\n");
  96.     mputs("\t-bg\t\tcreate ghost module on output\n");
  97.     mputs("\t-c\t\tleave comments in assember-files\n");
  98.     mputs("\t-d<name>\tdefine for cpp\n");
  99.     mputs("\t-e<=num>\tedition number for output\n");
  100.     mputs("\t-u<name>\tundefine for cpp\n");
  101.     mputs("\t-f<=path>\toutput path (exec-dir)\n");
  102.     mputs("\t-fd<=path>\toutpath (data-dir)\n");
  103.     mputs("\t-g\t\tgenerate debugging info\n");
  104.     mputs("\t-i\t\tuse clib-trap-library\n");
  105.     mputs("\t-j\t\tdont generate a jump-table\n");
  106.     mputs("\t-l<=name>\tadditional library to search\n");
  107.     mputs("\t-n<=name>\toutput module name\n");
  108.     mputs("\t-r<=dir>\tcompile/assemble to rel. files\n");
  109.     mputs("\t-o\t\tdon't run o68\n");
  110.     mputs("\t-p\t\tpipe cpp-output into the compiler\n");
  111.     mputs("\t-q\t\tquiet mode\n");
  112.     mputs("\t-s\t\tomit stack-checking\n");
  113.     mputs("\t-t<=dir>\tdir for temp. files\n");
  114.     mputs("\t-x\t\tuse math-trap-lib\n");
  115.     mputs("\t-v<=dir>\tsearch-dir for cpp\n");
  116.     mputs("\t-m<=n>\t\tadditional memory for stack in output module\n");
  117.     exit(1);
  118. }
  119.  
  120. void *
  121. Malloc( size )
  122. register    int size;
  123. {
  124.     register void *sp = (void *)malloc(size);
  125.     if( sp == (void *)0)
  126.         exit(errno);
  127.     memset(sp,0,size);
  128.     return sp;
  129. }
  130.  
  131. void *
  132. Realloc( ptr, size)
  133. register    void *ptr;
  134. register    int  size;
  135. {
  136.     ptr = (void *)realloc( ptr,size);
  137.     if( ptr == (void *)0)
  138.         exit(errno);
  139.     return ptr;
  140. }
  141.  
  142. /*
  143.  * Set-up a list
  144.  */
  145. initlist( where, list )
  146. struct  optlist *where;
  147. char    *list[];
  148. {
  149.     register    int     i;
  150.     register    char    **sp,**ssp;
  151.     for(i=0,sp=list; *sp; sp++,i++);
  152.     where->list = (char **) Malloc( sizeof(char **) * (i + 1));
  153.     ssp = where->list; sp = list;
  154.     while(*ssp++ = *sp++);
  155.     where->numel = i;
  156. }
  157.     
  158. /*
  159.  * append a string to a list
  160.  */
  161. appendlist( where, item)
  162. register    struct  optlist *where;
  163. register    char    *item;
  164. {
  165.     where->list = (char **) Realloc( where->list,
  166.         sizeof(char **) * (where->numel+2));
  167.     where->list[where->numel] = (char *)strcpy(Malloc(strlen(item)+1), item);
  168.     where->numel += 1;
  169.     where->list[where->numel]= (char *)0;
  170. }
  171.  
  172. /*
  173.  * make room in a list for two new args (needed for the filenames)
  174.  */
  175. preplist( where )
  176. register    struct  optlist *where;
  177. {
  178.     where->list = (char **) Realloc( where->list,
  179.         sizeof(char **) * (where->numel+3));
  180.     where->list[where->numel+2] = (char *)0;
  181. }
  182.     
  183. /*
  184.  * return the char after the rightmost '.' or '?'
  185.  */
  186. char
  187. filetype( name )
  188. char    *name;
  189. {
  190.     char    *rindex();
  191.     if((name = rindex(name,'.')) == (char *)0)
  192.         return '?';
  193.     return( (name[2] != '\0') ? '?' : name[1]);
  194. }
  195.  
  196. int
  197. sighand( sig)
  198. int sig;
  199. {
  200.     sig_rec=sig;
  201. }
  202.  
  203. main(argc,argv)
  204. int     argc;
  205. char    *argv[];
  206. {
  207.                 void    compile(),assemble();
  208.                 int     dofork();
  209.                 char    *getenv();
  210.     register    int     i;
  211.     register    char    *sp;
  212.                 char    tmp[100];
  213.                 char    *libs;
  214.                 char    *incs;
  215.                 int     iflag;  /* what c-lib to use */
  216.                 int     jflag;  /* generating a jumptable ? */
  217.                 int     xflag;  /* what math-lib to use */
  218.                 short   files;
  219.  
  220. /*
  221.  * Init the flags
  222.  */
  223.     tmpdir = rdir = ".";
  224.     jflag = iflag = xflag = compiler = assembler = linker = 1;
  225.     files = noopt = quietflag = showflag = pipeflag = sig_rec = 0;
  226. /*
  227.  * install a signal-handler
  228.  */
  229.     intercept(sighand);
  230. /*
  231.  * setup the lists, with the default values
  232.  */
  233.     initlist( &cppopt, cpplist);
  234.     initlist( &ccopt,  cclist);
  235.     initlist( &optopt, optlist);
  236.     initlist( &asopt,  asslist);
  237.     initlist( &lnopt,  lnlist);
  238.     initlist( &ccdo,   emptylist);
  239.     initlist( &asdo,   emptylist);
  240.  
  241. /*
  242.  * get the default dirs for <>-files and libs
  243.  */
  244.     if( (libs = getenv("CLIB")) == (char *)0)
  245.         libs = "/h0/lib";
  246.     if( (incs = getenv("CDEF")) == (char *)0)
  247.         incs = "/h0/defs";
  248. /*
  249.  * add cstart file to linker-args ...
  250.  */
  251.     sprintf(tmp,"%s/cstart.r", libs);
  252.     appendlist( &lnopt, tmp);
  253. /*
  254.  * add CDEF dir to cpp-args
  255.  */
  256.     sprintf(tmp,"-v=%s", incs);
  257.     appendlist( &cppopt, tmp);
  258.  
  259.     for( i=1; i < argc; i++) {
  260.         sp = argv[i];
  261.         switch ( *sp ) {
  262.             short contflag;
  263. /*
  264.  * various cases in the next switch statement set contflag to 0, indicating
  265.  * a completed arg ( eg: -t=<string> )
  266.  */
  267.             case '-':
  268.                 contflag = 1;
  269.                 for( sp++; *sp && contflag; sp++) {
  270.                     switch( *sp) {
  271.                         case '?':
  272.                             usagehelp();
  273.                         /* exits */
  274.  
  275.                         case 'Q':
  276.                         case 'q':
  277.                             quietflag = 1;
  278.                             break;
  279.  
  280.                         case 'a':
  281.                         case 'A':
  282.                         /* neither run assembler nor linker */
  283.                             assembler = 0;
  284.                             linker    = 0;
  285.                             break;
  286.  
  287.                         case 'g':
  288.                         case 'G':
  289.                             appendlist( &lnopt,  "-g");
  290.                             appendlist( &ccopt,  "-g");
  291.                             appendlist( &cppopt, "-g");
  292.                         /* fall though */
  293.                         case 'o':
  294.                         case 'O':
  295.                             noopt = 1;
  296.                             break;
  297.  
  298.                         case 'c':
  299.                         case 'C':
  300.                             appendlist( &cppopt, "-l");
  301.                             noopt     = 1;
  302.                             break;
  303.  
  304.                         case 'r':
  305.                         case 'R':
  306.                             if( sp[1] ) {
  307.                                 sp += (sp[1] == '=') ? 2:1;
  308.                                 rdir = sp;
  309.                             }
  310.                             contflag = 0;
  311.                         /* linker == 2, if 'cc -r=tmp -f=name...' */
  312.                             if( linker < 2 )
  313.                                 linker = 0;
  314.                             break;
  315.  
  316.                         case 'f':
  317.                         case 'F':
  318.                             if( tolower( sp[1] ) == 'd') {
  319.                                 sp++;
  320.                                 (void)strcpy(tmp,"-O=");
  321.                             } else
  322.                                 (void)strcpy(tmp,"-o=");
  323.                             sp += (sp[1] == '=') ? 2:1;
  324.                             strcat(tmp,sp);
  325.                             appendlist( &lnopt, tmp);
  326.                             contflag = 0;
  327.                             linker = 2;
  328.                             break;
  329.  
  330.                         case 'b':
  331.                         case 'B':
  332.                             switch( tolower(sp[1])) {
  333.                                 case 'p':
  334.                                     showflag = 1;
  335.                                     break;
  336.                                 case 'g':
  337.                                     appendlist( &lnopt,"-S");
  338.                                     break;
  339.                                 default:
  340.                                     usagehelp();
  341.                             }
  342.                             sp +=1;
  343.                             break;
  344.  
  345.                         case 's':
  346.                         case 'S':
  347.                             appendlist( &ccopt, "-s");
  348.                             break;
  349.  
  350.                         case 't':
  351.                         case 'T':
  352.                             sp += (sp[1] == '=' ) ? 2:1;
  353.                             tmpdir = sp;
  354.                             contflag = 0;
  355.                             break;
  356.  
  357.                         case 'd':
  358.                         case 'u':
  359.                         case 'D':
  360.                         case 'U':
  361.                         case 'v':
  362.                         case 'V':
  363.                             sprintf(tmp,"-%s",sp);
  364.                             contflag = 0;
  365.                             appendlist( &cppopt, tmp);
  366.                             break;
  367.  
  368.                         case 'j':
  369.                         case 'J':
  370.                             jflag = 0;
  371.                             break;
  372.  
  373.                         case 'I':
  374.                         case 'i':
  375.                             iflag = 0;
  376.                             sprintf(tmp,"-l=%s/cio.l", libs);
  377.                             appendlist( &lnopt, tmp);
  378.                             break;
  379.  
  380.                         case 'x':
  381.                         case 'X':
  382.                             xflag = 0;
  383.                             sprintf(tmp,"-l=%s/clib.l", libs);
  384.                             appendlist( &lnopt, tmp);
  385.                             break;
  386.  
  387.                         case 'p':
  388.                         case 'P':
  389.                             pipeflag = 1;
  390.                             break;
  391.  
  392.                         case 'e':
  393.                         case 'E':
  394.                         case 'l':
  395.                         case 'L':
  396.                         case 'N':
  397.                         case 'n':
  398.                         case 'm':
  399.                         case 'M':
  400.                             sprintf(tmp,"-%s",sp);
  401.                             contflag = 0;
  402.                             appendlist( &lnopt, tmp);
  403.                             break;
  404.  
  405.                         default:
  406.                             usagehelp();
  407.                         /* exits */
  408.                     }
  409.                 }
  410.                 break;
  411.  
  412.             default:
  413.                 switch( filetype(sp) ) {
  414.                     case 'a':
  415.                     case 'o':
  416.                         appendlist( &asdo, sp);
  417.                         break;
  418.                     case 'c':
  419.                         appendlist( &ccdo, sp);
  420.                         break;
  421.                     default:
  422.                         fprintf(stderr,"can't handle file: %s, giving to linker\n",sp);
  423.                     case 'r':
  424.                         appendlist( &lnopt, sp);
  425.                         break;
  426.                         
  427.                 }
  428.                 files++;
  429.                 break;
  430.     }
  431.     }
  432.             
  433.     if( xflag)
  434.         appendlist( &ccopt, "-t");
  435.  
  436.     if( linker > 0) {
  437.         if( jflag )
  438.             appendlist( &lnopt, "-a");
  439.         if( xflag) {
  440.             appendlist( &ccopt, "-t");
  441.             sprintf(tmp,"-l=%s/clibn.l", libs);
  442.             appendlist( &lnopt, tmp);
  443.             sprintf(tmp,"-l=%s/math.l", libs);
  444.             appendlist( &lnopt, tmp);
  445.         }
  446.         sprintf(tmp,"-l=%s/sys.l", libs);
  447.         appendlist( &lnopt, tmp);
  448.     }
  449.     if( files > 0 ) {
  450.     /*
  451.      * make room for filenames in the lists
  452.      */
  453.         preplist( &cppopt);
  454.         preplist( &ccopt);
  455.         preplist( &optopt);
  456.         preplist( &asopt);
  457.         if( compiler > 0)
  458.             compile( &ccdo);  /* assembles also and adds to lnopt-list */
  459.         if( assembler > 0 )
  460.             assemble( &asdo); /* adds to lnopt-list */
  461.         if( linker > 0 )
  462.             exit(dofork( lnopt.list,0 ));   /* link */
  463.     } else mputs("No Files !!!!!!!!\n");
  464. }
  465.  
  466. /*
  467.  * execute arg and if flag == 1, return with pid else
  468.  * wait until finished.
  469.  * if we receive a signal, send the signal to the running child too
  470.  * return exit-status of child
  471.  */
  472. int
  473. dofork( arg, flag )
  474. char    **arg;
  475. int     flag;
  476. {
  477.     extern  char    **environ;
  478.     int     pid,status,i;
  479.  
  480.     if( quietflag == 0) {
  481.         register    char    **sp;
  482.     /*
  483.      * show the arg-vector or the name of the executed programm
  484.      */
  485.         if ( showflag ) {
  486.             for( sp= arg; *sp; sp++)
  487.                 fprintf(stderr,"'%s' ", *sp);
  488.             fprintf(stderr,flag ? "|\n" : "\n");
  489.         } else
  490.             fprintf(stderr,"%s:\n", arg[0]);
  491.     }
  492.     if( (pid = os9exec(os9forkc, arg[0],arg,environ,0,0,3)) < 0 || flag)
  493.         return(pid);
  494.     while( pid != (i = wait(&status)))
  495.         if( i == 0)
  496.             kill(pid,sig_rec);
  497.     return(status);
  498. }
  499.  
  500. /*
  501.  * compile a list of files to assembler or rel-files
  502.  */
  503. void
  504. compile( filelist )
  505. register    struct  optlist *filelist;
  506. {
  507.     char    **sp;
  508.     int     i,j;
  509.     char    newname[32];
  510.     char    buffer[512];
  511.     char    buffer2[512];
  512.  
  513.     for(sp = filelist->list; *sp; sp++) {
  514.         register char   *cp = rindex( *sp, '/');
  515.         if( cp != (char *)0)
  516.             cp++;
  517.         else
  518.             cp = *sp;
  519.         if( quietflag == 0)
  520.             fprintf(stderr,"\n'%s'\n", *sp);
  521.         (void) strcpy( newname, cp);
  522.         newname[ strlen(newname) -1] = 'a';
  523.  
  524.         if( pipeflag ) {
  525.             int fd[5];
  526.             int pid[3];
  527.  
  528.         /*
  529.          * save fd's of stdin/stdout and open a unnamend pipe
  530.          */
  531.             fd[0] = dup(0);
  532.             fd[1] = dup(1);
  533.             if( (fd[2] = open("/pipe",3)) < 0)
  534.                 exit(errno);
  535.         /*
  536.          * prepare cpp-arg-vector, because we are giving only a input-file-
  537.          * name the output of the cpp is going to stdout
  538.          */
  539.             cppopt.list[cppopt.numel]   = *sp;
  540.             cppopt.list[cppopt.numel+1] = (char *)0;
  541.         /*
  542.          * make the /pipe the stdout of the child and fork
  543.          */
  544.             close(1);
  545.             dup(fd[2]);
  546.             if( (pid[0] = dofork( cppopt.list, 1)) < 0)
  547.                 exit(errno);
  548.         /*
  549.          * restore out old stdout
  550.          */
  551.             close(1);
  552.             dup( fd[1] );
  553.         /*
  554.          * setup the /pipe as stdin and prepare the output-path of
  555.          * the compiler (temp-file iff we are going to assemble)
  556.          */
  557.             close(0);
  558.             dup( fd[2] );
  559.             if( assembler == 0 ) {
  560.                 if( noopt == 0)
  561.                     newname[ strlen(newname) -1] = 'o';
  562.                 sprintf(buffer2,"-o=%s", newname);
  563.         } else
  564.                 sprintf(buffer2,"-o=%s/nctmp%d.a", tmpdir, getpid());
  565.         /*
  566.          * by giving only one name to the compiler the input for the
  567.          * compiler is stdin
  568.          */
  569.             if( noopt == 0) {
  570.                 if( (fd[3] = open("/pipe",3)) < 0)
  571.                     exit(errno);
  572.                 if( (fd[4] = creat( buffer2+3, 3)) < 0)
  573.                     exit(errno);
  574.                 ccopt.list[ccopt.numel] = (char *)0;
  575.                 close(1);
  576.                 dup( fd[3] );
  577.         } else
  578.                 ccopt.list[ccopt.numel] = buffer2;
  579.             ccopt.list[ccopt.numel+1] = (char *)0;
  580.             if( (pid[1] = dofork( ccopt.list,1)) < 0)
  581.                 exit(errno);
  582.         /*
  583.          * restore out old stdin - also closing the /pipe
  584.          */
  585.             if( noopt == 0) {
  586.                 close(1);
  587.                 dup( fd[1] );
  588.             }
  589.             close(0);
  590.             dup(fd[0]);
  591.             close(fd[2]);
  592.             if( noopt == 0) {
  593.                 close(0);
  594.                 dup( fd[3] );
  595.                 close(1);
  596.                 dup( fd[4] );
  597.                 if( (pid[1] = dofork( optopt.list,1)) < 0)
  598.                     exit(errno);
  599.                 close(0);
  600.                 dup(fd[0]);
  601.                 close(1);
  602.                 dup(fd[1]);
  603.                 close( fd[3]);
  604.                 close( fd[4]);
  605.             }
  606.         /*
  607.          * wait for signal or last process
  608.          */
  609.             do {
  610.                 i = wait(&pid[2]);
  611.                 if( i == 0) {
  612.                     kill(pid[0],sig_rec);
  613.                     kill(pid[1],sig_rec);
  614.                     unlink( buffer2+3);
  615.                     exit(errno);
  616.                 }
  617.             } while( i != pid[1]);
  618.             close(fd[0]);
  619.             close(fd[1]);
  620.         } else {
  621.         /*
  622.          * 'normal' compilation: put cpp-output to tempdir, fork
  623.          * and wait for completion
  624.          */
  625.             sprintf(buffer,"-o=%s/nctmp%d.p", tmpdir, getpid());
  626.             cppopt.list[cppopt.numel]   = *sp;
  627.             cppopt.list[cppopt.numel+1] = buffer;
  628.             if( (i=dofork(cppopt.list,0)) != 0) {
  629.                 unlink( buffer+3 );
  630.                 exit(i);
  631.             }
  632.         /*
  633.          * prepare input and output filenames for the compiler
  634.          * (temp-file iff we are going to assemble)
  635.          */
  636.             ccopt.list[ccopt.numel] = buffer+3;
  637.             if( noopt && assembler == 0 )
  638.                 sprintf(buffer2,"-o=%s", newname);
  639.             else {
  640.                 sprintf(buffer2,"-o=%s/nctmp%d.a", tmpdir, getpid());
  641.             }
  642.             ccopt.list[ccopt.numel+1] = buffer2;
  643.             j=dofork(ccopt.list,0);
  644.         /*
  645.          * delete cpp-output and iff compiler failed, also the compiler
  646.          * output
  647.          */
  648.             unlink(buffer+3);
  649.             if( j != 0) {
  650.                 unlink(buffer2+3);
  651.                 exit(j);
  652.             }
  653.             if( noopt == 0 ) {
  654.                 newname[ strlen(newname) -1] = 'o';
  655.                 strcpy( buffer, buffer2+3);
  656.                 optopt.list[optopt.numel] = buffer;
  657.                 if( assembler == 0)
  658.                     sprintf(buffer2,"-o=%s", newname);
  659.                 else
  660.                     sprintf(buffer2,"-o=%s/nctmp%d.o", tmpdir, getpid());
  661.                 optopt.list[optopt.numel+1] = buffer2+3;
  662.                 j=dofork(optopt.list,0);
  663.         /*
  664.          * delete c68-output and iff o68 failed, also the output
  665.          */
  666.                 unlink(buffer);
  667.                 if( j != 0) {
  668.                     unlink(buffer2+3);
  669.                     exit(j);
  670.                 }
  671.             }
  672.         }
  673.         if( assembler > 0 ) {
  674.         /*
  675.          * assemble the output of the compiler/o68 (name in buffer2)
  676.          */
  677.             newname[ strlen(newname) -1] = 'r';
  678.             sprintf(buffer,"-O=%s/%s",rdir, newname);
  679.             asopt.list[asopt.numel]  = buffer2+3;
  680.             asopt.list[asopt.numel+1]= buffer;
  681.             i = dofork( asopt.list,0);
  682.             unlink( buffer2+3);
  683.             if( i != 0) {
  684.                 unlink( buffer+3);
  685.                 exit(i);
  686.             }
  687.         /*
  688.          * iff we are going link later, append output of assembler to
  689.          * linker-arg-vector
  690.          */
  691.             if( linker > 0)
  692.                 appendlist( &lnopt, buffer+3);
  693.     }
  694.     }
  695. }
  696.  
  697. void
  698. assemble( filelist )
  699. register    struct  optlist *filelist;
  700. {
  701.     char    *rindex();
  702.     int     i;
  703.     char    **cp;
  704.     char    newname[32];
  705.     char    buffer[512];
  706.  
  707. /*
  708.  * The filelist contains only *.s files given as arguments to Newcc
  709.  */
  710.     for(cp = filelist->list; *cp; cp++) {
  711.         register char   *sp = rindex( *cp, '/');
  712.         if( sp != (char *)0)
  713.             sp++;
  714.         else
  715.             sp = *cp;
  716.         if( quietflag == 0)
  717.             fprintf(stderr,"\n'%s'\n", *cp);
  718.         (void) strcpy( newname, sp);
  719.         newname[ strlen(newname)-1] = 'r';
  720.         sprintf(buffer,"-O=%s/%s", rdir, newname);
  721.         asopt.list[asopt.numel]  = *cp;
  722.         asopt.list[asopt.numel+1]= buffer;
  723.         i = dofork( asopt.list,0);
  724.         unlink( *cp);
  725.         if( i != 0) {
  726.             unlink( buffer+3);
  727.             exit(i);
  728.         }
  729.     /*
  730.      * iff we are going link later, append output of assembler to
  731.      * linker-arg-vector
  732.      */
  733.         if( linker > 0)
  734.             appendlist( &lnopt, buffer+3);
  735.     }
  736. }
  737.  
  738.