[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simple Makefile Example
From: |
Alex Vinokur |
Subject: |
Re: Simple Makefile Example |
Date: |
Thu, 17 Jun 2004 08:42:43 +0300 |
"cppaddict" <hello@hello.com> wrote in message
pfrvc0tlhjf1aoit23egfn078cn99kmn29@4ax.com">news:pfrvc0tlhjf1aoit23egfn078cn99kmn29@4ax.com...
> Hi,
>
> I'm searching for an elegant way to write a Makefile for compiling a
> simple C++ application whose source files span multiple directories.
> I know this must be a common problem, but I can't seem to find any
> satisfactory examples or explanations of solutions on Google or in the
> archives. The general problem I have in mind can be summed up as
> follows:
>
> /module1/ -- contains .h .cpp files for module1 and (after make is
> run) the .o files
> /module2/ -- same as above but for module2
> /module2/subModuleA -- same thing, but accounting for nesting deeper
> than 1 level
> ....
> etc
>
> The final executable should be placed in the root directory.
>
> Ideally, the Makefile will:
>
> 1. Be simple and clean, using Automatic Variables whenever possible.
>
> 2. Be robust to changes in the directory structure. For example, if
> file A.cpp moves from module1 to module2 for some reason, only one or
> two lines in the Makefile should change. I imagine info about the
> directory structure would be set at the top of the file using
> variables somehow, and the guts of the Makefile would depend only on
> those variables.
>
> Can anyone send a simple example of such a solution, or point me to a
> good reference?
>
> Thanks for any help,
> cpp
A few years ago I did similar thing with using the mkmf utility;
* http://groups.google.com/groups?selm=83b3l0%244er%241%40nnrp1.deja.com
mkmf: http://efeu.cybertec.at/man_en/mkmf.html
--
Alex Vinokur
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn