问题
I want to read the content of a text file and assign it to a variable in my makefile. I read the make manual ch 8.6: The file function, and wrote this simple snippet in my makefile:
# Snippet from my makefile
my_var = $(file < C:/full/path/to/my_file.txt)
all:
@echo $(my_var)
I get the following error:
*** Invalid file operation: < C:/full/path/to/my_file.txt. Stop.
I deliberately choose for the $(file ..) instead of the $(shell ..) function to read out the file. That's because my makefile should be as platform independent as possible. The $(file ..) function is pure makefile-syntax, whereas the $(shell ..) function contains shell-syntax.
What am I doing wrong?
回答1:
You'll need to upgrade to at least make 4.2 if you want to read files with $(file <)
.
来源:https://stackoverflow.com/questions/39080029/makefiles-reading-a-file-with-pure-make-syntaxis-no-shell-commands