[Top][All Lists]

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

How can I generate rules automatically in make?

From: hans . peter . van . lohuizen
Subject: How can I generate rules automatically in make?
Date: Thu, 2 Oct 2003 15:46:57 +0200


As mentioned below I try to generate some rules in MAKE to define dependencies.
Can someone help me out here?
I tried a suggestion from Paul smith but I can't get this working, maybe I missed something?

I use the following lines:

MOD_PATH = $(foreach OBJ,$(MODULES),../../$(OBJ)/process)  Makefile
       rm -f $@
       for t in $(MOD_PATH); do \
         echo "$$t/gen.out : $$(wildcard $$t/cmd/*.tcl)" >> $@; \

 %process/gen.out :        
        echo "## out of date to:" ;\
        echo $?; \
        echo "## updating: $@"; \
        cd $*; \
        cmd/run1.tcl > $@; \
        cd - > /dev/null;
        echo "############ Finished gen run #############";\
        echo "";


I have the dir structure like:
bb/process/cmd/run1.tcl run2.tcl (run2.tcl is a dummy to proof the wildcard function)
(Note the makefile resides in aa/process)

What I see after running 'gmake gen', is that all not excisting .out files are generated as expected.
When I remove one .out only that one is remade.
But when I touch e.g. run1.tcl  for aa then I get "up to date" (as it was before I touched)
Also I do not get the "out of date" info from $? any more.
So I wonder how make looks to the dependencies now.
I even tried to outcomment the generated rules and get the same result!
So these generated rules are not seen at all.

Can somebody clearify this? What can I do to make it work for a touched dependency?

One other thing:
This construction has to work for parallel runs too!.
From the manual it is suggested to use .PHONY.
How could I do that for this example?

your help is greatly appreciated!!

Hans Peter.

Philips Semiconductors
ReUse Technology Group - Platform Infrastructure Department
Building WDA-3.86
Prof. Holstlaan 4 - 6565 AA Eindhoven - The Netherlands
Telnr. +31 40 27 45983  -  Faxnr. +31 40 27 43630
email: address@hidden

"Paul D. Smith" <address@hidden>

Sent by:
"Paul D. Smith" <address@hidden>

2003-09-10 14:08
Please respond to "Paul D. Smith"

        To:        Hans Peter van Lohuizen/EHV/SC/address@hidden
        cc:        address@hidden
        Subject:        Re: How to use wildcard for different 'stem' values


%% address@hidden writes:

 hpvl> Thanks Paul for your suggestions.

 hpvl> It seems to me the "old" solution is the savest to choose right
 hpvl> now.  Could you give me a small hint of how such a "generating
 hpvl> make fragment" rule should look like?

It would look something like this:

 include  Makefile
       rm -f $@
       for t in $(TARGETLIST); do \
         echo "$$t : \$$(wildcard $$t/cmd/*.tcl)" >> $@; \

 %process/gen.out :

In this case TARGETLIST would contain a list of prefixes that matched
the "%" in the pattern rule.  If your list has a different format you
can massage it in the rule.

Note I didn't run the above, but hopefully you get the idea.

Paul D. Smith <address@hidden>          Find some GNU make tips at:            
"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]