After speaking to someone here, it was pointed out that the line "$$(__FILE__)" is completely wrong. I've changed it to:
$$(eval $$($$(__FILE__).contents)) which generates the error: GNUmakefile:39: *** invalid syntax in conditional. Stop. which is the exact error I get if, rather than using the function, I use the line: ifndef A.mk A.mk := 1 A: B touch $@ .PHONY: clean-A clean: clean-A .PHONY: clean-A clean-A: rm A $(call include-makefile,B.mk) endif which is the contents of the included makefile without line breaks. Any suggestions on how to work around this? Thanks, Noel Noel Yap wrote: > > I'm trying to cache the contents of included makefiles with the following functions: > > # sets __FILE__ macro to file to be included, then includes the file. > # allows included file to know where it is in relation to includer. > # $(1) is the file to be included > # $(2) is the current value of $(__FILE__) > define _include-makefile > __FILE__ := $(1) > > ifndef $$(__FILE__).contents > $$(__FILE__).contents := $$(shell cat $$(__FILE__)) > endif > > $$(__FILE__) > > __FILE__ := $(2) > endef > > # include makefile passing in its name as __FILE__ > # $(1) is the file to be included > include-makefile = $(eval $(call _include-makefile,$(1),$(__FILE__))) > > which are used in the following way: > $(call include-makefile,Another.mk) > > but it's generating the error: > > GNUmakefile:37: *** missing separator. Stop. > > I think it's a white space issue. Does anyone have any suggestions on how to work > around it? > > Thanks, > Noel > -- > NOTICE: If received in error, please destroy and notify sender. Sender does not > waive confidentiality or privilege, and use is prohibited. > > _______________________________________________ > Help-make mailing list > [EMAIL PROTECTED] > http://mail.gnu.org/mailman/listinfo/help-make -- NOTICE: If received in error, please destroy and notify sender. Sender does not waive confidentiality or privilege, and use is prohibited. _______________________________________________ Help-make mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/help-make
