[prog]More questions on my first attempt at C++

Jimen Ching jching at flex.com
Mon Apr 14 22:15:17 EST 2003


On Mon, 14 Apr 2003, Sue Stones wrote:
>Are there any basic differences in writing a makefile for C++ than for C?

Not that I've ever seen.

>I know that many companies have strong conventions about makefiles.  Do you
>have any comments on good makefiles?

I have only seen two makefile conventions being used; flat, and
hierarchical.  Flat means you use one makefile for the entire project,
independent of whether you have multiple sub-directories.  Hierarchical
convention uses one makefile per sub-directory.

Though some people favor one or the other, I've used both conventions and
there are advantages and disadvantages to each.  I tend to use the flat
convention for projects with a small set of rules.  I.e. if the build
procedure is the same for all files, then it doesn't matter how many files
or directories you have, a single makefile makes things easier to
maintain.  But, if the project has a complex build process, and the
process can be broken down into smaller sub-steps, then I tend to use a
hierarchical convention, and hide the details in the sub-directories.

But in either convention, I also tend to use a 'common' makefile where I
store global macros, like the install directory or the compiler flags.
But not all 'make' utility supports the 'include' directive.  But GNU make
does, and I usually just require GNU make for my projects.  GNU make also
has very powerful string substitution features.  It comes in handy for
complex build procedures and different types of source files.

--jc
-- 
Jimen Ching (WH6BRR)      jching at flex.com     wh6brr at uhm.ampr.org


More information about the Programming mailing list