help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The smart way to use make in a directory tree


From: Josh Bialkowski
Subject: The smart way to use make in a directory tree
Date: Fri, 16 Jul 2010 11:07:46 +0800
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100528 Thunderbird/3.0.5

I'm going to start with a little story and then describe the question that it leads me to:

I started of with one c++ project. I started a second project but wanted to reuse some of that code, so I copied the directory structure and started my second project. Now I've started a third project for which I would like to reuse some of the code from both of the previous projects. I would like to setup these projects modularly using libraries so that I can use the same backend libraries in all three projects, but when I find bugs I can fix them in the library and I dont have to fix it two or three times.

So each of the libraries is located in it's own subdirectory and has it's own makefile. Kind of like this:


src
|-- libA
|-- libB
|-- libC
|-- libD
|-- projA (depends on libA, libB, libD)
|-- projB (depends on libB, libC, libD)
|-- projC (depends on libC, libD, libD)


Now my question: I'm looking for a "smart" way to handle the make structure for the different projects, so that when I "make" a project (i.e. projA) it will remake any of the libraries it depends on (i.e. libs A, B, D) if any of their dependencies have changed. Right now I have one makefile in each subdirectory (i.e. libA/makefile libB/makefile projA/makefile). In order to build project A I have to manually cd into each of the libraries and make them (if I've changed any code in there) and then cd into the project directory and rebuild that project.

The biggest problem is that these libraries aren't stable enough to really justify keeping them separate. As I'm working on the different projects, I'm frequently making changes to the libraries as well. I'd like to treat this as a unified "code base" composed of several modules which are combined into a couple of different programs.

I have come up with a couple of different ideas but they are too involved and hacky... I have to believe there is a more "standard" way of doing this kind of thing. There's probably even a way of dealing with trees with arbitrary depth (though my example is only depth 1).

Any suggestions would be greatly appreciated.



--
Josh Bialkowski
Ph.D. Candidate
Aerospace Robotics and Embedded Systems Group
Laboratory for Information and Decision Systems
Massachusetts Institute of Technology



reply via email to

[Prev in Thread] Current Thread [Next in Thread]