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, 6 Oct 2003 13:04:31 +0200
>>Did you look at the contents of the generated.mk file? Did it look
>>correct to you?
The following lines:
..............
MODULES=aa bb
MOD_PATH = $(foreach OBJ,$(MODULES),../../$(OBJ)/process)
generated.mk: Makefile
rm -f $@
for t in $(MOD_PATH); do\
echo "$$t/gen.out : \$$(wildcard $$t/cmd/*.tcl)" >> $@;\
done
%process/gen.db :
echo $?; \
run command;
.............
Gives me after running gmake -p 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/gen.out : \$$(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 coupled to the run commands.
When I remove a the .db file it is regenerated.
(which I can understand since make sees that no targed data
is there yet.)
>>The "echo" line above seems wrong to me. If you're going to get
>>$(wildcard ...) in the output it seems like you need to escape it to the
>>shell, like this:
>> echo "$$t/gen.out : \$$(wildcard $$t/cmd/*.tcl)" >> $@; \
^
OK I added this.
>>I think you're misreading the manual. In this case, since you're not
>>invoking make recursively in subdirectories, you don't need .PHONY
>>(indeed you certainly don't _want_ it or your make will recurse
>>forever!)
>>All you need to do for parallel builds is make sure all your
>>dependencies are properly declared.
OK thanks fot the info.
--
-------------------------------------------------------------------------------
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