(yet another) Recursive make question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

(yet another) Recursive make question

Darin Johnson
I'm building recursive makefiles for an existing project, and would like some
advice on some aspects I haven't seen mentioned much.

I'd like to use relative pathnames for include directoreis, so that the command
lines stay a manageable size (there may be over 100 include directories, at
least until I start figuring out which ones can be trimmed).  Is there a nice way
to either convert absolute paths to relative paths, or generate relative paths
on the fly when calling a sub-make?

Second, I'd like people to be able to type "make" from within a subdirectory
rather than having to be at the top level (which may be a few levels up).
Currently I've got a "build.mk" in each leaf directory and the "Makefile"s
are created by copying a template and updating the "TOP=..." line.  It seems
to work, but it's just a bit ugly (at least it's automatic so that "make makefiles"
isn't needed).  Does anyone have a better method?

Darin Johnson


_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: (yet another) Recursive make question

Johan Bezem
Hi,

Your last question first:
myself, I'm using a directory structure where the top-level directory is defined by being the only directory in the development tree having a subdirectory called 'make' containing a file called 'main.mk', the master template makefile.
If the Variable YT_ROOTDIR is not defined (by the environment or within make), a small shell script is run to determine this directory starting at the current directory, and stripping one level at a time. This directory name is then assigned to YT_ROOTDIR and exported, so that all subsequent recursive makes do not need to scan again.

Now your first question: Having this YT_ROOTDIR variable available, converting to relative paths is just replacing the part of all absolute paths matching YT_ROOTDIR with '.' if you're starting there.
My mechanism restarts make once anyway: stepping from the source directory into the (matching) tree where the intermediates are to be built, and there starts at the (object-) 'root', skipping all subdirectories the user is not interested in. See Paul's tips at his website. Building relative paths when recursing through the tree that way is almost trivial.

If anyone is interested in more detail, let me know [responses to the list, please]

Regards,

Johan Bezem

Darin Johnson wrote:

> ...
> I'd like to use relative pathnames for include directoreis, so that the command
> lines stay a manageable size (there may be over 100 include directories, at
> least until I start figuring out which ones can be trimmed).  Is there a nice way
> to either convert absolute paths to relative paths, or generate relative paths
> on the fly when calling a sub-make?
>
> Second, I'd like people to be able to type "make" from within a subdirectory
> rather than having to be at the top level (which may be a few levels up).
> Currently I've got a "build.mk" in each leaf directory and the "Makefile"s
> are created by copying a template and updating the "TOP=..." line.  It seems
> to work, but it's just a bit ugly (at least it's automatic so that "make makefiles"
> isn't needed).  Does anyone have a better method?
> ...
--
JB Enterprises - Johan Bezem         Tel:   +49 172 5463210
Software Architect - Project Manager Fax:   +49 172 50 5463210
Realtime / Embedded Consultant       Email: [hidden email]
Design - Development - Test - QA     Web:   http://www.bezem.de




_______________________________________________
Help-make mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-make