Fix for cc so that -o works with -c and -S
Kent Peacock
kent at oblio.UUCP
Fri Nov 30 03:58:38 AEST 1984
[]
Index: bin/cc.c 4.2BSD
Description:
The -o option on cc works only when creating a final load module.
It would be advantageous to be able to use it when the -c option
is specified, so that one could write:
cc -c directory/cfile.c -o directory/cfile.o
This is particularly useful in makefiles, for the rule:
.c.o:
cc -c $*.c -o $@
since source in subdirectories can be handled properly.
It also allows use of different suffixes (.b for example)
when object code for multiple machines is produced in a
single directory. Similary benefits accrue from allowing it
with -S also. Note that the change is also backwards compatible,
except that it is now possible to overwrite .o files when
-c or -S is not specified.
Repeat-By:
cc -c file.c -o file.o
Fix:
*** occ.c Thu Nov 29 09:17:10 1984
--- ncc.c Thu Nov 29 09:18:03 1984
***************
*** 57,63
switch (getsuf(outfile)) {
case 'c':
- case 'o':
error("-o would overwrite %s",
outfile);
exit(8);
--- 57,62 -----
switch (getsuf(outfile)) {
case 'c':
error("-o would overwrite %s",
outfile);
exit(8);
***************
*** 197,204
cflag++;
continue;
}
! if (sflag)
! assource = tmp3 = setsuf(clist[i], 's');
av[0] = "ccom"; av[1] = tmp4; av[2] = oflag?tmp5:tmp3; na = 3;
if (proflag)
av[na++] = "-XP";
--- 196,208 -----
cflag++;
continue;
}
! if (sflag) {
! if (nc==1 && outfile)
! tmp3 = outfile;
! else
! tmp3 = setsuf(clist[i], 's');
! assource = tmp3;
! }
av[0] = "ccom"; av[1] = tmp4; av[2] = oflag?tmp5:tmp3; na = 3;
if (proflag)
av[na++] = "-XP";
***************
*** 228,234
assemble:
cunlink(tmp1); cunlink(tmp2); cunlink(tmp4);
av[0] = "as"; av[1] = "-o";
! av[2] = setsuf(clist[i], 'o');
na = 3;
if (Rflag)
av[na++] = "-R";
--- 232,241 -----
assemble:
cunlink(tmp1); cunlink(tmp2); cunlink(tmp4);
av[0] = "as"; av[1] = "-o";
! if (cflag && nc==1 && outfile) {
! av[2] = outfile;
! } else
! av[2] = setsuf(clist[i], 'o');
na = 3;
if (Rflag)
av[na++] = "-R";
More information about the Comp.sources.unix
mailing list