[make] how to separate src from obj tree?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > [make] how to separate src from obj tree?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    [make] how to separate src from obj tree?  
Markus Dehmann


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-04-04 10:52 PM

How can I separate the src/ from the obj/ tree, using make? It looks
chaotic when my src folder is full of .o files.

The tricky thing is I have src files with the same name, just in
different subdirectories:
src/main.cpp
src/bmw/car.cpp
src/mercedes/car.cpp

Now, (GNU) make should place the obj files into obj, preserving the
directory structure:
obj/main.o
obj/bmw/car.o
obj/mercedes/car.o

This should be the most natural thing in the world for make to do. But
it seems it's tricky...?

Markus

Here is my stupid Makefile that just puts the o files next to the src
files:

SRC=src
OBJ=obj
FILES=main bmw/car mercedes/car
OFILES=$(FILES:%=$(SRC)/%.o)
TARGET=cars

all: $(TARGET)

$(TARGET): $(OFILES)
g++ $(OFILES) -o $@

%.o: %.cpp
g++ -I$(SRC) -c -o $@ $<





[ Post a follow-up to this message ]



    Re: [make] how to separate src from obj tree?  
Pascal Bourguignon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-05-04 07:49 AM


markus.cl@gmx.de (Markus Dehmann) writes:
> How can I separate the src/ from the obj/ tree, using make? It looks
> chaotic when my src folder is full of .o files.
> [...]
> %.o: %.cpp
> 	g++ -I$(SRC) -c -o $@ $<

Either use VPATH (but then you have to put the Makefile or a symlink
in the object directories), or specify the absolute paths:

$(OBJDIR)$(REL).o : $(SRCDIR)$(REL).c
g++ -I$(SRC) -c -o $@ $<


You could get good ideas from:

http://www.canb.auug.org.au/~miller...-cons-harm.html

--
__Pascal Bourguignon__                     http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein





[ Post a follow-up to this message ]



    Re: [make] how to separate src from obj tree?  
Ian Zimmerman


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-05-04 07:49 AM


Pascal> You could get good ideas from:
Pascal> http://www.canb.auug.org.au/~miller...-cons-harm.html

This is also very worthy of reading:

http://make.paulandlesley.org/

--
"It's not true or not."  A reality show producer (real quote)





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:48 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register