help-make
[Top][All Lists]
Advanced

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

Re: How can I generate rules automatically in make?


From: hans . peter . van . lohuizen
Subject: Re: How can I generate rules automatically in make?
Date: Mon, 20 Oct 2003 14:30:08 +0200


Hi,
I still have the issue of generating rules in gmake.
It seems that the generated rules are not taken into account at all.
Could someone (or maybe you Paul) give me a hint what could be wrong?

Thanks a lot!

Hans Peter.


I used the following makefile lines:
..............
MODULES=aa bb
 MOD_PATH = $(foreach OBJ,$(MODULES),../../$(OBJ)/synopsys)
 GEN_MOD  = $(foreach OBJ,$(MOD_PATH),$(OBJ)/ddb/gen.db)

   generated.mk : makefile
            rm -f $@;
          for t in $(MOD_PATH); do\
                 echo "$$t/ddb/gen.db : \$$(wildcard $$t/cmd/*.tcl)" >> $@;\
          done


 %ddb/gen.db :
        echo "## out of date to:" ;\
        echo $?; \
        cd $*; \
        cmd/gen.tcl > $@; \
        cd - > /dev/null;

 gen : $(GEN_MOD)
.............


After running gmake -p gen
this gives me for the generated.mk part:
..............
generated.mk: makefile
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.
#  commands to execute (from `makefile', line 24):
        rm -f $@;
        for t in $(MOD_PATH); do\
        echo "$$t/ddb/gen.db : \$$(wildcard $$t/cmd/*.tcl)" >> $@;\
        done
................

Is this ok or is it possible to see the expanded info?
(I somehow expected to see all generated rule lines)
(running with -d option shows nothing about generated.mk)
Would there be a way to make the generated lines more visible?

What strikes me is that I used an echo $? to see what files are out of date.
But now this echo returns nothing. So no dependencies are found?
I even tried to replace the wildcard by just one direct path to a .tcl file but
also this is not seen by make.
So somehow the generated dependency rules are not 'seen' by make.


-------------------------------------------------------------------------------
Some background info:
What I try to do with the generated rules is to generate dependencies for different files in a standard dir structure.

I started with the rule:

%ddb/gen.db : $(addprefix %, $(wildcard cmd/*.tcl))
        commands...

I have a dir structure like:
  aa/synopsys/cmd/run.tcl, run1.tcl
  bb/synopsys/cmd/run.tcl, run1.tcl

result is put in aa/synopsys/ddb/gen.db.
Now the make runs like I would expect: touching one run.tcl causes an update in the corresponding dir.

When I have however something like:
  aa/synopsys/cmd/run.tcl, run1.tcl
  bb/synopsys/cmd/run.tcl, run1.tcl, run2.tcl

Now run2.tcl is not taken into account when touched I get the message up to date.
The reason is that the wildcard is only filled in once for the first value of %.
So this is what I try to solve with generated rules above.
-------------------------------------------------------------------------------



reply via email to

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