|
From: | John Graham-Cumming |
Subject: | Re: multiple assignments on one line? |
Date: | Thu, 18 Jan 2007 17:33:25 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040208 Thunderbird/0.5 Mnenhy/0.6.0.104 |
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 themto 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_FILEThe 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.
[Prev in Thread] | Current Thread | [Next in Thread] |