Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site oblio.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!hao!hplabs!oblio!kent From: kent@oblio.UUCP (Kent Peacock) Newsgroups: net.sources Subject: Fix for cc so that -o works with -c and -S Message-ID: <118@oblio.UUCP> Date: Thu, 29-Nov-84 12:58:38 EST Article-I.D.: oblio.118 Posted: Thu Nov 29 12:58:38 1984 Date-Received: Sat, 1-Dec-84 19:13:56 EST Organization: Counterpoint Computers Lines: 86 [] 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";