How can I create a variable on-the-fly from makefile, the value of which would be the entire contents of another data file.
The variable $@ represents the name of the target and $< represents the first prerequisite required to create the output file.
+= is used for appending more text to variables e.g. objects=main.o foo.o bar.o. objects+=new.o. which will set objects to 'main.o foo.o bar.o new.o' = is for recursively expanded variable.
makefile Variables Automatic Variables Within the context of an individual rule, Make automatically defines a number of special variables. These variables can have a different value for each rule in a makefile and are designed to make writing rules simpler.
Assuming GNU make:
file := whatever.txt variable := $(shell cat ${file})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With