help-make
[Top][All Lists]
Advanced

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

Re: Importance of how make check dependances/builds targets


From: Paul D. Smith
Subject: Re: Importance of how make check dependances/builds targets
Date: Thu, 2 Oct 2003 08:17:41 -0400

%% Philippe Bernard <address@hidden> writes:

  pb> When a Makefile is submitted to make, it performs, roughly speaking, a 
  pb> two steps process:
  pb> 1) Recursively check that dependances are correct. In other words, for 
  pb> each requested file:
  pb>     * Either it already exists
  pb>     * And/or there is a rule to build it.
  pb> 2) Build!

This is not how make works.

  pb> Another way to do that would be to build targets "as soon as possible". 
  pb> Here, make would do:
  pb>     * To do all, I need myProg
  pb>         * To do myProg, I need main.o and other.o
  pb>             * To do main.o, I need main.c -> I've got it -> gcc -o 
  pb> main.o -c main.c
  pb>             * To do other.o, I need other.c -> I've got it -> gcc -o 
  pb> other.o -c other.c
  pb>           gcc -o myProg main.o other.o

This is how make works... mostly.

It really goes something like this:

 1) Read in all makefiles, constructing a graph of dependencies as you
    go.

 2) Examine the "current" target.  If it has prerequisites, take each
    one in turn and make it the "current" target, and go to step 2.

 4) After all the prerequisites are checked, if either the target
    doesn't exist _or_ any prerequisite is newer than the target, build
    the target.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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