help-make
[Top][All Lists]
Advanced

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

iteration thru makefile reloading


From: Kevin Route
Subject: iteration thru makefile reloading
Date: Mon, 25 Dec 2006 13:20:57 +0100

I am trying to create a makefile that will auto-discover dependencies by using what I call "iteration thru makefile reloading" (no recursive make).
It doesn't work for some reason (but found a workaround) and I would like to understand the problem....
Following, is a "simple makefile" showing it.

ifneq "$(words $(wildcard c*))" "6"
$(warning doing setup)
# depending on make version, ';' may be backslashed ...
$(shell x=0; while test $$x -lt 6; do f=c$$x; x=`expr $$x + 1`; echo $$x > $$f ; done; echo "" > $$f)
endif

#$(shell sleep 1)

x := 0

$(warning reloading a)
include a

clist := $(foreach i,$x,p$(i))
$(warning clist=$(clist))

t: a
    @echo $@ done

a: $(clist)
    cat $^ > $@
#    sleep 1

p%: c%
    echo "x += `cat $<`" > $@

clean:
    rm -rf a p*

#$(shell sleep 1)

Usually, it stops after the second iteration, and I suspected it had something to do with the "1 second precision" of the file timestamps.
This seems to be confirmed by the fact that adding a "1 second delay" somewhere makes it work fine.

What I don't understand, is the following debug info I get when running (g)make with -d and -r options.

   ..................................
   Must remake target `p1'.
echo "x += `cat c1`" > p1
Putting child 0x08072b80 (p1) PID 17482 on the chain.
Live child 0x08072b80 (p1) PID 17482
Reaping winning child 0x08072b80 PID 17482
Removing child 0x08072b80 PID 17482 from chain.
   Successfully remade target file `p1'.
  Finished prerequisites of target file `a'.
  Prerequisite `p0' is older than target `a'.
-->  Prerequisite `p1' is newer than target `a'.
--> ?? No need to remake target `a'.
 Considering target file `makefile.2'.
  ...................................

With a sleep I get the expected thing:
   
   ...................................
   Must remake target `p1'.
echo "x += `cat c1`" > p1
Putting child 0x08072b60 (p1) PID 17441 on the chain.
Live child 0x08072b60 (p1) PID 17441
Reaping winning child 0x08072b60 PID 17441
Removing child 0x08072b60 PID 17441 from chain.
   Successfully remade target file `p1'.
  Finished prerequisites of target file `a'.
  Prerequisite `p0' is older than target `a'.
-->  Prerequisite `p1' is newer than target `a'.
--> ok Must remake target `a'.
cat p0 p1 > a; sleep 1
Putting child 0x08072b60 (a) PID 17444 on the chain.
........................................



reply via email to

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