Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > How to arrange many files of C source code

Reply
Thread Tools

How to arrange many files of C source code

 
 
Jorgen Grahn
Guest
Posts: n/a
 
      03-13-2013
On Mon, 2013-03-04, James Harris wrote:
> On Mar 4, 4:55*pm, Shao Miller <(E-Mail Removed)> wrote:

....
>> > * What would be the process to build app1 - change to app1's directory
>> > and run 'make'?

>>
>> A top-level Makefile can invoke a Makefile in each subdir of src/


I strongly recommend against that. Google "recursive make considered
harmful". That paper does a good job of explaining why.

There may be working recursive Makefiles ... but I have never seen
one. I have seen the harm described in the paper, though!

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
 
Seebs
Guest
Posts: n/a
 
      03-14-2013
On 2013-03-13, Jorgen Grahn <(E-Mail Removed)> wrote:
> I strongly recommend against that. Google "recursive make considered
> harmful". That paper does a good job of explaining why.


> There may be working recursive Makefiles ... but I have never seen
> one. I have seen the harm described in the paper, though!


Not really directly C-related, but I've done fine with it for cases where the
things being built are NOT a single unified app, but rather, a selection of
logically-independent things. Even then, it's not awesome, and it's not clear
to me that there isn't a better way.

Come to think of it, I have some code that uses recursive make for packaging
because some of the things in it contain sub-things. And it's not bug-free or
hassle-free, but it's been better than the alternatives I thought of in terms
of "that took five minutes and now I can get back to code".

-s
--
Copyright 2013, all wrongs reversed. Peter Seebach / http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
 
Reply With Quote
 
 
 
 
Jorgen Grahn
Guest
Posts: n/a
 
      03-14-2013
On Thu, 2013-03-14, Seebs wrote:
> On 2013-03-13, Jorgen Grahn <(E-Mail Removed)> wrote:
>> I strongly recommend against that. Google "recursive make considered
>> harmful". That paper does a good job of explaining why.

>
>> There may be working recursive Makefiles ... but I have never seen
>> one. I have seen the harm described in the paper, though!

>
> Not really directly C-related, but I've done fine with it for cases where the
> things being built are NOT a single unified app, but rather, a selection of
> logically-independent things. Even then, it's not awesome, and it's not clear
> to me that there isn't a better way.


I think I'd reason like this:

- If they really /are/ independent things, they should be built
separately, each with its own Makefile, and no top-level one.

- If they aren't, I write a single Makefile which treats directory
components as part of the filename. No VPATH or anything like that.
I use libraries to divide and conquer if the number of files gets
too high:

libfoo.a: foo/bar.o
libfoo.a: foo/baz.o
libfoo.a: foo/bat.o

> Come to think of it, I have some code that uses recursive make for packaging
> because some of the things in it contain sub-things. And it's not bug-free or
> hassle-free, but it's been better than the alternatives I thought of in terms
> of "that took five minutes and now I can get back to code".


The cost of broken dependency tracking comes (if it comes) much later,
when you start debugging faulty builds, or develop the habit "I'll
do another 'make clean' just to be sure".

Also, with the small--medium projects I've been in, it's not really
harder to write one Makefile than one per directory. Not with Gnu
Make, anyway.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: Arrange files according to a text file Emile van Sebille Python 3 08-28-2011 01:10 AM
how to arrange classes in .py files? Kent Python 6 03-28-2009 12:30 AM
help on how to arrange python code Luca Fini Python 0 10-18-2003 01:02 PM
arrange page heading code shank ASP General 2 10-13-2003 07:46 AM



Advertisments