Computing.Net > Forums > Programming > Makefile Dependencies

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Makefile Dependencies

Reply to Message Icon

Name: JKelm
Date: August 28, 2006 at 19:03:15 Pacific
OS: winXP at the moment
CPU/Ram: P4
Comment:

I have a fairly large program that is comprised of about 15 object files so far. I have a main Makefile that calls the other sub-makefiles to create the individual objects. I want all of the output files to be put into a single specified folder. Currently I have all of this working except every time I run my Makefile, everything gets remade because there is no object file in the the original folder. I'm not exactly sure how to get the dependency to look in the right place.

Here is an example of part of one of the object Makefiles.

ClientListener.o: ClientListener.cpp \
ClientListener.h

g++ $(OPT) ClientListener.cpp -o \
$(OBJECT_DIR)/ClientListener.o

I want the Makefile to check $(OBJECT_DIR) to see if the object file exists instead of the current directory. Any help is greatly appreciated.

Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: August 29, 2006 at 16:36:43 Pacific
Reply:

In your sub-Makefile, you might consider making your object and then copying it to $(OBJECT_DIR) if it is out of date.

The only problem is now you have two copies of the object.


0

Response Number 2
Name: JKelm
Date: August 29, 2006 at 20:00:25 Pacific
Reply:

I thought about doing it the way you suggested, but the problem is, if I make the $(OBJECT_DIR)=/objects, then decide I to change versions of certain objects but want to remake all of the object files in a different folder, say $(OBJECT_DIR)=/objects_v2. Now the only objects that get remade are the ones that were changed to a new version instead of all of the objects that aren't in the $(OBJECT_DIR). Thanks for the thought though.


0

Response Number 3
Name: Wolfbone
Date: August 29, 2006 at 20:46:04 Pacific
Reply:

Since your target doesn't refer to the file that is actually built, that is bound to happen. You should find using vpath %.o $(OBJECT_DIR) or similar will stop the spurious remakes but it is bad form.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Makefile Dependencies

Problem with Makefiles www.computing.net/answers/programming/problem-with-makefiles/13155.html

Creating simple makefile in linux www.computing.net/answers/programming/creating-simple-makefile-in-linux/15088.html

error message help www.computing.net/answers/programming/error-message-help/8633.html