[comp.unix.aix] cc -o -c

auvnele@auvc7.tamu.edu (Eric L. Nelson) (05/31/91)

I'm working on a large software program where sources are in one
directory and objects go into another. I cannot get:

 cc -c -o../dir/foo.o foo.c 

to put foo.o in ../dir. It insists on putting it in the same dir as
foo.c. 

jackv@turnkey.tcc.com (Jack F. Vogel) (05/31/91)

In article <AUVNELE.91May30171500@auvc7.tamu.edu> auvnele@auvc7.tamu.edu (Eric L. Nelson) writes:
>I'm working on a large software program where sources are in one
>directory and objects go into another. I cannot get:
>
> cc -c -o../dir/foo.o foo.c 
>
>to put foo.o in ../dir. It insists on putting it in the same dir as
>foo.c. 

The problem, I believe, is that the '-c' flag overrides the '-o' and it
naturally puts the object in the current directory. What you want to do
can be accomplished in another way, run your builds in the target compilation
directory and then specify the path to the source. Either keep the makefile
in the target directory or symlink it there. This is what we do in our
build systems all the time.

Disclaimer: I don't speak for my employer.

-- 
Jack F. Vogel			jackv@locus.com
AIX370 Technical Support	       - or -
Locus Computing Corp.		jackv@turnkey.TCC.COM

jaime@excalibur.austin.ibm.com (06/01/91)

In article <AUVNELE.91May30171500@auvc7.tamu.edu>,
auvnele@auvc7.tamu.edu (Eric L. Nelson) writes:
> Path: awdprime!auschs!romp!cs.utexas.edu!helios!auvnele
> From: auvnele@auvc7.tamu.edu (Eric L. Nelson)
> Newsgroups: comp.unix.aix
> Subject: cc -o -c
> Message-ID: <AUVNELE.91May30171500@auvc7.tamu.edu>
> Date: 30 May 91 22:15:00 GMT
> Sender: usenet@helios.TAMU.EDU
> Distribution: comp
> Organization: Computer Science, Texas A&M University
> Lines: 7
> 
> I'm working on a large software program where sources are in one
> directory and objects go into another. I cannot get:
> 
>  cc -c -o../dir/foo.o foo.c 
> 
> to put foo.o in ../dir. It insists on putting it in the same dir as
> foo.c. 

Sorry.  Won't do it.  The -o flag is passed to the linker to rename the
final linked object.  The output of the compiler is always <file>.o.
Because you specified the -c flag, all you get is foo.o.  Also, the
compiler places the object in the current directory.  Maybe you
need to try:   cc -c  ../dir/foo.c instead.

Jaime Vazquez			Voice:  512-838-4829 or t/l 678-4829
AIX Technical Support           Fax:    512-838-4851 or t/l 678-4851
IBM AWD-Austin/2830             
6000:  jaime@excalibur.austin.ibm.com          
InterNet: jaime@austin.vnet.ibm.com  or jaime%austin@vnet.ibm.com
--------------------------------------------------------------------
<Standard disclaimers apply.>
<<GIG 'EM!!  A&M-76>>

dennis@gpu.utcs.utoronto.ca (Dennis Ferguson) (06/02/91)

In article <1991May31.144929.2471@turnkey.tcc.com> jackv@turnkey.TCC.COM (Jack F. Vogel) writes:
>In article <AUVNELE.91May30171500@auvc7.tamu.edu> auvnele@auvc7.tamu.edu (Eric L. Nelson) writes:
>>I'm working on a large software program where sources are in one
>>directory and objects go into another. I cannot get:
>>
>> cc -c -o../dir/foo.o foo.c 
>>
>>to put foo.o in ../dir. It insists on putting it in the same dir as
>>foo.c. 
>
>The problem, I believe, is that the '-c' flag overrides the '-o' and it
>naturally puts the object in the current directory. What you want to do
>can be accomplished in another way, run your builds in the target compilation
>directory and then specify the path to the source. Either keep the makefile
>in the target directory or symlink it there. This is what we do in our
>build systems all the time.

The 4.3 Reno distribution implements about the nicest scheme I have
ever seen for building binaries for multiple architectures from a
single source tree (with the sources mounted readonly via NFS if
you wish).  The scheme requires that the compiler support
"cc -c -o../dir/foo.o foo.c".

To support this requires a small change to the compiler driver.
The change should be backward compatible with all existing makefiles
and scripts.  "-c -o" is unlikely to be used anywhere since it doesn't
currently do anything useful.

I would much prefer that you made the change to the compiler rather
than me having to change makefiles.

Dennis Ferguson
University of Toronto