help-make
[Top][All Lists]
Advanced

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

Importance of how make check dependances/builds targets


From: Philippe Bernard
Subject: Importance of how make check dependances/builds targets
Date: Thu, 02 Oct 2003 11:15:23 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5b) Gecko/20030901 Thunderbird/0.2


Hi,


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

For example, if make is given the following Makfile:

all:

myProg: main.o other.o
   gcc -o $@ $^

main.o: main.c
   gcc -o $@ -c $<

other.o: other.c
   gcc -o $@ -c $<

Make does:
   * To do all, I need myProg
       * To do myProg, I need main.o and other.o
           * To do main.o, I need main.c -> I've got it
           * To do other.o, I need other.c -> I've got it
   * Go accros the deps tree:
           gcc -o main.o -c main.c
           gcc -o other.o -c other.c
           gcc -o myProg main.o other.o

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

The first approach has the great advantage of detecting broken dependances immediatly.

So here is my questions: Are there other advantages ? Is the second approach wrong in some way, or is it just worse ?


Cheers,

Philippe






reply via email to

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