List Info

Thread: Re: multiple assignments on one line?




Re: multiple assignments on one line?
user name
2007-01-18 10:33:25
Alexis Huxley wrote:
> I found a really ugly workaround; namely that if the
external script
> does not write the assignments to stdout, but instead
writes them
> to a temp file and just echos the name of the temp file
on stdout, 
> then I can include that file with:
> 
> 	include $(shell name-of-my-script)
> 
> but of course this is resulting in temporary files all
over the
> place that I don't really feel are the Makefile's
responsibility
> to clean up :-(

Well, you could do the following:

     TEMP_FILE := name_of_temporary_file

     -include $(TEMP_FILE)

     $(TEMP_FILE):
         commands to write out the TEMP_FILE

The nice thing here is that GNU Make makes the file for you
through its 
Makefile remaking feature.    It would be nice if it were
possible to 
make GNU Make delete the $(TEMP_FILE) automatically but
marking it is 
INTERMEDIATE has the undesired affect of getting GNU Make
stuck in an 
infinite loop.

There is actually a way to hack that by doing the
following:

     TEMP_FILE := name_of_temporary_file

     -include $(TEMP_FILE)

     $(TEMP_FILE):
         commands to write out the TEMP_FILE
         echo all $(MAKECMDGOALS): delete-$(TEMP_FILE)
>> $(TEMP_FILE)

     .PHONY: delete-$(TEMP_FILE)
     delete-$(TEMP_FILE):
         rm -f $(TEMP_FILE)

This assumes that the default goal is all, and works by
adding a rule 
that will delete the temporary file when the goal being
executed (either 
the default all or something in MAKECMDGOALS is done.

John.



_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )