Per Jessen wrote:
I think I'm seeing something odd in 'make':
ALLDOMAIN:=alldomains.list #ALLDOMAIN:=$(shell mktemp alldomain.XXXXXX)
.PHONY: $(ALLDOMAIN) .SILENT: $(ALLDOMAIN)
$(ALLDOMAIN): <commands to produce the file> >$@
What am I doing wrong here?
I think make and this Makefile do not work in the way you expect them to work. When you enter "make alldomains", then make starts to parse the Makefile (see ) and after some time finds the include statement. The file alldomains.list does not exist on disk at that point, so it's content cannot be included. This is no immediate error for make (you should get a warning though, see ), it continues parsing the Makefile. At the end, it looks for a rule to generate the file to be included because make determined that it is a dependency. This rule exists, so make goes off and generates the file alldomains.list which will (according to your description) contain a rule called "alldomains". Finally, make now tries to execute the rule "alldomains" - however, you should note that at this point the content of the alldomains.list file has still not been included in the Makefile (make parses a Makefile only once). Therefore, make aborts and you should get an error message like "no rule to make target alldomains" (see ). If you have a look at the directory, then you should observe that the include file alldomains.list has been generated (see ). If you run "make alldomains" a second time, it will work because now the include file exists when make parses the Makefile and therefore it knows about the target (see ).
$> cat Makefile ALLDOMAIN := alldomains.list
$(ALLDOMAIN): ; @echo "alldomains: ;" > $@ @echo -e "\t@echo "hello, world!"" >> $@
include $(ALLDOMAIN) $> make alldomains Makefile:9: alldomains.list: No such file or directory make: *** No rule to make target `alldomains'. Stop. $> ls alldomains.list Makefile $> make alldomains hello, world! $> --------------------------------------------------------------------- To unsubscribe, e-mail: firstname.lastname@example.org For additional commands, e-mail: email@example.com